Example #1
0
 def test_valid_auth(self):
     http_auth = 'Basic {0}'.format(base64.encodestring(settings.API_KEY))
     request = self.req_factory.post('/api/v1/metric/', {},
                                     HTTP_AUTHORIZATION=http_auth)
     auth = SettingsAuthentication()
     auth_resp = auth.authenticate(request)
     self.assertFalse(auth_resp is None, "Authentication failed")
Example #2
0
 def test_valid_auth(self):
     http_auth = 'Basic {0}'.format(
         base64.encodestring(settings.API_KEY))
     request = self.req_factory.post('/api/v1/metric/', {},
                                     HTTP_AUTHORIZATION=http_auth)
     auth = SettingsAuthentication()
     auth_resp = auth.authenticate(request)
     self.assertFalse(auth_resp is None, "Authentication failed")
Example #3
0
 def test_invalid_auth(self):
     http_auth = 'Basic {0}'.format(base64.encodestring('wrongkey'))
     request = self.req_factory.post('/api/v1/metric/', {},
                                     HTTP_AUTHORIZATION=http_auth)
     auth = SettingsAuthentication()
     self.assertRaises(exceptions.AuthenticationFailed, auth.authenticate,
                       request)
Example #4
0
 def test_no_auth(self):
     request = self.req_factory.post('/api/v1/metric/', {})
     auth = SettingsAuthentication()
     auth_resp = auth.authenticate(request)
     self.assertTrue(auth_resp is None, "Authentication succeeded")
Example #5
0
 def test_no_auth(self):
     request = self.req_factory.post('/api/v1/metric/', {})
     auth = SettingsAuthentication()
     auth_resp = auth.authenticate(request)
     self.assertTrue(auth_resp is None, "Authentication succeeded")