diff --git a/src/backend/model/diagnostics/ConfigDiagnostics.ts b/src/backend/model/diagnostics/ConfigDiagnostics.ts index f803763e..caa530f3 100644 --- a/src/backend/model/diagnostics/ConfigDiagnostics.ts +++ b/src/backend/model/diagnostics/ConfigDiagnostics.ts @@ -85,7 +85,7 @@ export class ConfigDiagnostics { private static async testEmailMessagingConfig(Messaging: MessagingConfig, config: PrivateConfigClass): Promise { Logger.debug(LOG_TAG, 'Testing EmailMessaging config'); - if (Messaging.Email.type === EmailMessagingType.sendmail && !Config.Environment.sendMailAvailable) { + if (Messaging.Email.type === EmailMessagingType.sendmail && ServerEnvironment.sendMailAvailable === false) { throw new Error('sendmail e-mail sending method is not supported as the sendmail application cannot be found in the OS.'); } } @@ -306,12 +306,12 @@ export class ConfigDiagnostics { sendmail: true, }); try { - Config.Environment.sendMailAvailable = await transporter.verify(); + ServerEnvironment.sendMailAvailable = await transporter.verify(); } catch (e) { - Config.Environment.sendMailAvailable = false; + ServerEnvironment.sendMailAvailable = false; } - ServerEnvironment.sendMailAvailable = Config.Environment.sendMailAvailable; - if (!Config.Environment.sendMailAvailable) { + Config.Environment.sendMailAvailable = ServerEnvironment.sendMailAvailable; + if (!ServerEnvironment.sendMailAvailable) { Config.Messaging.Email.type = EmailMessagingType.SMTP; Logger.info(LOG_TAG, 'Sendmail is not available on the OS. You will need to use an SMTP server if you wish the app to send mails.'); } diff --git a/test/backend/unit/middlewares/admin/SettingsMWs.ts b/test/backend/unit/middlewares/admin/SettingsMWs.ts index 0abc961a..d0dbc658 100644 --- a/test/backend/unit/middlewares/admin/SettingsMWs.ts +++ b/test/backend/unit/middlewares/admin/SettingsMWs.ts @@ -55,7 +55,7 @@ describe('Settings middleware', () => { it('should save enforced users settings', (done: (err?: any) => void) => { ServerEnvironment.sendMailAvailable = false; - Config.Environment.sendMailAvailable = false + Config.Environment.sendMailAvailable = false; Config.Messaging.Email.type = EmailMessagingType.sendmail; const req: any = { session: {}, @@ -80,9 +80,14 @@ describe('Settings middleware', () => { expect(Config.Users.enforcedUsers[0].name).to.be.equal('Apple'); expect(Config.Users.enforcedUsers.length).to.be.equal(1); Config.original().then((cfg) => { - expect(cfg.Users.enforcedUsers.length).to.be.equal(1); - expect(cfg.Users.enforcedUsers[0].name).to.be.equal('Apple'); - done(); + try { + expect(cfg.Users.enforcedUsers.length).to.be.equal(1); + expect(cfg.Users.enforcedUsers[0].name).to.be.equal('Apple'); + done(); + } catch (err) { + console.error(err); + done(err); + } }).catch(done); } catch (err) { console.error(err);