aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorCharles d'Hondt <charles.dhondt@gmail.com>2017-04-28 16:19:27 +0200
committerCharles d'Hondt <charles.dhondt@gmail.com>2017-04-28 16:19:27 +0200
commit5fb18ad275c701971e447c32b1a60f053edf2b35 (patch)
tree2c5aa4fcdf0c6d447baacb5ac068ea6b3a38d612 /test
parentb537997f4f5d7c33562414a414913b6cd89f99c3 (diff)
downloadmitmproxy-5fb18ad275c701971e447c32b1a60f053edf2b35.tar.gz
mitmproxy-5fb18ad275c701971e447c32b1a60f053edf2b35.tar.bz2
mitmproxy-5fb18ad275c701971e447c32b1a60f053edf2b35.zip
Added LDAP Auth
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()