Skip to content

Commit a230555

Browse files
committed
Change the unit test to lambdas/lambda_authorizer
1 parent 5f089f5 commit a230555

File tree

7 files changed

+50
-43
lines changed

7 files changed

+50
-43
lines changed

.github/workflows/ci.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,23 @@ jobs:
4343
run: |
4444
cd bmh_admin_portal_backend
4545
poetry run pytest -vv --cov-report xml tests
46+
47+
lambda_auth_unit_test:
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- name: Check out code
52+
uses: actions/checkout@v3
53+
- name: Set up python
54+
uses: actions/setup-python@v4
55+
with:
56+
python-version: "3.9"
57+
- name: Install pip requirements
58+
run: |
59+
cd bmh_admin_portal_backend/lambdas/lambda_authorizer
60+
pip --version
61+
pip install -r requirements.txt
62+
- name: Run test
63+
run: |
64+
cd bmh_admin_portal_backend/lambdas/lambda_authorizer
65+
pytest -vv --cov-report xml tests

.secrets.baseline

+21-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "bmh_admin_portal_ui/package-lock.json|^.secrets.baseline$|^../.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2024-06-11T18:37:34Z",
6+
"generated_at": "2024-06-13T15:50:28Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -58,21 +58,37 @@
5858
}
5959
],
6060
"results": {
61-
"lambdas/workspaces_api_resource/workspaces_api_resource_handler.py": [
61+
"bmh_admin_portal_backend/lambdas/workspaces_api_resource/workspaces_api_resource_handler.py": [
6262
{
6363
"hashed_secret": "505032eaf8a3acf9b094a326dfb1cd0537c75a0d",
6464
"is_verified": false,
6565
"line_number": 439,
6666
"type": "Secret Keyword"
6767
}
6868
],
69-
"poetry.lock": [
69+
"bmh_admin_portal_backend/poetry.lock": [
7070
{
71-
"hashed_secret": "7ea91fd4bc39f6ced54285ea67cfa7b247b33376",
71+
"hashed_secret": "c1dd1514fc9014ac7cb6fe5f5c71e5a6f71a01ce",
7272
"is_verified": false,
73-
"line_number": 2772,
73+
"line_number": 2740,
7474
"type": "Hex High Entropy String"
7575
}
76+
],
77+
"bmh_admin_portal_ui/README_DEPLOYMENT.md": [
78+
{
79+
"hashed_secret": "a033a528b603fed46f861d4b3542c417b99d41c8",
80+
"is_verified": false,
81+
"line_number": 74,
82+
"type": "Secret Keyword"
83+
}
84+
],
85+
"bmh_workspace/templates/BMHAccountBaseline.yml": [
86+
{
87+
"hashed_secret": "5ef4751aeb252031285d28e935b86bbbe959d6f5",
88+
"is_verified": false,
89+
"line_number": 290,
90+
"type": "Secret Keyword"
91+
}
7692
]
7793
},
7894
"version": "0.13.1",
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
PyJWT==2.4.0
22
cryptography==42.0.6
3+
jwcrypto==1.5.6

bmh_admin_portal_backend/tests/test_lambda_authorizer.py bmh_admin_portal_backend/lambdas/lambda_authorizer/tests/test_lambda_authorizer.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
import io
3+
import os
34
import json
45
import jwt
56
import time
@@ -16,6 +17,8 @@ def test_validate_token():
1617
Tests the functionality of validate token by creating a dummy JWT token using RS256 algorithm.
1718
Note: We also create an RSA key pair and a JWK for the public key for the test.
1819
"""
20+
os.environ["allowed_client_id_audience"] = "Valid test audience"
21+
os.environ["auth_base_url"] = "https://mock.data-commons.org/user"
1922

2023
# Generate RSA private key
2124
private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
@@ -94,3 +97,7 @@ def test_validate_token():
9497
):
9598
with pytest.raises(ExpiredSignatureError):
9699
payload = lambda_authorizer.validate_token(mock_jwt_token)
100+
101+
# teardown env vars
102+
del os.environ["allowed_client_id_audience"]
103+
del os.environ["auth_base_url"]

bmh_admin_portal_backend/poetry.lock

+1-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bmh_admin_portal_backend/pyproject.toml

-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ openapi-core = "^0.17.0"
4646
pytest = "^6.0.0"
4747
pytest-cov = "*"
4848
pyyaml = "^6.0.0"
49-
PyJWT = "^2.4.0"
50-
cryptography = "^42.0.6"
51-
jwcrypto = "^1.5.6"
5249

5350
[build-system]
5451
requires = ["poetry-core>=1.0.0"]

bmh_admin_portal_backend/tests/conftest.py

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ def setup_env_vars():
3030
"api_usage_id_param_name": "testUsageId",
3131
"total_usage_trigger_lambda_arn": "testTotalUsageArn",
3232
"user_services_email": "DummyUserServices@email.com",
33-
"allowed_client_id_audience": "Valid test audience",
34-
"auth_base_url": "https://mock.data-commons.org/user",
3533
},
3634
):
3735
yield

0 commit comments

Comments
 (0)