-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
Need to add an extensive CBOR decoding testing for the CatalystSignedDocument
structure, covering all different scenarios.
Description
Test flow:
- Generate a CBOR bytes using
minicbor
to be aCatalystSignedDocument
. - Trying to decode
CatalystSignedDocument
. - Comparing
CatalystSignedDocument
fields as they are as expected.
Blocked by
New CoseSignBuilder
#332
Implementation notes
Each separate test case make as a TestCase
object
type PostCheck = dyn Fn(&CatalystSignedDocument) -> bool;
struct TestCase {
name: &'static str,
bytes_gen: Box<dyn Fn() -> Vec<u8>>,
// If the provided bytes can be even decoded without error (valid COSE or not).
// If set to `false` all further checks will not even happen.
can_decode: bool,
// If the decoded doc is a valid `CatalystSignedDocument`, underlying problem report is empty.
valid_doc: bool,
post_checks: Option<Box<PostCheck>>,
}
and place into the test_cases
variable of the catalyst_signed_doc_decoding_test
test itself
let test_cases = [
decoding_empty_bytes_case(),
signed_doc_with_all_fields_case(),
...
];
Cases
Valid
- Signed document with all possible metadata correct metadata fields. (@saibatizoku)
- Minimally valid document cose tagged encoded (@saibatizoku).
- Minimally valid document cose untagged encoded (@saibatizoku).
- During non-strict decoding, metadata fields placed in the wrong order (@Mr-Leshiy ).
- Old
type
field cbor formattype = uuidv4
(@saibatizoku). - New
type
field cbor formattype = [1* uuidv4]
(@saibatizoku). -
content_encoding
field, allow upper and lower case key value:"content-encoding"
,"Content-Encoding"
. (@apskhem) - Provided
category_id
field should be processed asparameters
(alias). (@apskhem) - Provided
brand_id
field should be processed asparameters
(alias). (@apskhem) - Provided
campaign_id
field should be processed asparameters
(alias). (@apskhem) - Missing document content, content could encoded as cbor
null
or it could be an emptybstr
. (@saibatizoku).
Invalid
-
Wrong COSE sign tag value (not a
98
cose tag), should be non decodable object (can_decode = false
). (@apskhem ) -
During strict decoding, metadata fields placed in the wrong order (@Mr-Leshiy ).
-
Invalid
type
field format (random bytes). (@apskhem) -
Missing
type
field. (@apskhem) -
Invalid
id
field format (random bytes). (@apskhem) -
Missing
id
field. (@apskhem) -
Invalid
ver
field format (random bytes). (@apskhem) -
Missing
ver
field. (@apskhem) -
Missing
content_type
field. (@apskhem) -
Invalid
content_type
field format (random bytes). (@apskhem) -
Invalid
content_type
field, unsupported type. (@apskhem) -
Invalid
content_encoding
field format (ranbdom bytes). (@apskhem) -
Invalid
content_encoding
field, unsupported type. (@apskhem) -
Invalid
ref
field format (random bytes). (@apskhem) -
Invalid
template
field format (random bytes). (@apskhem) -
Invalid
reply
field format (random bytes). (@apskhem) -
Invalid
section
field format (random bytes). (@apskhem) -
Invalid
collabs
field format (random bytes). (@apskhem) -
Invalid
parameters
field format (random bytes). (@apskhem) -
Multiple definitions of
campaign_id
,brand_id
,category_id
andparameters
at once are invalid. (@apskhem) -
Provided some extra non supported metadata field (@saibatizoku).
-
Invalid signature
kid
field format (random bytes). (@apskhem) -
Invalid signature
kid
field in the id form instead of uri formCatalystId::as_id
(@saibatizoku). -
Provided some extra non supported protected header for the cose signature (@saibatizoku).
Metadata
Metadata
Assignees
Labels
Type
Projects
Status