Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
test.test_urllib2_localnet.ProxyAuthTests Class Reference
Collaboration diagram for test.test_urllib2_localnet.ProxyAuthTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown
def test_proxy_with_bad_password_raises_httperror
def test_proxy_with_no_password_raises_httperror
def test_proxy_qop_auth_works
def test_proxy_qop_auth_int_works_or_throws_urlerror

Public Attributes

 digest_auth_handler
 server
 proxy_digest_handler
 opener

Static Public Attributes

string URL = "http://localhost"
string USER = "tester"
string PASSWD = "test123"
string REALM = "TestRealm"

Detailed Description

Definition at line 233 of file test_urllib2_localnet.py.


Member Function Documentation

Definition at line 240 of file test_urllib2_localnet.py.

00240 
00241     def setUp(self):
00242         super(ProxyAuthTests, self).setUp()
00243         self.digest_auth_handler = DigestAuthHandler()
00244         self.digest_auth_handler.set_users({self.USER: self.PASSWD})
00245         self.digest_auth_handler.set_realm(self.REALM)
00246         def create_fake_proxy_handler(*args, **kwargs):
00247             return FakeProxyHandler(self.digest_auth_handler, *args, **kwargs)
00248 
00249         self.server = LoopbackHttpServerThread(create_fake_proxy_handler)
00250         self.server.start()
00251         self.server.ready.wait()
00252         proxy_url = "http://127.0.0.1:%d" % self.server.port
00253         handler = urllib.request.ProxyHandler({"http" : proxy_url})
00254         self.proxy_digest_handler = urllib.request.ProxyDigestAuthHandler()
00255         self.opener = urllib.request.build_opener(
00256             handler, self.proxy_digest_handler)

Here is the caller graph for this function:

Definition at line 257 of file test_urllib2_localnet.py.

00257 
00258     def tearDown(self):
00259         self.server.stop()
00260         super(ProxyAuthTests, self).tearDown()

Here is the caller graph for this function:

Definition at line 284 of file test_urllib2_localnet.py.

00284 
00285     def test_proxy_qop_auth_int_works_or_throws_urlerror(self):
00286         self.proxy_digest_handler.add_password(self.REALM, self.URL,
00287                                                self.USER, self.PASSWD)
00288         self.digest_auth_handler.set_qop("auth-int")
00289         try:
00290             result = self.opener.open(self.URL)
00291         except urllib.error.URLError:
00292             # It's okay if we don't support auth-int, but we certainly
00293             # shouldn't receive any kind of exception here other than
00294             # a URLError.
00295             result = None
00296         if result:
00297             while result.read():
00298                 pass
00299             result.close()
00300 

Definition at line 275 of file test_urllib2_localnet.py.

00275 
00276     def test_proxy_qop_auth_works(self):
00277         self.proxy_digest_handler.add_password(self.REALM, self.URL,
00278                                                self.USER, self.PASSWD)
00279         self.digest_auth_handler.set_qop("auth")
00280         result = self.opener.open(self.URL)
00281         while result.read():
00282             pass
00283         result.close()

Definition at line 261 of file test_urllib2_localnet.py.

00261 
00262     def test_proxy_with_bad_password_raises_httperror(self):
00263         self.proxy_digest_handler.add_password(self.REALM, self.URL,
00264                                                self.USER, self.PASSWD+"bad")
00265         self.digest_auth_handler.set_qop("auth")
00266         self.assertRaises(urllib.error.HTTPError,
00267                           self.opener.open,
00268                           self.URL)

Here is the call graph for this function:

Definition at line 269 of file test_urllib2_localnet.py.

00269 
00270     def test_proxy_with_no_password_raises_httperror(self):
00271         self.digest_auth_handler.set_qop("auth")
00272         self.assertRaises(urllib.error.HTTPError,
00273                           self.opener.open,
00274                           self.URL)

Here is the call graph for this function:


Member Data Documentation

Definition at line 242 of file test_urllib2_localnet.py.

Definition at line 254 of file test_urllib2_localnet.py.

Definition at line 237 of file test_urllib2_localnet.py.

Definition at line 253 of file test_urllib2_localnet.py.

Definition at line 238 of file test_urllib2_localnet.py.

Definition at line 248 of file test_urllib2_localnet.py.

Definition at line 234 of file test_urllib2_localnet.py.

Definition at line 236 of file test_urllib2_localnet.py.


The documentation for this class was generated from the following file: