def test_no_query_id(self):
     with self.app.test_client() as c:
         rv = c.get(
             "/{}/api/queries".format(self.query.org.slug),
             query_string={"api_key": self.api_key},
         )
         self.assertIsNone(hmac_load_user_from_request(request))
 def test_user_api_key(self):
     user = self.factory.create_user(api_key="user_key")
     path = '/api/queries/'
     with app.test_client() as c:
         signature = sign(user.api_key, path, self.expires)
         rv = c.get(path, query_string={'signature': signature, 'expires': self.expires, 'user_id': user.id})
         self.assertEqual(user.id, hmac_load_user_from_request(request).id)
 def test_user_api_key(self):
     user = user_factory.create(api_key="user_key")
     path = '/api/queries/'
     with app.test_client() as c:
         signature = sign(user.api_key, path, self.expires)
         rv = c.get(path, query_string={'signature': signature, 'expires': self.expires, 'user_id': user.id})
         self.assertEqual(user.id, hmac_load_user_from_request(request).id)
 def test_wrong_signature(self):
     with app.test_client() as c:
         rv = c.get(self.path,
                    query_string={
                        'signature': 'whatever',
                        'expires': self.expires
                    })
         self.assertIsNone(hmac_load_user_from_request(request))
 def test_correct_signature(self):
     with app.test_client() as c:
         rv = c.get('/api/queries/{0}'.format(self.query.id),
                    query_string={
                        'signature': self.signature(self.expires),
                        'expires': self.expires
                    })
         self.assertIsNotNone(hmac_load_user_from_request(request))
Exemple #6
0
 def test_correct_signature(self):
     with self.app.test_client() as c:
         rv = c.get(self.path,
                    query_string={
                        'signature': self.signature(self.expires),
                        'expires': self.expires
                    })
         self.assertIsNotNone(hmac_load_user_from_request(request))
Exemple #7
0
    def test_user_api_key(self):
        user = self.factory.create_user(api_key="user_key")
        path = '/api/queries/'
        models.db.session.flush()

        signature = sign(user.api_key, path, self.expires)
        with self.app.test_client() as c:
            rv = c.get(path, query_string={'signature': signature, 'expires': self.expires, 'user_id': user.id})
            self.assertEqual(user.id, hmac_load_user_from_request(request).id)
 def test_wrong_signature(self):
     with self.app.test_client() as c:
         rv = c.get(
             self.path,
             query_string={
                 "signature": "whatever",
                 "expires": self.expires
             },
         )
         self.assertIsNone(hmac_load_user_from_request(request))
 def test_no_query_id(self):
     with app.test_client() as c:
         rv = c.get('/{}/api/queries'.format(self.query.org.slug), query_string={'api_key': self.api_key})
         self.assertIsNone(hmac_load_user_from_request(request))
 def test_correct_signature(self):
     with app.test_client() as c:
         rv = c.get(self.path, query_string={'signature': self.signature(self.expires), 'expires': self.expires})
         self.assertIsNotNone(hmac_load_user_from_request(request))
 def test_wrong_signature(self):
     with app.test_client() as c:
         rv = c.get(self.path, query_string={'signature': 'whatever', 'expires': self.expires})
         self.assertIsNone(hmac_load_user_from_request(request))
 def test_no_signature(self):
     with app.test_client() as c:
         rv = c.get(self.path)
         self.assertIsNone(hmac_load_user_from_request(request))
Exemple #13
0
 def test_no_signature(self):
     with app.test_client() as c:
         rv = c.get(self.path)
         self.assertIsNone(hmac_load_user_from_request(request))
Exemple #14
0
 def test_no_query_id(self):
     with app.test_client() as c:
         rv = c.get('/api/queries', query_string={'api_key': self.api_key})
         self.assertIsNone(hmac_load_user_from_request(request))
 def test_correct_signature(self):
     with app.test_client() as c:
         rv = c.get('/api/queries/{0}'.format(self.query.id), query_string={'signature': self.signature(self.expires), 'expires': self.expires})
         self.assertIsNotNone(hmac_load_user_from_request(request))