diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2021-11-15 12:15:23 +0000 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2021-11-15 12:15:23 +0000 |
commit | bcff62d267b5294777a738b2cd1b35f943e20f2f (patch) | |
tree | 295ed7875c8db86b0496494ffce38cda2fde0cfd | |
parent | ae035852385032cc6c502c0e560fc682cacdbf34 (diff) | |
download | unit-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.
-rw-r--r-- | test/test_tls_session.py | 30 |
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' |