Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gpii.solutionsRegistry.schemaGenerator.generateSettingsSchema = function (that) {
var settingsSchema = require(fluid.module.resolvePath(that.options.baseSettingsSchema));
// settings schema template from that.options.baseSettingsSchema
// TODO: Add all solutions/settings and schemas from that.options.solutionsRegistryPath
var solutionsSettings = gpii.solutionsRegistry.schemaGenerator.settingsFromSolutions(that);
var genericSettings = gpii.solutionsRegistry.schemaGenerator.genericSettings(that);
var allSettings = fluid.extend({}, solutionsSettings, genericSettings);
// Merge the generated settings schema data into the "base schema" at the right point.
fluid.set(
settingsSchema,
"properties",
allSettings
);
var settingsOutputPath = fluid.module.resolvePath(that.options.settingsSchemaOutputPath);
var settingsOutputDir = path.dirname(settingsOutputPath);
if (!fs.existsSync(settingsOutputDir)) {
mkdirp.sync(settingsOutputDir);
}
fs.writeFileSync(settingsOutputPath, JSON.stringify(settingsSchema, null, 2));
};
fluid.each(secondary.contexts, function (context, contextId) {
var mcontext = master.contexts[contextId];
// if not in master, just copy over from secondary:
if (!mcontext) {
master.contexts[contextId] = context;
} else {
// preferences and metadata should be the only things varying
fluid.extend(true, mcontext.preferences, context.preferences);
mcontext.metadata = fluid.makeArray(mcontext.metadata).concat(fluid.makeArray(context.metadata));
}
});
gpii.tests.productionConfigTesting.testDefs = fluid.transform(gpii.tests.development.testDefs, function (testDefIn) {
var testDef = fluid.extend(true, {}, testDefIn, {
name: "Flow Manager production tests",
config: gpii.tests.productionConfigTesting.config,
expect: 6,
components: {
healthRequest: {
type: "kettle.test.request.http",
options: {
hostname: "flowmanager",
path: "/health",
method: "GET",
expectedStatusCode: 200,
expectedPayload: {"isHealthy": true}
}
},
readyRequest: {
type: "kettle.test.request.http",
gpii.tests.productionConfigTesting.testDefs = fluid.transform(gpii.tests.development.testDefs, function (testDefIn) {
var testDef = fluid.extend(true, {}, testDefIn, {
name: "Flow Manager production tests",
expect: 16,
config: gpii.tests.productionConfigTesting.config,
components: {
healthRequest: {
type: "kettle.test.request.http",
options: {
hostname: "flowmanager",
path: "/health",
method: "GET",
expectedStatusCode: 200,
expectedPayload: {"isHealthy": true}
}
},
readyRequest: {
type: "kettle.test.request.http",
gpii.test.untrusted.pspIntegration.verifyRawPrefsAtEnd = function (that, preferences, sequenceNum, expectedChange) {
var expectedPrefsChange = expectedChange ? expectedChange : gpii.test.untrusted.pspIntegration.expectedPrefsChange[sequenceNum];
var expected = fluid.extend(true, {}, that.options.initialPrefs, expectedPrefsChange);
jqUnit.assertDeepEq("The updated preferences have been saved to the cloud", expected, JSON.parse(preferences));
};
gpii.tests.untrusted.flowManager.browserChannel.testDefs = fluid.transform(gpii.tests.flowManager.browserChannel.testDefs, function (testDefIn) {
var testDef = fluid.extend(true, {}, testDefIn, {
config: {
configName: "gpii.tests.acceptance.untrusted.browserChannel.config",
configPath: "%gpii-universal/tests/configs"
}
});
return testDef;
});
return fluid.transform(gpii.tests.preferencesServerErrorTests.testDefs, function (testDef) {
return fluid.extend(true, {}, gpii.tests.preferencesServerErrorTests.testDefCommon, testDef);
});
};
gpii.test.untrusted.pspIntegration.verifyRawPrefsAtEnd = function (that, preferences, sequenceNum, expectedChange) {
fluid.log (that.options.name, ", number ", sequenceNum, " in the sequence");
var expectedPrefsChange = expectedChange ? expectedChange : gpii.test.untrusted.pspIntegration.expectedPrefsChange[sequenceNum];
var expected = fluid.extend(true, {}, that.options.initialPrefs, expectedPrefsChange);
jqUnit.assertDeepEq("The updated preferences have been saved to the cloud", expected, JSON.parse(preferences));
};
var validationResults = globalValidator.validate(schema, toValidate, schemaHash);
if (validationResults.isValid) {
validationPromise.resolve();
}
else {
if (dataPathPrefix) {
fluid.each(validationResults.errors, function (singleError) {
singleError.dataPath = fluid.copy(dataPathPrefix).concat(singleError.dataPath);
});
}
var localisedErrors = gpii.schema.validator.localiseErrors(validationResults.errors, toValidate, validationMiddleware.model.messages, validationMiddleware.options.rules.localisation);
var localisedPayload = fluid.copy(validationResults);
localisedPayload.errors = localisedErrors;
var failurePayload = fluid.extend({}, validationMiddleware.options.errorTemplate, localisedPayload);
validationPromise.reject(failurePayload);
}
return validationPromise;
};
};
}, function (err) {
var error = fluid.extend(err, {
message: "Rejected deviceReporter promise: " + err.message
});
errorEvent.fire(error);
});
};