-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle database permissions errors and workflow exceptions (#609)
* fix: fix zarf templating typo * fix: change user running the migrations * fix: delay removing the supabase deployment wihtin our e2e tests * fix: fix duplicate id name in e2e.yaml workflow * fix: test for the proper http return codes when testing row_level_security * chore: bump version of uds-core for the e2e tests * fix: created test utility for getting api key to test against --------- Co-authored-by: Gregory Horvath <gphorvath@defenseunicorns.com>
- Loading branch information
Showing
12 changed files
with
119 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import json | ||
import os | ||
|
||
import pytest | ||
import requests | ||
|
||
# This is the anon_key for supabase, it provides access to the endpoints that would otherwise be inaccessible | ||
ANON_KEY = os.environ["ANON_KEY"] | ||
|
||
DEFAULT_TEST_EMAIL = "fakeuser1@test.com" | ||
DEFAULT_TEST_PASSWORD = "password" | ||
|
||
|
||
def create_test_user( | ||
anon_key: str = ANON_KEY, | ||
email: str = DEFAULT_TEST_EMAIL, | ||
password: str = DEFAULT_TEST_PASSWORD, | ||
) -> str: | ||
headers = { | ||
"apikey": f"{anon_key}", | ||
"Authorization": f"Bearer {anon_key}", | ||
"Content-Type": "application/json", | ||
} | ||
|
||
requests.post( | ||
url="https://supabase-kong.uds.dev/auth/v1/signup", | ||
headers=headers, | ||
json={ | ||
"email": email, | ||
"password": password, | ||
"confirmPassword": password, | ||
}, | ||
) | ||
|
||
return get_jwt_token(anon_key, email, password) | ||
|
||
|
||
def get_jwt_token( | ||
api_key: str, | ||
test_email: str = DEFAULT_TEST_EMAIL, | ||
test_password: str = DEFAULT_TEST_PASSWORD, | ||
) -> str: | ||
url = "https://supabase-kong.uds.dev/auth/v1/token?grant_type=password" | ||
headers = {"apikey": f"{api_key}", "Content-Type": "application/json"} | ||
data = {"email": test_email, "password": test_password} | ||
|
||
response = requests.post(url, headers=headers, json=data) | ||
if response.status_code != 200: | ||
pytest.fail( | ||
f"Request for the JWT token failed with status code {response.status_code} expected 200", | ||
False, | ||
) | ||
|
||
return json.loads(response.content)["access_token"] |