-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
1 parent
a24960c
commit 8661202
Showing
2 changed files
with
52 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -468,19 +468,33 @@ def test_tcp_connector_expect_fingerprint_invalid_len(self): | |
with self.assertRaises(ValueError): | ||
aiohttp.TCPConnector(loop=self.loop, expect_fingerprint=invalid) | ||
|
||
def test_tcp_connector_expect_fingerprint_invalid_type(self): | ||
invalid = 123 | ||
with self.assertRaises(TypeError): | ||
aiohttp.TCPConnector(loop=self.loop, expect_fingerprint=invalid) | ||
|
||
def test_tcp_connector_expect_fingerprint(self): | ||
# the even-index fingerprints below are for sample.crt.der, | ||
# the certificate presented by test_utils.run_server | ||
# The even-index fingerprints below are "expect success" cases | ||
# for ./sample.crt.der, the cert presented by test_utils.run_server. | ||
# The odd-index fingerprints are "expect fail" cases. | ||
testcases = ( | ||
# md5 | ||
'a20647adaaf5d85c4a995e62793b063d', # good | ||
'ffffffffffffffffffffffffffffffff', # bad | ||
'a2:06:47:ad:aa:f5:d8:5c:4a:99:5e:62:79:3b:06:3d', # good | ||
'ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff', # bad | ||
|
||
'A20647ADAAF5D85C4A995E62793B063D', # colons and case ignored | ||
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
b'\xa2\x06G\xad\xaa\xf5\xd8\\J\x99^by;\x06=', # bytes ok too | ||
b'\xff' * 16, | ||
|
||
# sha1 | ||
'7393fd3aed081d6fa9ae71391ae3c57f89e76cf9', # good | ||
'ffffffffffffffffffffffffffffffffffffffff', # bad | ||
'7393fd3aed081d6fa9ae71391ae3c57f89e76cf9', | ||
'ffffffffffffffffffffffffffffffffffffffff', | ||
|
||
# sha256 | ||
'309ac94483dc9127889111a16497fdcb7e37551444404c11ab99a8aeb714ee8b', # good # flake8: noqa | ||
'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', # bad # flake8: noqa | ||
'309ac94483dc9127889111a16497fdcb7e37551444404c11ab99a8aeb714ee8b', # flake8: noqa | ||
'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', # flake8: noqa | ||
) | ||
for i, fingerprint in enumerate(testcases): | ||
expect_fail = i % 2 | ||
|
@@ -490,10 +504,8 @@ def test_tcp_connector_expect_fingerprint(self): | |
coro = client.request('get', httpd.url('method', 'get'), | ||
connector=conn, loop=self.loop) | ||
if expect_fail: | ||
with self.assertRaises(FingerprintMismatch) as cm: | ||
with self.assertRaises(FingerprintMismatch): | ||
self.loop.run_until_complete(coro) | ||
self.assertEqual(cm.exception.expected, fingerprint) | ||
self.assertEqual(cm.exception.got, testcases[i-1]) | ||
This comment has been minimized.
Sorry, something went wrong.
requiredfield
Author
Contributor
|
||
else: | ||
# should not raise | ||
self.loop.run_until_complete(coro) | ||
|
added test cases for colons and mixed case