-
Notifications
You must be signed in to change notification settings - Fork 3
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
73df0ab
commit e2f4b33
Showing
31 changed files
with
994 additions
and
1,543 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# yaml-language-server: disable | ||
name: Deploy | ||
|
||
on: | ||
|
@@ -6,6 +7,7 @@ on: | |
- "*" | ||
- "!skipci*" | ||
|
||
# yaml-language-server: $schema: https://json.schemastore.org/github-workflow.json | ||
concurrency: | ||
group: ${{ startsWith(github.ref_name, 'snyk-') && 'snyk' || github.ref_name }}-group | ||
|
||
|
@@ -188,42 +190,6 @@ jobs: | |
uses: stelligent/[email protected] | ||
with: | ||
input_path: cftemplates | ||
resources: | ||
runs-on: ubuntu-20.04 | ||
needs: | ||
- deploy | ||
environment: | ||
name: ${{ startsWith(github.ref_name, 'snyk-') && 'snyk' || github.ref_name }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- uses: ./.github/actions/setup | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }} | ||
aws-region: us-east-1 | ||
role-duration-seconds: 10800 | ||
|
||
- name: Get AWS Stage Resources | ||
id: stage-resources | ||
run: | | ||
mkdir -p resources | ||
resourceData=() | ||
stackList=(`aws cloudformation describe-stacks --query "Stacks[?Tags[?Key=='STAGE' && Value=='$STAGE_NAME'] && Tags[?Key=='PROJECT' && Value=='$PROJECT']].StackName" --output text`) | ||
for stack in "${stackList[@]}"; do | ||
resources=$(aws cloudformation list-stack-resources --stack-name "$stack" --query "StackResourceSummaries[].{PhysicalResourceId:PhysicalResourceId, ResourceType:ResourceType, ResourceStatus:ResourceStatus, LogicalResourceId:LogicalResourceId, LastUpdatedTimestamp:LastUpdatedTimestamp}" --output json) | ||
resourceData+=( $(echo "$resources" | jq -c --arg stack_name "$stack" '.[] + { StackName: $stack_name }') ) | ||
done | ||
join_by() { local IFS="$1"; shift; echo "$*"; } | ||
echo "["$(join_by "," "${resourceData[@]}")"]" > "resources/aws-resources.json" | ||
- name: Archive stage resources | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: aws-resources-${{ startsWith(github.ref_name, 'snyk-') && 'snyk' || github.ref_name }} | ||
path: resources/aws-resources.json | ||
|
||
release: | ||
runs-on: ubuntu-20.04 | ||
|
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,13 @@ | ||
extends: default | ||
|
||
rules: | ||
document-start: disable | ||
line-length: disable | ||
truthy: | ||
allowed-values: ['true', 'false', 'on', 'off', 'yes', 'no'] | ||
comments: | ||
min-spaces-from-content: 1 | ||
|
||
ignore: | | ||
node_modules/ | ||
.github/ |
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,92 @@ | ||
import { describe, it, expect, vi } from "vitest"; | ||
import { handler as processEmailsHandler } from "./processEmails"; | ||
|
||
vi.mock("aws-sdk/clients/sqs", () => { | ||
return { | ||
SQS: vi.fn().mockImplementation(() => { | ||
return { | ||
sendMessage: vi.fn().mockReturnValue({ promise: () => Promise.resolve({}) }) | ||
}; | ||
}) | ||
}; | ||
}); | ||
|
||
vi.mock("../processEmails", async () => { | ||
const actual = await vi.importActual("../processEmails"); | ||
return { | ||
...actual, | ||
// If needed, mock internal functions | ||
}; | ||
}); | ||
|
||
describe("processEmails handler", () => { | ||
it("should gracefully handle an empty records set", async () => { | ||
const event = { | ||
records: {} | ||
}; | ||
const res = await processEmailsHandler(event as any, {} as any, () => {}); | ||
// no error means passed | ||
expect(res).toBeUndefined(); | ||
}); | ||
|
||
it("should process a valid record without errors", async () => { | ||
const event = { | ||
records: { | ||
"test-topic": [ | ||
{ | ||
key: Buffer.from("testKey").toString("base64"), | ||
value: Buffer.from(JSON.stringify({ event: "new-medicaid-submission", authority: "Medicaid SPA", origin: "mako" })).toString("base64"), | ||
timestamp: Date.now(), | ||
} | ||
] | ||
} | ||
}; | ||
const res = await processEmailsHandler(event as any, {} as any, () => {}); | ||
expect(res).toBeUndefined(); | ||
}); | ||
}); | ||
40 changes: 40 additions & 0 deletions40 | ||
lib/lambda/__tests__/sinkMain.test.ts | ||
Viewed | ||
Original file line number Original file line Diff line number Diff line change | ||
@@ -0,0 +1,40 @@ | ||
import { describe, it, expect, vi } from "vitest"; | ||
import { handler as sinkMainHandler } from "../sinkMain"; | ||
|
||
vi.mock("../sinkMainProcessors", () => { | ||
return { | ||
insertOneMacRecordsFromKafkaIntoMako: vi.fn(() => Promise.resolve()), | ||
insertNewSeatoolRecordsFromKafkaIntoMako: vi.fn(() => Promise.resolve()), | ||
syncSeatoolRecordDatesFromKafkaWithMako: vi.fn(() => Promise.resolve()) | ||
}; | ||
}); | ||
|
||
describe("sinkMain handler", () => { | ||
it("handles empty event gracefully", async () => { | ||
const event = { | ||
records: {} | ||
}; | ||
const res = await sinkMainHandler(event as any, {} as any, () => {}); | ||
expect(res).toBeUndefined(); | ||
}); | ||
|
||
it("handles unknown topic gracefully", async () => { | ||
const event = { | ||
records: { | ||
"unknown-topic": [ | ||
{ | ||
key: "base64Key", | ||
value: "base64Value", | ||
topic: "unknown-topic", | ||
partition: 0, | ||
offset: 0, | ||
timestamp: Date.now(), | ||
timestampType: "CREATE_TIME", | ||
headers: {} | ||
} | ||
] | ||
} | ||
}; | ||
await expect(sinkMainHandler(event as any, {} as any, () => {})).rejects.toThrow(); | ||
}); | ||
}); |
Oops, something went wrong.