fix: explictly disabling using existing creds works now (#2047)

This commit is contained in:
Michael Lehmann authored and GitHub committed 2026-11-30 22:03:43 +00:00
1 parent 4301ae5f0f
commit ba75ef8845
3 files changed
+20 -1

No files matched your search

+1 -1
View File
@@ -61,7 +61,7 @@ export async function run() {
const unsetCurrentCredentials = getBooleanInput('unset-current-credentials', { required: false }); const unsetCurrentCredentials = getBooleanInput('unset-current-credentials', { required: false });
let disableRetry = getBooleanInput('disable-retry', { required: false }); let disableRetry = getBooleanInput('disable-retry', { required: false });
const specialCharacterWorkaround = getBooleanInput('special-characters-workaround', { 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; let maxRetries = Number.parseInt(core.getInput('retry-max-attempts', { required: false })) || 12;
const expectedAccountIds = core const expectedAccountIds = core
.getInput('allowed-account-ids', { required: false }) .getInput('allowed-account-ids', { required: false })
+14
View File
@@ -648,6 +648,20 @@ describe('Configure AWS Credentials', {}, () => {
await run(); await run();
expect(core.setFailed).not.toHaveBeenCalled(); 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 () => { it("doesn't export credentials as environment variables if told not to", {}, async () => {
mockedSTSClient.on(AssumeRoleWithWebIdentityCommand).resolvesOnce(mocks.outputs.STS_CREDENTIALS); mockedSTSClient.on(AssumeRoleWithWebIdentityCommand).resolvesOnce(mocks.outputs.STS_CREDENTIALS);
// Credentials are validated (and their account resolved) even when not exported to the // Credentials are validated (and their account resolved) even when not exported to the
+5
View File
@@ -91,6 +91,11 @@ const inputs = {
'output-env-credentials': 'false', 'output-env-credentials': 'false',
'output-credentials': 'true', '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 = { const envs = {