Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions lambdas/src/order-result-lambda/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIGatewayProxyEvent, Context } from 'aws-lambda';
import { APIGatewayProxyEvent } from 'aws-lambda';

const mockSQSClientSendMessage = jest.fn();

Expand All @@ -8,16 +8,6 @@ jest.mock('../lib/sqs/sqs-client', () => ({
close: jest.fn(),
})),
}));
// Silence validation errors from appearing on console output during tests
const mockCommonsLoggerError = jest.fn();
const mockCommonsLoggerInfo = jest.fn();

jest.mock('../lib/commons', () => ({
ConsoleCommons: jest.fn().mockImplementation(() => ({
logError: mockCommonsLoggerError,
logInfo: mockCommonsLoggerInfo,
})),
}));

process.env.RESULT_QUEUE_URL = 'https://sqs.eu-west-1./wiremock:8080/test-results-queue';
process.env.AWS_REGION = 'eu-west-1';
Expand All @@ -34,7 +24,9 @@ describe('Order Result Lambda Handler', () => {
httpMethod: 'POST',
path: '/result',
body: null,
headers: {},
headers: {
'X-Correlation-ID': '550e8400-e29b-41d4-a716-446655440000',
},
};

body = {
Expand Down Expand Up @@ -73,8 +65,6 @@ describe('Order Result Lambda Handler', () => {
};

mockSQSClientSendMessage.mockReset();
mockCommonsLoggerError.mockReset();
mockCommonsLoggerInfo.mockReset();
});

afterEach(() => {
Expand Down Expand Up @@ -106,7 +96,6 @@ describe('Order Result Lambda Handler', () => {
const result = await handler(mockEvent as APIGatewayProxyEvent);

expect(result.statusCode).toBe(400);
expect(mockCommonsLoggerError).toHaveBeenCalledTimes(1);
expect(JSON.parse(result.body)).toMatchObject({
issue: [
{
Expand All @@ -125,7 +114,6 @@ describe('Order Result Lambda Handler', () => {
const result = await handler(mockEvent as APIGatewayProxyEvent);

expect(result.statusCode).toBe(400);
expect(mockCommonsLoggerError).toHaveBeenCalledTimes(1);
expect(JSON.parse(result.body)).toMatchObject({
issue: [
{
Expand Down
5 changes: 3 additions & 2 deletions lambdas/src/order-result-lambda/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
import { Observation, Parameters } from 'fhir/r4';
import { Observation } from 'fhir/r4';
import { z } from 'zod';
import { AWSSQSClient } from '../lib/sqs/sqs-client';
import { createFhirErrorResponse, createFhirResponse } from '../lib/fhir-response';
import { ConsoleCommons } from '../lib/commons';
import {getCorrelationIdFromEventHeaders} from "../lib/utils";

const sqsClient = new AWSSQSClient();
const commons = new ConsoleCommons();
Expand Down Expand Up @@ -64,7 +65,7 @@ export const handler = async (

try{
const orderUid = extractOrderUid(observation);
const correlationId = event.headers['X-Correlation-ID'];
const correlationId = getCorrelationIdFromEventHeaders(event);
const messageBody = JSON.stringify({
observation,
correlationId,
Expand Down
12 changes: 11 additions & 1 deletion scripts/config/gitleaks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,14 @@ regexes = [
]

[allowlist]
paths = ['''.terraform.lock.hcl''', '''poetry.lock''', '''yarn.lock''', '''local-environment/*''', '''lambdas/.*\.test\..*''', '''tests/playwright.config.ts''', '''ui/.next/*''', '''ui/build/*''', '''cdk.out/*''', '''lambdas/dist/*''']
paths = [
'''.terraform.lock.hcl''',
'''poetry.lock''',
'''yarn.lock''',
'''local-environment/*''',
'''lambdas/.*\.test\..*''', '''lambdas/dist/*''',
'''tests/playwright.config.ts''',
'''ui/.next/*''', '''ui/build/*''',
'''cdk.out/*''',
'''.idea/*'''
]