def test_auth_good_legacy_mode(self): plugin = DigestAuthPlugin("test", get_password=lambda u: "testing") environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/legacy") params = get_challenge(plugin, environ) params = build_response(environ, params, "tester", "testing", qop=None) self.failIf("qop" in params) self.assertNotEquals(plugin.authenticate(environ, params), None)
def test_auth_with_different_realm(self): plugin = DigestAuthPlugin("test", get_password=lambda u: "testing") environ = make_environ() params = get_challenge(plugin, environ) params["realm"] = "other-realm" params = build_response(environ, params, "tester", "testing") self.assertEquals(plugin.authenticate(environ, params), None)
def test_auth_good_get_with_vars(self): pwdhash = calculate_pwdhash("tester", "testing", "test") plugin = DigestAuthPlugin("test", get_pwdhash=lambda u, r: pwdhash) environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/hi?who=me") params = get_challenge(plugin, environ) params = build_response(environ, params, "tester", "testing") self.assertNotEquals(plugin.authenticate(environ, params), None)
def test_auth_with_bad_digest_response(self): plugin = DigestAuthPlugin("test", get_password=lambda u: "testing") environ = make_environ() params = get_challenge(plugin, environ) params = build_response(environ, params, "tester", "testing") params["response"] += "WRONG" self.assertEquals(plugin.authenticate(environ, params), None)
def test_auth_with_invalid_content_md5(self): plugin = DigestAuthPlugin("test", get_password=lambda u: "testing") environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/authint", HTTP_CONTENT_MD5="1B2M2Y8AsgTpgAmY7PhCfg==") params = get_challenge(plugin, environ) params = build_response(environ, params, "tester", "testing", qop="auth-int") params["content-md5"] = "8baNZjN6gc+g0gdhccuiqA==" self.assertNotEquals(plugin.identify(environ), None) self.assertEquals(plugin.authenticate(environ, params), None)
def test_auth_good_authint_mode(self): plugin = DigestAuthPlugin("test", get_password=lambda u: "testing") environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/authint", HTTP_CONTENT_MD5="1B2M2Y8AsgTpgAmY7PhCfg==") params = get_challenge(plugin, environ) params = build_response(environ, params, "tester", "testing", qop="auth-int") self.assertNotEquals(plugin.authenticate(environ, params), None)
def test_auth_with_no_password_callbacks(self): plugin = DigestAuthPlugin("test") environ = make_environ() params = get_challenge(plugin, environ) params = build_response(environ, params, "tester", "testing") self.assertEquals(plugin.authenticate(environ, params), None)
def test_auth_with_no_identity(self): plugin = DigestAuthPlugin("test", get_password=lambda u: "testing") environ = make_environ() self.assertEquals(plugin.authenticate(environ, {}), None)
def test_auth_good_post(self): plugin = DigestAuthPlugin("test", get_password=lambda u: "testing") environ = make_environ(REQUEST_METHOD="POST", PATH_INFO="/do/stuff") params = get_challenge(plugin, environ) params = build_response(environ, params, "tester", "testing") self.assertNotEquals(plugin.authenticate(environ, params), None)