Co-authored-by: Josh Dover <1813008+joshdover@users.noreply.github.com>
This commit is contained in:
parent
4115b2d8f4
commit
37a9d12a54
2 changed files with 49 additions and 0 deletions
37
x-pack/plugins/cloud/server/config.test.ts
Normal file
37
x-pack/plugins/cloud/server/config.test.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { config } from './config';
|
||||
|
||||
describe('xpack.cloud config', () => {
|
||||
describe('full_story', () => {
|
||||
it('allows orgId when enabled: false', () => {
|
||||
expect(() =>
|
||||
config.schema.validate({ full_story: { enabled: false, org_id: 'asdf' } })
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('rejects undefined or empty orgId when enabled: true', () => {
|
||||
expect(() =>
|
||||
config.schema.validate({ full_story: { enabled: true } })
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"[full_story.org_id]: expected value of type [string] but got [undefined]"`
|
||||
);
|
||||
expect(() =>
|
||||
config.schema.validate({ full_story: { enabled: true, org_id: '' } })
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"[full_story.org_id]: value has length [0] but it must have a minimum length of [1]."`
|
||||
);
|
||||
});
|
||||
|
||||
it('accepts orgId when enabled: true', () => {
|
||||
expect(() =>
|
||||
config.schema.validate({ full_story: { enabled: true, org_id: 'asdf' } })
|
||||
).not.toThrow();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -18,6 +18,16 @@ const apmConfigSchema = schema.object({
|
|||
),
|
||||
});
|
||||
|
||||
const fullStoryConfigSchema = schema.object({
|
||||
enabled: schema.boolean({ defaultValue: false }),
|
||||
org_id: schema.conditional(
|
||||
schema.siblingRef('enabled'),
|
||||
true,
|
||||
schema.string({ minLength: 1 }),
|
||||
schema.maybe(schema.string())
|
||||
),
|
||||
});
|
||||
|
||||
const configSchema = schema.object({
|
||||
enabled: schema.boolean({ defaultValue: true }),
|
||||
id: schema.maybe(schema.string()),
|
||||
|
@ -27,6 +37,7 @@ const configSchema = schema.object({
|
|||
profile_url: schema.maybe(schema.string()),
|
||||
deployment_url: schema.maybe(schema.string()),
|
||||
organization_url: schema.maybe(schema.string()),
|
||||
full_story: fullStoryConfigSchema,
|
||||
});
|
||||
|
||||
export type CloudConfigType = TypeOf<typeof configSchema>;
|
||||
|
@ -39,6 +50,7 @@ export const config: PluginConfigDescriptor<CloudConfigType> = {
|
|||
profile_url: true,
|
||||
deployment_url: true,
|
||||
organization_url: true,
|
||||
full_story: true,
|
||||
},
|
||||
schema: configSchema,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue