-
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.
enable mass presigned download support (#43)
* enable mass presign support * fix * fix indent * update swagger * update method * stuff * check a few of them
- Loading branch information
1 parent
5cbe789
commit 7b4d9e8
Showing
10 changed files
with
144 additions
and
6 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 |
---|---|---|
|
@@ -5,4 +5,5 @@ __pycache__ | |
test.json | ||
build | ||
.vscode/settings.json | ||
node_modules/ | ||
node_modules/ | ||
api/.mise.toml |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
aws-lambda-powertools | ||
pydantic[email] | ||
psycopg[binary] | ||
openai | ||
openai | ||
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
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,53 @@ | ||
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 | ||
s3resp = requests.get(rjson[10]) | ||
assert s3resp.status_code == 200 | ||
s3resp = requests.get(rjson[19]) | ||
assert s3resp.status_code == 200 |