Skip to content

Commit

Permalink
Add unmarshal unit tests for extensions
Browse files Browse the repository at this point in the history
Adds missing unmarshal unit tests for extensions that did not have them.
These ensure that marshal / unmarshal is round-trippable.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
  • Loading branch information
hasheddan committed Jul 6, 2023
1 parent 4fea5b7 commit 3ddcaba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/protocol/extension/supported_elliptic_curves_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ func TestExtensionSupportedGroups(t *testing.T) {
} else if !reflect.DeepEqual(raw, rawSupportedGroups) {
t.Errorf("extensionSupportedGroups marshal: got %#v, want %#v", raw, rawSupportedGroups)
}

roundtrip := &SupportedEllipticCurves{}
if err := roundtrip.Unmarshal(raw); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(roundtrip, parsedSupportedGroups) {
t.Errorf("extensionSupportedGroups unmarshal: got %#v, want %#v", roundtrip, parsedSupportedGroups)
}
}
7 changes: 7 additions & 0 deletions pkg/protocol/extension/supported_point_formats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ func TestExtensionSupportedPointFormats(t *testing.T) {
} else if !reflect.DeepEqual(raw, rawExtensionSupportedPointFormats) {
t.Errorf("extensionSupportedPointFormats marshal: got %#v, want %#v", raw, rawExtensionSupportedPointFormats)
}

roundtrip := &SupportedPointFormats{}
if err := roundtrip.Unmarshal(raw); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(roundtrip, parsedExtensionSupportedPointFormats) {
t.Errorf("extensionSupportedPointFormats unmarshal: got %#v, want %#v", roundtrip, parsedExtensionSupportedPointFormats)
}
}
7 changes: 7 additions & 0 deletions pkg/protocol/extension/supported_signature_algorithms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ func TestExtensionSupportedSignatureAlgorithms(t *testing.T) {
} else if !reflect.DeepEqual(raw, rawExtensionSupportedSignatureAlgorithms) {
t.Errorf("extensionSupportedSignatureAlgorithms marshal: got %#v, want %#v", raw, rawExtensionSupportedSignatureAlgorithms)
}

roundtrip := &SupportedSignatureAlgorithms{}
if err := roundtrip.Unmarshal(raw); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(roundtrip, parsedExtensionSupportedSignatureAlgorithms) {
t.Errorf("extensionSupportedSignatureAlgorithms unmarshal: got %#v, want %#v", roundtrip, parsedExtensionSupportedSignatureAlgorithms)
}
}

0 comments on commit 3ddcaba

Please sign in to comment.