Skip to content

Commit

Permalink
fix: configure auth server when configuring environment (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
jekabs-karklins authored Mar 6, 2023
1 parent 790a22f commit 692bb1b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FeatureId } from '../../models/Feature';
import { SettingsId } from '../../models/Settings';
import { setTimezone, setDateTimeFormats } from '../setTimezoneAndFormat';
import { Tokens } from '../Tokens';
import { updateOIDCSettings } from '../updateOIDCSettings';

async function setEssColourTheme() {
const db = container.resolve<AdminDataSource>(Tokens.AdminDataSource);
Expand Down Expand Up @@ -99,4 +100,5 @@ export async function configureESSDevelopmentEnvironment() {
await enableDefaultEssFeatures();
await setTimezone();
await setDateTimeFormats();
await updateOIDCSettings();
}
26 changes: 26 additions & 0 deletions apps/user-office-backend/src/config/updateOIDCSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { OpenIdClient } from '@user-office-software/openid';
import { container } from 'tsyringe';

import { AdminDataSource } from '../datasources/AdminDataSource';
import { SettingsId } from '../models/Settings';
import { Tokens } from './Tokens';

export async function updateOIDCSettings() {
if (OpenIdClient.hasConfig() === false) {
return;
}

const loginUrl = await OpenIdClient.loginUrl();
const logoutUrl = await OpenIdClient.logoutUrl();
const db = container.resolve<AdminDataSource>(Tokens.AdminDataSource);

await db.updateSettings({
settingsId: SettingsId.EXTERNAL_AUTH_LOGIN_URL,
settingsValue: loginUrl,
});

await db.updateSettings({
settingsId: SettingsId.EXTERNAL_AUTH_LOGOUT_URL,
settingsValue: logoutUrl,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ context('App settings tests', () => {
cy.get('[data-cy="officer-menu-items"]').contains('App settings').click();

cy.get('[data-cy="settings-table"]')
.find('button[aria-label="Next Page"]')
.click();
.get('input[aria-label="Search"]')
.type(initialDBData.settings.dateTimeFormat.id);

cy.get('[data-cy="settings-table"]')
.contains(initialDBData.settings.dateTimeFormat.id)
Expand Down

0 comments on commit 692bb1b

Please sign in to comment.