Skip to content

Commit d86bb1c

Browse files
Merge pull request #401 from csg-org/development
Sprint 13
2 parents a9fb983 + ab920aa commit d86bb1c

File tree

420 files changed

+17637
-8000
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

420 files changed

+17637
-8000
lines changed

.github/workflows/check-lambda-js.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ on:
1010
- main
1111
- development
1212
- ia-web-development
13+
- ia-development
1314
paths:
14-
- backend/compact-connect/lambdas/cloudfront-csp/**
15+
- backend/compact-connect/lambdas/nodejs/**
1516

1617
# Allows you to run this workflow manually from the Actions tab
1718
workflow_dispatch:
1819

1920
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2021
jobs:
21-
CheckLambdaJS:
22+
CheckLambdas:
2223
runs-on: ubuntu-latest
2324

2425
steps:
@@ -36,28 +37,30 @@ jobs:
3637
- name: Setup Node
3738
uses: actions/setup-node@v1
3839
with:
39-
node-version: '20.15.1'
40+
node-version: '22.1.0'
4041

4142
# Use any cached yarn dependencies (saves build time)
4243
- uses: actions/cache@v2
4344
with:
4445
path: '**/node_modules'
4546
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
4647

47-
# =======================================================================
48-
# = Cloudfront CSP Lambda =
49-
# =======================================================================
5048
# Install Yarn Dependencies
5149
- name: Install JS dependencies (Cloudfront CSP Lambda)
5250
run: yarn install
53-
working-directory: ./backend/compact-connect/lambdas/cloudfront-csp
51+
working-directory: ./backend/compact-connect/lambdas/nodejs
5452

5553
# Run Linter Checks
5654
- name: Run linter (Cloudfront CSP Lambda)
5755
run: yarn run lint
58-
working-directory: ./backend/compact-connect/lambdas/cloudfront-csp
56+
working-directory: ./backend/compact-connect/lambdas/nodejs
5957

6058
# Run Unit Tests
6159
- name: Run unit tests (Cloudfront CSP Lambda)
6260
run: yarn test
63-
working-directory: ./backend/compact-connect/lambdas/cloudfront-csp
61+
working-directory: ./backend/compact-connect/lambdas/nodejs
62+
63+
# Audit dependencies for vulnerabilities
64+
- name: Audit dependencies (Cloudfront CSP Lambda)
65+
run: yarn run audit:dependencies
66+
working-directory: ./backend/compact-connect/lambdas/nodejs

.github/workflows/check-python.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ jobs:
3333
TestPython:
3434
runs-on: ubuntu-latest
3535
steps:
36-
- uses: actions/setup-python@v5
36+
- name: Setup Python
37+
uses: actions/setup-python@v5
3738
with:
3839
python-version: '3.12'
3940

@@ -47,7 +48,7 @@ jobs:
4748
run: "cd backend; bin/sync_deps.sh"
4849

4950
- name: Test backend
50-
run: "cd backend; bin/run_tests.sh no-report"
51+
run: "cd backend; bin/run_tests.sh python no-report"
5152

5253
- name: Check Dependencies
5354
run: "pip-audit"

backend/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ cdk.out
1212
# Save for local config
1313
cdk.context.json
1414
*-cdk.context.json
15+
# smoke test env
16+
smoke_tests_env.json

backend/bin/compile_requirements.sh

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
set -e
22

3-
pip-compile --no-emit-index-url --upgrade multi-account/requirements.in
43
pip-compile --no-emit-index-url --upgrade multi-account/requirements-dev.in
5-
pip-compile --no-emit-index-url --upgrade compact-connect/requirements.in
4+
pip-compile --no-emit-index-url --upgrade multi-account/requirements.in
65
pip-compile --no-emit-index-url --upgrade compact-connect/requirements-dev.in
7-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/common-python/requirements.in
8-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/common-python/requirements-dev.in
9-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/custom-resources/requirements.in
10-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/custom-resources/requirements-dev.in
11-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/license-data/requirements.in
12-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/license-data/requirements-dev.in
13-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/provider-data-v1/requirements.in
14-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/provider-data-v1/requirements-dev.in
15-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/purchases/requirements.in
16-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/purchases/requirements-dev.in
17-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/staff-user-pre-token/requirements.in
18-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/staff-user-pre-token/requirements-dev.in
19-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/staff-users/requirements.in
20-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/staff-users/requirements-dev.in
21-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/delete-objects/requirements.in
22-
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/delete-objects/requirements-dev.in
6+
pip-compile --no-emit-index-url --upgrade compact-connect/requirements.in
7+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/common/requirements-dev.in
8+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/common/requirements.in
9+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/custom-resources/requirements-dev.in
10+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/custom-resources/requirements.in
11+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/data-events/requirements-dev.in
12+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/data-events/requirements.in
13+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/provider-data-v1/requirements-dev.in
14+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/provider-data-v1/requirements.in
15+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/purchases/requirements-dev.in
16+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/purchases/requirements.in
17+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/staff-user-pre-token/requirements-dev.in
18+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/staff-user-pre-token/requirements.in
19+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/staff-users/requirements-dev.in
20+
pip-compile --no-emit-index-url --upgrade compact-connect/lambdas/python/staff-users/requirements.in
2321
bin/sync_deps.sh

backend/bin/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ if [ -n "$files" ]; then
9595
fi
9696

9797
# Run the back-end tests
98-
bin/run_tests.sh no-report || exit "$?"
98+
bin/run_tests.sh all no-report || exit "$?"
9999

100100
# Check dependencies for known vulnerabilities
101101
pip-audit || exit "$?"

backend/bin/run_tests.sh

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,55 @@
11
# To disable the report, provide basically anything as a first argument
2-
REPORT="$1"
2+
set -e
3+
LANGUAGE="${1:-all}"
4+
REPORT="$2"
35

4-
# Run CDK tests, tracking code coverage in a new data file
5-
(
6-
cd compact-connect
7-
pytest --cov=. --cov-config=.coveragerc tests
8-
) || exit "$?"
9-
for dir in \
10-
compact-connect/lambdas/common-python \
11-
compact-connect/lambdas/license-data \
12-
compact-connect/lambdas/provider-data-v1 \
13-
compact-connect/lambdas/staff-user-pre-token \
14-
compact-connect/lambdas/staff-users \
15-
compact-connect/lambdas/delete-objects \
16-
compact-connect/lambdas/custom-resources \
17-
compact-connect/lambdas/purchases \
18-
multi-account
19-
do
6+
# Set this to 1 ahead of running tests, so this script will fail if neither node or python tests ran
7+
EXIT=1
8+
if [[ "$LANGUAGE" == 'nodejs' || "$LANGUAGE" == 'all' ]]; then
9+
# Run NodeJS tests first
2010
(
21-
cd "$dir"
22-
echo "Running tests in $dir"
23-
# update the PYTHONPATH to include the shared code if not common-python
24-
[ "$dir" = "compact-connect/lambdas/common-python" ] || export PYTHONPATH=../common-python
25-
# Run lambda tests, appending data to the same data file
26-
pytest --cov=. --cov-config=.coveragerc --cov-append tests
11+
cd compact-connect/lambdas/nodejs
12+
yarn test || exit "$?"
13+
if [ -z "$REPORT" ]; then
14+
open 'coverage/lcov-report/index.html'
15+
fi
2716
) || exit "$?"
28-
done
17+
# If this didn't exit already, we'll set our exit status to success for now
18+
EXIT=0
19+
fi
20+
21+
if [[ "$LANGUAGE" == 'python' || "$LANGUAGE" == 'all' ]]; then
22+
# Run CDK tests, tracking code coverage in a new, combined, data file
23+
(
24+
cd compact-connect
25+
pytest --cov=. --cov-config=.coveragerc tests
26+
) || exit "$?"
27+
for dir in \
28+
compact-connect/lambdas/python/common \
29+
compact-connect/lambdas/python/custom-resources \
30+
compact-connect/lambdas/python/data-events \
31+
compact-connect/lambdas/python/provider-data-v1 \
32+
compact-connect/lambdas/python/purchases \
33+
compact-connect/lambdas/python/staff-user-pre-token \
34+
compact-connect/lambdas/python/staff-users \
35+
multi-account
36+
do
37+
(
38+
cd "$dir"
39+
echo "Running tests in $dir"
40+
# update the PYTHONPATH to include the shared code if not python/common
41+
[ "$dir" = "compact-connect/lambdas/python/common" ] || export PYTHONPATH=../common
42+
# Run lambda tests, appending data to the same data file
43+
pytest --cov=. --cov-config=.coveragerc --cov-append tests
44+
) || exit "$?"
45+
done
2946

30-
# Run a coverage report with the combined data
31-
coverage html --fail-under=90
32-
EXIT=$?
33-
if [ -z "$REPORT" ]; then
34-
open 'coverage/index.html'
47+
# Run a coverage report with the combined data
48+
coverage html --fail-under=90
49+
EXIT=$?
50+
if [ -z "$REPORT" ]; then
51+
open 'coverage/index.html'
52+
fi
3553
fi
3654

3755
exit "$EXIT"

backend/bin/sync_deps.sh

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1+
(
2+
cd compact-connect/lambdas/nodejs
3+
yarn install
4+
)
5+
16
pip-sync \
2-
multi-account/requirements.txt \
37
multi-account/requirements-dev.txt \
4-
compact-connect/requirements.txt \
8+
multi-account/requirements.txt \
59
compact-connect/requirements-dev.txt \
6-
compact-connect/lambdas/license-data/requirements.txt \
7-
compact-connect/lambdas/license-data/requirements-dev.txt \
8-
compact-connect/lambdas/provider-data-v1/requirements.txt \
9-
compact-connect/lambdas/provider-data-v1/requirements-dev.txt \
10-
compact-connect/lambdas/staff-user-pre-token/requirements.txt \
11-
compact-connect/lambdas/staff-user-pre-token/requirements-dev.txt \
12-
compact-connect/lambdas/staff-users/requirements.txt \
13-
compact-connect/lambdas/staff-users/requirements-dev.txt \
14-
compact-connect/lambdas/delete-objects/requirements.txt \
15-
compact-connect/lambdas/delete-objects/requirements-dev.txt \
16-
compact-connect/lambdas/custom-resources/requirements.txt \
17-
compact-connect/lambdas/custom-resources/requirements-dev.txt \
18-
compact-connect/lambdas/purchases/requirements.txt \
19-
compact-connect/lambdas/purchases/requirements-dev.txt \
20-
compact-connect/lambdas/common-python/requirements.txt \
21-
compact-connect/lambdas/common-python/requirements-dev.txt
10+
compact-connect/requirements.txt \
11+
compact-connect/lambdas/python/common/requirements-dev.txt \
12+
compact-connect/lambdas/python/common/requirements.txt \
13+
compact-connect/lambdas/python/custom-resources/requirements-dev.txt \
14+
compact-connect/lambdas/python/custom-resources/requirements.txt \
15+
compact-connect/lambdas/python/data-events/requirements-dev.txt \
16+
compact-connect/lambdas/python/data-events/requirements.txt \
17+
compact-connect/lambdas/python/provider-data-v1/requirements-dev.txt \
18+
compact-connect/lambdas/python/provider-data-v1/requirements.txt \
19+
compact-connect/lambdas/python/purchases/requirements-dev.txt \
20+
compact-connect/lambdas/python/purchases/requirements.txt \
21+
compact-connect/lambdas/python/staff-user-pre-token/requirements-dev.txt \
22+
compact-connect/lambdas/python/staff-user-pre-token/requirements.txt \
23+
compact-connect/lambdas/python/staff-users/requirements-dev.txt \
24+
compact-connect/lambdas/python/staff-users/requirements.txt

backend/compact-connect/README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ Python requirements are pinned in [`requirements.txt`](requirements.txt). Instal
4949
$ pip install -r requirements.txt
5050
```
5151

52+
Node.js requirements (for some selected Lambda runtimes) are defined in [`package.json`](./lambdas/nodejs). Install them using `yarn`.
53+
54+
```shell
55+
$ cd lambdas/nodejs
56+
$ yarn install
57+
```
58+
5259
At this point you can now synthesize the CloudFormation template(s) for this code.
5360

5461
```
@@ -89,7 +96,17 @@ tests are defined under the [tests](./tests) directory. Runtime code tests shoul
8996
lambda folders. Code that is common across all lambdas should be tested in the `common-python` directory, to reduce
9097
duplication and ensure consistency across the app.
9198

92-
To execute the tests, simply run `bin/run_tests.sh` from the `backend` directory.
99+
To execute the tests, simply run `bin/sync_deps.sh` then `bin/run_tests.sh` from the `backend` directory.
100+
101+
## Documentation
102+
[Back to top](#compact-connect---backend-developer-documentation)
103+
104+
Keeping documentation current is an important part of feature development in this project. If the feature involves a non-trivial amount of architecture or other technical design, be sure that the design and considerations are captured in the [design documentation](./docs/design). If any updates are made to the API, be sure to follow these steps to keep the documentation current:
105+
1) Export a fresh api specification (OAS 3.0) is exported from API Gateway and used to update [the Open API Specification JSON file](./docs/api-specification/latest-oas30.json).
106+
2) Run `bin/trim_oas30.py` to organize and trim the API to include only supported API endpoints (and update the script itself, if needed).
107+
3) If you exported the api specification from somewhere other than the CSG Test environment, be sure to set the `servers[0].url` entry back to the correct base URL for the CSG Test environment.
108+
4) Update the change summary at the bottom of the [Technical User Docs](./docs/README.md).
109+
5) Update the [Postman Collection and Environment](./docs/postman) as appropriate.
93110

94111
## Deployment
95112
[Back to top](#compact-connect---backend-developer-documentation)
@@ -101,7 +118,7 @@ its environment:
101118
your app. See [About Route53 Hosted Zones](#about-route53-hosted-zones) for more. Note: Without this step, you will
102119
not be able to log in to the UI hosted in CloudFront. The Oauth2 authentication process requires a predictable
103120
callback url to be pre-configured, which the domain name provides. You can still run a local UI against this app,
104-
so long as you leave the `allow_local_ui` context value set to `true` in your environment's context.
121+
so long as you leave the `allow_local_ui` context value set to `true` in your environment's context.
105122
2) *Optional if testing SES email notifications with custom domain:* By default, AWS does not allow sending emails to unverified email
106123
addresses. If you need to test SES email notifications and do not want to request AWS to remove your account from
107124
the SES sandbox, you will need to set up a verified SES email identity for each address you want to send emails to.
@@ -111,10 +128,11 @@ its environment:
111128
See [Default User Pool Email Settings](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-email.html#user-pool-email-default)
112129
3) Copy [cdk.context.sandbox-example.json](./cdk.context.sandbox-example.json) to `cdk.context.json`.
113130
4) At the top level of the JSON structure update the `"environment_name"` field to your own name.
114-
5) Update the environment entry under `ssm_context.environments` to your own name and your own AWS sandbox account id,
115-
and domain name, if you set one up. If you opted not to create a HostedZone, just remove the `domain_name` field.
131+
5) Update the environment entry under `ssm_context.environments` to your own name and your own AWS sandbox account id (which you can find by following these [these instructions](https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-identifiers.html#FindAccountId)),
132+
and domain name, if you set one up. **If you opted not to create a HostedZone, remove the `domain_name` field.**
116133
The key under `environments` must match the value you put under `environment_name`.
117-
6) Configure your aws cli to authenticate against your own account.
134+
6) Configure your aws cli to authenticate against your own account. There are several ways to do this based on the
135+
type of authentication you use to login to your account. See the [AWS CLI Configuration Guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html).
118136
7) Run `cdk bootstrap` to add some base CDK support infrastructure to your AWS account.
119137
8) Run `cdk deploy 'Sandbox/*'` to get the initial stack resources deployed.
120138

backend/compact-connect/bin/create_staff_user.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import boto3
1616
from botocore.exceptions import ClientError
1717

18-
provider_data_path = os.path.join('lambdas', 'staff-users')
18+
provider_data_path = os.path.join('lambdas', 'python', 'staff-users')
19+
common_lib_path = os.path.join('lambdas', 'python', 'common')
1920
sys.path.append(provider_data_path)
21+
sys.path.append(common_lib_path)
2022

2123
with open('cdk.json') as context_file:
2224
_context = json.load(context_file)['context']
@@ -27,7 +29,7 @@
2729
os.environ['JURISDICTIONS'] = json.dumps(JURISDICTIONS)
2830

2931
# We have to import this after we've mucked with our path and environment
30-
from data_model.schema.user import UserRecordSchema # noqa: E402
32+
from cc_common.data_model.schema.user import UserRecordSchema # noqa: E402
3133

3234
USER_POOL_ID = os.environ['USER_POOL_ID']
3335
USER_TABLE_NAME = os.environ['USER_TABLE_NAME']

backend/compact-connect/bin/generate_mock_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# We have to do some set-up before we can import everything we need
1616
# Add the provider data lambda runtime to our pythonpath
17-
provider_data_path = os.path.join('lambdas', 'provider-data-v1')
17+
provider_data_path = os.path.join('lambdas', 'python', 'common')
1818
sys.path.append(provider_data_path)
1919

2020
with open('cdk.json') as context_file:
@@ -26,7 +26,7 @@
2626
os.environ['COMPACTS'] = json.dumps(COMPACTS)
2727
os.environ['JURISDICTIONS'] = json.dumps(JURISDICTIONS)
2828

29-
from data_model.schema.license import LicensePostSchema # noqa: E402
29+
from cc_common.data_model.schema.license import LicensePostSchema # noqa: E402
3030

3131
# We'll grab three different localizations to provide a variety of names/characters
3232
name_faker = Faker(['en_US', 'ja_JP', 'es_MX'])

backend/compact-connect/cdk.context.sandbox-example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
"email": [
1717
1818
]
19+
},
20+
"jurisdiction_configuration_overrides": {
21+
"jurisdictionOperationsTeamEmails": [
22+
23+
]
1924
}
2025
}
2126
}

0 commit comments

Comments
 (0)