-
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.
register logstash route handlers in NP
- Loading branch information
Showing
11 changed files
with
184 additions
and
28 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
"requiredPlugins": [ | ||
"licensing" | ||
], | ||
"optionalPlugins": ["security"], | ||
"server": true, | ||
"ui": false | ||
} |
59 changes: 59 additions & 0 deletions
59
x-pack/plugins/logstash/server/lib/check_license/check_license.test.ts
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,59 @@ | ||
/* | ||
* 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 { licensingMock } from '../../../../licensing/server/mocks'; | ||
import { checkLicense } from './check_license'; | ||
|
||
describe('check_license', function() { | ||
describe('returns "valid": false & message', () => { | ||
it('license information is not available', () => { | ||
const license = licensingMock.createLicenseMock(); | ||
license.isAvailable = false; | ||
|
||
const { valid, message } = checkLicense(license); | ||
|
||
expect(valid).toBe(false); | ||
expect(message).toStrictEqual(expect.any(String)); | ||
}); | ||
|
||
it('license level is not enough', () => { | ||
const license = licensingMock.createLicenseMock(); | ||
license.hasAtLeast.mockReturnValue(false); | ||
|
||
const { valid, message } = checkLicense(license); | ||
|
||
expect(valid).toBe(false); | ||
expect(message).toStrictEqual(expect.any(String)); | ||
}); | ||
|
||
it('license is expired', () => { | ||
const license = licensingMock.createLicenseMock(); | ||
license.isActive = false; | ||
|
||
const { valid, message } = checkLicense(license); | ||
|
||
expect(valid).toBe(false); | ||
expect(message).toStrictEqual(expect.any(String)); | ||
}); | ||
|
||
it('elasticsearch security is disabled', () => { | ||
const license = licensingMock.createLicenseMock(); | ||
license.getFeature.mockReturnValue({ isEnabled: false, isAvailable: false }); | ||
|
||
const { valid, message } = checkLicense(license); | ||
|
||
expect(valid).toBe(false); | ||
expect(message).toStrictEqual(expect.any(String)); | ||
}); | ||
}); | ||
it('returns "valid": true without message otherwise', () => { | ||
const license = licensingMock.createLicenseMock(); | ||
|
||
const { valid, message } = checkLicense(license); | ||
|
||
expect(valid).toBe(true); | ||
expect(message).toBe(null); | ||
}); | ||
}); |
65 changes: 65 additions & 0 deletions
65
x-pack/plugins/logstash/server/lib/check_license/check_license.ts
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,65 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
import { CheckLicense } from '../../../../licensing/server'; | ||
|
||
export const checkLicense: CheckLicense = license => { | ||
if (!license.isAvailable) { | ||
return { | ||
valid: false, | ||
message: i18n.translate( | ||
'xpack.logstash.managementSection.notPossibleToManagePipelinesMessage', | ||
{ | ||
defaultMessage: | ||
'You cannot manage Logstash pipelines because license information is not available at this time.', | ||
} | ||
), | ||
}; | ||
} | ||
|
||
if (!license.hasAtLeast('standard')) { | ||
return { | ||
valid: false, | ||
message: i18n.translate('xpack.logstash.managementSection.licenseDoesNotSupportDescription', { | ||
defaultMessage: | ||
'Your {licenseType} license does not support Logstash pipeline management features. Please upgrade your license.', | ||
values: { licenseType: license.type }, | ||
}), | ||
}; | ||
} | ||
|
||
if (!license.isActive) { | ||
return { | ||
valid: false, | ||
message: i18n.translate( | ||
'xpack.logstash.managementSection.pipelineCrudOperationsNotAllowedDescription', | ||
{ | ||
defaultMessage: | ||
'You cannot edit, create, or delete your Logstash pipelines because your {licenseType} license has expired.', | ||
values: { licenseType: license.type }, | ||
} | ||
), | ||
}; | ||
} | ||
|
||
if (!license.getFeature('security').isEnabled) { | ||
return { | ||
valid: false, | ||
message: i18n.translate('xpack.logstash.managementSection.enableSecurityDescription', { | ||
defaultMessage: | ||
'Security must be enabled in order to use Logstash pipeline management features.' + | ||
' Please set xpack.security.enabled: true in your elasticsearch.yml.', | ||
}), | ||
}; | ||
} | ||
|
||
return { | ||
valid: true, | ||
message: null, | ||
}; | ||
}; |
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,7 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { checkLicense } from './check_license'; |
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
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
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
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
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
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,18 @@ | ||
/* | ||
* 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 { SearchResponse } from 'elasticsearch'; | ||
|
||
type UnwrapArray<T> = T extends Array<infer U> ? U : T; | ||
|
||
export type Hits = SearchResponse<any>['hits']['hits']; | ||
export type Hit = UnwrapArray<Hits>; | ||
|
||
export interface PipelineListItemOptions { | ||
id: string; | ||
description: string; | ||
last_modified: string; | ||
username: string; | ||
} |