aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_authentication.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-12-31 10:34:25 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-12-31 10:34:25 +1300
commit3b84111493dee7c21c4dd6ba390fd70cb13a8674 (patch)
treeb37bda18c09f4b60928f782702ebad3c88733674 /test/test_authentication.py
parent018c229ae40d93f0f0987a37a33256db57cdc62c (diff)
downloadmitmproxy-3b84111493dee7c21c4dd6ba390fd70cb13a8674.tar.gz
mitmproxy-3b84111493dee7c21c4dd6ba390fd70cb13a8674.tar.bz2
mitmproxy-3b84111493dee7c21c4dd6ba390fd70cb13a8674.zip
Test and robustify BasicProxyAuth.parse_auth_value
- This is partly in preparation for moving the implementation to netlib - Also add an unparse_auth_value for testing (and use in pathod once the move is done)
Diffstat (limited to 'test/test_authentication.py')
-rw-r--r--test/test_authentication.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test_authentication.py b/test/test_authentication.py
index 25714263..cc797d68 100644
--- a/test/test_authentication.py
+++ b/test/test_authentication.py
@@ -1,5 +1,7 @@
+import binascii
from libmproxy import authentication
from netlib import odict
+import tutils
class TestNullProxyAuth:
@@ -16,3 +18,13 @@ class TestBasicProxyAuth:
assert ba.auth_challenge_headers()
assert not ba.authenticate(h)
+ def test_parse_auth_value(self):
+ ba = authentication.BasicProxyAuth(authentication.PermissivePasswordManager())
+ 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)
+