feat: Recommending using OIDC (#871)

* Recommending using OIDC

* Added tests

* fix test and package

* update readme

---------

Co-authored-by: peterwoodworth <woodwoop@amazon.com>
This commit is contained in:
Justin Plock
2023-09-29 17:05:32 -04:00
committed by GitHub
parent 164817a8f8
commit f31c158843
5 changed files with 244 additions and 0 deletions
+22
View File
@@ -105,6 +105,9 @@ describe('Configure AWS Credentials', () => {
jest.spyOn(core, 'info').mockImplementation((string) => {
return string;
});
jest.spyOn(core, 'warning').mockImplementation((string) => {
return string;
});
(fromEnv as jest.Mock)
.mockImplementationOnce(() => () => ({
accessKeyId: FAKE_ACCESS_KEY_ID,
@@ -868,4 +871,23 @@ describe('Configure AWS Credentials', () => {
expect(core.setOutput).toHaveBeenCalledTimes(4);
});
test('prints warning for access key usage and no session token', async () => {
jest.spyOn(core, 'getInput').mockImplementation(mockGetInput(ASSUME_ROLE_INPUTS));
await run();
expect(core.warning).toHaveBeenCalledWith(
'To avoid using long-term AWS credentials, please update your workflows to authenticate using OpenID Connect.' +
' See https://s12d.com/gha-oidc-aws for more information.'
);
});
test('skips warning for access key usage with session token', async () => {
jest.spyOn(core, 'getInput').mockImplementation(mockGetInput(DEFAULT_INPUTS));
await run();
expect(core.warning).toHaveBeenCalledTimes(0);
});
});