Skip to content

Commit

Permalink
Fix wrong credentials param api_key/test_auth_credentials.py
Browse files Browse the repository at this point in the history
  • Loading branch information
azgabur committed Nov 6, 2023
1 parent 37a26c4 commit 28fd1dc
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,35 @@ def authorization(authorization, api_key, credentials):
def test_custom_selector(client, auth, credentials):
"""Test if auth credentials are stored in right place"""
response = client.get("/get", headers={"authorization": "API_KEY " + auth.api_key})
assert response.status_code == 200 if credentials == "authorization_header" else 401
if credentials == "authorizationHeader":
assert response.status_code == 200
else:
assert response.status_code == 401


def test_custom_header(client, auth, credentials):
"""Test if auth credentials are stored in right place"""
response = client.get("/get", headers={"API_KEY": auth.api_key})
assert response.status_code == 200 if credentials == "custom_header" else 401
if credentials == "customHeader":
assert response.status_code == 200
else:
assert response.status_code == 401


def test_query(client, auth, credentials):
"""Test if auth credentials are stored in right place"""
response = client.get("/get", params={"API_KEY": auth.api_key})
assert response.status_code == 200 if credentials == "query" else 401
if credentials == "queryString":
assert response.status_code == 200
else:
assert response.status_code == 401


def test_cookie(route, auth, credentials):
"""Test if auth credentials are stored in right place"""
with route.client(cookies={"API_KEY": auth.api_key}) as client:
response = client.get("/get")
assert response.status_code == 200 if credentials == "cookie" else 401
if credentials == "cookie":
assert response.status_code == 200
else:
assert response.status_code == 401

0 comments on commit 28fd1dc

Please sign in to comment.