diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_validators.test.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_validators.test.tsx index 4352a3a6b8248e..2e17153ee34e75 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_validators.test.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_validators.test.tsx @@ -142,6 +142,13 @@ describe('Output form validation', () => { expect(res).toBeUndefined(); }); + + it('should work with hostnames using uppercase letters', () => { + const res = validateLogstashHosts(['tEsT.fr:9200', 'TEST2.fr:9200', 'teSt.fR:9999']); + + expect(res).toBeUndefined(); + }); + it('should throw for invalid hosts starting with http', () => { const res = validateLogstashHosts(['https://test.fr:5044']); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_validators.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_validators.tsx index 330d5c5d201224..116e9f4abf1579 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_validators.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_validators.tsx @@ -166,7 +166,7 @@ export function validateLogstashHosts(value: string[]) { const url = new URL(`http://${val}`); - if (url.host !== val) { + if (url.host !== val.toLowerCase()) { throw new Error('Invalid host'); } } catch (error) { diff --git a/x-pack/plugins/fleet/server/types/models/output.test.ts b/x-pack/plugins/fleet/server/types/models/output.test.ts index 06edd900fec2a8..9c850766b9ba82 100644 --- a/x-pack/plugins/fleet/server/types/models/output.test.ts +++ b/x-pack/plugins/fleet/server/types/models/output.test.ts @@ -13,6 +13,10 @@ describe('Output model', () => { expect(validateLogstashHost('test.fr:5044')).toBeUndefined(); }); + it('should support valid host with uppercase letters', () => { + expect(validateLogstashHost('tEsT.fr:5044')).toBeUndefined(); + }); + it('should return an error for an invalid host', () => { expect(validateLogstashHost('!@#%&!#!@')).toMatchInlineSnapshot(`"Invalid Logstash host"`); }); diff --git a/x-pack/plugins/fleet/server/types/models/output.ts b/x-pack/plugins/fleet/server/types/models/output.ts index 730ec512f5a0fb..765018f3ac88f6 100644 --- a/x-pack/plugins/fleet/server/types/models/output.ts +++ b/x-pack/plugins/fleet/server/types/models/output.ts @@ -26,7 +26,7 @@ export function validateLogstashHost(val: string) { try { const url = new URL(`http://${val}`); - if (url.host !== val) { + if (url.host !== val.toLowerCase()) { return 'Invalid host'; } } catch (err) {