aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http_auth.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2013-12-08 13:35:42 +1300
committerAldo Cortesi <aldo@nullcube.com>2013-12-08 13:35:42 +1300
commit7213f86d49960a625643fb6179e6a3731b16d462 (patch)
tree72637191abaf59e93c3949302d287aa8260598da /netlib/http_auth.py
parentd05c20d8fab3345e19c06ac0de00a2c8f30c44ef (diff)
downloadmitmproxy-7213f86d49960a625643fb6179e6a3731b16d462.tar.gz
mitmproxy-7213f86d49960a625643fb6179e6a3731b16d462.tar.bz2
mitmproxy-7213f86d49960a625643fb6179e6a3731b16d462.zip
Unit test auth actions.
Diffstat (limited to 'netlib/http_auth.py')
-rw-r--r--netlib/http_auth.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/netlib/http_auth.py b/netlib/http_auth.py
index 6c91c7c5..71f120d6 100644
--- a/netlib/http_auth.py
+++ b/netlib/http_auth.py
@@ -125,23 +125,19 @@ class AuthAction(Action):
"""
def __call__(self, parser, namespace, values, option_string=None):
passman = self.getPasswordManager(values)
- if passman:
- authenticator = BasicProxyAuth(passman, "mitmproxy")
- else:
- authenticator = NullProxyAuth(None)
+ authenticator = BasicProxyAuth(passman, "mitmproxy")
setattr(namespace, "authenticator", authenticator)
- def getPasswordManager(self, s):
- """
- returns the password manager
- """
+ def getPasswordManager(self, s): # pragma: nocover
raise NotImplementedError()
class SingleuserAuthAction(AuthAction):
def getPasswordManager(self, s):
if len(s.split(':')) != 2:
- raise ArgumentTypeError("Invalid single-user specification. Please use the format username:password")
+ raise ArgumentTypeError(
+ "Invalid single-user specification. Please use the format username:password"
+ )
username, password = s.split(':')
return PassManSingleUser(username, password)
@@ -154,4 +150,5 @@ class NonanonymousAuthAction(AuthAction):
class HtpasswdAuthAction(AuthAction):
def getPasswordManager(self, s):
with open(s, "r") as f:
- return PassManHtpasswd(f) \ No newline at end of file
+ return PassManHtpasswd(f)
+