def test_challenge_with_other_status(self): plugin = DigestAuthPlugin("test") environ = make_environ() app = plugin.challenge(environ, "200 OK", [], []) self.assertNotEqual(app, None) response = get_response(app, environ) self.failUnless(response.startswith("401 Unauthorized"))
def test_challenge_with_extra_domains(self): plugin = DigestAuthPlugin("test", domain="http://example.com") environ = make_environ() app = plugin.challenge(environ, "200 OK", [], []) self.assertNotEqual(app, None) response = get_response(app, environ) self.failUnless(response.startswith("401 Unauthorized")) self.failUnless("http://example.com" in response)
def test_challenge(self): plugin = DigestAuthPlugin("test") environ = make_environ() app = plugin.challenge(environ, "401 Unauthorized", [], []) self.assertNotEqual(app, None) response = get_response(app, environ) self.failUnless(response.startswith("401 Unauthorized")) self.failUnless("WWW-Authenticate: Digest" in response)
def test_challenge_with_stale_nonce(self): plugin = DigestAuthPlugin("test") environ = make_environ() # Identify with a bad nonce to mark it as stale. params = get_challenge(plugin, environ) params["nonce"] += "STALE" params = build_response(environ, params, "tester", "testing") self.assertEquals(plugin.identify(environ), None) # The challenge should then include stale=TRUE app = plugin.challenge(environ, "200 OK", [], []) self.assertNotEqual(app, None) response = get_response(app, environ) self.failUnless(response.startswith("401 Unauthorized")) self.failUnless('stale="TRUE"' in response)
def test_challenge_with_extra_headers(self): plugin = DigestAuthPlugin("test") environ = make_environ() app_headers = [("X-Test-One", "test1")] forget_headers = [("X-Test-Two", "test2")] app = plugin.challenge(environ, "401 Unauthorized", app_headers, forget_headers) self.assertNotEqual(app, None) response = get_response(app, environ) self.failUnless(response.startswith("401 Unauthorized")) self.failUnless("WWW-Authenticate: Digest" in response) self.failUnless("X-Test-One" in response) self.failUnless("test1" in response) self.failUnless("X-Test-Two" in response) self.failUnless("test2" in response)