@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)
72 lines • 3.97 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 });
// Copyright (C), Siemens AG 2017
const chai = require("chai");
const debug = require("debug");
require("url-search-params-polyfill");
const src_1 = require("../src");
const log = debug("mindconnect-agent-test");
chai.should();
describe("[SDK] using different auths @s4f", () => {
it("should instantiate", () => {
const sdk = new src_1.MindSphereSdk();
sdk.should.not.be.undefined;
});
it("should instantiate with browser auth @sanity @s4f", () => {
const sdk = new src_1.MindSphereSdk(new src_1.BrowserAuth());
sdk.should.not.be.undefined;
});
it("should instantiate with backend auth @sanity @s4f", () => __awaiter(void 0, void 0, void 0, function* () {
const sdk = new src_1.MindSphereSdk(new src_1.UserAuth("123", "https://gateway.eu1.mindsphere.io"));
sdk.should.not.be.undefined;
sdk.GetGateway().should.equal("https://gateway.eu1.mindsphere.io");
const token = yield sdk.GetToken();
token.should.equal("123");
}));
it("should instantiate with backend auth and bearer @sanity @s4f", () => __awaiter(void 0, void 0, void 0, function* () {
const sdk = new src_1.MindSphereSdk(new src_1.UserAuth("Bearer 123", "https://gateway.eu1.mindsphere.io"));
sdk.should.not.be.undefined;
sdk.GetGateway().should.equal("https://gateway.eu1.mindsphere.io");
const token = yield sdk.GetToken();
token.should.equal("123");
}));
it("should instantiate with CredentialsAuth @s4f", () => __awaiter(void 0, void 0, void 0, function* () {
const sdk = new src_1.MindSphereSdk(new src_1.CredentialAuth("https://gateway.eu1.mindsphere.io", "Basic: " + Buffer.from("a:b").toString("base64"), "test"));
sdk.should.not.be.undefined;
sdk.GetGateway().should.equal("https://gateway.eu1.mindsphere.io");
sdk.GetAssetManagementClient().GetGateway().should.equal("https://gateway.eu1.mindsphere.io");
}));
it("should instantiate with ServiceCredentials @s4f", () => __awaiter(void 0, void 0, void 0, function* () {
const sdk = new src_1.MindSphereSdk({
gateway: "https://gateway.eu1.mindsphere.io",
basicAuth: "Basic: " + Buffer.from("a:b").toString("base64"),
tenant: "test",
});
sdk.should.not.be.undefined;
sdk.GetGateway().should.equal("https://gateway.eu1.mindsphere.io");
sdk.GetAssetManagementClient().GetGateway().should.equal("https://gateway.eu1.mindsphere.io");
}));
it("should instantiate with AppCredentials @s4f", () => __awaiter(void 0, void 0, void 0, function* () {
const sdk = new src_1.MindSphereSdk({
gateway: "https://gateway.eu1.mindsphere.io",
basicAuth: "Basic: " + Buffer.from("a:b").toString("base64"),
tenant: "test",
usertenant: "test",
appName: "test",
appVersion: "1.0.0",
});
sdk.should.not.be.undefined;
sdk.GetGateway().should.equal("https://gateway.eu1.mindsphere.io");
sdk.GetAssetManagementClient().GetGateway().should.equal("https://gateway.eu1.mindsphere.io");
}));
});
//# sourceMappingURL=sdk-auth-test.spec.js.map