Skip to content

Commit e55967e

Browse files
committed
cleanup tests
1 parent ccb99bd commit e55967e

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

setup.py

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
from setuptools import setup
23
from io import open
34

tests/test_utils.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,23 @@ def test_generate_hotp_uri():
116116
assert generated_uri.netloc == expected_uri.netloc
117117
assert generated_uri.path == expected_uri.path
118118
assert urlparse.parse_qs(generated_uri.params) == urlparse.parse_qs(expected_uri.params)
119-
print(expected_uri, generated_uri)
120119
assert urlparse.parse_qs(generated_uri.query) == urlparse.parse_qs(expected_uri.query)
121120

122-
def test_check_token_detects_valid_totp_token():
123-
test_request = generate_request()
121+
def provision_valid_token(token_model, attr, not_attr):
122+
test_request = generate_request(token_model=token_model)
124123
test_response = requests.post(PROVISIONING_URL, data=test_request)
125124
test_otp_token = get_token_from_response(test_response.content)
125+
assert test_otp_token[attr] is not None
126+
assert test_otp_token[not_attr] is None
127+
assert test_otp_token['id'].startswith(token_model)
126128
test_token_secret = decrypt_key(test_otp_token['iv'], test_otp_token['cipher'])
127129
assert check_token(test_otp_token, test_token_secret)
128130

129-
def test_check_token_detects_valid_hotp_token():
130-
test_request = generate_request(token_model='UBHE')
131-
test_response = requests.post(PROVISIONING_URL, data=test_request)
132-
test_otp_token = get_token_from_response(test_response.content)
133-
test_token_secret = decrypt_key(test_otp_token['iv'], test_otp_token['cipher'])
134-
assert check_token(test_otp_token, test_token_secret)
131+
def test_check_token_models():
132+
for token_model in ('VSMT', 'VSST', 'SYMC'):
133+
yield provision_valid_token, token_model, 'period', 'counter'
134+
for token_model in ('UBHE',):
135+
yield provision_valid_token, token_model, 'counter', 'period'
135136

136137
def test_check_token_detects_invalid_token():
137138
test_token = {'id': 'VSST26070843', 'period': 30}

0 commit comments

Comments
 (0)