Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NP licensing plugin improvements #51818

Merged
merged 26 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6eb8572
add onPreResponse interceptor
mshustov Nov 27, 2019
c861c8b
use onPreResponse interceptor to add license sign
mshustov Nov 27, 2019
58a31d2
expose registerPreResponse to plugins
mshustov Nov 27, 2019
d536a92
refresh for license update get the most fresh license
mshustov Nov 27, 2019
c194e37
license plugin injects own header for signature: 'kbn-license-sig'
mshustov Nov 27, 2019
674062e
add integration tests for license type and license header
mshustov Nov 27, 2019
5c30f9f
Merge branch 'master' into np-licensing
mshustov Nov 28, 2019
b5e409a
Merge branch 'master' into np-licensing
mshustov Nov 28, 2019
58c92b6
switch config to duration
mshustov Nov 29, 2019
61d8a72
don't run interceptor on anon paths. add tests
mshustov Nov 29, 2019
2166b3d
add functional tests for licensing plugin
mshustov Nov 29, 2019
268cc45
regen docs
mshustov Nov 29, 2019
a3a890a
fix test in security due to updated mocks;
mshustov Nov 29, 2019
b1b79a8
Merge branch 'master' into np-licensing
mshustov Dec 2, 2019
6f0397d
update snapshots accoring to new mock implementation
mshustov Dec 2, 2019
d4cb636
Merge branch 'master' into np-licensing
mshustov Dec 3, 2019
5992878
migrate license expired banner to NP
mshustov Dec 3, 2019
10a91eb
Merge branch 'master' into np-licensing
mshustov Dec 4, 2019
4b45708
add readme for the licensing plugin
mshustov Dec 4, 2019
6b9c7bf
remove outdated import. licensing has separate functional tests
mshustov Dec 4, 2019
b9fbe71
add tag for test to run on CI
mshustov Dec 4, 2019
c9d6259
Merge branch 'master' into np-licensing
mshustov Dec 6, 2019
7eec72a
regen docs
mshustov Dec 6, 2019
404582d
Update x-pack/plugins/licensing/README.md
mshustov Dec 7, 2019
cf83cb9
Merge branch 'master' into np-licensing
mshustov Dec 9, 2019
5168054
update tests
mshustov Dec 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,7 @@ In server code, `core` can be accessed from either `server.newPlatform` or `kbnS
| `request.getBasePath()` | [`core.http.basePath.get`](/docs/development/core/server/kibana-plugin-server.httpservicesetup.basepath.md) | |
| `server.plugins.elasticsearch.getCluster('data')` | [`core.elasticsearch.dataClient$`](/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.dataclient_.md) | Handlers will also include a pre-configured client |
| `server.plugins.elasticsearch.getCluster('admin')` | [`core.elasticsearch.adminClient$`](/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.adminclient_.md) | Handlers will also include a pre-configured client |
| `xpackMainPlugin.info.feature(pluginID).registerLicenseCheckResultsGenerator` | [`x-pack licensing plugin`](/x-pack/plugins/licensing/README.md) | |
_See also: [Server's CoreSetup API Docs](/docs/development/core/server/kibana-plugin-server.coresetup.md)_

Expand Down
7 changes: 5 additions & 2 deletions src/core/public/http/http_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import { HttpService } from './http_service';
import { HttpSetup } from './types';
import { BehaviorSubject } from 'rxjs';
import { BasePath } from './base_path_service';
import { AnonymousPaths } from './anonymous_paths';

export type HttpSetupMock = jest.Mocked<HttpSetup> & {
basePath: BasePath;
anonymousPaths: jest.Mocked<HttpSetup['anonymousPaths']>;
};

const createServiceMock = ({ basePath = '' } = {}): HttpSetupMock => ({
Expand All @@ -37,7 +37,10 @@ const createServiceMock = ({ basePath = '' } = {}): HttpSetupMock => ({
delete: jest.fn(),
options: jest.fn(),
basePath: new BasePath(basePath),
anonymousPaths: new AnonymousPaths(new BasePath(basePath)),
anonymousPaths: {
register: jest.fn(),
isAnonymous: jest.fn(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plugin authors doesn't have to read AnonymousPaths implementation to be able to use mocks. WDYT?

},
addLoadingCount: jest.fn(),
getLoadingCount$: jest.fn().mockReturnValue(new BehaviorSubject(0)),
stop: jest.fn(),
Expand Down
6 changes: 3 additions & 3 deletions src/core/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import { applicationServiceMock } from './application/application_service.mock';
import { chromeServiceMock } from './chrome/chrome_service.mock';
import { CoreContext, CoreSetup, CoreStart, PluginInitializerContext, NotificationsSetup } from '.';
import { CoreContext, PluginInitializerContext } from '.';
import { docLinksServiceMock } from './doc_links/doc_links_service.mock';
import { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock';
import { httpServiceMock } from './http/http_service.mock';
Expand All @@ -42,7 +42,7 @@ export { overlayServiceMock } from './overlays/overlay_service.mock';
export { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';

function createCoreSetupMock({ basePath = '' } = {}) {
const mock: MockedKeys<CoreSetup> & { notifications: MockedKeys<NotificationsSetup> } = {
const mock = {
application: applicationServiceMock.createSetupContract(),
context: contextServiceMock.createSetupContract(),
fatalErrors: fatalErrorsServiceMock.createSetupContract(),
Expand All @@ -58,7 +58,7 @@ function createCoreSetupMock({ basePath = '' } = {}) {
}

function createCoreStartMock({ basePath = '' } = {}) {
const mock: MockedKeys<CoreStart> & { notifications: MockedKeys<NotificationsSetup> } = {
const mock = {
application: applicationServiceMock.createStartContract(),
chrome: chromeServiceMock.createStartContract(),
docLinks: docLinksServiceMock.createStartContract(),
Expand Down
6 changes: 6 additions & 0 deletions src/core/server/http/http_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { OnPreAuthToolkit } from './lifecycle/on_pre_auth';
import { AuthToolkit } from './lifecycle/auth';
import { sessionStorageMock } from './cookie_session_storage.mocks';
import { OnPostAuthToolkit } from './lifecycle/on_post_auth';
import { OnPreResponseToolkit } from './lifecycle/on_pre_response';

export type HttpServiceSetupMock = jest.Mocked<InternalHttpServiceSetup> & {
basePath: jest.Mocked<InternalHttpServiceSetup['basePath']>;
Expand Down Expand Up @@ -93,12 +94,17 @@ const createAuthToolkitMock = (): jest.Mocked<AuthToolkit> => ({
authenticated: jest.fn(),
});

const createOnPreResponseToolkitMock = (): jest.Mocked<OnPreResponseToolkit> => ({
next: jest.fn(),
});

export const httpServiceMock = {
create: createHttpServiceMock,
createBasePath: createBasePathMock,
createSetupContract: createSetupContractMock,
createOnPreAuthToolkit: createOnPreAuthToolkitMock,
createOnPostAuthToolkit: createOnPostAuthToolkitMock,
createOnPreResponseToolkit: createOnPreResponseToolkitMock,
createAuthToolkit: createAuthToolkitMock,
createRouter: mockRouter.create,
};
1 change: 0 additions & 1 deletion src/core/server/http/integration_tests/lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,6 @@ describe('OnPreResponse', () => {
headers: { 'x-kibana-header': 'value' },
})
);

registerOnPreResponse((req, res, t) =>
t.next({
headers: { 'x-kibana-header': 'value' },
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions x-pack/legacy/plugins/xpack_main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ export const xpackMain = (kibana) => {
},

uiExports: {
hacks: [
'plugins/xpack_main/hacks/check_xpack_info_change',
],
replaceInjectedVars,
injectDefaultVars(server) {
const config = server.config();
Expand Down

This file was deleted.

Loading