mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-23 01:27:14 +02:00
Improving integration tests.
This commit is contained in:
parent
ed0ea40758
commit
6b3a208794
@ -111,13 +111,15 @@ export class RenderingMWs {
|
||||
const originalConf = await ExtensionConfigWrapper.original();
|
||||
// These are sensitive information, do not send to the client side
|
||||
originalConf.Server.sessionSecret = null;
|
||||
const originalConfJSON = JSON.parse(JSON.stringify(originalConf.toJSON({
|
||||
attachState: true,
|
||||
attachVolatile: true,
|
||||
skipTags: {secret: true} as TAGS
|
||||
}) as PrivateConfigClass));
|
||||
|
||||
const message = new Message<PrivateConfigClass>(
|
||||
null,
|
||||
originalConf.toJSON({
|
||||
attachState: true,
|
||||
attachVolatile: true,
|
||||
skipTags: {secret: true} as TAGS
|
||||
}) as PrivateConfigClass
|
||||
originalConfJSON
|
||||
);
|
||||
res.json(message);
|
||||
}
|
||||
|
@ -12,17 +12,17 @@ const LOG_TAG = '[ExtensionConfigWrapper]';
|
||||
*/
|
||||
export class ExtensionConfigWrapper {
|
||||
|
||||
static async original(showError = false): Promise<PrivateConfigClass & IConfigClass> {
|
||||
static async original(showDetailedError = false): Promise<PrivateConfigClass & IConfigClass> {
|
||||
const pc = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass());
|
||||
ExtensionConfigTemplateLoader.Instance.loadExtensionTemplates(pc);
|
||||
try {
|
||||
await pc.load(); // loading the basic configs, but we do not know the extension config hierarchy yet
|
||||
|
||||
} catch (e) {
|
||||
if(showError){
|
||||
console.error(LOG_TAG,'Error during loading config. Reverting to defaults.');
|
||||
console.error(LOG_TAG,'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.');
|
||||
console.error(e);
|
||||
console.error(LOG_TAG, 'Error during loading config. Reverting to defaults.');
|
||||
console.error(e);
|
||||
if (showDetailedError) {
|
||||
console.error(LOG_TAG, 'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.');
|
||||
NotificationManager.error('Can\'t load config. Reverting to default. This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.', (e.toString ? e.toString() : JSON.stringify(e)));
|
||||
}
|
||||
}
|
||||
@ -30,17 +30,17 @@ export class ExtensionConfigWrapper {
|
||||
}
|
||||
|
||||
|
||||
static originalSync(showError = false): PrivateConfigClass & IConfigClass {
|
||||
static originalSync(showDetailedError = false): PrivateConfigClass & IConfigClass {
|
||||
const pc = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass());
|
||||
ExtensionConfigTemplateLoader.Instance.loadExtensionTemplates(pc);
|
||||
try {
|
||||
pc.loadSync(); // loading the basic configs, but we do not know the extension config hierarchy yet
|
||||
|
||||
} catch (e) {
|
||||
if(showError){
|
||||
console.error(LOG_TAG,'Error during loading config. Reverting to defaults.');
|
||||
console.error(LOG_TAG,'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.');
|
||||
console.error(e);
|
||||
console.error(LOG_TAG, 'Error during loading config. Reverting to defaults.');
|
||||
console.error(e);
|
||||
if (showDetailedError) {
|
||||
console.error(LOG_TAG, 'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.');
|
||||
NotificationManager.error('Ca\'nt load config. Reverting to default. This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.', (e.toString ? e.toString() : JSON.stringify(e)));
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,13 @@ describe('SettingsRouter', () => {
|
||||
Config.Users.unAuthenticatedUserRole = UserRoles.Admin;
|
||||
const originalSettings = await ExtensionConfigWrapper.original();
|
||||
|
||||
originalSettings.Environment.upTime = null;
|
||||
const originalJSON = JSON.parse(JSON.stringify(originalSettings.toJSON({
|
||||
attachState: true,
|
||||
attachVolatile: true,
|
||||
skipTags: {secret: true} as TAGS
|
||||
})));
|
||||
|
||||
const result = await chai.request(server.Server)
|
||||
.get(Config.Server.apiPath + '/settings');
|
||||
|
||||
@ -48,12 +55,7 @@ describe('SettingsRouter', () => {
|
||||
result.body.should.be.a('object');
|
||||
should.equal(result.body.error, null);
|
||||
(result.body.result as ServerConfig).Environment.upTime = null;
|
||||
originalSettings.Environment.upTime = null;
|
||||
result.body.result.should.deep.equal(JSON.parse(JSON.stringify(originalSettings.toJSON({
|
||||
attachState: true,
|
||||
attachVolatile: true,
|
||||
skipTags: {secret: true} as TAGS
|
||||
}))));
|
||||
result.body.result.should.deep.equal(originalJSON);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user