示例#1
0
    def test_post_delete_same_key_hash(self):
        api_key = {'user': '******', 'key_hash': 'ABCDE'}
        resp1 = self.app.post_json('/v1/apikeys', api_key)
        self.assertEqual(resp1.status_int, 201)
        self.assertEqual(resp1.json['key'], None, 'Key should be None.')

        # drop into the DB since API will be masking this value.
        api_key_db = ApiKey.get_by_id(resp1.json['id'])

        self.assertEqual(api_key_db.key_hash, api_key['key_hash'],
                         'Key_hash should match.')
        self.assertEqual(api_key_db.user, api_key['user'],
                         'Key_hash should match.')

        resp = self.app.delete('/v1/apikeys/%s' % resp1.json['id'])
        self.assertEqual(resp.status_int, 204)
示例#2
0
    def test_post_delete_same_key_hash(self):
        api_key = {
            'user': '******',
            'key_hash': 'ABCDE'
        }
        resp1 = self.app.post_json('/v1/apikeys', api_key)
        self.assertEqual(resp1.status_int, 201)
        self.assertEqual(resp1.json['key'], None, 'Key should be None.')

        # drop into the DB since API will be masking this value.
        api_key_db = ApiKey.get_by_id(resp1.json['id'])

        self.assertEqual(api_key_db.key_hash, api_key['key_hash'], 'Key_hash should match.')
        self.assertEqual(api_key_db.user, api_key['user'], 'Key_hash should match.')

        resp = self.app.delete('/v1/apikeys/%s' % resp1.json['id'])
        self.assertEqual(resp.status_int, 204)
示例#3
0
    def test_post_delete_same_key_hash(self):
        api_key = {
            "id": "5c5dbb576cb8de06a2d79a4d",
            "user": "******",
            "key_hash": "ABCDE",
        }
        resp1 = self.app.post_json("/v1/apikeys", api_key)
        self.assertEqual(resp1.status_int, 201)
        self.assertEqual(resp1.json["key"], None, "Key should be None.")

        # drop into the DB since API will be masking this value.
        api_key_db = ApiKey.get_by_id(resp1.json["id"])

        self.assertEqual(resp1.json["id"], api_key["id"],
                         "PK ID of created API should match.")
        self.assertEqual(api_key_db.key_hash, api_key["key_hash"],
                         "Key_hash should match.")
        self.assertEqual(api_key_db.user, api_key["user"],
                         "User should match.")

        resp = self.app.delete("/v1/apikeys/%s" % resp1.json["id"])
        self.assertEqual(resp.status_int, 204)