1. Amit Aronovitch
  2. python-ntlm

Commits

sam...@gmail.com@fb9420a8-c688-11dd-8ca8-e3ff79f713b6  committed cb943b9

Issue 13: Bug: HTTPPasswordMgr is not defined

  • Participants
  • Parent commits 08fb4cb
  • Branches default
  • Tags svn_r89

Comments (0)

Files changed (1)

File python26/ntlm/HTTPNtlmAuthHandler.py

View file
  • Ignore whitespace
 
 class AbstractNtlmAuthHandler:
     def __init__(self, password_mgr=None, debuglevel=0):
+        """Initialize an instance of a AbstractNtlmAuthHandler.
+
+Verify operation with all default arguments.
+>>> abstrct = AbstractNtlmAuthHandler()
+
+Verify "normal" operation.
+>>> abstrct = AbstractNtlmAuthHandler(urllib2.HTTPPasswordMgrWithDefaultRealm())
+"""
         if password_mgr is None:
-            password_mgr = HTTPPasswordMgr()
+            password_mgr = urllib2.HTTPPasswordMgr()
         self.passwd = password_mgr
         self.add_password = self.passwd.add_password
         self._debuglevel = debuglevel
 
 
 if __name__ == "__main__":
-    url = "http://ntlmprotectedserver/securedfile.html"
-    user = u'DOMAIN\\User'
-    password = 'Password'
+    import doctest
+    doctest.testmod()
 
-    passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
-    passman.add_password(None, url, user , password)
-    auth_basic = urllib2.HTTPBasicAuthHandler(passman)
-    auth_digest = urllib2.HTTPDigestAuthHandler(passman)
-    auth_NTLM = HTTPNtlmAuthHandler(passman)
-
-    # disable proxies (just for testing)
-    proxy_handler = urllib2.ProxyHandler({})
-
-    opener = urllib2.build_opener(proxy_handler, auth_NTLM) #, auth_digest, auth_basic)
-
-    urllib2.install_opener(opener)
-
-    response = urllib2.urlopen(url)
-    print(response.read())
-
+### TODO: Move this to the ntlm examples directory.
+##if __name__ == "__main__":
+##    url = "http://ntlmprotectedserver/securedfile.html"
+##    user = u'DOMAIN\\User'
+##    password = 'Password'
+##
+##    passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
+##    passman.add_password(None, url, user , password)
+##    auth_basic = urllib2.HTTPBasicAuthHandler(passman)
+##    auth_digest = urllib2.HTTPDigestAuthHandler(passman)
+##    auth_NTLM = HTTPNtlmAuthHandler(passman)
+##
+##    # disable proxies (just for testing)
+##    proxy_handler = urllib2.ProxyHandler({})
+##
+##    opener = urllib2.build_opener(proxy_handler, auth_NTLM) #, auth_digest, auth_basic)
+##
+##    urllib2.install_opener(opener)
+##
+##    response = urllib2.urlopen(url)
+##    print(response.read())