mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-03-12 18:07:10 -04:00
feat: depenency update and feature cleanup (#1414)
* chore: add clean script * chore: run npm audit fix * chore: unblock update to vitest 3.x * chore(deps-dev): update vitest dependencies Closes #1275 Closes #1276 * chore(deps): update https-proxy-agent and types to match Closes #1407. * chore: add lint:fix script * feat: support HTTPS_PROXY environment variable Closes #1061 Closes #861 * feat: output ARN of authenticated prinicpal Closes #1062 Closes #1191
This commit is contained in:
@@ -11,9 +11,9 @@ describe('Configure AWS Credentials helpers', {}, () => {
|
||||
const actor = 'actor[bot]';
|
||||
expect(helpers.sanitizeGitHubVariables(actor)).toBe('actor_bot_');
|
||||
});
|
||||
it('can sleep', {}, () => {
|
||||
it('can sleep', {}, async () => {
|
||||
const sleep = helpers.defaultSleep(10);
|
||||
expect(Promise.race([sleep, new Promise((_, reject) => setTimeout(reject, 20))])).resolves.toBe(undefined);
|
||||
await expect(Promise.race([sleep, new Promise((_, reject) => setTimeout(reject, 20))])).resolves.toBe(undefined);
|
||||
});
|
||||
it('removes special characters from workflow names', {}, () => {
|
||||
expect(helpers.sanitizeGitHubVariables('sdf234@#$%$^&*()_+{}|:"<>?')).toEqual('sdf234@__________+___:____');
|
||||
|
||||
@@ -47,7 +47,7 @@ describe('Configure AWS Credentials', {}, () => {
|
||||
expect(core.info).toHaveBeenCalledWith('Authenticated as assumedRoleId AROAFAKEASSUMEDROLEID');
|
||||
expect(core.info).toHaveBeenCalledTimes(2);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('aws-account-id', '111111111111');
|
||||
expect(core.setOutput).toHaveBeenCalledOnce();
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(2);
|
||||
expect(core.setSecret).toHaveBeenCalledWith('STSAWSACCESSKEYID');
|
||||
expect(core.setSecret).toHaveBeenCalledWith('STSAWSSECRETACCESSKEY');
|
||||
expect(core.setSecret).toHaveBeenCalledWith('STSAWSSESSIONTOKEN');
|
||||
@@ -71,7 +71,7 @@ describe('Configure AWS Credentials', {}, () => {
|
||||
expect(core.info).toHaveBeenCalledWith('Authenticated as assumedRoleId AROAFAKEASSUMEDROLEID');
|
||||
expect(core.info).toHaveBeenCalledTimes(3);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('aws-account-id', '111111111111');
|
||||
expect(core.setOutput).toHaveBeenCalledOnce();
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(2);
|
||||
expect(core.setSecret).toHaveBeenCalledWith('STSAWSACCESSKEYID');
|
||||
expect(core.setSecret).toHaveBeenCalledWith('STSAWSSECRETACCESSKEY');
|
||||
expect(core.setSecret).toHaveBeenCalledWith('STSAWSSESSIONTOKEN');
|
||||
@@ -106,7 +106,7 @@ describe('Configure AWS Credentials', {}, () => {
|
||||
expect(core.setSecret).toHaveBeenCalledWith('MYAWSSECRETACCESSKEY');
|
||||
expect(core.setSecret).toHaveBeenCalledTimes(2);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('aws-account-id', '111111111111');
|
||||
expect(core.setOutput).toHaveBeenCalledOnce();
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(2);
|
||||
expect(core.info).toHaveBeenCalledWith('Proceeding with IAM user credentials');
|
||||
expect(core.info).toHaveBeenCalledOnce();
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
@@ -140,7 +140,7 @@ describe('Configure AWS Credentials', {}, () => {
|
||||
expect(core.setSecret).toHaveBeenCalledWith('MYAWSSECRETACCESSKEY');
|
||||
expect(core.setSecret).toHaveBeenCalledTimes(5);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('aws-account-id', '111111111111');
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(2);
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(4);
|
||||
expect(core.info).toHaveBeenCalledWith('Assuming role with user credentials');
|
||||
expect(core.info).toHaveBeenCalledWith('Authenticated as assumedRoleId AROAFAKEASSUMEDROLEID');
|
||||
expect(core.info).toHaveBeenCalledTimes(2);
|
||||
@@ -173,7 +173,7 @@ describe('Configure AWS Credentials', {}, () => {
|
||||
expect(core.setSecret).toHaveBeenCalledWith('STSAWSSESSIONTOKEN');
|
||||
expect(core.setSecret).toHaveBeenCalledTimes(3);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('aws-account-id', '111111111111');
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(1);
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(2);
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -204,7 +204,7 @@ describe('Configure AWS Credentials', {}, () => {
|
||||
expect(core.setSecret).toHaveBeenCalledWith('STSAWSSESSIONTOKEN');
|
||||
expect(core.setSecret).toHaveBeenCalledTimes(3);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('aws-account-id', '111111111111');
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(2);
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(4);
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
});
|
||||
it('exports environment variables from inputs', {}, async () => {
|
||||
@@ -237,7 +237,7 @@ describe('Configure AWS Credentials', {}, () => {
|
||||
expect(core.setSecret).toHaveBeenCalledWith('STSAWSSESSIONTOKEN');
|
||||
expect(core.setSecret).toHaveBeenCalledTimes(6);
|
||||
expect(core.setOutput).toHaveBeenCalledWith('aws-account-id', '111111111111');
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(2);
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(4);
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -333,4 +333,81 @@ describe('Configure AWS Credentials', {}, () => {
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('HTTP Proxy Configuration', {}, () => {
|
||||
beforeEach(() => {
|
||||
vi.spyOn(core, 'getInput').mockImplementation(mocks.getInput(mocks.GH_OIDC_INPUTS));
|
||||
vi.spyOn(core, 'getIDToken').mockResolvedValue('testoidctoken');
|
||||
mockedSTSClient.on(GetCallerIdentityCommand).resolvesOnce({ ...mocks.outputs.GET_CALLER_IDENTITY });
|
||||
mockedSTSClient.on(AssumeRoleWithWebIdentityCommand).resolvesOnce(mocks.outputs.STS_CREDENTIALS);
|
||||
process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN = 'fake-token';
|
||||
});
|
||||
|
||||
it('configures proxy from http-proxy input', async () => {
|
||||
const infoSpy = vi.spyOn(core, 'info');
|
||||
vi.spyOn(core, 'getInput').mockImplementation(
|
||||
mocks.getInput({
|
||||
...mocks.GH_OIDC_INPUTS,
|
||||
'http-proxy': 'http://proxy.example.com:8080'
|
||||
})
|
||||
);
|
||||
|
||||
await run();
|
||||
|
||||
expect(infoSpy).toHaveBeenCalledWith('Configuring proxy handler for STS client');
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('configures proxy from HTTP_PROXY environment variable', async () => {
|
||||
const infoSpy = vi.spyOn(core, 'info');
|
||||
process.env.HTTP_PROXY = 'http://proxy.example.com:8080';
|
||||
|
||||
await run();
|
||||
|
||||
expect(infoSpy).toHaveBeenCalledWith('Configuring proxy handler for STS client');
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('configures proxy from HTTPS_PROXY environment variable', async () => {
|
||||
const infoSpy = vi.spyOn(core, 'info');
|
||||
process.env.HTTPS_PROXY = 'https://proxy.example.com:8080';
|
||||
|
||||
await run();
|
||||
|
||||
expect(infoSpy).toHaveBeenCalledWith('Configuring proxy handler for STS client');
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('prioritizes http-proxy input over environment variables', async () => {
|
||||
const infoSpy = vi.spyOn(core, 'info');
|
||||
process.env.HTTP_PROXY = 'http://env-proxy.example.com:8080';
|
||||
vi.spyOn(core, 'getInput').mockImplementation(
|
||||
mocks.getInput({
|
||||
...mocks.GH_OIDC_INPUTS,
|
||||
'http-proxy': 'http://input-proxy.example.com:8080'
|
||||
})
|
||||
);
|
||||
|
||||
await run();
|
||||
|
||||
expect(infoSpy).toHaveBeenCalledWith('Configuring proxy handler for STS client');
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('properly configures proxy agent in STS client', async () => {
|
||||
const infoSpy = vi.spyOn(core, 'info');
|
||||
|
||||
vi.spyOn(core, 'getInput').mockImplementation(
|
||||
mocks.getInput({
|
||||
...mocks.GH_OIDC_INPUTS,
|
||||
'http-proxy': 'http://proxy.example.com:8080'
|
||||
})
|
||||
);
|
||||
|
||||
await run();
|
||||
|
||||
expect(infoSpy).toHaveBeenCalledWith('Configuring proxy handler for STS client');
|
||||
expect(core.setFailed).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user