Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner committed Feb 7, 2020
1 parent 898e2d5 commit 34987b1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ import { isSystemApiRequest } from '../system_api';

describe('system_api', () => {
describe('#isSystemApiRequest', () => {
it('returns true for a system API HTTP request', () => {
it('returns true for a system HTTP request', () => {
const mockHapiRequest = {
headers: {
'kbn-system-request': true,
},
};
expect(isSystemApiRequest(mockHapiRequest)).to.be(true);
});

it('returns true for a legacy system API HTTP request', () => {
const mockHapiRequest = {
headers: {
'kbn-system-api': true,
Expand Down
15 changes: 12 additions & 3 deletions src/legacy/ui/public/system_api/__tests__/system_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,25 @@ describe('system_api', () => {
};
const newHeaders = addSystemApiHeader(headers);

expect(newHeaders).to.have.property('kbn-system-api');
expect(newHeaders['kbn-system-api']).to.be(true);
expect(newHeaders).to.have.property('kbn-system-request');
expect(newHeaders['kbn-system-request']).to.be(true);

expect(newHeaders).to.have.property('kbn-version');
expect(newHeaders['kbn-version']).to.be('4.6.0');
});
});

describe('#isSystemApiRequest', () => {
it('returns true for a system API HTTP request', () => {
it('returns true for a system HTTP request', () => {
const mockRequest = {
headers: {
'kbn-system-request': true,
},
};
expect(isSystemApiRequest(mockRequest)).to.be(true);
});

it('returns true for a legacy system API HTTP request', () => {
const mockRequest = {
headers: {
'kbn-system-api': true,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/security/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function({ getService }: FtrProviderContext) {
supertest
.get('/internal/security/session')
.set('kbn-xsrf', 'xxx')
.set('kbn-system-api', 'true')
.set('kbn-system-request', 'true')
.set('Cookie', sessionCookie.cookieString())
.send()
.expect(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export default function({ getService }: FtrProviderContext) {
const systemAPIResponse = await supertest
.get('/internal/security/me')
.set('kbn-xsrf', 'xxx')
.set('kbn-system-api', 'true')
.set('kbn-system-request', 'true')
.set('Cookie', sessionCookie.cookieString())
.expect(200);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export default function({ getService }) {
const systemAPIResponse = await supertest
.get('/internal/security/me')
.set('kbn-xsrf', 'xxx')
.set('kbn-system-api', 'true')
.set('kbn-system-request', 'true')
.set('Cookie', sessionCookie.cookieString())
.expect(200);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export default function({ getService }: FtrProviderContext) {
const systemAPIResponse = await supertest
.get('/internal/security/me')
.set('kbn-xsrf', 'xxx')
.set('kbn-system-api', 'true')
.set('kbn-system-request', 'true')
.set('Cookie', sessionCookie.cookieString())
.expect(200);

Expand Down

0 comments on commit 34987b1

Please sign in to comment.