-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix license_pre_routing_factory tests
- Loading branch information
1 parent
6d1a0db
commit 9dfe043
Showing
2 changed files
with
62 additions
and
66 deletions.
There are no files selected for viewing
66 changes: 0 additions & 66 deletions
66
...ns/rollup/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
...plugins/rollup/server/lib/license_pre_routing_factory/license_pre_routing_factory.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |