File tree Expand file tree Collapse file tree
x-pack/plugins/actions/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -163,6 +163,28 @@ describe('config validation', () => {
163163 ` ) ;
164164 } ) ;
165165
166+ test ( 'validates proxyUrl' , ( ) => {
167+ const proxyUrl = 'https://test.com' ;
168+ const badProxyUrl = 'bad url' ;
169+ let validated : ActionsConfig ;
170+
171+ validated = configSchema . validate ( { proxyUrl } ) ;
172+ expect ( validated . proxyUrl ) . toEqual ( proxyUrl ) ;
173+ expect ( getValidatedConfig ( mockLogger , validated ) . proxyUrl ) . toEqual ( proxyUrl ) ;
174+ expect ( mockLogger . warn . mock . calls ) . toMatchInlineSnapshot ( `Array []` ) ;
175+
176+ validated = configSchema . validate ( { proxyUrl : badProxyUrl } ) ;
177+ expect ( validated . proxyUrl ) . toEqual ( badProxyUrl ) ;
178+ expect ( getValidatedConfig ( mockLogger , validated ) . proxyUrl ) . toEqual ( badProxyUrl ) ;
179+ expect ( mockLogger . warn . mock . calls ) . toMatchInlineSnapshot ( `
180+ Array [
181+ Array [
182+ "The confguration xpack.actions.proxyUrl: bad url is invalid.",
183+ ],
184+ ]
185+ ` ) ;
186+ } ) ;
187+
166188 // Most of the customHostSettings tests are in ./lib/custom_host_settings.test.ts
167189 // but this one seemed more relevant for this test suite, since url is the one
168190 // required property.
Original file line number Diff line number Diff line change @@ -127,6 +127,15 @@ export type ActionsConfig = TypeOf<typeof configSchema>;
127127export function getValidatedConfig ( logger : Logger , originalConfig : ActionsConfig ) : ActionsConfig {
128128 const proxyBypassHosts = originalConfig . proxyBypassHosts ;
129129 const proxyOnlyHosts = originalConfig . proxyOnlyHosts ;
130+ const proxyUrl = originalConfig . proxyUrl ;
131+
132+ if ( proxyUrl ) {
133+ try {
134+ new URL ( proxyUrl ) ;
135+ } catch ( err ) {
136+ logger . warn ( `The confguration xpack.actions.proxyUrl: ${ proxyUrl } is invalid.` ) ;
137+ }
138+ }
130139
131140 if ( proxyBypassHosts && proxyOnlyHosts ) {
132141 logger . warn (
You can’t perform that action at this time.
0 commit comments