mirror of
https://github.com/docker/login-action.git
synced 2026-03-19 20:20:27 +08:00
fix: changed the error message for registry timeout to be more usefull
This commit is contained in:
parent
3227f5311c
commit
62746db9fb
2 changed files with 60 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ import {expect, jest, test} from '@jest/globals';
|
|||
import * as path from 'path';
|
||||
|
||||
import {loginStandard, logout} from '../src/docker';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||
|
||||
|
|
@ -37,6 +38,50 @@ test('loginStandard calls exec', async () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('loginStandard throws plain error on auth failure', async () => {
|
||||
jest.spyOn(Docker, 'getExecOutput').mockImplementation(async () => {
|
||||
return {
|
||||
exitCode: 1,
|
||||
stdout: '',
|
||||
stderr: 'Error response from daemon: unauthorized: incorrect username or password'
|
||||
};
|
||||
});
|
||||
|
||||
await expect(loginStandard('https://ghcr.io', 'user', 'wrongpass')).rejects.toThrow(
|
||||
'Error response from daemon: unauthorized: incorrect username or password'
|
||||
);
|
||||
});
|
||||
|
||||
test('loginStandard appends network hint on timeout error', async () => {
|
||||
jest.spyOn(Docker, 'getExecOutput').mockImplementation(async () => {
|
||||
return {
|
||||
exitCode: 1,
|
||||
stdout: '',
|
||||
stderr: 'Error response from daemon: Get "https://ghcr.io/v2/": context deadline exceeded (Client.Timeout exceeded while awaiting headers)'
|
||||
};
|
||||
});
|
||||
jest.spyOn(core, 'warning').mockImplementation(() => undefined);
|
||||
|
||||
await expect(loginStandard('https://ghcr.io', 'user', 'pass')).rejects.toThrow(
|
||||
/context deadline exceeded[\s\S]*Hint: looks like a network connectivity issue/
|
||||
);
|
||||
});
|
||||
|
||||
test('loginStandard appends network hint on dial tcp error', async () => {
|
||||
jest.spyOn(Docker, 'getExecOutput').mockImplementation(async () => {
|
||||
return {
|
||||
exitCode: 1,
|
||||
stdout: '',
|
||||
stderr: 'Error response from daemon: Get "https://ghcr.io/v2/": dial tcp 140.82.112.21:443: i/o timeout'
|
||||
};
|
||||
});
|
||||
jest.spyOn(core, 'warning').mockImplementation(() => undefined);
|
||||
|
||||
await expect(loginStandard('https://ghcr.io', 'user', 'pass')).rejects.toThrow(
|
||||
/dial tcp[\s\S]*Hint: looks like a network connectivity issue/
|
||||
);
|
||||
});
|
||||
|
||||
test('logout calls exec', async () => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue