Пример #1
0
 def test_valid(self):
     """ Returns username, password if everything is valid """
     username = '******'
     password = '******'
     userpass = (username + ':' + password).encode('base64')
     self.request.environ['HTTP_AUTHORIZATION'] = 'Basic ' + userpass
     creds = auth.get_basicauth_credentials(self.request)
     self.assertEqual(creds, {'login': username, 'password': password})
Пример #2
0
 def test_valid(self):
     """Returns username, password if everything is valid"""
     username = "******"
     password = "******"
     userpass = b64encode((username + ":" + password).encode("utf8")).decode("utf8")
     self.request.environ["HTTP_AUTHORIZATION"] = "Basic " + userpass
     creds = auth.get_basicauth_credentials(self.request)
     self.assertEqual(creds, {"login": username, "password": password})
Пример #3
0
 def test_valid(self):
     """ Returns username, password if everything is valid """
     username = "******"
     password = "******"
     userpass = (username + ":" + password).encode("base64")
     self.request.environ["HTTP_AUTHORIZATION"] = "Basic " + userpass
     creds = auth.get_basicauth_credentials(self.request)
     self.assertEqual(creds, {"login": username, "password": password})
Пример #4
0
 def test_malformed_user_pass(self):
     """ Returns None if username/password is malformed """
     userpass = '******'.encode('base64')
     self.request.environ['HTTP_AUTHORIZATION'] = 'Basic ' + userpass
     creds = auth.get_basicauth_credentials(self.request)
     self.assertIsNone(creds)
Пример #5
0
 def test_not_base64(self):
     """ Returns None if auth isn't base64 encoded """
     self.request.environ['HTTP_AUTHORIZATION'] = 'Basic abcdefg'
     creds = auth.get_basicauth_credentials(self.request)
     self.assertIsNone(creds)
Пример #6
0
 def test_not_basic(self):
     """ Returns None if auth isn't 'basic' """
     self.request.environ['HTTP_AUTHORIZATION'] = 'advanced abcdefg'
     creds = auth.get_basicauth_credentials(self.request)
     self.assertIsNone(creds)
Пример #7
0
 def test_bad_format(self):
     """ Returns None if headers malformed """
     self.request.environ['HTTP_AUTHORIZATION'] = 'alskdjasd'
     creds = auth.get_basicauth_credentials(self.request)
     self.assertIsNone(creds)
Пример #8
0
 def test_no_headers(self):
     """ Returns None if no headers found """
     creds = auth.get_basicauth_credentials(self.request)
     self.assertIsNone(creds)
Пример #9
0
 def test_malformed_user_pass(self):
     """Returns None if username/password is malformed"""
     userpass = b64encode(b"abcd").decode("utf8")
     self.request.environ["HTTP_AUTHORIZATION"] = "Basic " + userpass
     creds = auth.get_basicauth_credentials(self.request)
     self.assertIsNone(creds)
Пример #10
0
 def test_malformed_user_pass(self):
     """ Returns None if username/password is malformed """
     userpass = "******".encode("base64")
     self.request.environ["HTTP_AUTHORIZATION"] = "Basic " + userpass
     creds = auth.get_basicauth_credentials(self.request)
     self.assertIsNone(creds)
Пример #11
0
 def test_not_base64(self):
     """ Returns None if auth isn't base64 encoded """
     self.request.environ["HTTP_AUTHORIZATION"] = "Basic abcdefg"
     creds = auth.get_basicauth_credentials(self.request)
     self.assertIsNone(creds)
Пример #12
0
 def test_not_basic(self):
     """ Returns None if auth isn't 'basic' """
     self.request.environ["HTTP_AUTHORIZATION"] = "advanced abcdefg"
     creds = auth.get_basicauth_credentials(self.request)
     self.assertIsNone(creds)
Пример #13
0
 def test_bad_format(self):
     """ Returns None if headers malformed """
     self.request.environ["HTTP_AUTHORIZATION"] = "alskdjasd"
     creds = auth.get_basicauth_credentials(self.request)
     self.assertIsNone(creds)
Пример #14
0
 def test_no_headers(self):
     """ Returns None if no headers found """
     creds = auth.get_basicauth_credentials(self.request)
     self.assertIsNone(creds)