Skip to content

Commit

Permalink
Username required
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
CrazyMax committed Oct 16, 2020
1 parent 4b15841 commit 1c2cf99
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 42 deletions.
34 changes: 17 additions & 17 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ test('errors without password', async () => {
});

test('successful with only password', async () => {
const platSpy = jest.spyOn(osm, 'platform');
platSpy.mockImplementation(() => 'linux');
const setRegistrySpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy: jest.SpyInstance = jest.spyOn(docker, 'login');
dockerSpy.mockImplementation(() => {});
const password: string = 'groundcontrol';
process.env[`INPUT_PASSWORD`] = password;

await run();

expect(setRegistrySpy).toHaveBeenCalledWith('');
expect(setLogoutSpy).toHaveBeenCalledWith('');
expect(dockerSpy).toHaveBeenCalledWith('', '', password);
const platSpy = jest.spyOn(osm, 'platform');
platSpy.mockImplementation(() => 'linux');

const setRegistrySpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy: jest.SpyInstance = jest.spyOn(docker, 'login');
dockerSpy.mockImplementation(() => {});

const password: string = 'groundcontrol';
process.env[`INPUT_PASSWORD`] = password;

await run();

expect(setRegistrySpy).toHaveBeenCalledWith('');
expect(setLogoutSpy).toHaveBeenCalledWith('');
expect(dockerSpy).toHaveBeenCalledWith('', '', password);
});

test('calls docker login', async () => {
Expand All @@ -66,7 +66,7 @@ test('calls docker login', async () => {
process.env[`INPUT_REGISTRY`] = registry;

const logout: string = 'true';
process.env['INPUT_LOGOUT'] = logout
process.env['INPUT_LOGOUT'] = logout;

await run();

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inputs:
required: false
username:
description: 'Username used to log against the Docker registry'
required: false
required: true
password:
description: 'Password or personal access token used to log against the Docker registry'
required: true
Expand Down
36 changes: 13 additions & 23 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface Inputs {
export function getInputs(): Inputs {
return {
registry: core.getInput('registry'),
username: core.getInput('username'),
username: core.getInput('username', {required: true}),
password: core.getInput('password', {required: true}),
logout: core.getInput('logout')
};
Expand Down

0 comments on commit 1c2cf99

Please sign in to comment.