UNPKG

kentico-cloud-delivery

Version:

Official Kentico Cloud Delivery SDK

36 lines 2.1 kB
import { Context, setup } from '../../setup'; describe('Secured headers', function () { var context = new Context({ useSecuredMode: true }); 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