@kilterset/auth0-actions-testing
Version:
Test and develop Auth0 Actions or Okta CIC Actions locally.
118 lines • 6.82 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());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = __importDefault(require("node:test"));
const node_assert_1 = require("node:assert");
const saml_response_1 = require("../../mock/api/saml-response");
(0, node_test_1.default)("Saml Response", (t) => __awaiter(void 0, void 0, void 0, function* () {
const baseApi = Symbol("Base API");
const { build, state } = (0, saml_response_1.samlResponseMock)("Another Flow");
const api = build(baseApi);
yield t.test("attributes", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.deepStrictEqual)(state.attributes, {});
api.setAttribute("species", "cat");
api.setAttribute("nickname", "Buddy");
(0, node_assert_1.deepStrictEqual)(state.attributes, {
species: "cat",
nickname: "Buddy",
});
}));
yield t.test("audience", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.strictEqual)(state.audience, "default-audience");
api.setAudience("custom-audience");
(0, node_assert_1.strictEqual)(state.audience, "custom-audience");
}));
yield t.test("recipient", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.strictEqual)(state.recipient, "default-recipient");
api.setRecipient("custom-recipient");
(0, node_assert_1.strictEqual)(state.recipient, "custom-recipient");
}));
yield t.test("destination", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.strictEqual)(state.destination, "default-destination");
api.setDestination("custom-destination");
(0, node_assert_1.strictEqual)(state.destination, "custom-destination");
}));
yield t.test("createUpnClaim", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.strictEqual)(state.createUpnClaim, true);
api.setCreateUpnClaim(false);
(0, node_assert_1.strictEqual)(state.createUpnClaim, false);
}));
yield t.test("passthroughClaimsWithNoMapping", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.strictEqual)(state.passthroughClaimsWithNoMapping, true);
api.setPassthroughClaimsWithNoMapping(false);
(0, node_assert_1.strictEqual)(state.passthroughClaimsWithNoMapping, false);
}));
yield t.test("mapUnknownClaimsAsIs", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.strictEqual)(state.mapUnknownClaimsAsIs, false);
api.setMapUnknownClaimsAsIs(true);
(0, node_assert_1.strictEqual)(state.mapUnknownClaimsAsIs, true);
}));
yield t.test("mapIdentities", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.strictEqual)(state.mapIdentities, true);
api.setMapIdentities(false);
(0, node_assert_1.strictEqual)(state.mapIdentities, false);
}));
yield t.test("signResponse", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.strictEqual)(state.signResponse, false);
api.setSignResponse(true);
(0, node_assert_1.strictEqual)(state.signResponse, true);
}));
yield t.test("includeAttributeNameFormat", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.strictEqual)(state.includeAttributeNameFormat, true);
api.setIncludeAttributeNameFormat(false);
(0, node_assert_1.strictEqual)(state.includeAttributeNameFormat, false);
}));
yield t.test("typedAttributes", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.strictEqual)(state.typedAttributes, true);
api.setTypedAttributes(false);
(0, node_assert_1.strictEqual)(state.typedAttributes, false);
}));
yield t.test("lifetimeInSeconds", (t) => __awaiter(void 0, void 0, void 0, function* () {
(0, node_assert_1.strictEqual)(state.lifetimeInSeconds, 3600);
api.setLifetimeInSeconds(42);
(0, node_assert_1.strictEqual)(state.lifetimeInSeconds, 42);
}));
yield t.test("nameIdentifierFormat", (t) => __awaiter(void 0, void 0, void 0, function* () {
const { build, state } = (0, saml_response_1.samlResponseMock)("Another Flow");
const api = build(baseApi);
(0, node_assert_1.strictEqual)(state.nameIdentifierFormat, "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified");
api.setNameIdentifierFormat("custom-format");
(0, node_assert_1.strictEqual)(state.nameIdentifierFormat, "custom-format");
}));
yield t.test("nameIdentifierProbes", (t) => __awaiter(void 0, void 0, void 0, function* () {
const { build, state } = (0, saml_response_1.samlResponseMock)("Another Flow");
const api = build(baseApi);
(0, node_assert_1.deepStrictEqual)(state.nameIdentifierProbes, [
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress",
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name",
]);
api.setNameIdentifierProbes([
"custom-probe-a",
"custom-probe-b",
]);
(0, node_assert_1.deepStrictEqual)(state.nameIdentifierProbes, [
"custom-probe-a",
"custom-probe-b",
]);
}));
yield t.test("authnContextClassRef", (t) => __awaiter(void 0, void 0, void 0, function* () {
const { build, state } = (0, saml_response_1.samlResponseMock)("Another Flow");
const api = build(baseApi);
(0, node_assert_1.strictEqual)(state.authnContextClassRef, "urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified");
api.setAuthnContextClassRef("custom-authn-context-class-ref");
(0, node_assert_1.strictEqual)(state.authnContextClassRef, "custom-authn-context-class-ref");
}));
}));
//# sourceMappingURL=saml-response.test.js.map