@@ -79,12 +79,15 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
7979 const createdAction = actionResponse . body ;
8080 objectRemover . add ( Spaces . space1 . id , createdAction . id , 'action' , 'actions' ) ;
8181
82+ // from x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/alert_types.ts
83+ const varsTemplate = '{{context.escapableDoubleQuote}} -- {{context.escapableLineFeed}}' ;
84+
8285 const alertResponse = await supertest
8386 . post ( `${ getUrlPrefix ( Spaces . space1 . id ) } /api/alerts/alert` )
8487 . set ( 'kbn-xsrf' , 'foo' )
8588 . send (
8689 getTestAlertData ( {
87- name : 'contains "double quote" ' ,
90+ name : 'testing variable escapes for webhook ' ,
8891 alertTypeId : 'test.patternFiring' ,
8992 params : {
9093 pattern : { instance : [ true ] } ,
@@ -94,7 +97,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
9497 id : createdAction . id ,
9598 group : 'default' ,
9699 params : {
97- body : ' payload {{alertId}} - {{alertName}}' ,
100+ body : ` payload {{alertId}} - ${ varsTemplate } ` ,
98101 } ,
99102 } ,
100103 ] ,
@@ -107,10 +110,10 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
107110 const body = await retry . try ( async ( ) =>
108111 waitForActionBody ( webhookSimulatorURL , createdAlert . id )
109112 ) ;
110- expect ( body ) . to . be ( `contains \\"double quote\\"` ) ;
113+ expect ( body ) . to . be ( `\\"double quote\\" -- line\\nfeed ` ) ;
111114 } ) ;
112115
113- it ( 'should handle bold and italic escapes in slack' , async ( ) => {
116+ it ( 'should handle escapes in slack' , async ( ) => {
114117 const actionResponse = await supertest
115118 . post ( `${ getUrlPrefix ( Spaces . space1 . id ) } /api/actions/action` )
116119 . set ( 'kbn-xsrf' , 'test' )
@@ -125,58 +128,16 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
125128 const createdAction = actionResponse . body ;
126129 objectRemover . add ( Spaces . space1 . id , createdAction . id , 'action' , 'actions' ) ;
127130
128- const alertResponse = await supertest
129- . post ( `${ getUrlPrefix ( Spaces . space1 . id ) } /api/alerts/alert` )
130- . set ( 'kbn-xsrf' , 'foo' )
131- . send (
132- getTestAlertData ( {
133- name : 'contains *bold* and _italic_ and back`tic and htmlish <&> things' ,
134- alertTypeId : 'test.patternFiring' ,
135- params : {
136- pattern : { instance : [ true ] } ,
137- } ,
138- actions : [
139- {
140- id : createdAction . id ,
141- group : 'default' ,
142- params : {
143- message : 'message {{alertId}} - {{alertName}}' ,
144- } ,
145- } ,
146- ] ,
147- } )
148- ) ;
149- expect ( alertResponse . status ) . to . eql ( 200 ) ;
150- const createdAlert = alertResponse . body ;
151- objectRemover . add ( Spaces . space1 . id , createdAlert . id , 'alert' , 'alerts' ) ;
152-
153- const body = await retry . try ( async ( ) =>
154- waitForActionBody ( slackSimulatorURL , createdAlert . id )
155- ) ;
156- expect ( body ) . to . be ( "`contains *bold* and _italic_ and back'tic and htmlish <&> things`" ) ;
157- } ) ;
158-
159- it ( 'should handle single escapes in slack' , async ( ) => {
160- const actionResponse = await supertest
161- . post ( `${ getUrlPrefix ( Spaces . space1 . id ) } /api/actions/action` )
162- . set ( 'kbn-xsrf' , 'test' )
163- . send ( {
164- name : 'testing single mustache escapes for slack' ,
165- actionTypeId : '.slack' ,
166- secrets : {
167- webhookUrl : slackSimulatorURL ,
168- } ,
169- } ) ;
170- expect ( actionResponse . status ) . to . eql ( 200 ) ;
171- const createdAction = actionResponse . body ;
172- objectRemover . add ( Spaces . space1 . id , createdAction . id , 'action' , 'actions' ) ;
131+ // from x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/alert_types.ts
132+ const varsTemplate =
133+ '{{context.escapableBacktic}} -- {{context.escapableBold}} -- {{context.escapableBackticBold}} -- {{context.escapableHtml}}' ;
173134
174135 const alertResponse = await supertest
175136 . post ( `${ getUrlPrefix ( Spaces . space1 . id ) } /api/alerts/alert` )
176137 . set ( 'kbn-xsrf' , 'foo' )
177138 . send (
178139 getTestAlertData ( {
179- name : 'contains back`tic and htmlish <&> things ' ,
140+ name : 'testing variable escapes for slack ' ,
180141 alertTypeId : 'test.patternFiring' ,
181142 params : {
182143 pattern : { instance : [ true ] } ,
@@ -186,7 +147,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
186147 id : createdAction . id ,
187148 group : 'default' ,
188149 params : {
189- message : ' message {{alertId}} - {{alertName}}' ,
150+ message : ` message {{alertId}} - ${ varsTemplate } ` ,
190151 } ,
191152 } ,
192153 ] ,
@@ -199,7 +160,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
199160 const body = await retry . try ( async ( ) =>
200161 waitForActionBody ( slackSimulatorURL , createdAlert . id )
201162 ) ;
202- expect ( body ) . to . be ( "contains back'tic and htmlish <&> things " ) ;
163+ expect ( body ) . to . be ( "back'tic -- `*bold*` -- `'*bold*'` -- <&>" ) ;
203164 } ) ;
204165 } ) ;
205166
0 commit comments