Commit 3d374f2f authored by Luc Yriarte's avatar Luc Yriarte
Browse files

Merge branch 'slb-tests-restore' into 'master'

Slb tests restore

See merge request !64
parents d959c5c0 44a39788
Pipeline #35046 passed with stages
in 15 minutes and 38 seconds
......@@ -14,6 +14,8 @@
import requests
import pytest
import datetime
import jwt
payload = {}
......@@ -40,8 +42,9 @@ def skip_if_gcp_environment(base_url):
# Test for expired token
def test_expired_token_returns_40X(base_url, check_cert, token):
url = build_url(base_url, "/about")
token_expired = jwt.encode({"email":"nobody@example.com", "exp":datetime.datetime.utcnow() - datetime.timedelta(seconds=300)}, key="secret", algorithm="HS256")
headers = {
'Authorization': 'Bearer REMOVED_FOR_CICD_SCAN'
'Authorization': f"Bearer {token_expired}"
}
response = requests.request("GET", url, headers=headers, data=payload, verify=check_cert)
assert response.status_code == 401
......@@ -81,7 +84,7 @@ def test_invalid_token_returns_40X(base_url, check_cert, token):
blank = {}
token_invalid = token[0:len(token) - 10]
headers = {
'Authorization': 'Bearer REMOVED_FOR_CICD_SCAN'
'Authorization': f"Bearer {token_invalid}"
}
response = requests.request("GET", url, headers=headers, data=blank, verify=check_cert)
......@@ -92,8 +95,9 @@ def test_invalid_token_returns_40X(base_url, check_cert, token):
def test_invalid_issuer_token_returns_40X(base_url, check_cert, token):
url = build_url(base_url, "/about")
blank = {}
token_no_iss = jwt.encode({"email": "nobody@example.com"}, key="secret", algorithm="HS256")
headers = {
'Authorization': 'Bearer REMOVED_FOR_CICD_SCAN'
'Authorization': f"Bearer {token_no_iss}"
}
response = requests.request("GET", url, headers=headers, data=blank, verify=check_cert)
assert response.status_code == 401
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment