Skip to content

Commit

Permalink
increase headers type validation coverage
Browse files Browse the repository at this point in the history
Signed-off-by: qmuntal <[email protected]>
  • Loading branch information
qmuntal committed Jul 11, 2022
1 parent 33ff2e9 commit 66229c9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions headers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ func TestProtectedHeader_MarshalCBOR(t *testing.T) {
},
wantErr: true,
},
{
name: "invalid content type value",
h: ProtectedHeader{
HeaderLabelContentType: []byte("foo"),
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -800,7 +807,7 @@ func TestHeaders_MarshalUnprotected(t *testing.T) {
HeaderLabelAlgorithm: AlgorithmES256,
},
Unprotected: UnprotectedHeader{
HeaderLabelContentType: 42,
HeaderLabelContentType: uint8(42),
},
},
want: []byte{0xa1, 0x03, 0x18, 0x2a},
Expand Down Expand Up @@ -866,7 +873,7 @@ func TestHeaders_UnmarshalFromRaw(t *testing.T) {
},
RawUnprotected: []byte{0xa1, 0x04, 0x18, 0x2a},
Unprotected: UnprotectedHeader{
HeaderLabelContentType: 42,
HeaderLabelContentType: int8(42),
},
},
},
Expand All @@ -879,7 +886,7 @@ func TestHeaders_UnmarshalFromRaw(t *testing.T) {
},
RawUnprotected: []byte{0xa1, 0x03, 0x18, 0x2a},
Unprotected: UnprotectedHeader{
HeaderLabelContentType: 43,
HeaderLabelContentType: int16(43),
},
},
want: Headers{
Expand Down

0 comments on commit 66229c9

Please sign in to comment.