fix: explictly disabling using existing creds works now

This commit is contained in:
Michael Lehmann committed 2026-11-30 13:52:10 -08:00
1 parent 4301ae5f0f
commit 514b0dcff3
3 files changed
+20 -1

No files matched your search

+14
View File
@@ -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
+5
View File
@@ -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 = {