def test_identify_with_bad_noncecount(self):
     plugin = DigestAuthPlugin("test", get_password=lambda u: "testing")
     environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/one")
     # Do an initial auth to get the nonce.
     params = get_challenge(plugin, environ)
     build_response(environ, params, "tester", "testing", nc="01")
     identity = plugin.identify(environ)
     self.assertNotEquals(identity, None)
     plugin.remember(environ, identity)
     # Authing without increasing nc will fail.
     environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/two")
     build_response(environ, params, "tester", "testing", nc="01")
     self.assertEquals(plugin.identify(environ), None)
     # Authing with a badly-formed nc will fail
     environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/two")
     build_response(environ, params, "tester", "testing", nc="02XXX")
     self.assertEquals(plugin.identify(environ), None)
     # Authing with a badly-formed nc will fail
     environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/two")
     build_response(environ, params, "tester", "testing", nc="02XXX")
     self.assertEquals(plugin.identify(environ), None)
     # Authing with increasing nc will succeed.
     environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/two")
     build_response(environ, params, "tester", "testing", nc="02")
     self.assertNotEquals(plugin.identify(environ), None)
示例#2
0
 def test_identify_with_bad_noncecount(self):
     plugin = DigestAuthPlugin("test", get_password=lambda u: "testing")
     environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/one")
     # Do an initial auth to get the nonce.
     params = get_challenge(plugin, environ)
     build_response(environ, params, "tester", "testing", nc="01")
     identity = plugin.identify(environ)
     self.assertNotEquals(identity, None)
     plugin.remember(environ, identity)
     # Authing without increasing nc will fail.
     environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/two")
     build_response(environ, params, "tester", "testing", nc="01")
     self.assertEquals(plugin.identify(environ), None)
     # Authing with a badly-formed nc will fail
     environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/two")
     build_response(environ, params, "tester", "testing", nc="02XXX")
     self.assertEquals(plugin.identify(environ), None)
     # Authing with a badly-formed nc will fail
     environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/two")
     build_response(environ, params, "tester", "testing", nc="02XXX")
     self.assertEquals(plugin.identify(environ), None)
     # Authing with increasing nc will succeed.
     environ = make_environ(REQUEST_METHOD="GET", PATH_INFO="/two")
     build_response(environ, params, "tester", "testing", nc="02")
     self.assertNotEquals(plugin.identify(environ), None)
 def test_remember_with_next_nonce(self):
     plugin = DigestAuthPlugin("test", nonce_manager=EasyNonceManager())
     environ = make_environ()
     params = get_challenge(plugin, environ)
     params = build_response(environ, params, "tester", "testing")
     headers = plugin.remember(environ, params)
     self.assertEquals(headers[0][0], "Authentication-Info")
示例#4
0
 def test_remember_with_next_nonce(self):
     plugin = DigestAuthPlugin("test", nonce_manager=EasyNonceManager())
     environ = make_environ()
     params = get_challenge(plugin, environ)
     params = build_response(environ, params, "tester", "testing")
     headers = plugin.remember(environ, params)
     self.assertEquals(headers[0][0], "Authentication-Info")
 def test_remember_with_no_next_nonce(self):
     plugin = DigestAuthPlugin("test")
     environ = make_environ()
     params = get_challenge(plugin, environ)
     params = build_response(environ, params, "tester", "testing")
     self.assertEquals(plugin.remember(environ, params), None)
 def test_remember_with_no_identity(self):
     plugin = DigestAuthPlugin("test")
     environ = make_environ()
     self.assertEquals(plugin.remember(environ, {}), None)
示例#7
0
 def test_remember_with_no_next_nonce(self):
     plugin = DigestAuthPlugin("test")
     environ = make_environ()
     params = get_challenge(plugin, environ)
     params = build_response(environ, params, "tester", "testing")
     self.assertEquals(plugin.remember(environ, params), None)
示例#8
0
 def test_remember_with_no_identity(self):
     plugin = DigestAuthPlugin("test")
     environ = make_environ()
     self.assertEquals(plugin.remember(environ, {}), None)