Skip to content

Commit

Permalink
Merge branch 'main' into github-actions/upgrade-main
Browse files Browse the repository at this point in the history
  • Loading branch information
moelasmar authored Sep 19, 2024
2 parents 9f66bbf + 9af9a71 commit fc6604b
Show file tree
Hide file tree
Showing 18 changed files with 573 additions and 451 deletions.
30 changes: 13 additions & 17 deletions lib/__tests__/chime-notifier.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as https from 'https';
import https from 'https';
import {
App, Lazy, Stack,
aws_codepipeline as aws_codepipeline,
Expand All @@ -9,27 +9,23 @@ import { Construct } from 'constructs';
import { ChimeNotifier } from '../../lib';
import { codePipeline, handler } from '../../lib/chime-notifier/handler/notifier-handler';

jest.mock('https', () => {
const mockHttpsWrite = jest.fn();

https.request = jest.fn().mockImplementation((_url, _options, cb) => {
return {
request: jest.fn((_url, _options, cb) => {
return {
on: jest.fn(),
write: mockHttpsWrite,
end: () => cb({
statusCode: 200,
headers: {},
setEncoding: () => undefined,
on: (event: string, listener: () => void) => {
if (event === 'end') { listener(); }
},
}),
};
on: jest.fn(),
write: mockHttpsWrite,
end: () => cb({
statusCode: 200,
headers: {},
setEncoding: () => undefined,
on: (event: string, listener: () => void) => {
if (event === 'end') { listener(); }
},
}),
};
});

const mockHttpsWrite = jest.fn();

test('call codepipeline and then post to webhooks', async () => {
codePipeline.getPipelineExecution = jest.fn().mockReturnValue(
Promise.resolve({
Expand Down
4 changes: 2 additions & 2 deletions lib/__tests__/code-signing-cert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test('secret name consists of stack name and relative construct path', () => {
// THEN - specifically: does not include construct names above the containing stack
// uses the actual stack name (and not the stack NODE name)
template.hasResourceProperties('Custom::RsaPrivateKeySecret', {
SecretName: 'ActualStackName/Inbetween/Cert/RSAPrivateKey',
SecretName: 'ActualStackName/Inbetween/Cert/RSAPrivateKeyV2',
});
});

Expand All @@ -59,6 +59,6 @@ test('secret name can be overridden', () => {
const template = Template.fromStack(stack);

template.hasResourceProperties('Custom::RsaPrivateKeySecret', {
SecretName: 'Sekrit/RSAPrivateKey',
SecretName: 'Sekrit/RSAPrivateKeyV2',
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ test('Create', async () => {
};

mockExec.mockImplementation(async (cmd: string, ...args: string[]) => {
expect(cmd).toBe('/opt/openssl');
expect(cmd).toBe('openssl');
switch (args[0]) {
case 'req':
expect(args).toEqual(['req', '-config', require('path').join(mockTmpDir, 'csr.config'),
Expand Down Expand Up @@ -187,7 +187,7 @@ test('Update', async () => {
};

mockExec.mockImplementation(async (cmd: string, ...args: string[]) => {
expect(cmd).toBe('/opt/openssl');
expect(cmd).toBe('openssl');
switch (args[0]) {
case 'req':
expect(args).toEqual(['req', '-config', require('path').join(mockTmpDir, 'csr.config'),
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/custom-resource-handlers/private-key.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const secretArn = 'arn::::::secret';

cfn.sendResponse = jest.fn().mockName('cfn.sendResponse').mockResolvedValue(undefined);
jest.mock('../../custom-resource-handlers/src/_exec', () => async (cmd: string, ...args: string[]) => {
expect(cmd).toBe('/opt/openssl');
expect(cmd).toBe('openssl');
expect(args).toEqual(['genrsa', '-out', require('path').join(mockTmpDir, 'private_key.pem'), mockKeySize]);
return '';
});
Expand Down
Loading

0 comments on commit fc6604b

Please sign in to comment.