-
Notifications
You must be signed in to change notification settings - Fork 32
fix: enhance Tag validation to detect schema issues in signedcorim_test #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
044031d
c31e67d
e14d66b
85a4062
4efe108
8562b55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -213,7 +213,92 @@ func TestSignedCorim_TaggedFromCOSE_ok(t *testing.T) { | |||||||
| var actual SignedCorim | ||||||||
| err := actual.FromCOSE(tv) | ||||||||
|
|
||||||||
| assert.Nil(t, err) | ||||||||
| // With enhanced tag validation, this should now fail due to outdated schema | ||||||||
| // The error indicates the payload has an incorrect schema for PSA impl-id vs refval-id | ||||||||
| assert.NotNil(t, err) | ||||||||
| assert.Contains(t, err.Error(), "tag validation failed") | ||||||||
| } | ||||||||
|
|
||||||||
| // TestSignedCorim_TaggedFromCOSE_enhanced_validation tests that our enhanced | ||||||||
| // tag validation correctly identifies schema problems with outdated payloads | ||||||||
| func TestSignedCorim_TaggedFromCOSE_enhanced_validation(t *testing.T) { | ||||||||
|
||||||||
| // This is the same outdated payload as above but with explicit expectation of failure | ||||||||
| tv := []byte{0xd9, 0x01, 0xf4, 0xd9, 0x01, 0xf6, 0xd2, | ||||||||
| 0x84, 0x58, 0x59, 0xa4, 0x01, 0x26, 0x03, 0x74, | ||||||||
| 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, | ||||||||
| 0x69, 0x6f, 0x6e, 0x2f, 0x72, 0x69, 0x6d, 0x2b, | ||||||||
| 0x63, 0x62, 0x6f, 0x72, 0x04, 0x58, 0x24, 0x6d, | ||||||||
| 0x65, 0x72, 0x69, 0x61, 0x64, 0x6f, 0x63, 0x2e, | ||||||||
| 0x62, 0x72, 0x61, 0x6e, 0x64, 0x79, 0x62, 0x75, | ||||||||
| 0x63, 0x6b, 0x40, 0x62, 0x75, 0x63, 0x6b, 0x6c, | ||||||||
| 0x61, 0x6e, 0x64, 0x2e, 0x65, 0x78, 0x61, 0x6d, | ||||||||
| 0x70, 0x6c, 0x65, 0x08, 0x57, 0xa2, 0x00, 0xa1, | ||||||||
| 0x00, 0x69, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x4c, | ||||||||
| 0x74, 0x64, 0x2e, 0x01, 0xa1, 0x01, 0xc1, 0x1a, | ||||||||
| 0x5f, 0xad, 0x20, 0x56, 0xa0, 0x59, 0x01, 0xbb, | ||||||||
| 0xd9, 0x01, 0xf5, 0xa2, 0x00, 0x6d, 0x74, 0x65, | ||||||||
| 0x73, 0x74, 0x20, 0x63, 0x6f, 0x72, 0x69, 0x6d, | ||||||||
| 0x20, 0x69, 0x64, 0x01, 0x81, 0xd9, 0x01, 0xfa, | ||||||||
| 0x59, 0x01, 0xa0, 0xa4, 0x00, 0x65, 0x65, 0x6e, | ||||||||
| 0x2d, 0x47, 0x42, 0x01, 0xa1, 0x00, 0x50, 0x43, | ||||||||
| 0xbb, 0xe3, 0x7f, 0x2e, 0x61, 0x4b, 0x33, 0xae, | ||||||||
| 0xd3, 0x53, 0xcf, 0xf1, 0x42, 0x8b, 0x16, 0x02, | ||||||||
| 0x81, 0xa3, 0x00, 0x69, 0x41, 0x43, 0x4d, 0x45, | ||||||||
| 0x20, 0x4c, 0x74, 0x64, 0x2e, 0x01, 0xd8, 0x20, | ||||||||
| 0x74, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, | ||||||||
| 0x2f, 0x61, 0x63, 0x6d, 0x65, 0x2e, 0x65, 0x78, | ||||||||
| 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x02, 0x83, 0x00, | ||||||||
| 0x01, 0x02, 0x04, 0xa1, 0x00, 0x81, 0x82, 0xa1, | ||||||||
| 0x00, 0xa3, 0x00, 0xd9, 0x02, 0x58, 0x58, 0x20, | ||||||||
| 0x61, 0x63, 0x6d, 0x65, 0x2d, 0x69, 0x6d, 0x70, | ||||||||
| 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, | ||||||||
| 0x69, 0x6f, 0x6e, 0x2d, 0x69, 0x64, 0x2d, 0x30, | ||||||||
| 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, | ||||||||
| 0x01, 0x64, 0x41, 0x43, 0x4d, 0x45, 0x02, 0x6a, | ||||||||
| 0x52, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6e, 0x6e, | ||||||||
| 0x65, 0x72, 0x83, 0xa2, 0x00, 0xd9, 0x02, 0x58, | ||||||||
| 0xa3, 0x01, 0x62, 0x42, 0x4c, 0x04, 0x65, 0x32, | ||||||||
| 0x2e, 0x31, 0x2e, 0x30, 0x05, 0x58, 0x20, 0xac, | ||||||||
| 0xbb, 0x11, 0xc7, 0xe4, 0xda, 0x21, 0x72, 0x05, | ||||||||
| 0x52, 0x3c, 0xe4, 0xce, 0x1a, 0x24, 0x5a, 0xe1, | ||||||||
| 0xa2, 0x39, 0xae, 0x3c, 0x6b, 0xfd, 0x9e, 0x78, | ||||||||
| 0x71, 0xf7, 0xe5, 0xd8, 0xba, 0xe8, 0x6b, 0x01, | ||||||||
| 0xa1, 0x02, 0x81, 0x82, 0x01, 0x58, 0x20, 0x87, | ||||||||
| 0x42, 0x8f, 0xc5, 0x22, 0x80, 0x3d, 0x31, 0x06, | ||||||||
| 0x5e, 0x7b, 0xce, 0x3c, 0xf0, 0x3f, 0xe4, 0x75, | ||||||||
| 0x09, 0x66, 0x31, 0xe5, 0xe0, 0x7b, 0xbd, 0x7a, | ||||||||
| 0x0f, 0xde, 0x60, 0xc4, 0xcf, 0x25, 0xc7, 0xa2, | ||||||||
| 0x00, 0xd9, 0x02, 0x58, 0xa3, 0x01, 0x64, 0x50, | ||||||||
| 0x52, 0x6f, 0x54, 0x04, 0x65, 0x31, 0x2e, 0x33, | ||||||||
| 0x2e, 0x35, 0x05, 0x58, 0x20, 0xac, 0xbb, 0x11, | ||||||||
| 0xc7, 0xe4, 0xda, 0x21, 0x72, 0x05, 0x52, 0x3c, | ||||||||
| 0xe4, 0xce, 0x1a, 0x24, 0x5a, 0xe1, 0xa2, 0x39, | ||||||||
| 0xae, 0x3c, 0x6b, 0xfd, 0x9e, 0x78, 0x71, 0xf7, | ||||||||
| 0xe5, 0xd8, 0xba, 0xe8, 0x6b, 0x01, 0xa1, 0x02, | ||||||||
| 0x81, 0x82, 0x01, 0x58, 0x20, 0x02, 0x63, 0x82, | ||||||||
| 0x99, 0x89, 0xb6, 0xfd, 0x95, 0x4f, 0x72, 0xba, | ||||||||
| 0xaf, 0x2f, 0xc6, 0x4b, 0xc2, 0xe2, 0xf0, 0x1d, | ||||||||
| 0x69, 0x2d, 0x4d, 0xe7, 0x29, 0x86, 0xea, 0x80, | ||||||||
| 0x8f, 0x6e, 0x99, 0x81, 0x3f, 0xa2, 0x00, 0xd9, | ||||||||
| 0x02, 0x58, 0xa3, 0x01, 0x64, 0x41, 0x52, 0x6f, | ||||||||
| 0x54, 0x04, 0x65, 0x30, 0x2e, 0x31, 0x2e, 0x34, | ||||||||
| 0x05, 0x58, 0x20, 0xac, 0xbb, 0x11, 0xc7, 0xe4, | ||||||||
| 0xda, 0x21, 0x72, 0x05, 0x52, 0x3c, 0xe4, 0xce, | ||||||||
| 0x1a, 0x24, 0x5a, 0xe1, 0xa2, 0x39, 0xae, 0x3c, | ||||||||
| 0x6b, 0xfd, 0x9e, 0x78, 0x71, 0xf7, 0xe5, 0xd8, | ||||||||
| 0xba, 0xe8, 0x6b, 0x01, 0xa1, 0x02, 0x81, 0x82, | ||||||||
| 0x01, 0x58, 0x20, 0xa3, 0xa5, 0xe7, 0x15, 0xf0, | ||||||||
| 0xcc, 0x57, 0x4a, 0x73, 0xc3, 0xf9, 0xbe, 0xbb, | ||||||||
| 0x6b, 0xc2, 0x4f, 0x32, 0xff, 0xd5, 0xb6, 0x7b, | ||||||||
| 0x38, 0x72, 0x44, 0xc2, 0xc9, 0x09, 0xda, 0x77, | ||||||||
| 0x9a, 0x14, 0x78, 0x44, 0xde, 0xad, 0xbe, 0xef} | ||||||||
|
|
||||||||
| var actual SignedCorim | ||||||||
| err := actual.FromCOSE(tv) | ||||||||
|
|
||||||||
| // Enhanced validation should detect the outdated schema and return an error | ||||||||
| assert.NotNil(t, err) | ||||||||
| assert.Contains(t, err.Error(), "tag validation failed") | ||||||||
|
||||||||
| assert.NotNil(t, err) | |
| assert.Contains(t, err.Error(), "tag validation failed") | |
| assert.ErrorContains(t, err, "tag validation failed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case is supposed to test correct unmarshalling of a valid CoRIM. Rather than changing the expected error to be non-nil, the input needs to be amended with a valide signed CoRIM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIX