Skip to content

Commit 181ca45

Browse files
committed
add unit tests for HTTPS port modifications
1 parent 5142558 commit 181ca45

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
@@ -4,7 +4,7 @@
44

55

66
def my_setup():
7-
global a, b, c, d, e, f, g, h
7+
global a, b, c, d, e, f, g, h, k
88
a = ['-p', '8443', '-t', '/etc/my_tls']
99
b = ['-a']
1010
c = ['-a', 'abc']
@@ -13,6 +13,7 @@ def my_setup():
1313
f = ['-c', '10', '-s', '9.155.108.199', '-p', '8443', '-t', '/opt/registry/certs', '--tlsKeyFile', 'privkey.pem', '--tlsCertFile', 'cert.pem']
1414
g = ['-p', '4242', '-P', '9084']
1515
h = ['-d', 'no']
16+
k = ['-p', '4243', '-r', 'https']
1617

1718

1819
def test_case01():
@@ -66,7 +67,9 @@ def test_case07():
6667
result = vars(args)
6768
assert len(result.keys()) > 0
6869
assert 'port' in result.keys()
70+
assert 'protocol' in result.keys()
6971
assert result.get('port') == 8443
72+
assert result.get('protocol') is None
7073

7174

7275
def test_case08():
@@ -82,3 +85,12 @@ def test_case09():
8285
result = vars(args)
8386
assert 'includeDiskData' in result.keys()
8487
assert result.get('includeDiskData') == 'no'
88+
89+
90+
@with_setup(my_setup)
91+
def test_case10():
92+
args, msg = parse_cmd_args(k)
93+
result = vars(args)
94+
assert len(result.keys()) > 0
95+
assert 'port' in result.keys()
96+
assert 'protocol' in result.keys()

tests/test_configManager.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,10 @@ def test_case11():
7474
result = cm.defaults
7575
assert 'includeDiskData' in result.keys()
7676
assert result['includeDiskData'] == 'no'
77+
78+
79+
def test_case11():
80+
cm = ConfigManager()
81+
result = cm.defaults
82+
assert 'protocol' in result.keys()
83+
assert result['protocol'] == 'http'

tests/test_params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def test_case04():
4343
assert 'tlsKeyPath' not in result.keys()
4444
assert 'tlsKeyFile' not in result.keys()
4545
assert 'tlsCertFile' not in result.keys()
46+
assert 'protocol' in result.keys()
4647
assert result.get('port') == 8443
48+
assert result.get('protocol') == 'http'
4749

4850

4951
@with_setup(my_setup)

0 commit comments

Comments
 (0)