-
Notifications
You must be signed in to change notification settings - Fork 3
CCM-13303: Create report scheduler #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| "dependencies": { | ||
| "aws-lambda": "^1.0.7", | ||
| "digital-letters-events": "^0.0.1", | ||
| "p-limit": "^3.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably missed it, but is it used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, I'll remove it!
| apim_keystore_s3_bucket = "nhs-${var.aws_account_id}-${var.region}-${var.environment}-${var.component}-static-assets" | ||
| unscanned_files_bucket = local.acct.additional_s3_buckets["digital-letters_unscanned-files"]["id"] | ||
| ssm_mesh_prefix = "/${var.component}/${var.environment}/mesh" | ||
| ssm_senders_prefix = "/${var.component}/${var.environment}/senders" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is more clear this way and we could reuse it in module_lambda_ttl_create.tf and module_lambda_core_notifier.tf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
| CVE-2024-49761 # https://avd.aquasec.com/nvd/cve-2024-49761 ## latest Jekyll Webpack (0.2.7) installs old version of rexml | ||
| CVE-2024-47220 # https://avd.aquasec.com/nvd/cve-2024-47220 ## latest lint_roller (1.1.0) installs old version of rexml | ||
| CVE-2024-7254 # https://avd.aquasec.com/nvd/cve-2024-7254 ## latest Jekyll Webpack (0.2.7) installs old version of google-protobuf | ||
| CVE-2026-25128 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to merge this now the fix is in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes agreed. I should have used the tag to skip the check.
| const senderIds = parsedEvents.map((event) => event.data.senderId); | ||
| expect(senderIds).toContain('2b8ebb33-8b33-49bd-949e-c12e22d25320'); | ||
| expect(senderIds).toContain('f017669b-6da4-4576-9d59-3d2b7f005ae2'); | ||
| expect(senderIds).toContain('67403568-166e-41d0-900a-1f31fe93a091'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should probably use the constants from tests-constants.ts, right?
Also, it might be worth a comment to explain why we expect the event to contain these sender IDs (I believe it's because we've put them into the sender config in SSM). It wasn't immediately clear to me what these IDs were.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll replace the hardcoded IDs with constants but isn't the name of the test a good clue for what's happening?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's a fair point. It was probably more the fact that I reviewed it late in the day than the code being unclear!
| @@ -0,0 +1,29 @@ | |||
| { | |||
| "dependencies": { | |||
| "aws-lambda": "^1.0.7", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you're using aws-lambda (or @types/aws-lambda) in this function.
| "@types/lodash": "^4.17.20", | ||
| "aws-sdk-client-mock": "^4.1.0", | ||
| "aws-sdk-client-mock-jest": "^4.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure you're using any of these dependencies either.
| "@types/lodash": "^4.17.20", | |
| "aws-sdk-client-mock": "^4.1.0", | |
| "aws-sdk-client-mock-jest": "^4.1.0", |
| "aws-sdk-client-mock": "^4.1.0", | ||
| "aws-sdk-client-mock-jest": "^4.1.0", | ||
| "jest": "^29.7.0", | ||
| "jest-mock-extended": "^3.0.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or jest-mock-extended!
| "jest-mock-extended": "^3.0.7", |
| it('should calculate yesterday date range correctly', async () => { | ||
| const mockDate = new Date('2024-01-15T12:00:00.000Z'); | ||
| jest.setSystemTime(mockDate); | ||
|
|
||
| mockSenderManagement.listSenders.mockResolvedValue([]); | ||
| mockEventPublisher.sendEvents.mockResolvedValue([]); | ||
|
|
||
| const handler = createHandler({ | ||
| logger: mockLogger, | ||
| senderManagement: mockSenderManagement, | ||
| eventPublisher: mockEventPublisher, | ||
| }); | ||
|
|
||
| await handler(); | ||
|
|
||
| expect(mockLogger.debug).toHaveBeenCalledWith({ | ||
| description: 'Calculated yesterday date range', | ||
| yesterdayStart: '2024-01-14T00:00:00.000Z', | ||
| yesterdayEnd: '2024-01-14T23:59:59.999Z', | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test would be better verifying the value of the data.reportPeriodStartTime and data.reportPeriodEndTime fields in the return value of handler(), rather than what was logged. Ultimately, it's the return values that are used.
| it('should handle event publisher errors', async () => { | ||
| const mockSenders = [{ senderId: 'sender-1' }] as unknown as Sender[]; | ||
| const error = new Error('Failed to publish events'); | ||
|
|
||
| mockSenderManagement.listSenders.mockResolvedValue(mockSenders); | ||
| mockEventPublisher.sendEvents.mockRejectedValue(error); | ||
|
|
||
| const handler = createHandler({ | ||
| logger: mockLogger, | ||
| senderManagement: mockSenderManagement, | ||
| eventPublisher: mockEventPublisher, | ||
| }); | ||
|
|
||
| await expect(handler()).rejects.toThrow('Failed to publish events'); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that sendEvents throws an error. I think it reutrns a list of failed events instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has a lot more changes in it than I'd expect, given the changes you've made to the package.json files. It also appears to undo the fix for the fast-xml-parser vulnerability (from a local run of npm audit at least).
Description
Component to trigger daily reports for all the senders.
Notes:
Testing
Type of changes
Checklist
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.