Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
devksingh4 committed Sep 10, 2024
1 parent 15dcc3e commit 823eb63
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
python = "3.10"
3 changes: 2 additions & 1 deletion api/requirements-testing.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pytest
moto
moto
pyjwt
3 changes: 2 additions & 1 deletion api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ aws-lambda-powertools
pydantic[email]
psycopg[binary]
openai
aioboto3
aioboto3
pyjwt
49 changes: 49 additions & 0 deletions tests/live_integration/test_recruiter_mass_download.py
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

0 comments on commit 823eb63

Please sign in to comment.