Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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)
Exemplo n.º 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")
Exemplo n.º 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")