mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-12-01 04:04:24 +01:00
fix: explictly disabling using existing creds works now (#2047)
This commit is contained in:
1 parent
4301ae5f0f
commit
ba75ef8845
3 files changed
+20
-1
No files matched your search
+1
-1
@@ -61,7 +61,7 @@ export async function run() {
|
||||
const unsetCurrentCredentials = getBooleanInput('unset-current-credentials', { required: false });
|
||||
let disableRetry = getBooleanInput('disable-retry', { required: false });
|
||||
const specialCharacterWorkaround = getBooleanInput('special-characters-workaround', { required: false });
|
||||
const useExistingCredentials = core.getInput('use-existing-credentials', { required: false });
|
||||
const useExistingCredentials = getBooleanInput('use-existing-credentials', { required: false });
|
||||
let maxRetries = Number.parseInt(core.getInput('retry-max-attempts', { required: false })) || 12;
|
||||
const expectedAccountIds = core
|
||||
.getInput('allowed-account-ids', { required: false })
|
||||
|
||||
@@ -648,6 +648,20 @@ describe('Configure AWS Credentials', {}, () => {
|
||||
await run();
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
});
|
||||
it('gets new creds if user explicitly said not to use existing credentials', {}, async () => {
|
||||
vi.mocked(core.getInput).mockImplementation(mocks.getInput(mocks.USE_EXISTING_CREDENTIALS_FALSE_INPUTS));
|
||||
vi.mocked(core.getIDToken).mockResolvedValue('testoidctoken');
|
||||
process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN = 'fake-token';
|
||||
// Valid existing credentials are available, but should be ignored
|
||||
mockedSTSClient.on(GetCallerIdentityCommand).resolves(mocks.outputs.GET_CALLER_IDENTITY);
|
||||
mockedSTSClient.on(AssumeRoleWithWebIdentityCommand).resolvesOnce(mocks.outputs.STS_CREDENTIALS);
|
||||
await run();
|
||||
expect(core.notice).not.toHaveBeenCalledWith('Pre-existing credentials are valid. No need to generate new ones.');
|
||||
expect(core.info).toHaveBeenCalledWith('Assuming role with OIDC');
|
||||
expect(mockedSTSClient.commandCalls(AssumeRoleWithWebIdentityCommand)).toHaveLength(1);
|
||||
expect(core.exportVariable).toHaveBeenCalledWith('AWS_ACCESS_KEY_ID', 'STSAWSACCESSKEYID');
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
});
|
||||
it("doesn't export credentials as environment variables if told not to", {}, async () => {
|
||||
mockedSTSClient.on(AssumeRoleWithWebIdentityCommand).resolvesOnce(mocks.outputs.STS_CREDENTIALS);
|
||||
// Credentials are validated (and their account resolved) even when not exported to the
|
||||
|
||||
@@ -91,6 +91,11 @@ const inputs = {
|
||||
'output-env-credentials': 'false',
|
||||
'output-credentials': 'true',
|
||||
},
|
||||
USE_EXISTING_CREDENTIALS_FALSE_INPUTS: {
|
||||
'aws-region': 'fake-region-1',
|
||||
'use-existing-credentials': 'false',
|
||||
'role-to-assume': 'arn:aws:iam::111111111111:role/MY-ROLE',
|
||||
},
|
||||
};
|
||||
|
||||
const envs = {
|
||||
|
||||
Reference in new issue
Block a user