mirror of
https://gitea.com/actions/setup-java.git
synced 2025-04-05 14:59:37 +00:00
move required parameters to auth module
username and password are required from within the auth module now. Update the tests to ensure this is the case.
This commit is contained in:
@ -1,15 +1,22 @@
|
||||
import io = require('@actions/io');
|
||||
import fs = require('fs');
|
||||
import os = require('os');
|
||||
import path = require('path');
|
||||
import child_process = require('child_process');
|
||||
|
||||
const m2Dir = path.join(__dirname, '.m2');
|
||||
const settingsFile = path.join(m2Dir, 'settings.xml');
|
||||
// make the os.homedir() call be local to the tests
|
||||
jest.doMock('os', () => {
|
||||
return {
|
||||
homedir: jest.fn(() => __dirname)
|
||||
};
|
||||
});
|
||||
|
||||
import * as auth from '../src/auth';
|
||||
|
||||
const m2Dir = path.join(__dirname, auth.M2_DIR);
|
||||
const settingsFile = path.join(m2Dir, auth.SETTINGS_FILE);
|
||||
|
||||
describe('auth tests', () => {
|
||||
beforeAll(async () => {
|
||||
beforeEach(async () => {
|
||||
await io.rmRF(m2Dir);
|
||||
}, 300000);
|
||||
|
||||
@ -21,7 +28,7 @@ describe('auth tests', () => {
|
||||
}
|
||||
}, 100000);
|
||||
|
||||
it('Creates settings.xml file with username and password', async () => {
|
||||
it('creates settings.xml with username and password', async () => {
|
||||
const username = 'bluebottle';
|
||||
const password = 'SingleOrigin';
|
||||
|
||||
@ -33,4 +40,21 @@ describe('auth tests', () => {
|
||||
auth.generate(username, password)
|
||||
);
|
||||
}, 100000);
|
||||
|
||||
it('does not create settings.xml without username and / or password', async () => {
|
||||
await auth.configAuthentication('FOO', '');
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(false);
|
||||
expect(fs.existsSync(settingsFile)).toBe(false);
|
||||
|
||||
await auth.configAuthentication('', 'BAR');
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(false);
|
||||
expect(fs.existsSync(settingsFile)).toBe(false);
|
||||
|
||||
await auth.configAuthentication('', ''); // BAZ!!!
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(false);
|
||||
expect(fs.existsSync(settingsFile)).toBe(false);
|
||||
}, 100000);
|
||||
});
|
||||
|
Reference in New Issue
Block a user