Skip to content

Commit

Permalink
fix license_pre_routing_factory tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth committed Feb 3, 2020
1 parent 6d1a0db commit 9dfe043
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 66 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { licensePreRoutingFactory } from '.';
import {
LICENSE_STATUS_VALID,
LICENSE_STATUS_INVALID,
} from '../../../../../common/constants/license_status';
import { kibanaResponseFactory } from '../../../../../../../src/core/server';

describe('licensePreRoutingFactory()', () => {
let mockServer;
let mockLicenseCheckResults;

beforeEach(() => {
mockServer = {
plugins: {
xpack_main: {
info: {
feature: () => ({
getLicenseCheckResults: () => mockLicenseCheckResults,
}),
},
},
},
};
});

describe('status is invalid', () => {
beforeEach(() => {
mockLicenseCheckResults = {
status: LICENSE_STATUS_INVALID,
};
});

it('replies with 403', () => {
const routeWithLicenseCheck = licensePreRoutingFactory(mockServer, () => {});
const stubRequest = {};
const response = routeWithLicenseCheck({}, stubRequest, kibanaResponseFactory);
expect(response.status).to.be(403);
});
});

describe('status is valid', () => {
beforeEach(() => {
mockLicenseCheckResults = {
status: LICENSE_STATUS_VALID,
};
});

it('replies with nothing', () => {
const routeWithLicenseCheck = licensePreRoutingFactory(mockServer, () => null);
const stubRequest = {};
const response = routeWithLicenseCheck({}, stubRequest, kibanaResponseFactory);
expect(response).to.be(null);
});
});
});

0 comments on commit 9dfe043

Please sign in to comment.