Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
fluid.defaults("gpii.tests.cloud.oauth2.settingsPut.disruption.mainSequence", {
gradeNames: ["gpii.test.disruption.settings.sequenceGrade"],
testCaseGradeNames: "gpii.tests.cloud.oauth2.settingsPut.requests",
sequenceElements: {
mainSequence: {
priority: "after:startServer",
gradeNames: "gpii.tests.cloud.oauth2.settingsPut.mainSequence"
}
}
});
// For failed test case that are rejected by /settings endpoint
// 1. rejected when requesting /settings without providing an access token
fluid.defaults("gpii.tests.cloud.oauth2.settingsPut.settingsPutNoAccessTokenSequence", {
gradeNames: ["fluid.test.sequenceElement"],
sequence: [
{ funcName: "fluid.log", args: ["Flowmanager rejected put settings sequence -- no access token..."]},
{
func: "{settingsPutRequest}.send",
args: ["{testCaseHolder}.options.updatedPrefsSet"]
},
{
event: "{settingsPutRequest}.events.onComplete",
listener: "gpii.test.verifyStatusCodeResponse",
args: ["{arguments}.0", "{settingsPutRequest}", "{testCaseHolder}.options.expectedStatusCode"]
}
]
});
fluid.defaults("gpii.tests.cloud.oauth2.settingsPut.disruption.settingsPutNoAccessTokenSequence", {
fluid.registerNamespace("gpii.test.cloudBased.oauth2");
/*
* ========================================================================
* Testing of untrusted local config with the live cloud based flow manager
* ========================================================================
*/
require("./ProductionTestsUtils.js");
require("../shared/FlowManagerSettingsPutTestDefs.js");
gpii.loadTestingSupport();
// PUT /settings tests
fluid.defaults("gpii.tests.productionConfigTesting.settingsPut.testCaseHolder", {
gradeNames: [
"gpii.test.cloudBased.oauth2.testCaseHolder",
"gpii.tests.cloud.oauth2.accessTokensDeleteRequests"
],
productionHostConfig: {
hostname: "flowmanager",
port: 9082
},
distributeOptions: {
"accessTokenRequest.hostConfig": {
source: "{that}.options.productionHostConfig",
target: "{that accessTokenRequest}.options"
},
"settingsPutRequest.hostConfig": {
source: "{that}.options.productionHostConfig",
target: "{that settingsPutRequest}.options"
/*jshint node:true*/
"use strict";
var fluid = require("infusion"),
osc = require("osc");
require("infusion-electron");
var oscjs = fluid.registerNamespace("oscjs");
fluid.defaults("oscjs.tests.electron.app", {
gradeNames: "electron.app",
components: {
browserTestWindow: {
createOnEvent: "onReady",
type: "oscjs.tests.electron.browserTestWindow"
},
// We need a separate window for Electron-specific tests
// because qunit-composite uses iFrames, which are sandboxed from the
// Electron Node.js API (e.g. require()).
electronTestWindow: {
createOnEvent: "onReady",
type: "oscjs.tests.electron.electronTestWindow",
options: {
windowOptions: {
*
* @param {Object} baseSchema - The original GSS schema to filter.
* @param {Object} req - The request object from which we extract our observed settings.
* @param {Object} rules - Model transformation rules to use to extract the observed settings from the request.
* @return {Object} - The filtered GSS schema.
*/
gpii.universal.solutionsRegistry.requestValidation.generateFilteredSchema = function (baseSchema, req, rules) {
// Find the location of the settings payload using the supplied transformation rules.
var observedSettings = fluid.model.transformWithRules(req, rules);
// Filter the underlying schema using the derived settings.
var filteredSchema = gpii.universal.solutionsRegistry.filterSchemaToSettings(observedSettings, baseSchema);
return filteredSchema;
};
fluid.defaults("gpii.universal.solutionsRegistry.requestValidation.base", {
gradeNames: ["gpii.schema.kettle.request.http"],
mergePolicy: {
// TODO: Discuss whether to move this up to gpii-json-schema and whether the "has query data" mix-in grade is worth preserving.
"rules.requestContentToValidate": "nomerge",
"rules.filterInput": "nomerge"
},
settingsSchemaPath: "%gpii-universal/build/schemas/settings-schema.json",
settingsSchema: "@expand:gpii.universal.solutionsRegistry.getSettingsSchema({that}.options.settingsSchemaPath)",
filteredSettingsSchema: "@expand:gpii.universal.solutionsRegistry.requestValidation.generateFilteredSchema({that}.options.settingsSchema, {request}.req, {that}.options.rules.filterInput)",
rules: {
filterInput: "{that}.options.rules.requestContentToValidate"
},
components: {
validationMiddleware: {
options: {
inputSchema: "{gpii.universal.solutionsRegistry.requestValidation.base}.options.inputSchema"
var gpiiPid = gpii.singleInstance.checkInstance(pidFile);
if (gpiiPid === null) {
// Write the pid, but fail if the file exists. The stale one was deleted, but there might be another
// GPII instance just starting.
fs.writeFileSync(pidFile, process.pid, { flag: "wx" });
}
var success = !gpiiPid || gpiiPid === process.pid;
if (!success) {
fluid.log(fluid.logLevel.WARN, "There's already an instance of GPII detected.");
}
return success;
};
fluid.defaults("gpii.singleInstance.registerInstance", {
gradeNames: "fluid.function"
});
/**
* Checks for another GPII instance.
*
* @param {String} [pidFile] - [optional] The path of the pid file. Default is "gpii.pid" in the settings directory.
* @return {Number} Non-zero PID of the other GPII process (including this process), or null if this is the only one.
*/
gpii.singleInstance.checkInstance = function (pidFile) {
if (!pidFile || typeof(pidFile) !== "string") {
pidFile = gpii.singleInstance.getDefaultPidFile();
}
var pid = null;
(function () {
"use strict";
var fluid = require("infusion"),
gpii = fluid.registerNamespace("gpii"),
$ = fluid.registerNamespace("jQuery");
fluid.registerNamespace("gpii.ontology.get");
fluid.defaults("kettle.requests.request.handler.ontologyGet", {
gradeNames: ["autoInit", "fluid.littleComponent"],
invokers: {
handle: {
funcName: "gpii.ontology.get.request",
args: [ "{request}", "{ontologyHandler}", "{that}.events.onRawPreferences"],
dynamic: true
},
getHandler: {
funcName: "gpii.ontology.get.getHandler",
args: [ "{arguments}.0", "{request}", "{requestProxy}", "{ontologyHandler}.ontologySource", "{ontologyHandler}" ]
}
},
events: {
onRawPreferences: null
},
listeners: {
(function () {
"use strict";
var fluid = require("infusion"),
gpii = fluid.registerNamespace("gpii");
fluid.registerNamespace("gpii.lifecycleManager");
/** A mixin request grade for requests which require an active user session to do their work. Exposes a method
* withSession which will acquire the session tokens and supply them as an argument or else fail if none is available.
*/
fluid.defaults("gpii.flowManager.sessionAware", {
invokers: {
withSession: {
funcName: "gpii.flowManager.sessionAware.withSession",
args: ["{that}", "{lifecycleManager}", "{arguments}.0", "{arguments}.1", "{arguments}.2"]
}
}
});
gpii.flowManager.sessionAware.withSession = function (that, lifecycleManager, onSuccess, failMessage, onError) {
onError = onError || that.events.onError.fire;
var gpiiKeys = lifecycleManager.getActiveSessionGpiiKeys();
if (gpiiKeys.length === 0) {
failMessage = failMessage || "Error handling request which required active session, but none was active";
onError({
isError: true,
statusCode: 401,
ontologySource: {
type: "kettle.dataSource.URL"
}
},
distributeOptions: {
source: "{that}.options.urlExpanderGradeNames",
target: "{that urlExpander}.options.gradeNames"
},
urlExpanderGradeNames: ["kettle.urlExpander.development"]
});
gpii.ontologyServer.responseParser = function (ontology) {
return ontology.transformations;
};
fluid.defaults("gpii.ontologyServer.development", {
gradeNames: ["autoInit", "fluid.littleComponent"],
components: {
ontologySource: {
type: "kettle.dataSource.URL",
options: {
gradeNames: ["kettle.dataSource.promiseCallbackWrapper"],
url: "{gpii.matchMaker}.options.ontologyServerUrl"
}
}
},
invokers: {
set: {
funcName: "gpii.ontologyServer.development.set",
args: ["{ontologySource}", "{callbackWrapper}", "{arguments}.0", "{arguments}.1", "{arguments}.2"]
}
}
var fluid = require("infusion"),
path = require("path"),
semver = require("semver"),
gpii = fluid.registerNamespace("gpii"),
$ = fluid.registerNamespace("jQuery");
fluid.require("kettle", require);
fluid.require("./MatchPost.js", require);
fluid.require("transformer", require);
fluid.require("ontologyHandler", require);
fluid.registerNamespace("gpii.matchMaker");
gpii.matchMaker.inverseCapabilities = require("./inverseCapabilities.json");
fluid.defaults("gpii.matchMaker", {
gradeNames: ["kettle.app", "autoInit"],
mergePolicy: {
inverseCapabilities: "nomerge"
},
handlers: {
matchPost: {
route: "/match",
type: "post"
}
},
inverseCapabilities: gpii.matchMaker.inverseCapabilities,
strategy: "gpii.matchMaker.flat.disposeStrategy",
solutionsReporterUrl: "",
root: path.join(__dirname, ".."),
components: {
solutionsReporter: {
});
fluid.defaults("gpii.deviceReporter.handlers.get", {
gradeNames: ["kettle.request.http"],
invokers: {
handleRequest: {
func: "{deviceReporter}.get",
args: [
"{request}"
]
}
}
});
fluid.defaults("gpii.deviceReporter.nameResolver", {
gradeNames: ["fluid.component"],
invokers: {
resolveName: {
funcName: "fluid.identity"
}
}
});
gpii.deviceReporter.fireResponse = function (request, installedSolutions, platformReporter) {
request.events.onSuccess.fire({
solutions: installedSolutions,
OS: platformReporter.reportPlatform()
});
};
fluid.defaults("gpii.deviceReporter.static", {