@@ -66,7 +66,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
66
66
67
67
describe ( 'escaping' , ( ) => {
68
68
it ( 'should handle escapes in webhook' , async ( ) => {
69
- // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/alert_types .ts,
69
+ // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/rule_types .ts
70
70
// const EscapableStrings
71
71
const template = '{{context.escapableDoubleQuote}} -- {{context.escapableLineFeed}}' ;
72
72
const rule = await createRule ( {
@@ -81,7 +81,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
81
81
} ) ;
82
82
83
83
it ( 'should handle escapes in slack' , async ( ) => {
84
- // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/alert_types .ts,
84
+ // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/rule_types .ts
85
85
// const EscapableStrings
86
86
const template =
87
87
'{{context.escapableBacktic}} -- {{context.escapableBold}} -- {{context.escapableBackticBold}} -- {{context.escapableHtml}} -- {{context.escapableLink}}' ;
@@ -101,7 +101,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
101
101
} ) ;
102
102
103
103
it ( 'should handle context variable object expansion' , async ( ) => {
104
- // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/alert_types .ts,
104
+ // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/rule_types .ts
105
105
// const DeepContextVariables
106
106
const template = '{{context.deep}}' ;
107
107
const rule = await createRule ( {
@@ -113,7 +113,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
113
113
} ) ;
114
114
const body = await retry . try ( async ( ) => waitForActionBody ( slackSimulatorURL , rule . id ) ) ;
115
115
expect ( body ) . to . be (
116
- '{"objectA":{"stringB":"B","arrayC":[{"stringD":"D1","numberE":42},{"stringD":"D2","numberE":43}],"objectF":{"stringG":"G","nullG":null}},"stringH":"H","arrayI":[44,45],"nullJ":null,"dateL":"2023-04-20T04:13:17.858Z"}'
116
+ '{"objectA":{"stringB":"B","arrayC":[{"stringD":"D1","numberE":42},{"stringD":"D2","numberE":43}],"objectF":{"stringG":"G","nullG":null}},"stringH":"H","arrayI":[44,45],"nullJ":null,"dateL":"2023-04-20T04:13:17.858Z","encodeableUrl":"https://www.elastic.co?foo=bar&baz= qux" }'
117
117
) ;
118
118
} ) ;
119
119
@@ -165,7 +165,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
165
165
} ) ;
166
166
167
167
it ( 'should handle asJSON' , async ( ) => {
168
- // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/alert_types .ts,
168
+ // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/rule_types .ts
169
169
// const DeepContextVariables
170
170
const template = `{{#context.deep.objectA}}
171
171
{{{arrayC}}} {{{arrayC.asJSON}}}
@@ -185,7 +185,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
185
185
} ) ;
186
186
187
187
it ( 'should handle EvalMath' , async ( ) => {
188
- // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/alert_types .ts,
188
+ // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/rule_types .ts
189
189
// const DeepContextVariables
190
190
const template = `{{#context.deep}}avg({{arrayI.0}}, {{arrayI.1}})/100 => {{#EvalMath}}
191
191
round((arrayI[0] + arrayI[1]) / 2 / 100, 2)
@@ -202,7 +202,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
202
202
} ) ;
203
203
204
204
it ( 'should handle FormatDate' , async ( ) => {
205
- // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/alert_types .ts,
205
+ // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/rule_types .ts
206
206
// const DeepContextVariables
207
207
const template = `{{#context.deep}}{{#FormatDate}}
208
208
{{{dateL}}} ; America/New_York; dddd MMM Do YYYY HH:mm:ss
@@ -220,7 +220,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
220
220
} ) ;
221
221
222
222
it ( 'should handle FormatNumber' , async ( ) => {
223
- // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/alert_types .ts,
223
+ // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/rule_types .ts
224
224
// const DeepContextVariables
225
225
const template = `{{#context.deep}}{{#FormatNumber}}
226
226
{{{arrayI.1}}}; en-US; style: currency, currency: EUR
@@ -236,6 +236,36 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
236
236
expect ( body . trim ( ) ) . to . be ( '€45.00' ) ;
237
237
} ) ;
238
238
239
+ it ( 'should handle EncodeURI' , async ( ) => {
240
+ // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/rule_types.ts
241
+ // const DeepContextVariables
242
+ const template = `{{#context.deep}}{{#EncodeURI}}{{{encodeableUrl}}}{{/EncodeURI}}{{/context.deep}}` ;
243
+ const rule = await createRule ( {
244
+ id : slackConnector . id ,
245
+ group : 'default' ,
246
+ params : {
247
+ message : `message {{rule.id}} - ${ template } ` ,
248
+ } ,
249
+ } ) ;
250
+ const body = await retry . try ( async ( ) => waitForActionBody ( slackSimulatorURL , rule . id ) ) ;
251
+ expect ( body . trim ( ) ) . to . be ( 'https://www.elastic.co?foo=bar&baz=%20qux' ) ;
252
+ } ) ;
253
+
254
+ it ( 'should handle EncodeURIComponent' , async ( ) => {
255
+ // from x-pack/test/alerting_api_integration/common/plugins/alerts/server/rule_types.ts
256
+ // const DeepContextVariables
257
+ const template = `{{#context.deep}}{{#EncodeURIComponent}}{{{encodeableUrl}}}{{/EncodeURIComponent}}{{/context.deep}}` ;
258
+ const rule = await createRule ( {
259
+ id : slackConnector . id ,
260
+ group : 'default' ,
261
+ params : {
262
+ message : `message {{rule.id}} - ${ template } ` ,
263
+ } ,
264
+ } ) ;
265
+ const body = await retry . try ( async ( ) => waitForActionBody ( slackSimulatorURL , rule . id ) ) ;
266
+ expect ( body . trim ( ) ) . to . be ( 'https%3A%2F%2Fwww.elastic.co%3Ffoo%3Dbar%26baz%3D%20qux' ) ;
267
+ } ) ;
268
+
239
269
async function createRule ( action : any ) {
240
270
const ruleResponse = await supertest
241
271
. post ( `${ getUrlPrefix ( Spaces . space1 . id ) } /api/alerting/rule` )
0 commit comments