mirror of
https://github.com/docker/login-action.git
synced 2026-04-22 02:19:51 +00:00
fix scoped Docker Hub cleanup path when registry is omitted
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
da5b89b92c
commit
7277d4d442
3 changed files with 31 additions and 13 deletions
|
|
@ -1,6 +1,17 @@
|
|||
import {expect, test} from 'vitest';
|
||||
import {afterEach, expect, test} from 'vitest';
|
||||
import * as path from 'path';
|
||||
|
||||
import {getInputs} from '../src/context.js';
|
||||
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx.js';
|
||||
|
||||
import {getAuthList, getInputs} from '../src/context.js';
|
||||
|
||||
afterEach(() => {
|
||||
for (const key of Object.keys(process.env)) {
|
||||
if (key.startsWith('INPUT_')) {
|
||||
delete process.env[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('with password and username getInputs does not throw error', async () => {
|
||||
process.env['INPUT_USERNAME'] = 'dbowie';
|
||||
|
|
@ -10,3 +21,15 @@ test('with password and username getInputs does not throw error', async () => {
|
|||
getInputs();
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
test('getAuthList uses the default Docker Hub registry when computing scoped config dir', async () => {
|
||||
process.env['INPUT_USERNAME'] = 'dbowie';
|
||||
process.env['INPUT_PASSWORD'] = 'groundcontrol';
|
||||
process.env['INPUT_SCOPE'] = 'myscope';
|
||||
process.env['INPUT_LOGOUT'] = 'false';
|
||||
const [auth] = getAuthList(getInputs());
|
||||
expect(auth).toMatchObject({
|
||||
registry: 'docker.io',
|
||||
configDir: path.join(Buildx.configDir, 'config', 'registry-1.docker.io', 'myscope')
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue