mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-03-12 18:07:10 -04:00
* chore(deps-dev): bump @biomejs/biome from 1.9.4 to 2.1.2 Bumps [@biomejs/biome](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome) from 1.9.4 to 2.1.2. - [Release notes](https://github.com/biomejs/biome/releases) - [Changelog](https://github.com/biomejs/biome/blob/main/packages/@biomejs/biome/CHANGELOG.md) - [Commits](https://github.com/biomejs/biome/commits/@biomejs/biome@2.1.2/packages/@biomejs/biome) --- updated-dependencies: - dependency-name: "@biomejs/biome" dependency-version: 2.1.2 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * chore: bump biome and fix linting errors --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kellertk <kellertk@amazon.com> Co-authored-by: Tom Keller <1083460+kellertk@users.noreply.github.com>
54 lines
2.2 KiB
TypeScript
54 lines
2.2 KiB
TypeScript
import * as core from '@actions/core';
|
|
import { STSClient } from '@aws-sdk/client-sts';
|
|
import { mockClient } from 'aws-sdk-client-mock';
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import { cleanup } from '../src/cleanup';
|
|
import mocks from './mockinputs.test';
|
|
|
|
const mockedSTSClient = mockClient(STSClient);
|
|
|
|
describe('Configure AWS Credentials cleanup', {}, () => {
|
|
beforeEach(() => {
|
|
// Reset mock state
|
|
vi.restoreAllMocks();
|
|
mockedSTSClient.reset();
|
|
// Mock GitHub Actions core functions
|
|
vi.spyOn(core, 'exportVariable').mockImplementation((_n, _v) => {});
|
|
vi.spyOn(core, 'setSecret').mockImplementation((_s) => {});
|
|
vi.spyOn(core, 'setFailed').mockImplementation((_m) => {});
|
|
vi.spyOn(core, 'setOutput').mockImplementation((_n, _v) => {});
|
|
vi.spyOn(core, 'debug').mockImplementation((_m) => {});
|
|
vi.spyOn(core, 'info').mockImplementation((_m) => {});
|
|
process.env = {
|
|
...mocks.envs,
|
|
AWS_ACCESS_KEY_ID: 'CLEANUPTEST',
|
|
AWS_SECRET_ACCESS_KEY: 'CLEANUPTEST',
|
|
AWS_SESSION_TOKEN: 'CLEANUPTEST',
|
|
AWS_REGION: 'CLEANUPTEST',
|
|
AWS_DEFAULT_REGION: 'CLEANUPTEST',
|
|
};
|
|
});
|
|
it('replaces AWS credential and region environment variables with empty strings', {}, () => {
|
|
cleanup();
|
|
expect(core.setFailed).toHaveBeenCalledTimes(0);
|
|
expect(core.exportVariable).toHaveBeenCalledTimes(5);
|
|
expect(core.exportVariable).toHaveBeenCalledWith('AWS_ACCESS_KEY_ID', '');
|
|
expect(core.exportVariable).toHaveBeenCalledWith('AWS_SECRET_ACCESS_KEY', '');
|
|
expect(core.exportVariable).toHaveBeenCalledWith('AWS_SESSION_TOKEN', '');
|
|
expect(core.exportVariable).toHaveBeenCalledWith('AWS_DEFAULT_REGION', '');
|
|
expect(core.exportVariable).toHaveBeenCalledWith('AWS_REGION', '');
|
|
});
|
|
it('handles errors', {}, () => {
|
|
vi.spyOn(core, 'exportVariable').mockImplementationOnce(() => {
|
|
throw new Error('Test error');
|
|
});
|
|
cleanup();
|
|
expect(core.setFailed).toHaveBeenCalled();
|
|
});
|
|
it(`doesn't export credentials as empty env variables if asked not to`, {}, () => {
|
|
vi.spyOn(core, 'getInput').mockImplementation(mocks.getInput(mocks.NO_ENV_CREDS_INPUTS));
|
|
cleanup();
|
|
expect(core.exportVariable).toHaveBeenCalledTimes(0);
|
|
});
|
|
});
|