Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,27 @@ describe('init', () => {
};
await expect(init(amplifyServiceParamsStub)).rejects.toMatchInlineSnapshot(`[ConfigurationError: Missing Region in Config]`);
});

it('throws ProjectInitError if secret access key is invalid', async () => {
const amplifyClientStub = {
createApp: jest.fn().mockReturnValue({
promise: jest.fn().mockRejectedValue({
code: 'InvalidSignatureException',
}),
}),
} as unknown as Amplify;
getConfiguredAmplifyClientMock.mockClear();
getConfiguredAmplifyClientMock.mockResolvedValue(amplifyClientStub);

const amplifyServiceParamsStub = {
context: {},
awsConfigInfo: {},
projectName: 'test-project',
envName: 'test',
stackName: 'test-stack-name',
};
await expect(init(amplifyServiceParamsStub)).rejects.toMatchInlineSnapshot(
`[ProjectInitError: The request signature we calculated does not match the signature you provided]`,
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ export async function init(amplifyServiceParams) {
resolution: 'https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html',
});
}
if (e.code === 'InvalidSignatureException') {
throw new AmplifyError(
'ProjectInitError',
{
message: 'The request signature we calculated does not match the signature you provided',
resolution: 'Check your AWS Secret Access Key',
},
e,
);
}
// default fault
throw new AmplifyFault(
'ProjectInitFault',
Expand Down