@@ -2,14 +2,22 @@ import { getInMemoryCustomerVariables } from '../utils/customer-variables/in-mem
22import { CustomerVariableType } from '../../utils/customer-variables/types'
33import { getStatusInfo , handleStatus } from '../../handlers/handleStatus'
44
5+ const styleNonce = 'hardcodedStyleNonce'
6+
57describe ( 'Handle status' , ( ) => {
68 it ( 'returns correct status info in html if all variables are set' , async ( ) => {
79 const { customerVariables } = getInMemoryCustomerVariables ( )
810
9- const result = await handleStatus ( customerVariables )
11+ const result = await handleStatus ( customerVariables , styleNonce )
1012
1113 expect ( result . headers ) . toEqual ( {
1214 'content-type' : [ { key : 'Content-Type' , value : 'text/html' } ] ,
15+ 'content-security-policy' : [
16+ {
17+ key : 'Content-Security-Policy' ,
18+ value : `default-src 'none'; img-src https://fingerprint.com; style-src 'nonce-${ styleNonce } '` ,
19+ } ,
20+ ] ,
1321 } )
1422
1523 expect ( result . body ) . toMatchSnapshot ( )
@@ -22,10 +30,16 @@ describe('Handle status', () => {
2230 variables . fpjs_agent_download_path = null
2331 variables . fpjs_get_result_path = null
2432
25- const result = await handleStatus ( customerVariables )
33+ const result = await handleStatus ( customerVariables , styleNonce )
2634
2735 expect ( result . headers ) . toEqual ( {
2836 'content-type' : [ { key : 'Content-Type' , value : 'text/html' } ] ,
37+ 'content-security-policy' : [
38+ {
39+ key : 'Content-Security-Policy' ,
40+ value : `default-src 'none'; img-src https://fingerprint.com; style-src 'nonce-${ styleNonce } '` ,
41+ } ,
42+ ] ,
2943 } )
3044
3145 expect ( result . body ) . toMatchSnapshot ( )
@@ -36,10 +50,16 @@ describe('Handle status', () => {
3650
3751 variables . fpjs_pre_shared_secret = null
3852
39- const result = await handleStatus ( customerVariables )
53+ const result = await handleStatus ( customerVariables , styleNonce )
4054
4155 expect ( result . headers ) . toEqual ( {
4256 'content-type' : [ { key : 'Content-Type' , value : 'text/html' } ] ,
57+ 'content-security-policy' : [
58+ {
59+ key : 'Content-Security-Policy' ,
60+ value : `default-src 'none'; img-src https://fingerprint.com; style-src 'nonce-${ styleNonce } '` ,
61+ } ,
62+ ] ,
4363 } )
4464
4565 expect ( result . body ) . toMatchSnapshot ( )
@@ -50,7 +70,7 @@ describe('Get status info', () => {
5070 it ( 'returns correct status info' , async ( ) => {
5171 const { customerVariables } = getInMemoryCustomerVariables ( )
5272
53- const result = await getStatusInfo ( customerVariables )
73+ const result = await getStatusInfo ( customerVariables , styleNonce )
5474
5575 expect ( result ) . toMatchSnapshot ( )
5676 } )
@@ -59,15 +79,15 @@ describe('Get status info', () => {
5979 const { customerVariables, variables } = getInMemoryCustomerVariables ( )
6080 variables [ CustomerVariableType . PreSharedSecret ] = null
6181
62- const result = await getStatusInfo ( customerVariables )
82+ const result = await getStatusInfo ( customerVariables , styleNonce )
6383
6484 expect ( result ) . toMatchSnapshot ( )
6585 } )
6686
6787 it ( 'returns correct response with empty non obfuscated variable' , async ( ) => {
6888 const { customerVariables } = getInMemoryCustomerVariables ( )
6989
70- const result = await getStatusInfo ( customerVariables )
90+ const result = await getStatusInfo ( customerVariables , styleNonce )
7191
7292 expect ( result ) . toMatchSnapshot ( )
7393 } )
0 commit comments