diff options
author | Rouli <rouli.net@gmail.com> | 2013-03-18 14:24:13 +0200 |
---|---|---|
committer | Rouli <rouli.net@gmail.com> | 2013-03-18 14:24:13 +0200 |
commit | c94aadcb0ee5e7aab8acc46a0e4ac7d02a28df6f (patch) | |
tree | 1e62785d669d86f6e551a99b9debfe445389bd48 /test/test_authentication.py | |
parent | b6cae7cd2d0105d6a6fe9d35864d0f9b7c5f8924 (diff) | |
parent | 5c33f6784b4ba34dd9825ea7e3070cdf0b2b4621 (diff) | |
download | mitmproxy-c94aadcb0ee5e7aab8acc46a0e4ac7d02a28df6f.tar.gz mitmproxy-c94aadcb0ee5e7aab8acc46a0e4ac7d02a28df6f.tar.bz2 mitmproxy-c94aadcb0ee5e7aab8acc46a0e4ac7d02a28df6f.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'test/test_authentication.py')
-rw-r--r-- | test/test_authentication.py | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/test/test_authentication.py b/test/test_authentication.py deleted file mode 100644 index f7a5ecd3..00000000 --- a/test/test_authentication.py +++ /dev/null @@ -1,58 +0,0 @@ -import binascii -from libmproxy import authentication -from netlib import odict -import tutils - - -class TestNullProxyAuth: - def test_simple(self): - na = authentication.NullProxyAuth(authentication.PermissivePasswordManager()) - assert not na.auth_challenge_headers() - assert na.authenticate("foo") - na.clean({}) - - -class TestBasicProxyAuth: - def test_simple(self): - ba = authentication.BasicProxyAuth(authentication.PermissivePasswordManager(), "test") - h = odict.ODictCaseless() - assert ba.auth_challenge_headers() - assert not ba.authenticate(h) - - def test_parse_auth_value(self): - ba = authentication.BasicProxyAuth(authentication.PermissivePasswordManager(), "test") - vals = ("basic", "foo", "bar") - assert ba.parse_auth_value(ba.unparse_auth_value(*vals)) == vals - tutils.raises(ValueError, ba.parse_auth_value, "") - tutils.raises(ValueError, ba.parse_auth_value, "foo bar") - - v = "basic " + binascii.b2a_base64("foo") - tutils.raises(ValueError, ba.parse_auth_value, v) - - def test_authenticate_clean(self): - ba = authentication.BasicProxyAuth(authentication.PermissivePasswordManager(), "test") - - hdrs = odict.ODictCaseless() - vals = ("basic", "foo", "bar") - hdrs[ba.AUTH_HEADER] = [ba.unparse_auth_value(*vals)] - assert ba.authenticate(hdrs) - - ba.clean(hdrs) - assert not ba.AUTH_HEADER in hdrs - - - hdrs[ba.AUTH_HEADER] = [""] - assert not ba.authenticate(hdrs) - - hdrs[ba.AUTH_HEADER] = ["foo"] - assert not ba.authenticate(hdrs) - - vals = ("foo", "foo", "bar") - hdrs[ba.AUTH_HEADER] = [ba.unparse_auth_value(*vals)] - assert not ba.authenticate(hdrs) - - ba = authentication.BasicProxyAuth(authentication.PasswordManager(), "test") - vals = ("basic", "foo", "bar") - hdrs[ba.AUTH_HEADER] = [ba.unparse_auth_value(*vals)] - assert not ba.authenticate(hdrs) - |