aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/http/http1/test_protocol.py19
-rw-r--r--test/http/test_authentication.py21
2 files changed, 21 insertions, 19 deletions
diff --git a/test/http/http1/test_protocol.py b/test/http/http1/test_protocol.py
index 05e82831..d0a2ee02 100644
--- a/test/http/http1/test_protocol.py
+++ b/test/http/http1/test_protocol.py
@@ -71,13 +71,13 @@ def test_connection_close():
def test_get_header_tokens():
h = odict.ODictCaseless()
- assert protocol.get_header_tokens(h, "foo") == []
+ assert http.get_header_tokens(h, "foo") == []
h["foo"] = ["bar"]
- assert protocol.get_header_tokens(h, "foo") == ["bar"]
+ assert http.get_header_tokens(h, "foo") == ["bar"]
h["foo"] = ["bar, voing"]
- assert protocol.get_header_tokens(h, "foo") == ["bar", "voing"]
+ assert http.get_header_tokens(h, "foo") == ["bar", "voing"]
h["foo"] = ["bar, voing", "oink"]
- assert protocol.get_header_tokens(h, "foo") == ["bar", "voing", "oink"]
+ assert http.get_header_tokens(h, "foo") == ["bar", "voing", "oink"]
def test_read_http_body_request():
@@ -357,17 +357,6 @@ def test_read_response():
assert tst(data, "GET", None, include_body=False).content is None
-def test_parse_http_basic_auth():
- vals = ("basic", "foo", "bar")
- assert protocol.parse_http_basic_auth(
- protocol.assemble_http_basic_auth(*vals)
- ) == vals
- assert not protocol.parse_http_basic_auth("")
- assert not protocol.parse_http_basic_auth("foo bar")
- v = "basic " + binascii.b2a_base64("foo")
- assert not protocol.parse_http_basic_auth(v)
-
-
def test_get_request_line():
r = cStringIO.StringIO("\nfoo")
assert protocol.get_request_line(r) == "foo"
diff --git a/test/http/test_authentication.py b/test/http/test_authentication.py
index c0dae1a2..8f231643 100644
--- a/test/http/test_authentication.py
+++ b/test/http/test_authentication.py
@@ -1,8 +1,21 @@
+import binascii
+
from netlib import odict, http
from netlib.http import authentication
from .. import tutils
+def test_parse_http_basic_auth():
+ vals = ("basic", "foo", "bar")
+ assert http.authentication.parse_http_basic_auth(
+ http.authentication.assemble_http_basic_auth(*vals)
+ ) == vals
+ assert not http.authentication.parse_http_basic_auth("")
+ assert not http.authentication.parse_http_basic_auth("foo bar")
+ v = "basic " + binascii.b2a_base64("foo")
+ assert not http.authentication.parse_http_basic_auth(v)
+
+
class TestPassManNonAnon:
def test_simple(self):
@@ -23,7 +36,7 @@ class TestPassManHtpasswd:
pm = authentication.PassManHtpasswd(tutils.test_data.path("data/htpasswd"))
vals = ("basic", "test", "test")
- http.http1.assemble_http_basic_auth(*vals)
+ authentication.assemble_http_basic_auth(*vals)
assert pm.test("test", "test")
assert not pm.test("test", "foo")
assert not pm.test("foo", "test")
@@ -62,7 +75,7 @@ class TestBasicProxyAuth:
hdrs = odict.ODictCaseless()
vals = ("basic", "foo", "bar")
- hdrs[ba.AUTH_HEADER] = [http.http1.assemble_http_basic_auth(*vals)]
+ hdrs[ba.AUTH_HEADER] = [authentication.assemble_http_basic_auth(*vals)]
assert ba.authenticate(hdrs)
ba.clean(hdrs)
@@ -75,12 +88,12 @@ class TestBasicProxyAuth:
assert not ba.authenticate(hdrs)
vals = ("foo", "foo", "bar")
- hdrs[ba.AUTH_HEADER] = [http.http1.assemble_http_basic_auth(*vals)]
+ hdrs[ba.AUTH_HEADER] = [authentication.assemble_http_basic_auth(*vals)]
assert not ba.authenticate(hdrs)
ba = authentication.BasicProxyAuth(authentication.PassMan(), "test")
vals = ("basic", "foo", "bar")
- hdrs[ba.AUTH_HEADER] = [http.http1.assemble_http_basic_auth(*vals)]
+ hdrs[ba.AUTH_HEADER] = [authentication.assemble_http_basic_auth(*vals)]
assert not ba.authenticate(hdrs)