summaryrefslogtreecommitdiffhomepage
path: root/test/test_tls_session.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2021-11-15 12:15:23 +0000
committerAndrei Zeliankou <zelenkov@nginx.com>2021-11-15 12:15:23 +0000
commitbcff62d267b5294777a738b2cd1b35f943e20f2f (patch)
tree295ed7875c8db86b0496494ffce38cda2fde0cfd /test/test_tls_session.py
parentae035852385032cc6c502c0e560fc682cacdbf34 (diff)
downloadunit-bcff62d267b5294777a738b2cd1b35f943e20f2f.tar.gz
unit-bcff62d267b5294777a738b2cd1b35f943e20f2f.tar.bz2
Tests: fixed session reuse tests.
Since SSL_CTX_sess_set_cache_size() can't guarantee the size of the cache there is no need to test edge "cache_size" values.
Diffstat (limited to 'test/test_tls_session.py')
-rw-r--r--test/test_tls_session.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/test/test_tls_session.py b/test/test_tls_session.py
index f173913b..58f11f2d 100644
--- a/test/test_tls_session.py
+++ b/test/test_tls_session.py
@@ -76,7 +76,7 @@ class TestTLSSession(TestApplicationTLS):
client, _, _, reused = self.connect(ctx, sess)
assert not reused, 'no cache'
- assert 'success' in self.add_session(cache_size=1)
+ assert 'success' in self.add_session(cache_size=2)
client, sess, ctx, reused = self.connect()
assert not reused, 'new connection cache'
@@ -87,30 +87,26 @@ class TestTLSSession(TestApplicationTLS):
client, _, _, reused = self.connect(ctx, sess)
assert reused, 'cache 2'
- # check that at least one session of two is not reused
+ # check that at least one session of four is not reused
- client, sess, ctx, reused = self.connect()
- client2, sess2, ctx2, reused2 = self.connect()
- assert True not in [reused, reused2], 'new connection cache small'
+ clients = [self.connect() for _ in range(4)]
+ assert True not in [c[-1] for c in clients], 'cache small all new'
- client, _, _, reused = self.connect(ctx, sess)
- client2, _, _, reused2 = self.connect(ctx2, sess2)
- assert False in [reused, reused2], 'cache small'
+ clients_again = [self.connect(c[2], c[1]) for c in clients]
+ assert False in [c[-1] for c in clients_again], 'cache small no reuse'
- # both sessions are reused
+ # all four sessions are reused
- assert 'success' in self.add_session(cache_size=2)
+ assert 'success' in self.add_session(cache_size=8)
- client, sess, ctx, reused = self.connect()
- client2, sess2, ctx2, reused2 = self.connect()
- assert True not in [reused, reused2], 'new connection cache big'
+ clients = [self.connect() for _ in range(4)]
+ assert True not in [c[-1] for c in clients], 'cache big all new'
- client, _, _, reused = self.connect(ctx, sess)
- client2, _, _, reused2 = self.connect(ctx2, sess2)
- assert False not in [reused, reused2], 'cache big'
+ clients_again = [self.connect(c[2], c[1]) for c in clients]
+ assert False not in [c[-1] for c in clients_again], 'cache big reuse'
def test_tls_session_timeout(self):
- assert 'success' in self.add_session(cache_size=1, timeout=1)
+ assert 'success' in self.add_session(cache_size=5, timeout=1)
client, sess, ctx, reused = self.connect()
assert not reused, 'new connection'