Skip to content

Commit

Permalink
bpo-34001: add test for protocol boundary restrictions
Browse files Browse the repository at this point in the history
This commit adds tests for the new {min,max}imum_version restrictions.
Attempting to set an invalid range should ValueError, and the value
should not be changed after the attempt.
  • Loading branch information
Alan Huang authored and Alan Huang committed Jul 3, 2018
1 parent 77d24d8 commit 2a09611
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Lib/test/test_ssl.py
Expand Up @@ -1105,6 +1105,23 @@ def test_min_max_version(self):
{ssl.TLSVersion.TLSv1_2, ssl.TLSVersion.TLSv1_3}
)

with self.assertRaises(ValueError):
ctx.maximum_version = ssl.TLSVersion.MINIMUM_SUPPORTED

self.assertEqual(
ctx.maximum_version, ssl.TLSVersion.MAXIMUM_SUPPORTED
)

ctx.minimum_version = ssl.TLSVersion.MINIMUM_SUPPORTED
ctx.maximum_version = ssl.TLSVersion.MINIMUM_SUPPORTED

with self.assertRaises(ValueError):
ctx.minimum_version = ssl.TLSVersion.MAXIMUM_SUPPORTED

self.assertEqual(
ctx.minimum_version, ssl.TLSVersion.MINIMUM_SUPPORTED
)

with self.assertRaises(ValueError):
ctx.minimum_version = 42

Expand Down

0 comments on commit 2a09611

Please sign in to comment.