UNPKG

omnipartners

Version:
87 lines (86 loc) 3.09 kB
"use strict"; /* eslint-env mocha */ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseIdentityTest = exports.baseConfig = void 0; const __1 = __importDefault(require("..")); const test_utils_1 = require("../../../tests/test.utils"); exports.baseConfig = { host: "http://cis.staging.rcbe.omnipartners.be", key: "b59b129e7c4dbe53ede4874535b5c784667936ce", secret: "3788ac15ba321a8b9913b5130ef2f4aa0e822fd0", }; class BaseIdentityTest { constructor() { this.Api = __1.default; this.apiConfig = exports.baseConfig; } } exports.BaseIdentityTest = BaseIdentityTest; class Authenticate extends BaseIdentityTest { constructor() { super(...arguments); this.name = "authenticate"; this.httpPath = "/service/auth/credentials"; this.httpMethod = "get"; this.httpDefaultData = { hash: test_utils_1.REGEX_HASH, key: exports.baseConfig.key, }; } "without body"({ err }) { expect(err).toBeInstanceOf(Error); } "with invalid credentials"({ err }) { expect(err.code).toEqual("OP/OPStatusError/5"); } "with valid credentials"({ err, response, }) { expect(err).toEqual(null); expect(response.owner).toBeTruthy(); } } __decorate([ (0, test_utils_1.withMock)({ reply: { statusCode: 2 } }), (0, test_utils_1.withArguments)({}, { shouldThrow: true }) ], Authenticate.prototype, "without body", null); __decorate([ (0, test_utils_1.withMock)({ query: { identifier: "loic%40igloo.be", password: "12345", }, reply: { statusCode: 5, }, }), (0, test_utils_1.withArguments)({ identifier: "loic@igloo.be", password: "12345", }, { shouldThrow: true, }) ], Authenticate.prototype, "with invalid credentials", null); __decorate([ (0, test_utils_1.withMock)({ query: { identifier: "loic%40igloo.be", password: "igloo", }, reply: require("./fixtures/valid.json"), }), (0, test_utils_1.withArguments)({ identifier: "loic@igloo.be", password: "igloo", }) ], Authenticate.prototype, "with valid credentials", null); (0, test_utils_1.describeApi)("identity", () => { (0, test_utils_1.describeMethod)(Authenticate); });