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

[Fleet] Fix preconfigured remote ES outputs with secrets #172550

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
61 changes: 61 additions & 0 deletions x-pack/plugins/fleet/server/types/models/preconfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('Test preconfiguration schema', () => {
]);
}).toThrowError('preconfigured outputs can only have one default output.');
});

it('should not allow multiple default monitoring output', () => {
expect(() => {
PreconfiguredOutputsSchema.validate([
Expand All @@ -49,6 +50,7 @@ describe('Test preconfiguration schema', () => {
]);
}).toThrowError('preconfigured outputs can only have one default monitoring output.');
});

it('should not allow multiple output with same ids', () => {
expect(() => {
PreconfiguredOutputsSchema.validate([
Expand All @@ -67,6 +69,7 @@ describe('Test preconfiguration schema', () => {
]);
}).toThrowError('preconfigured outputs need to have unique ids.');
});

it('should not allow multiple output with same names', () => {
expect(() => {
PreconfiguredOutputsSchema.validate([
Expand All @@ -85,5 +88,63 @@ describe('Test preconfiguration schema', () => {
]);
}).toThrowError('preconfigured outputs need to have unique names.');
});

it('should allow logstash type outputs', () => {
expect(() => {
PreconfiguredOutputsSchema.validate([
{
id: 'output-1',
name: 'my logstash output',
type: 'logstash',
hosts: ['localhost:9200'],
ssl: {
certificate: 'xxxxx',
},
secrets: {
ssl: {
key: 'mykey',
},
},
},
]);
}).not.toThrowError();
});

it('should allow kafka type outputs', () => {
expect(() => {
PreconfiguredOutputsSchema.validate([
{
id: 'output-1',
name: 'my kafka output',
type: 'kafka',
hosts: ['localhost:9200'],
auth_type: 'ssl',
topics: [{ topic: 'topic1' }],
secrets: {
password: 'mypassword',
ssl: {
key: 'mykey',
},
},
},
]);
}).not.toThrowError();
});

it('should allow remote elasticsearch type outputs', () => {
expect(() => {
PreconfiguredOutputsSchema.validate([
{
id: 'output-1',
name: 'my remote elasticsearch output',
type: 'remote_elasticsearch',
hosts: ['http://test.fr:9200'],
secrets: {
service_token: 'myservicetoken',
},
},
]);
}).not.toThrowError();
});
});
});
8 changes: 7 additions & 1 deletion x-pack/plugins/fleet/server/types/models/preconfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import semverValid from 'semver/functions/valid';
import { PRECONFIGURATION_LATEST_KEYWORD } from '../../constants';
import type { PreconfiguredOutput } from '../../../common/types';

import { ElasticSearchSchema, KafkaSchema, LogstashSchema } from './output';
import {
ElasticSearchSchema,
KafkaSchema,
LogstashSchema,
RemoteElasticSearchSchema,
} from './output';

import { AgentPolicyBaseSchema } from './agent_policy';
import { NamespaceSchema } from './package_policy';
Expand Down Expand Up @@ -87,6 +92,7 @@ export const PreconfiguredOutputsSchema = schema.arrayOf(
schema.object({ ...ElasticSearchSchema }).extends(PreconfiguredOutputBaseSchema),
schema.object({ ...LogstashSchema }).extends(PreconfiguredOutputBaseSchema),
schema.object({ ...KafkaSchema }).extends(PreconfiguredOutputBaseSchema),
schema.object({ ...RemoteElasticSearchSchema }).extends(PreconfiguredOutputBaseSchema),
]),
{ defaultValue: [], validate: validatePreconfiguredOutputs }
);
Expand Down