UNPKG

kentico-cloud-delivery

Version:

Official Kentico Cloud Delivery SDK

38 lines 2.15 kB
"use strict"; exports.__esModule = true; var setup_1 = require("../../setup"); describe('Secured headers', function () { var context = new setup_1.Context({ useSecuredMode: true }); setup_1.setup(context); it("secured authorization header should be defined when getting items (global config)'", function () { var headers = context.deliveryClient.items().getHeaders(); var authorizationHeader = headers.find(function (m) { return m.header === 'authorization'; }); expect(authorizationHeader).toBeDefined(); }); it("secured authorization header should be defined when getting taxonomies (global config)'", function () { var headers = context.deliveryClient.types().getHeaders(); var authorizationHeader = headers.find(function (m) { return m.header === 'authorization'; }); expect(authorizationHeader).toBeDefined(); }); it("secured authorization header should be defined for getting types (global config)'", function () { var headers = context.deliveryClient.taxonomies().getHeaders(); var authorizationHeader = headers.find(function (m) { return m.header === 'authorization'; }); expect(authorizationHeader).toBeDefined(); }); it("secured authorization header should contain secured API key (global config)'", function () { var headers = context.deliveryClient.items().getHeaders(); var authorizationHeader = headers.find(function (m) { return m.header === 'authorization'; }); var expectedValue = 'bearer ' + context.securedApiKey; expect(authorizationHeader.value).toEqual(expectedValue); }); it("secured authorization header should NOT be defined when QueryConfig specifically disables it'", function () { var headers = context.deliveryClient.items().queryConfig({ useSecuredMode: false }).getHeaders(); var authorizationHeader = headers.find(function (m) { return m.header === 'authorization'; }); expect(authorizationHeader).toBeUndefined(); }); }); //# sourceMappingURL=secured-api-headers.spec.js.map