44 * you may not use this file except in compliance with the Elastic License.
55 */
66
7- import { ActionsConfigType } from './types ' ;
7+ import { ActionsConfig } from './config ' ;
88import {
99 getActionsConfigurationUtilities ,
1010 AllowedHosts ,
1111 EnabledActionTypes ,
1212} from './actions_config' ;
1313
14- const DefaultActionsConfig : ActionsConfigType = {
14+ const defaultActionsConfig : ActionsConfig = {
1515 enabled : false ,
1616 allowedHosts : [ ] ,
1717 enabledActionTypes : [ ] ,
18+ preconfigured : { } ,
19+ proxyRejectUnauthorizedCertificates : true ,
20+ rejectUnauthorized : true ,
1821} ;
1922
2023describe ( 'ensureUriAllowed' , ( ) => {
2124 test ( 'returns true when "any" hostnames are allowed' , ( ) => {
22- const config : ActionsConfigType = {
25+ const config : ActionsConfig = {
26+ ...defaultActionsConfig ,
2327 enabled : false ,
2428 allowedHosts : [ AllowedHosts . Any ] ,
2529 enabledActionTypes : [ ] ,
@@ -30,7 +34,7 @@ describe('ensureUriAllowed', () => {
3034 } ) ;
3135
3236 test ( 'throws when the hostname in the requested uri is not in the allowedHosts' , ( ) => {
33- const config : ActionsConfigType = DefaultActionsConfig ;
37+ const config : ActionsConfig = defaultActionsConfig ;
3438 expect ( ( ) =>
3539 getActionsConfigurationUtilities ( config ) . ensureUriAllowed ( 'https://github.com/elastic/kibana' )
3640 ) . toThrowErrorMatchingInlineSnapshot (
@@ -39,7 +43,7 @@ describe('ensureUriAllowed', () => {
3943 } ) ;
4044
4145 test ( 'throws when the uri cannot be parsed as a valid URI' , ( ) => {
42- const config : ActionsConfigType = DefaultActionsConfig ;
46+ const config : ActionsConfig = defaultActionsConfig ;
4347 expect ( ( ) =>
4448 getActionsConfigurationUtilities ( config ) . ensureUriAllowed ( 'github.com/elastic' )
4549 ) . toThrowErrorMatchingInlineSnapshot (
@@ -48,7 +52,8 @@ describe('ensureUriAllowed', () => {
4852 } ) ;
4953
5054 test ( 'returns true when the hostname in the requested uri is in the allowedHosts' , ( ) => {
51- const config : ActionsConfigType = {
55+ const config : ActionsConfig = {
56+ ...defaultActionsConfig ,
5257 enabled : false ,
5358 allowedHosts : [ 'github.com' ] ,
5459 enabledActionTypes : [ ] ,
@@ -61,7 +66,8 @@ describe('ensureUriAllowed', () => {
6166
6267describe ( 'ensureHostnameAllowed' , ( ) => {
6368 test ( 'returns true when "any" hostnames are allowed' , ( ) => {
64- const config : ActionsConfigType = {
69+ const config : ActionsConfig = {
70+ ...defaultActionsConfig ,
6571 enabled : false ,
6672 allowedHosts : [ AllowedHosts . Any ] ,
6773 enabledActionTypes : [ ] ,
@@ -72,7 +78,7 @@ describe('ensureHostnameAllowed', () => {
7278 } ) ;
7379
7480 test ( 'throws when the hostname in the requested uri is not in the allowedHosts' , ( ) => {
75- const config : ActionsConfigType = DefaultActionsConfig ;
81+ const config : ActionsConfig = defaultActionsConfig ;
7682 expect ( ( ) =>
7783 getActionsConfigurationUtilities ( config ) . ensureHostnameAllowed ( 'github.com' )
7884 ) . toThrowErrorMatchingInlineSnapshot (
@@ -81,7 +87,8 @@ describe('ensureHostnameAllowed', () => {
8187 } ) ;
8288
8389 test ( 'returns true when the hostname in the requested uri is in the allowedHosts' , ( ) => {
84- const config : ActionsConfigType = {
90+ const config : ActionsConfig = {
91+ ...defaultActionsConfig ,
8592 enabled : false ,
8693 allowedHosts : [ 'github.com' ] ,
8794 enabledActionTypes : [ ] ,
@@ -94,7 +101,8 @@ describe('ensureHostnameAllowed', () => {
94101
95102describe ( 'isUriAllowed' , ( ) => {
96103 test ( 'returns true when "any" hostnames are allowed' , ( ) => {
97- const config : ActionsConfigType = {
104+ const config : ActionsConfig = {
105+ ...defaultActionsConfig ,
98106 enabled : false ,
99107 allowedHosts : [ AllowedHosts . Any ] ,
100108 enabledActionTypes : [ ] ,
@@ -105,21 +113,22 @@ describe('isUriAllowed', () => {
105113 } ) ;
106114
107115 test ( 'throws when the hostname in the requested uri is not in the allowedHosts' , ( ) => {
108- const config : ActionsConfigType = DefaultActionsConfig ;
116+ const config : ActionsConfig = defaultActionsConfig ;
109117 expect (
110118 getActionsConfigurationUtilities ( config ) . isUriAllowed ( 'https://github.com/elastic/kibana' )
111119 ) . toEqual ( false ) ;
112120 } ) ;
113121
114122 test ( 'throws when the uri cannot be parsed as a valid URI' , ( ) => {
115- const config : ActionsConfigType = DefaultActionsConfig ;
123+ const config : ActionsConfig = defaultActionsConfig ;
116124 expect ( getActionsConfigurationUtilities ( config ) . isUriAllowed ( 'github.com/elastic' ) ) . toEqual (
117125 false
118126 ) ;
119127 } ) ;
120128
121129 test ( 'returns true when the hostname in the requested uri is in the allowedHosts' , ( ) => {
122- const config : ActionsConfigType = {
130+ const config : ActionsConfig = {
131+ ...defaultActionsConfig ,
123132 enabled : false ,
124133 allowedHosts : [ 'github.com' ] ,
125134 enabledActionTypes : [ ] ,
@@ -132,7 +141,8 @@ describe('isUriAllowed', () => {
132141
133142describe ( 'isHostnameAllowed' , ( ) => {
134143 test ( 'returns true when "any" hostnames are allowed' , ( ) => {
135- const config : ActionsConfigType = {
144+ const config : ActionsConfig = {
145+ ...defaultActionsConfig ,
136146 enabled : false ,
137147 allowedHosts : [ AllowedHosts . Any ] ,
138148 enabledActionTypes : [ ] ,
@@ -141,12 +151,13 @@ describe('isHostnameAllowed', () => {
141151 } ) ;
142152
143153 test ( 'throws when the hostname in the requested uri is not in the allowedHosts' , ( ) => {
144- const config : ActionsConfigType = DefaultActionsConfig ;
154+ const config : ActionsConfig = defaultActionsConfig ;
145155 expect ( getActionsConfigurationUtilities ( config ) . isHostnameAllowed ( 'github.com' ) ) . toEqual ( false ) ;
146156 } ) ;
147157
148158 test ( 'returns true when the hostname in the requested uri is in the allowedHosts' , ( ) => {
149- const config : ActionsConfigType = {
159+ const config : ActionsConfig = {
160+ ...defaultActionsConfig ,
150161 enabled : false ,
151162 allowedHosts : [ 'github.com' ] ,
152163 enabledActionTypes : [ ] ,
@@ -157,7 +168,8 @@ describe('isHostnameAllowed', () => {
157168
158169describe ( 'isActionTypeEnabled' , ( ) => {
159170 test ( 'returns true when "any" actionTypes are allowed' , ( ) => {
160- const config : ActionsConfigType = {
171+ const config : ActionsConfig = {
172+ ...defaultActionsConfig ,
161173 enabled : false ,
162174 allowedHosts : [ ] ,
163175 enabledActionTypes : [ 'ignore' , EnabledActionTypes . Any ] ,
@@ -166,7 +178,8 @@ describe('isActionTypeEnabled', () => {
166178 } ) ;
167179
168180 test ( 'returns false when no actionType is allowed' , ( ) => {
169- const config : ActionsConfigType = {
181+ const config : ActionsConfig = {
182+ ...defaultActionsConfig ,
170183 enabled : false ,
171184 allowedHosts : [ ] ,
172185 enabledActionTypes : [ ] ,
@@ -175,7 +188,8 @@ describe('isActionTypeEnabled', () => {
175188 } ) ;
176189
177190 test ( 'returns false when the actionType is not in the enabled list' , ( ) => {
178- const config : ActionsConfigType = {
191+ const config : ActionsConfig = {
192+ ...defaultActionsConfig ,
179193 enabled : false ,
180194 allowedHosts : [ ] ,
181195 enabledActionTypes : [ 'foo' ] ,
@@ -184,7 +198,8 @@ describe('isActionTypeEnabled', () => {
184198 } ) ;
185199
186200 test ( 'returns true when the actionType is in the enabled list' , ( ) => {
187- const config : ActionsConfigType = {
201+ const config : ActionsConfig = {
202+ ...defaultActionsConfig ,
188203 enabled : false ,
189204 allowedHosts : [ ] ,
190205 enabledActionTypes : [ 'ignore' , 'foo' ] ,
@@ -195,7 +210,8 @@ describe('isActionTypeEnabled', () => {
195210
196211describe ( 'ensureActionTypeEnabled' , ( ) => {
197212 test ( 'does not throw when any actionType is allowed' , ( ) => {
198- const config : ActionsConfigType = {
213+ const config : ActionsConfig = {
214+ ...defaultActionsConfig ,
199215 enabled : false ,
200216 allowedHosts : [ ] ,
201217 enabledActionTypes : [ 'ignore' , EnabledActionTypes . Any ] ,
@@ -204,7 +220,7 @@ describe('ensureActionTypeEnabled', () => {
204220 } ) ;
205221
206222 test ( 'throws when no actionType is not allowed' , ( ) => {
207- const config : ActionsConfigType = DefaultActionsConfig ;
223+ const config : ActionsConfig = defaultActionsConfig ;
208224 expect ( ( ) =>
209225 getActionsConfigurationUtilities ( config ) . ensureActionTypeEnabled ( 'foo' )
210226 ) . toThrowErrorMatchingInlineSnapshot (
@@ -213,7 +229,8 @@ describe('ensureActionTypeEnabled', () => {
213229 } ) ;
214230
215231 test ( 'throws when actionType is not enabled' , ( ) => {
216- const config : ActionsConfigType = {
232+ const config : ActionsConfig = {
233+ ...defaultActionsConfig ,
217234 enabled : false ,
218235 allowedHosts : [ ] ,
219236 enabledActionTypes : [ 'ignore' ] ,
@@ -226,7 +243,8 @@ describe('ensureActionTypeEnabled', () => {
226243 } ) ;
227244
228245 test ( 'does not throw when actionType is enabled' , ( ) => {
229- const config : ActionsConfigType = {
246+ const config : ActionsConfig = {
247+ ...defaultActionsConfig ,
230248 enabled : false ,
231249 allowedHosts : [ ] ,
232250 enabledActionTypes : [ 'ignore' , 'foo' ] ,
0 commit comments