@@ -699,7 +699,7 @@ def test_iso_timestamp(iso_timestamp, should_be_valid)
699699
700700 describe ".parse_structured_header" do
701701 it "parses valid structured header with timestamp and signature" do
702- config = { signature_key : "v1" , timestamp_key : "t" }
702+ config = { signature_key : "v1" , timestamp_key : "t" , key_value_separator : "=" , structured_header_separator : "," }
703703 header_value = "t=1663781880,v1=0123456789abcdef"
704704
705705 result = described_class . send ( :parse_structured_header , header_value , config )
@@ -710,8 +710,20 @@ def test_iso_timestamp(iso_timestamp, should_be_valid)
710710 } )
711711 end
712712
713+ it "parses valid structured header with timestamp and signature using different separators" do
714+ config = { signature_key : "v1" , timestamp_key : "t" , key_value_separator : ":" , structured_header_separator : "." }
715+ header_value = "t:1663781880.v1:0123456789abcdef"
716+
717+ result = described_class . send ( :parse_structured_header , header_value , config )
718+
719+ expect ( result ) . to eq ( {
720+ signature : "0123456789abcdef" ,
721+ timestamp : "1663781880"
722+ } )
723+ end
724+
713725 it "parses structured header with only signature" do
714- config = { signature_key : "v1" , timestamp_key : "t" }
726+ config = { signature_key : "v1" , timestamp_key : "t" , key_value_separator : "=" , structured_header_separator : "," }
715727 header_value = "v1=abcdef123456"
716728
717729 result = described_class . send ( :parse_structured_header , header_value , config )
@@ -722,7 +734,7 @@ def test_iso_timestamp(iso_timestamp, should_be_valid)
722734 end
723735
724736 it "handles extra whitespace in key-value pairs" do
725- config = { signature_key : "v1" , timestamp_key : "t" }
737+ config = { signature_key : "v1" , timestamp_key : "t" , key_value_separator : "=" , structured_header_separator : "," }
726738 header_value = "t = 1663781880 , v1 = 0123456789abcdef "
727739
728740 result = described_class . send ( :parse_structured_header , header_value , config )
@@ -734,7 +746,7 @@ def test_iso_timestamp(iso_timestamp, should_be_valid)
734746 end
735747
736748 it "returns nil for malformed header (missing equals)" do
737- config = { signature_key : "v1" , timestamp_key : "t" }
749+ config = { signature_key : "v1" , timestamp_key : "t" , key_value_separator : "=" , structured_header_separator : "," }
738750 header_value = "t,v1=abcdef"
739751
740752 result = described_class . send ( :parse_structured_header , header_value , config )
@@ -743,7 +755,7 @@ def test_iso_timestamp(iso_timestamp, should_be_valid)
743755 end
744756
745757 it "returns nil when signature key is missing" do
746- config = { signature_key : "v1" , timestamp_key : "t" }
758+ config = { signature_key : "v1" , timestamp_key : "t" , key_value_separator : "=" , structured_header_separator : "," }
747759 header_value = "t=1663781880,other=value"
748760
749761 result = described_class . send ( :parse_structured_header , header_value , config )
@@ -752,7 +764,7 @@ def test_iso_timestamp(iso_timestamp, should_be_valid)
752764 end
753765
754766 it "returns nil when signature value is empty" do
755- config = { signature_key : "v1" , timestamp_key : "t" }
767+ config = { signature_key : "v1" , timestamp_key : "t" , key_value_separator : "=" , structured_header_separator : "," }
756768 header_value = "t=1663781880,v1="
757769
758770 result = described_class . send ( :parse_structured_header , header_value , config )
@@ -761,7 +773,7 @@ def test_iso_timestamp(iso_timestamp, should_be_valid)
761773 end
762774
763775 it "ignores extra key-value pairs not in config" do
764- config = { signature_key : "v1" , timestamp_key : "t" }
776+ config = { signature_key : "v1" , timestamp_key : "t" , key_value_separator : "=" , structured_header_separator : "," }
765777 header_value = "t=1663781880,v1=abcdef,extra=ignored,another=also_ignored"
766778
767779 result = described_class . send ( :parse_structured_header , header_value , config )
0 commit comments