mirror of
https://github.com/docker/login-action.git
synced 2026-10-17 19:07:53 +02:00
test: simplify registry-auth ECR regression coverage
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
3 files changed
+1
-31
No files matched your search
@@ -176,7 +176,7 @@ test.each([
|
|||||||
['true', 'true'],
|
['true', 'true'],
|
||||||
['auto', 'auto'],
|
['auto', 'auto'],
|
||||||
['""', 'auto']
|
['""', 'auto']
|
||||||
])('getAuthList keeps registry-auth ecr: %s', async (ecr, expected) => {
|
])('getAuthList normalizes registry-auth ecr: %s', (ecr, expected) => {
|
||||||
const [auth] = getAuthList({
|
const [auth] = getAuthList({
|
||||||
registry: '',
|
registry: '',
|
||||||
username: '',
|
username: '',
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import {afterEach, expect, test, vi} from 'vitest';
|
|||||||
|
|
||||||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';
|
import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';
|
||||||
|
|
||||||
import * as aws from '../src/aws.js';
|
|
||||||
import {getAuthList} from '../src/context.js';
|
|
||||||
import {login, loginStandard, logout} from '../src/docker.js';
|
import {login, loginStandard, logout} from '../src/docker.js';
|
||||||
import * as dockerhub from '../src/dockerhub.js';
|
import * as dockerhub from '../src/dockerhub.js';
|
||||||
|
|
||||||
@@ -94,30 +92,3 @@ test('logout calls exec', async () => {
|
|||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('login uses standard login for an ECR registry with registry-auth ecr: false', async () => {
|
|
||||||
const execSpy = vi.spyOn(Docker, 'getExecOutput').mockResolvedValue({
|
|
||||||
exitCode: 0,
|
|
||||||
stdout: '',
|
|
||||||
stderr: ''
|
|
||||||
});
|
|
||||||
const ecrSpy = vi.spyOn(aws, 'getRegistriesData').mockRejectedValue(new Error('AWS SDK called'));
|
|
||||||
|
|
||||||
const [auth] = getAuthList({
|
|
||||||
registry: '',
|
|
||||||
username: '',
|
|
||||||
password: '',
|
|
||||||
scope: '',
|
|
||||||
ecr: '',
|
|
||||||
logout: true,
|
|
||||||
registryAuth: '- registry: 012345678910.dkr.ecr.eu-west-3.amazonaws.com\n username: AWS\n password: token\n ecr: false\n'
|
|
||||||
});
|
|
||||||
await login(auth);
|
|
||||||
|
|
||||||
expect(ecrSpy).not.toHaveBeenCalled();
|
|
||||||
expect(execSpy).toHaveBeenCalledWith(['login', '--password-stdin', '--username', 'AWS', '012345678910.dkr.ecr.eu-west-3.amazonaws.com'], {
|
|
||||||
input: Buffer.from('token'),
|
|
||||||
silent: true,
|
|
||||||
ignoreReturnCode: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -62,7 +62,6 @@ export function getAuthList(inputs: Inputs): Array<Auth> {
|
|||||||
username: auth.username,
|
username: auth.username,
|
||||||
password: auth.password,
|
password: auth.password,
|
||||||
scope: auth.scope,
|
scope: auth.scope,
|
||||||
// YAML parses an unquoted `ecr: false` as a boolean, keep it instead of falling back to auto
|
|
||||||
ecr: String(auth.ecr ?? '') || 'auto',
|
ecr: String(auth.ecr ?? '') || 'auto',
|
||||||
configDir: scopeToConfigDir(registry, auth.scope)
|
configDir: scopeToConfigDir(registry, auth.scope)
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user