diff --git a/src/lib/create-config.ts b/src/lib/create-config.ts index c3626cfaacc4..e6d49d5f34af 100644 --- a/src/lib/create-config.ts +++ b/src/lib/create-config.ts @@ -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; }; diff --git a/src/lib/services/user-service.test.ts b/src/lib/services/user-service.test.ts index 92a1024d5a22..03966f662b19 100644 --- a/src/lib/services/user-service.test.ts +++ b/src/lib/services/user-service.test.ts @@ -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 () => {