-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
115 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from unittest import mock | ||
from showcert.cli.gencert_main import main | ||
|
||
def test_cacert(): | ||
with mock.patch('sys.argv', ['gencert_main.py', | ||
'--ca', '--cert', '/tmp/ca.pem', '--key', '/tmp/ca-priv.pem', "My CA"]): | ||
code = main() | ||
assert code == 0 | ||
|
||
|
||
def test_cacert_combined(): | ||
with mock.patch('sys.argv', ['gencert_main.py', | ||
'--ca', '--cert', '/tmp/ca2.pem', "My CA"]): | ||
code = main() | ||
assert code == 0 | ||
|
||
|
||
def test_cert(): | ||
with mock.patch('sys.argv', ['gencert_main.py', | ||
'--cacert', '/tmp/ca.pem', '--cakey', '/tmp/ca-priv.pem', 'example.com', 'www.example.com', '0.0.0.1']): | ||
code = main() | ||
assert code == 0 | ||
|
||
def test_cert_combined(): | ||
with mock.patch('sys.argv', ['gencert_main.py', | ||
'--cacert', '/tmp/ca2.pem', 'example.com', 'www.example.com']): | ||
code = main() | ||
assert code == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,25 @@ | ||
from unittest import mock | ||
from showcert.cli.showcert_main import main | ||
|
||
|
||
snakeoil = '/etc/ssl/certs/ssl-cert-snakeoil.pem' | ||
|
||
def test_main(): | ||
with mock.patch('sys.argv', ['showcert_main.py', 'github.com']): | ||
main() | ||
|
||
code = main() | ||
assert code == 0 | ||
|
||
def test_main_le(): | ||
with mock.patch('sys.argv', ['showcert_main.py', ':le']): | ||
code = main() | ||
assert code == 0 | ||
|
||
def test_main_snakeoil(): | ||
with mock.patch('sys.argv', ['showcert_main.py', snakeoil]): | ||
code = main() | ||
assert code == 1 | ||
|
||
def test_main_notacert(): | ||
with mock.patch('sys.argv', ['showcert_main.py', "/etc/fstab"]): | ||
code = main() | ||
assert code == 1 |