def test_proxy_auth(self): # First, test the case where we have the particular realm registered headers = strToHeaders(''' Proxy-Authenticate: Basic realm="foo" ''') host = 'flipper.seomoz.org' Auth.register(host, 'foo', 'Aladdin', 'open sesame') self.assertEqual(Auth.auth(host, None, headers), {'Proxy-Authorization': 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='}) Auth.unregister(host, 'foo') # First, test the case where we don't have this realm registered headers = strToHeaders(''' Proxy-Authenticate: Basic realm="bar" ''') self.assertEqual(Auth.auth(host, None, headers), {})
def test_wild_proxy_auth(self): headers = strToHeaders(''' Server: squid/2.7.STABLE6 Date: Tue, 17 Jan 2012 20:41:42 GMT Content-Type: text/html Content-Length: 1303 X-Squid-Error: ERR_CACHE_ACCESS_DENIED 0 Proxy-Authenticate: Basic realm="Squid proxy-caching web server" X-Cache: MISS from flipper.seomoz.com Connection: close ''') host = 'flipper.seomoz.org' Auth.register(host, None, 'Aladdin', 'open sesame') self.assertEqual(Auth.auth(host, None, headers), {'Proxy-Authorization': 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='}) Auth.unregister(host)