@@ -158,10 +158,7 @@ fn signed_doc_with_missing_header_field_case(field: &'static str) -> TestCase {
158158 // protected headers (metadata fields)
159159 e. bytes ( {
160160 let mut p_headers = Encoder :: new ( Vec :: new ( ) ) ;
161- p_headers. map ( 4 ) ?;
162- if field != "content-type" {
163- p_headers. u8 ( 3 ) ?. encode ( ContentType :: Json ) ?;
164- }
161+ p_headers. map ( 3 ) ?;
165162 if field != "type" {
166163 p_headers. str ( "type" ) ?. encode ( & doc_type) ?;
167164 }
@@ -198,9 +195,6 @@ fn signed_doc_with_missing_header_field_case(field: &'static str) -> TestCase {
198195 valid_doc : false ,
199196 post_checks : Some ( Box :: new ( {
200197 move |doc| {
201- if field == "content-type" {
202- anyhow:: ensure!( doc. doc_meta( ) . content_type( ) . is_err( ) ) ;
203- }
204198 if field == "type" {
205199 anyhow:: ensure!( doc. doc_meta( ) . doc_type( ) . is_err( ) ) ;
206200 }
@@ -234,17 +228,10 @@ fn signed_doc_with_random_header_field_case(field: &'static str) -> TestCase {
234228 let mut rand_buf = [ 0u8 ; 128 ] ;
235229 rng. try_fill ( & mut rand_buf) ?;
236230
237- let is_required_header = [ "content-type" , "type" , "id" , "ver" ]
238- . iter ( )
239- . any ( |v| v == & field) ;
231+ let is_required_header = [ "type" , "id" , "ver" ] . iter ( ) . any ( |v| v == & field) ;
240232
241233 let mut p_headers = Encoder :: new ( Vec :: new ( ) ) ;
242- p_headers. map ( if is_required_header { 4 } else { 5 } ) ?;
243- if field == "content-type" {
244- p_headers. u8 ( 3 ) ?. encode_with ( rand_buf, & mut ( ) ) ?;
245- } else {
246- p_headers. u8 ( 3 ) ?. encode ( ContentType :: Json ) ?;
247- }
234+ p_headers. map ( if is_required_header { 3 } else { 4 } ) ?;
248235 if field == "type" {
249236 p_headers. str ( "type" ) ?. encode_with ( rand_buf, & mut ( ) ) ?;
250237 } else {
@@ -287,6 +274,7 @@ fn signed_doc_with_random_header_field_case(field: &'static str) -> TestCase {
287274 valid_doc : false ,
288275 post_checks : Some ( Box :: new ( {
289276 move |doc| {
277+ anyhow:: ensure!( doc. doc_meta( ) . content_type( ) . is_none( ) ) ;
290278 anyhow:: ensure!( doc. doc_meta( ) . content_encoding( ) . is_none( ) ) ;
291279 anyhow:: ensure!( doc. doc_meta( ) . doc_ref( ) . is_none( ) ) ;
292280 anyhow:: ensure!( doc. doc_meta( ) . template( ) . is_none( ) ) ;
@@ -295,9 +283,6 @@ fn signed_doc_with_random_header_field_case(field: &'static str) -> TestCase {
295283 anyhow:: ensure!( doc. doc_meta( ) . parameters( ) . is_none( ) ) ;
296284 anyhow:: ensure!( doc. doc_meta( ) . collaborators( ) . is_empty( ) ) ;
297285
298- if field == "content-type" {
299- anyhow:: ensure!( doc. doc_meta( ) . content_type( ) . is_err( ) ) ;
300- }
301286 if field == "type" {
302287 anyhow:: ensure!( doc. doc_meta( ) . doc_type( ) . is_err( ) ) ;
303288 }
@@ -594,7 +579,7 @@ fn signed_doc_with_minimal_metadata_fields_case() -> TestCase {
594579 anyhow:: ensure!( doc. doc_type( ) ? == & doc_type) ;
595580 anyhow:: ensure!( doc. doc_id( ) ? == uuid_v7) ;
596581 anyhow:: ensure!( doc. doc_ver( ) ? == uuid_v7) ;
597- anyhow:: ensure!( doc. doc_content_type( ) ? == ContentType :: Json ) ;
582+ anyhow:: ensure!( doc. doc_content_type( ) == Some ( ContentType :: Json ) ) ;
598583 anyhow:: ensure!(
599584 doc. encoded_content( ) == serde_json:: to_vec( & serde_json:: Value :: Null ) ?
600585 ) ;
@@ -682,7 +667,7 @@ fn signed_doc_with_complete_metadata_fields_case() -> TestCase {
682667 anyhow:: ensure!( doc. doc_meta( ) . doc_ref( ) == Some ( & refs) ) ;
683668 anyhow:: ensure!( doc. doc_meta( ) . template( ) == Some ( & refs) ) ;
684669 anyhow:: ensure!( doc. doc_meta( ) . reply( ) == Some ( & refs) ) ;
685- anyhow:: ensure!( doc. doc_content_type( ) ? == ContentType :: Json ) ;
670+ anyhow:: ensure!( doc. doc_content_type( ) == Some ( ContentType :: Json ) ) ;
686671 anyhow:: ensure!( doc. encoded_content( ) == serde_json:: to_vec( & serde_json:: Value :: Null ) ?) ;
687672 anyhow:: ensure!( doc. kids( ) . len( ) == 1 ) ;
688673 anyhow:: ensure!( !doc. is_deprecated( ) ?) ;
@@ -735,7 +720,7 @@ fn minimally_valid_tagged_signed_doc() -> TestCase {
735720 anyhow:: ensure!( doc. doc_type( ) ? == & doc_type) ;
736721 anyhow:: ensure!( doc. doc_id( ) ? == uuid_v7) ;
737722 anyhow:: ensure!( doc. doc_ver( ) ? == uuid_v7) ;
738- anyhow:: ensure!( doc. doc_content_type( ) ? == ContentType :: Json ) ;
723+ anyhow:: ensure!( doc. doc_content_type( ) == Some ( ContentType :: Json ) ) ;
739724 anyhow:: ensure!( doc. doc_meta( ) . doc_ref( ) . is_none( ) ) ;
740725 anyhow:: ensure!( doc. doc_meta( ) . template( ) . is_none( ) ) ;
741726 anyhow:: ensure!( doc. doc_meta( ) . reply( ) . is_none( ) ) ;
@@ -791,7 +776,7 @@ fn minimally_valid_untagged_signed_doc() -> TestCase {
791776 anyhow:: ensure!( doc. doc_type( ) ? == & doc_type) ;
792777 anyhow:: ensure!( doc. doc_id( ) ? == uuid_v7) ;
793778 anyhow:: ensure!( doc. doc_ver( ) ? == uuid_v7) ;
794- anyhow:: ensure!( doc. doc_content_type( ) ? == ContentType :: Json ) ;
779+ anyhow:: ensure!( doc. doc_content_type( ) == Some ( ContentType :: Json ) ) ;
795780 anyhow:: ensure!( doc. doc_meta( ) . doc_ref( ) . is_none( ) ) ;
796781 anyhow:: ensure!( doc. doc_meta( ) . template( ) . is_none( ) ) ;
797782 anyhow:: ensure!( doc. doc_meta( ) . reply( ) . is_none( ) ) ;
@@ -1100,7 +1085,7 @@ fn signed_doc_with_non_strict_deterministic_decoding_wrong_order() -> TestCase {
11001085 anyhow:: ensure!( doc. doc_type( ) ? == & doc_type) ;
11011086 anyhow:: ensure!( doc. doc_id( ) ? == uuid_v7) ;
11021087 anyhow:: ensure!( doc. doc_ver( ) ? == uuid_v7) ;
1103- anyhow:: ensure!( doc. doc_content_type( ) ? == ContentType :: Json ) ;
1088+ anyhow:: ensure!( doc. doc_content_type( ) == Some ( ContentType :: Json ) ) ;
11041089 anyhow:: ensure!(
11051090 doc. encoded_content( ) == serde_json:: to_vec( & serde_json:: Value :: Null ) ?
11061091 ) ;
@@ -1159,7 +1144,7 @@ fn signed_doc_with_non_supported_metadata_invalid() -> TestCase {
11591144 anyhow:: ensure!( doc. doc_type( ) ? == & doc_type) ;
11601145 anyhow:: ensure!( doc. doc_id( ) ? == uuid_v7) ;
11611146 anyhow:: ensure!( doc. doc_ver( ) ? == uuid_v7) ;
1162- anyhow:: ensure!( doc. doc_content_type( ) ? == ContentType :: Json ) ;
1147+ anyhow:: ensure!( doc. doc_content_type( ) == Some ( ContentType :: Json ) ) ;
11631148 anyhow:: ensure!(
11641149 doc. encoded_content( ) == serde_json:: to_vec( & serde_json:: Value :: Null ) ?
11651150 ) ;
@@ -1227,7 +1212,7 @@ fn signed_doc_with_kid_in_id_form_invalid() -> TestCase {
12271212 anyhow:: ensure!( doc. doc_type( ) ? == & doc_type) ;
12281213 anyhow:: ensure!( doc. doc_id( ) ? == uuid_v7) ;
12291214 anyhow:: ensure!( doc. doc_ver( ) ? == uuid_v7) ;
1230- anyhow:: ensure!( doc. doc_content_type( ) ? == ContentType :: Json ) ;
1215+ anyhow:: ensure!( doc. doc_content_type( ) == Some ( ContentType :: Json ) ) ;
12311216 anyhow:: ensure!(
12321217 doc. encoded_content( ) == serde_json:: to_vec( & serde_json:: Value :: Null ) ?
12331218 ) ;
@@ -1323,7 +1308,6 @@ fn catalyst_signed_doc_decoding_test() {
13231308 signed_doc_with_valid_alias_case ( "brand_id" ) ,
13241309 signed_doc_with_valid_alias_case ( "campaign_id" ) ,
13251310 signed_doc_with_valid_alias_case ( "parameters" ) ,
1326- signed_doc_with_missing_header_field_case ( "content-type" ) ,
13271311 signed_doc_with_missing_header_field_case ( "type" ) ,
13281312 signed_doc_with_missing_header_field_case ( "id" ) ,
13291313 signed_doc_with_missing_header_field_case ( "ver" ) ,
0 commit comments