@@ -32,7 +32,9 @@ const SECRET = 'e2e-intake-secret'
3232 */
3333function sign ( body : string ) : string {
3434 const timestamp = Math . floor ( Date . now ( ) / 1000 )
35- const signature = createHmac ( 'sha256' , SECRET ) . update ( `${ timestamp } .${ body } ` ) . digest ( 'hex' )
35+ const signature = createHmac ( 'sha256' , SECRET )
36+ . update ( `${ timestamp } .${ body } ` )
37+ . digest ( 'hex' )
3638
3739 return `t=${ timestamp } ,v1=${ signature } `
3840}
@@ -43,7 +45,10 @@ function sign(body: string): string {
4345 * @param request The Playwright request context.
4446 * @param channelId The channel id.
4547 */
46- async function seedChannelSource ( request : APIRequestContext , channelId : string ) : Promise < void > {
48+ async function seedChannelSource (
49+ request : APIRequestContext ,
50+ channelId : string ,
51+ ) : Promise < void > {
4752 const resp = await request . post ( `${ OR_BASE } /source` , {
4853 failOnStatusCode : false ,
4954 data : {
@@ -67,7 +72,10 @@ async function seedChannelSource(request: APIRequestContext, channelId: string):
6772 * @param request The Playwright request context.
6873 * @param rule The rule.
6974 */
70- async function seedRule ( request : APIRequestContext , rule : Record < string , unknown > ) : Promise < void > {
75+ async function seedRule (
76+ request : APIRequestContext ,
77+ rule : Record < string , unknown > ,
78+ ) : Promise < void > {
7179 const resp = await request . post ( `${ OR_BASE } /intake_routing_rule` , {
7280 failOnStatusCode : false ,
7381 data : rule ,
@@ -89,14 +97,17 @@ async function deliver(
8997 payload : Record < string , unknown > ,
9098) : Promise < Record < string , any > > {
9199 const body = JSON . stringify ( payload )
92- const resp = await request . post ( `${ API_BASE } /intake/channels/${ channelId } /inbound` , {
93- failOnStatusCode : false ,
94- headers : {
95- 'Content-Type' : 'application/json' ,
96- 'X-OpenConnector-Signature' : sign ( body ) ,
100+ const resp = await request . post (
101+ `${ API_BASE } /intake/channels/${ channelId } /inbound` ,
102+ {
103+ failOnStatusCode : false ,
104+ headers : {
105+ 'Content-Type' : 'application/json' ,
106+ 'X-OpenConnector-Signature' : sign ( body ) ,
107+ } ,
108+ data : body ,
97109 } ,
98- data : body ,
99- } )
110+ )
100111 expect ( resp . status ( ) , 'a signed delivery must be accepted' ) . toBe ( 202 )
101112
102113 return await resp . json ( )
@@ -164,14 +175,18 @@ test.describe('intake channels', () => {
164175 expect ( result . status ) . toBe ( 'held' )
165176 expect ( result . reason ) . toContain ( 'messaging' )
166177
167- await page . goto ( `${ APP_BASE } /messages/intake` , { waitUntil : 'domcontentloaded' } )
178+ await page . goto ( `${ APP_BASE } /messages/intake` , {
179+ waitUntil : 'domcontentloaded' ,
180+ } )
168181 await expect (
169182 page . getByText ( 'Een vraag zonder regel' ) . first ( ) ,
170183 'a held message is on the page somebody actually reads' ,
171184 ) . toBeVisible ( { timeout : 20_000 } )
172185 } )
173186
174- test ( 'a mapping onto a field that does not exist fails at configuration time' , async ( { request } ) => {
187+ test ( 'a mapping onto a field that does not exist fails at configuration time' , async ( {
188+ request,
189+ } ) => {
175190 const resp = await request . post ( `${ API_BASE } /intake/routing-rules` , {
176191 failOnStatusCode : false ,
177192 headers : { 'OCS-APIRequest' : 'true' } ,
@@ -186,7 +201,9 @@ test.describe('intake channels', () => {
186201
187202 expect ( resp . status ( ) , 'the save must be refused' ) . toBe ( 400 )
188203 const body = await resp . json ( )
189- expect ( body . error , 'and it must name the field' ) . toContain ( 'veldDatNietBestaat' )
204+ expect ( body . error , 'and it must name the field' ) . toContain (
205+ 'veldDatNietBestaat' ,
206+ )
190207 } )
191208
192209 test ( 'an anonymous caller cannot change routing' , async ( ) => {
@@ -200,7 +217,11 @@ test.describe('intake channels', () => {
200217 const resp = await anonymous . post ( `${ API_BASE } /intake/routing-rules` , {
201218 failOnStatusCode : false ,
202219 headers : { 'OCS-APIRequest' : 'true' } ,
203- data : { name : 'nope' , channelId : 'messaging' , targetSchema : 'algemene_vraag' } ,
220+ data : {
221+ name : 'nope' ,
222+ channelId : 'messaging' ,
223+ targetSchema : 'algemene_vraag' ,
224+ } ,
204225 } )
205226
206227 expect ( resp . status ( ) ) . toBeGreaterThanOrEqual ( 401 )
0 commit comments