@mindconnect/mindconnect-nodejs
Version:
NodeJS Library for Siemens Insights Hub Connectivity - TypeScript SDK for Insights Hub and Industrial IoT - Command Line Interface - Insights Hub Development Proxy (Siemens Insights Hub was formerly known as MindSphere)
248 lines (237 loc) • 11.4 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const chai = require("chai");
require("url-search-params-polyfill");
const src_1 = require("../src");
const utils_1 = require("../src/api/utils");
const test_device_setup_utils_1 = require("./test-device-setup-utils");
const test_utils_1 = require("./test-utils");
chai.should();
const timeOffset = new Date().getTime();
describe.skip("[SDK] DeviceManagementClient.EdgeAppDeployment", () => {
const auth = (0, utils_1.loadAuth)();
const sdk = new src_1.MindSphereSdk(Object.assign(Object.assign({}, auth), { basicAuth: (0, utils_1.decrypt)(auth, (0, test_utils_1.getPasskeyForUnitTest)()) }));
const appDeploymentClient = sdk.GetEdgeDeploymentClient();
const edgeAppInstanceClient = sdk.GetEdgeAppInstanceManagementClient();
const tenant = sdk.GetTenant();
const testAppInstance = {
name: `testAppInst_${tenant}_${timeOffset}`,
appInstanceId: `testAppInst_${tenant}_${timeOffset}`,
deviceId: "string",
releaseId: "string",
applicationId: `testApp_${tenant}_${timeOffset}`,
};
const testConfigurations = {
deviceId: `${tenant}.UnitTestDeviceType`,
appId: "718ca5ad0...",
appReleaseId: "718ca5ad0...",
appInstanceId: "718ca5ad0...",
configuration: {
sampleKey1: "sampleValue1",
sampleKey2: "sampleValue2",
},
};
const taskTemplate = {
deviceId: "7d018c...",
softwareId: "7d018c...",
softwareReleaseId: "7d018c...",
customData: {
sampleKey1: "sampleValue1",
sampleKey2: "sampleValue2",
},
};
const workflowInstance = {
deviceId: "",
model: {
key: `${tenant}_fwupdate`,
customTransitions: [],
},
data: {
userDefined: {},
},
};
let deviceTypeId = "aee2e37f-f562-4ed6-b90a-c43208dc054a";
let assetTypeId = `${tenant}.UnitTestDeviceAssetType`;
let assetId = "";
let gFolderid = "";
let deviceId = "";
let appId = "";
let appReleaseId = "";
let appInstanceId = "";
// let installationTaskId = "";
// let removalTaskId = "";
before(() => __awaiter(void 0, void 0, void 0, function* () {
// tear Down test infrastructure
yield (0, test_device_setup_utils_1.tearDownDeviceTestStructure)(sdk);
// Setup the testing architecture
const { device, deviceAsset, deviceType, deviceAssetType, folderid } = yield (0, test_device_setup_utils_1.setupDeviceTestStructure)(sdk);
assetTypeId = `${deviceAssetType.id}`;
deviceTypeId = `${deviceType.id}`;
assetId = `${deviceAsset.assetId}`;
deviceId = `${device.id}`;
gFolderid = `${folderid}`;
// Create a new app
testAppInstance.deviceId = `${deviceId}`;
testAppInstance.releaseId = `V001${timeOffset}`;
const appInstRes = yield edgeAppInstanceClient.PostAppInstance(testAppInstance);
appInstanceId = appInstRes.id;
appId = appInstRes.applicationId;
appReleaseId = appInstRes.releaseId;
// Create a new app instance configuration
testConfigurations.deviceId = `${deviceId}`;
testConfigurations.appId = `${appId}`;
testConfigurations.appInstanceId = `${appInstanceId}`;
testConfigurations.appReleaseId = `${appReleaseId}`;
const instConfRes = yield edgeAppInstanceClient.PostAppInstanceConfigurations(testConfigurations);
// Set the task template
taskTemplate.deviceId = `${deviceId}`;
taskTemplate.softwareId = `${appId}`;
taskTemplate.softwareReleaseId = `${appInstanceId}`;
}));
after(() => __awaiter(void 0, void 0, void 0, function* () {
// delete App configuration
yield edgeAppInstanceClient.DeleteAppInstanceConfiguration(appInstanceId);
// Delete the app
yield edgeAppInstanceClient.DeleteAppInstance(appInstanceId);
// tear Down test infrastructure
yield (0, test_device_setup_utils_1.tearDownDeviceTestStructure)(sdk);
}));
it("SDK should not be undefined", () => __awaiter(void 0, void 0, void 0, function* () {
sdk.should.not.be.undefined;
}));
it("standard properties shoud be defined", () => __awaiter(void 0, void 0, void 0, function* () {
appDeploymentClient.should.not.be.undefined;
appDeploymentClient.GetGateway().should.be.equal(auth.gateway);
(yield appDeploymentClient.GetToken()).length.should.be.greaterThan(200);
(yield appDeploymentClient.GetToken()).length.should.be.greaterThan(200);
}));
it("should POST accepted term and conditions", () => __awaiter(void 0, void 0, void 0, function* () {
appDeploymentClient.should.not.be.undefined;
// Prepare a new workflow instance
const acceptedTermsAndConditions = yield appDeploymentClient.PostAcceptTermsAndConditions({
deviceId: deviceId,
releaseId: appReleaseId,
});
acceptedTermsAndConditions.should.not.be.undefined;
acceptedTermsAndConditions.should.not.be.null;
acceptedTermsAndConditions.firstAccepted.should.not.be.undefined;
acceptedTermsAndConditions.firstAccepted.should.not.be.null;
}));
it("should GET terms and conditions", () => __awaiter(void 0, void 0, void 0, function* () {
appDeploymentClient.should.not.be.undefined;
// Get terms and conditions
const appTermAndConditions = yield appDeploymentClient.GetTermsAndConditions(deviceId, appReleaseId);
appTermAndConditions.should.not.be.undefined;
appTermAndConditions.should.not.be.null;
appTermAndConditions.firstAccepted.should.not.be.null;
}));
/* TODO: 27-06-2021 Not supported in yet
it("should POST a new deployment task", async () => {
appDeploymentClient.should.not.be.undefined;
// Set the task template
taskTemplate.deviceId = `${deviceId}`;
taskTemplate.softwareId = `${appId}`;
taskTemplate.softwareReleaseId = `${appInstanceId}`;
const installationTask = await appDeploymentClient.PostInstallationTask(taskTemplate);
(installationTask as any).should.not.be.undefined;
(installationTask as any).should.not.be.null;
(installationTask as any).id.should.not.be.undefined;
(installationTask as any).id.should.not.be.null;
(installationTask as any).currentState.should.not.be.undefined;
(installationTask as any).currentState.should.not.be.null;
installationTaskId = `${(installationTask as any).id}`;
});*/
it("should GET list of installation tasks.", () => __awaiter(void 0, void 0, void 0, function* () {
appDeploymentClient.should.not.be.undefined;
const taks = yield appDeploymentClient.GetInstallationTasks(deviceId);
taks.should.not.be.undefined;
taks.should.not.be.null;
taks.page.number.should.equal(0);
taks.page.size.should.be.gte(10);
taks.content.length.should.be.gte(0);
}));
/* TODO: 27-06-2021 Not supported in yet
it("should GET specific installation task", async () => {
appDeploymentClient.should.not.be.undefined;
const task = await appDeploymentClient.GetInstallationTask(installationTaskId);
(task as any).should.not.be.undefined;
(task as any).should.not.be.null;
(task as any).id.should.not.be.undefined;
(task as any).id.should.not.be.null;
});*/
/* TODO: 27-06-2021 Not supported in yet
it("should PATCH installation Status as downloading", async () => {
appDeploymentClient.should.not.be.undefined;
// Set the task template
const status = {
state: EdgeAppDeploymentModels.TaskStatus.StateEnum.DOWNLOAD,
progress: 0.9,
message: "Task status updated as DOWNLOAD",
details: {
sampleKey1: "sampleValue1",
sampleKey2: "sampleValue2"
}
};
const installationTAsk = await appDeploymentClient.PatchInstallationTask(installationTaskId, status);
(installationTAsk as any).should.not.be.undefined;
(installationTAsk as any).should.not.be.null;
(installationTAsk as any).currentState.should.not.be.undefined;
(installationTAsk as any).currentState.should.not.be.null;
});
*/
/* TODO: 27-06-2021 Not supported in yet
it("should PATCH installation Status as activate", async () => {
appDeploymentClient.should.not.be.undefined;
// Set the task template
const status = {
state: EdgeAppDeploymentModels.TaskStatus.StateEnum.ACTIVATE,
progress: 1.0,
message: "Task status updated as ACTIVATE",
details: {
sampleKey1: "sampleValue1",
sampleKey2: "sampleValue2"
}
};
const installationTAsk = await appDeploymentClient.PatchInstallationTask(installationTaskId, status);
(installationTAsk as any).should.not.be.undefined;
(installationTAsk as any).should.not.be.null;
(installationTAsk as any).currentState.should.not.be.undefined;
(installationTAsk as any).currentState.should.not.be.null;
});
*/
/* TODO: 27-06-2021 Not supported in yet
it("should POST to create a removal task", async () => {
appDeploymentClient.should.not.be.undefined;
// Set the task template
taskTemplate.deviceId = `${deviceId}`;
taskTemplate.softwareId = `${appId}`;
taskTemplate.softwareReleaseId = `${appInstanceId}`;
const installationTask = await appDeploymentClient.PostRemovalTask(taskTemplate);
(installationTask as any).should.not.be.undefined;
(installationTask as any).should.not.be.null;
(installationTask as any).id.should.not.be.undefined;
(installationTask as any).id.should.not.be.null;
(installationTask as any).currentState.should.not.be.undefined;
(installationTask as any).currentState.should.not.be.null;
removalTaskId = `${(installationTask as any).id}`;
});*/
it("should GET list of removal tasks.", () => __awaiter(void 0, void 0, void 0, function* () {
appDeploymentClient.should.not.be.undefined;
const taks = yield appDeploymentClient.GetRemovalTasks(deviceId);
taks.should.not.be.undefined;
taks.should.not.be.null;
taks.page.number.should.equal(0);
taks.page.size.should.be.gte(10);
taks.content.length.should.be.gte(0);
}));
});
//# sourceMappingURL=oe-app-deployment.spec.js.map