Skip to content

Commit e6a1f67

Browse files
committed
add unit tests for HTTPS port modifications
1 parent 458e965 commit e6a1f67

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

tests/test_cli_parser.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def my_setup():
9-
global a, b, c, d, e, f, g, h
9+
global a, b, c, d, e, f, g, h, k
1010
a = ['-p', '8443', '-t', '/etc/my_tls']
1111
b = ['-a']
1212
c = ['-a', 'abc']
@@ -15,6 +15,7 @@ def my_setup():
1515
f = ['-c', '10', '-s', '9.155.108.199', '-p', '8443', '-t', '/opt/registry/certs', '--tlsKeyFile', 'privkey.pem', '--tlsCertFile', 'cert.pem']
1616
g = ['-p', '4242', '-P', '9084']
1717
h = ['-d', 'no']
18+
k = ['-p', '4243', '-r', 'https']
1819

1920

2021
def test_case01():
@@ -76,7 +77,9 @@ def test_case07():
7677
result = vars(args)
7778
assert len(result.keys()) > 0
7879
assert 'port' in result.keys()
80+
assert 'protocol' in result.keys()
7981
assert result.get('port') == 8443
82+
assert result.get('protocol') is None
8083

8184

8285
def test_case08():
@@ -92,3 +95,12 @@ def test_case09():
9295
result = vars(args)
9396
assert 'includeDiskData' in result.keys()
9497
assert result.get('includeDiskData') == 'no'
98+
99+
100+
@with_setup(my_setup)
101+
def test_case10():
102+
args, msg = parse_cmd_args(k)
103+
result = vars(args)
104+
assert len(result.keys()) > 0
105+
assert 'port' in result.keys()
106+
assert 'protocol' in result.keys()

tests/test_configManager.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,10 @@ def test_case12():
8484
cm = ConfigManager()
8585
result = cm.defaults
8686
assert 'apiKeyValue' not in result.keys()
87+
88+
89+
def test_case13():
90+
cm = ConfigManager()
91+
result = cm.defaults
92+
assert 'protocol' in result.keys()
93+
assert result['protocol'] == 'http'

tests/test_params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def test_case04():
4848
assert 'tlsKeyFile' not in result.keys()
4949
assert 'tlsCertFile' not in result.keys()
5050
assert 'apiKeyValue' not in result.keys()
51+
assert 'protocol' in result.keys()
5152
assert result.get('port') == 8443
53+
assert result.get('protocol') == 'http'
5254

5355

5456
@with_setup(my_setup)

0 commit comments

Comments
 (0)