1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

fix: use the correct env vars for initial admin account (#8095)

https://github.com/Unleash/unleash/pull/7795 mistakenly changed the
initial admin account environment variables to be:

 - `INITIAL_ADMIN_USER_USERNAME`
 - `INITIAL_ADMIN_USER_PASSWORD`

Instead of the previous:

 - `UNLEASH_DEFAULT_ADMIN_USERNAME`
 - `UNLEASH_DEFAULT_ADMIN_PASSWORD`

See:
https://github.com/Unleash/unleash/pull/7795/files?diff=unified&w=0#diff-a38cc7ae9f963264333b6535498970a33e046dba50a6af554f438343a6edd2ddR319-R334

This PR reverts them back to the correct environment variable names and
adds a test to prevent something similar from happening in the future.
This commit is contained in:
Nuno Góis 2024-09-05 09:10:51 +01:00 committed by GitHub
parent 4b1de563f7
commit 39538012ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View File

@ -317,8 +317,8 @@ const defaultVersionOption: IVersionOption = {
};
const parseEnvVarInitialAdminUser = (): UsernameAdminUser | undefined => {
const username = process.env.INITIAL_ADMIN_USER_USERNAME;
const password = process.env.INITIAL_ADMIN_USER_PASSWORD;
const username = process.env.UNLEASH_DEFAULT_ADMIN_USERNAME;
const password = process.env.UNLEASH_DEFAULT_ADMIN_PASSWORD;
return username && password ? { username, password } : undefined;
};

View File

@ -185,6 +185,23 @@ describe('Default admin initialization', () => {
'The combination of password and username you provided is invalid',
);
});
test('Should use the correct environment variables when initializing the default admin account', async () => {
jest.resetModules();
process.env.UNLEASH_DEFAULT_ADMIN_USERNAME = CUSTOM_ADMIN_USERNAME;
process.env.UNLEASH_DEFAULT_ADMIN_PASSWORD = CUSTOM_ADMIN_PASSWORD;
const createTestConfig =
require('../../test/config/test-config').createTestConfig;
const config = createTestConfig();
expect(config.authentication.initialAdminUser).toStrictEqual({
username: CUSTOM_ADMIN_USERNAME,
password: CUSTOM_ADMIN_PASSWORD,
});
});
});
test('Should be a valid password', async () => {