aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_proxyauth.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/mitmproxy/addons/test_proxyauth.py b/test/mitmproxy/addons/test_proxyauth.py
index 86621709..6c36b7e8 100644
--- a/test/mitmproxy/addons/test_proxyauth.py
+++ b/test/mitmproxy/addons/test_proxyauth.py
@@ -1,4 +1,5 @@
import binascii
+import ldap3
import pytest
@@ -41,6 +42,13 @@ def test_configure():
ctx.configure(up, proxyauth=None)
assert not up.nonanonymous
+ ctx.configure(up, proxyauth="ldap:ldap.forumsys.com:uid=?,dc=example,dc=com:person")
+ assert up.ldapserver
+ ctx.configure(up, proxyauth="ldaps:ldap.forumsys.com:uid=?,dc=example,dc=com:person")
+ assert up.ldapserver
+ with pytest.raises(exceptions.OptionsError):
+ ctx.configure(up, proxyauth="ldapldap.forumsys.com:uid=?dc=example,dc=com:person")
+
with pytest.raises(exceptions.OptionsError):
ctx.configure(
up,
@@ -109,6 +117,24 @@ def test_check():
)
assert not up.check(f)
+ ctx.configure(
+ up,
+ proxyauth="ldap:ldap.forumsys.com:uid=?,dc=example,dc=com:person"
+ )
+ f.request.headers["Proxy-Authorization"] = proxyauth.mkauth(
+ "einstein", "password"
+ )
+ assert up.check(f)
+ f.request.headers["Proxy-Authorization"] = proxyauth.mkauth(
+ "", ""
+ )
+ assert not up.check(f)
+ with pytest.raises(ldap3.core.exceptions.LDAPBindError):
+ f.request.headers["Proxy-Authorization"] = proxyauth.mkauth(
+ "einstein", "foo"
+ )
+ assert not up.check(f)
+
def test_authenticate():
up = proxyauth.ProxyAuth()