-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15dcc3e
commit 823eb63
Showing
4 changed files
with
55 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[tools] | ||
python = "3.10" |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pytest | ||
moto | ||
moto | ||
pyjwt |
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ aws-lambda-powertools | |
pydantic[email] | ||
psycopg[binary] | ||
openai | ||
aioboto3 | ||
aioboto3 | ||
pyjwt |
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,49 @@ | ||
import requests | ||
|
||
def test_unauthenticated(api_client): | ||
"""Sad Path: Test that accessing the profile when not correctly authenticated returns a failure.""" | ||
response = api_client.get( | ||
"/api/v1/student/profile", headers={"Authorization": "Bearer invalid"} | ||
) | ||
assert response.status_code == 403 | ||
assert response.json() == { | ||
"Message": "User is not authorized to access this resource with an explicit deny" | ||
} | ||
|
||
def test_student_noaccess(api_client, jwt_generator): | ||
"""Sad Path: Test that accessing the profile when authenticated as a student returns a failure.""" | ||
jwt = jwt_generator(role="student", env="dev", email="noone@testing.megacorp.com") | ||
response = api_client.post( | ||
"/api/v1/recruiter/mass_download", headers={"Authorization": f"Bearer {jwt}"} | ||
) | ||
assert response.status_code == 403 | ||
assert response.json() == { | ||
"Message": "User is not authorized to access this resource" | ||
} | ||
|
||
|
||
def test_one_profile(api_client, jwt_generator): | ||
"""Happy path: test that we can download one profile.""" | ||
jwt = jwt_generator(role="recruiter", env="dev", email="noone@testing.megacorp.com") | ||
response = api_client.post( | ||
"/api/v1/recruiter/mass_download", headers={"Authorization": f"Bearer {jwt}"}, | ||
json={"usernames": ["dsingh14@illinois.edu"]} | ||
) | ||
assert response.status_code == 200 | ||
rjson = response.json() | ||
assert len(rjson) == 1 | ||
s3resp = requests.get(rjson[0]) | ||
assert s3resp.status_code == 200 | ||
|
||
def test_twenty_profiles(api_client, jwt_generator): | ||
"""Happy path: test that we can download one profile.""" | ||
jwt = jwt_generator(role="recruiter", env="dev", email="noone@testing.megacorp.com") | ||
response = api_client.post( | ||
"/api/v1/recruiter/mass_download", headers={"Authorization": f"Bearer {jwt}"}, | ||
json={"usernames": ["dsingh14@illinois.edu"] * 20} | ||
) | ||
assert response.status_code == 200 | ||
rjson = response.json() | ||
assert len(rjson) == 20 | ||
s3resp = requests.get(rjson[0]) | ||
assert s3resp.status_code == 200 |