diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-09-04 03:29:54 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2017-09-04 14:02:43 +0200 |
commit | de006ea8adc08b9a8a6aa94eda2b30468727c307 (patch) | |
tree | 96561254cfc4ae415d2a45d4466221a14489640c /test/mitmproxy/net/test_tls.py | |
parent | 2b4f58eb4416beff3d0a246b8cfb55b5eb8f735b (diff) | |
download | mitmproxy-de006ea8adc08b9a8a6aa94eda2b30468727c307.tar.gz mitmproxy-de006ea8adc08b9a8a6aa94eda2b30468727c307.tar.bz2 mitmproxy-de006ea8adc08b9a8a6aa94eda2b30468727c307.zip |
move hostname validation into mitmproxy.net.tls
Diffstat (limited to 'test/mitmproxy/net/test_tls.py')
-rw-r--r-- | test/mitmproxy/net/test_tls.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/mitmproxy/net/test_tls.py b/test/mitmproxy/net/test_tls.py index 473163aa..d0583d34 100644 --- a/test/mitmproxy/net/test_tls.py +++ b/test/mitmproxy/net/test_tls.py @@ -1,10 +1,13 @@ +import pytest + +from mitmproxy import exceptions from mitmproxy.net import tls from mitmproxy.net.tcp import TCPClient from test.mitmproxy.net.test_tcp import EchoHandler from . import tservers -class TestSSLKeyLogger(tservers.ServerTestBase): +class TestMasterSecretLogger(tservers.ServerTestBase): handler = EchoHandler ssl = dict( cipher_list="AES256-SHA" @@ -36,3 +39,17 @@ class TestSSLKeyLogger(tservers.ServerTestBase): tls.MasterSecretLogger.create_logfun("test"), tls.MasterSecretLogger) assert not tls.MasterSecretLogger.create_logfun(False) + + +class TestTLSInvalid: + def test_invalid_ssl_method_should_fail(self): + fake_ssl_method = 100500 + with pytest.raises(exceptions.TlsException): + tls.create_client_context(method=fake_ssl_method) + + def test_alpn_error(self): + with pytest.raises(exceptions.TlsException, match="must be a function"): + tls.create_client_context(alpn_select_callback="foo") + + with pytest.raises(exceptions.TlsException, match="ALPN error"): + tls.create_client_context(alpn_select="foo", alpn_select_callback="bar") |