@@ -1056,18 +1056,25 @@ describe('Definitions', () => {
10561056 expect ( header [ 0 ] ) . to . equal ( 'sid=fihfieuhr9384hf; Secure; HttpOnly; SameSite=None; Partitioned' ) ;
10571057 } ) ;
10581058
1059- it ( 'ignores partitioned option if not secure' , async ( ) => {
1059+ it ( 'throws error if partitioned option if not secure' , async ( ) => {
10601060
10611061 const definitions = new Statehood . Definitions ( ) ;
1062- const header = await definitions . format ( { name : 'sid' , value : 'fihfieuhr9384hf' , options : { isPartitioned : true , isSecure : false , isHttpOnly : true , isSameSite : 'None' } } ) ;
1063- expect ( header [ 0 ] ) . to . equal ( 'sid=fihfieuhr9384hf; HttpOnly; SameSite=None ' ) ;
1062+ const result = await definitions . format ( { name : 'sid' , value : 'fihfieuhr9384hf' , options : { isPartitioned : true , isSecure : false , isHttpOnly : true , isSameSite : 'None' } } ) ;
1063+ expect ( result . message ) . to . equal ( 'Partitioned cookies must be secure ' ) ;
10641064 } ) ;
10651065
1066- it ( 'ignores partitioned option if not SameSite=None' , async ( ) => {
1066+ it ( 'throws error if partitioned option if not SameSite=None' , async ( ) => {
10671067
10681068 const definitions = new Statehood . Definitions ( ) ;
1069- const header = await definitions . format ( { name : 'sid' , value : 'fihfieuhr9384hf' , options : { isPartitioned : true , isSecure : true , isHttpOnly : true , isSameSite : 'Lax' } } ) ;
1070- expect ( header [ 0 ] ) . to . equal ( 'sid=fihfieuhr9384hf; Secure; HttpOnly; SameSite=Lax' ) ;
1069+ const result = await definitions . format ( { name : 'sid' , value : 'fihfieuhr9384hf' , options : { isPartitioned : true , isSecure : true , isHttpOnly : true , isSameSite : 'Lax' } } ) ;
1070+ expect ( result . message ) . to . equal ( 'Partitioned cookies must have SameSite=None' ) ;
1071+ } ) ;
1072+
1073+ it ( 'throws error if partitioned option if not secure and not SameSite=None' , async ( ) => {
1074+
1075+ const definitions = new Statehood . Definitions ( ) ;
1076+ const result = await definitions . format ( { name : 'sid' , value : 'fihfieuhr9384hf' , options : { isPartitioned : true , isSecure : false , isHttpOnly : true , isSameSite : 'Lax' } } ) ;
1077+ expect ( result . message ) . to . equal ( 'Partitioned cookies must be secure and have SameSite=None' ) ;
10711078 } ) ;
10721079 } ) ;
10731080
0 commit comments