diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-05-28 12:12:37 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-05-28 12:12:37 +1200 |
commit | 41af65a1c478825d4df6239b33fbcb971dcf1df8 (patch) | |
tree | 9830657189938900adad330beba0478f0d0761c2 /test/test_http_auth.py | |
parent | 5265b289575d3935e8af29b5c27c963832efc8ad (diff) | |
parent | 80378306960379f12aca72309dc47437cd1a825c (diff) | |
download | mitmproxy-41af65a1c478825d4df6239b33fbcb971dcf1df8.tar.gz mitmproxy-41af65a1c478825d4df6239b33fbcb971dcf1df8.tar.bz2 mitmproxy-41af65a1c478825d4df6239b33fbcb971dcf1df8.zip |
Merge branch 'Kriechi-cleanup'
Diffstat (limited to 'test/test_http_auth.py')
-rw-r--r-- | test/test_http_auth.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/test/test_http_auth.py b/test/test_http_auth.py index 176aa3ff..045fb13e 100644 --- a/test/test_http_auth.py +++ b/test/test_http_auth.py @@ -1,9 +1,9 @@ -import binascii, cStringIO from netlib import odict, http_auth, http -import mock import tutils + class TestPassManNonAnon: + def test_simple(self): p = http_auth.PassManNonAnon() assert not p.test("", "") @@ -11,6 +11,7 @@ class TestPassManNonAnon: class TestPassManHtpasswd: + def test_file_errors(self): tutils.raises("malformed htpasswd file", http_auth.PassManHtpasswd, tutils.test_data.path("data/server.crt")) @@ -18,7 +19,7 @@ class TestPassManHtpasswd: pm = http_auth.PassManHtpasswd(tutils.test_data.path("data/htpasswd")) vals = ("basic", "test", "test") - p = http.assemble_http_basic_auth(*vals) + http.assemble_http_basic_auth(*vals) assert pm.test("test", "test") assert not pm.test("test", "foo") assert not pm.test("foo", "test") @@ -27,6 +28,7 @@ class TestPassManHtpasswd: class TestPassManSingleUser: + def test_simple(self): pm = http_auth.PassManSingleUser("test", "test") assert pm.test("test", "test") @@ -35,6 +37,7 @@ class TestPassManSingleUser: class TestNullProxyAuth: + def test_simple(self): na = http_auth.NullProxyAuth(http_auth.PassManNonAnon()) assert not na.auth_challenge_headers() @@ -43,6 +46,7 @@ class TestNullProxyAuth: class TestBasicProxyAuth: + def test_simple(self): ba = http_auth.BasicProxyAuth(http_auth.PassManNonAnon(), "test") h = odict.ODictCaseless() @@ -60,7 +64,6 @@ class TestBasicProxyAuth: ba.clean(hdrs) assert not ba.AUTH_HEADER in hdrs - hdrs[ba.AUTH_HEADER] = [""] assert not ba.authenticate(hdrs) @@ -77,25 +80,27 @@ class TestBasicProxyAuth: assert not ba.authenticate(hdrs) -class Bunch: pass +class Bunch: + pass class TestAuthAction: + def test_nonanonymous(self): m = Bunch() aa = http_auth.NonanonymousAuthAction(None, "authenticator") aa(None, m, None, None) - assert m.authenticator + assert m.authenticator def test_singleuser(self): m = Bunch() aa = http_auth.SingleuserAuthAction(None, "authenticator") aa(None, m, "foo:bar", None) - assert m.authenticator + assert m.authenticator tutils.raises("invalid", aa, None, m, "foo", None) def test_httppasswd(self): m = Bunch() aa = http_auth.HtpasswdAuthAction(None, "authenticator") aa(None, m, tutils.test_data.path("data/htpasswd"), None) - assert m.authenticator + assert m.authenticator |