Skip to content

Commit b6171c1

Browse files
committed
Add OtaUpdateCmdDown with corrupted fields test 1 e 2
1 parent b4cdd57 commit b6171c1

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

extras/test/src/test_command_decode.cpp

+116
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,122 @@ SCENARIO("Test the decoding of command messages") {
404404
}
405405
}
406406

407+
/****************************************************************************/
408+
409+
WHEN("Decode the OtaUpdateCmdDown message with corrupted fields 1")
410+
{
411+
CommandDown command;
412+
413+
/*
414+
DA 00010100 # tag(65792)
415+
84 # array(4)
416+
50 # bytes(16)
417+
C73CB045F9C2434585AFFA36A307BFE7"\xC7<\xB0E\xF9\xC2CE\x85\xAF\xFA6\xA3\a\xBF\xE7"
418+
78 72 # text(141)
419+
68747470733A2F2F626F617264732D69
420+
6E742E6F6E69756472612E63632F7374
421+
6F726167652F6669726D776172652F76
422+
312F6466316561633963376264363334
423+
37336666666231313766393837333730
424+
33653465633935353933316532363766
425+
32363236326230393439626331366463
426+
3439 # "https://boards-int.oniudra.cc/storage/firmware/v1/df1eac9c7bd63473fffb117f9873703e4ec955931e267f26262b0949bc16dc49"
427+
1A 65DCB821 # unsigned(1708963873)
428+
58 20 # bytes(32)
429+
DF1EAC9C7BD63473FFFB117F9873703E
430+
4EC955931E267F26262B0949BC16DC49# "\xDF\u001E\xAC\x9C{\xD64s\xFF\xFB\u0011\u007F\x98sp>N\xC9U\x93\u001E&\u007F&&+\tI\xBC\u0016\xDCI"
431+
432+
*/
433+
uint8_t const payload[] = { 0xda, 0x00, 0x01, 0x01, 0x00, 0x84, 0x50, 0xc7,
434+
0x3c, 0xb0, 0x45, 0xf9, 0xc2, 0x43, 0x45, 0x85,
435+
0xaf, 0xfa, 0x36, 0xa3, 0x07, 0xbf, 0xe7, 0x78,
436+
0x72, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f,
437+
0x2f, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x2d,
438+
0x69, 0x6e, 0x74, 0x2e, 0x6f, 0x6e, 0x69, 0x75,
439+
0x64, 0x72, 0x61, 0x2e, 0x63, 0x63, 0x2f, 0x73,
440+
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x66,
441+
0x69, 0x72, 0x6d, 0x77, 0x61, 0x72, 0x65, 0x2f,
442+
0x76, 0x31, 0x2f, 0x64, 0x66, 0x31, 0x65, 0x61,
443+
0x63, 0x39, 0x63, 0x37, 0x62, 0x64, 0x36, 0x33,
444+
0x34, 0x37, 0x33, 0x66, 0x66, 0x66, 0x62, 0x31,
445+
0x31, 0x37, 0x66, 0x39, 0x38, 0x37, 0x33, 0x37,
446+
0x30, 0x33, 0x65, 0x34, 0x65, 0x63, 0x39, 0x35,
447+
0x35, 0x39, 0x33, 0x31, 0x65, 0x32, 0x36, 0x37,
448+
0x66, 0x32, 0x36, 0x32, 0x36, 0x32, 0x62, 0x30,
449+
0x39, 0x34, 0x39, 0x62, 0x63, 0x31, 0x36, 0x64,
450+
0x63, 0x34, 0x39, 0x1A, 0x65, 0xDC, 0xB8, 0x21,
451+
0x58, 0x20, 0xdf, 0x1e, 0xac, 0x9c, 0x7b, 0xd6,
452+
0x34, 0x73, 0xff, 0xfb, 0x11, 0x7f, 0x98, 0x73,
453+
0x70, 0x3e, 0x4e, 0xc9, 0x55, 0x93, 0x1e, 0x26,
454+
0x7f, 0x26, 0x26, 0x2b, 0x09, 0x49, 0xbc, 0x16,
455+
0xdc, 0x49};
456+
size_t payload_length = sizeof(payload) / sizeof(uint8_t);
457+
CBORMessageDecoder decoder;
458+
Decoder::Status err = decoder.decode((Message*)&command, payload, payload_length);
459+
460+
THEN("The decode is successful") {
461+
REQUIRE(err == Decoder::Status::Error);
462+
}
463+
}
464+
465+
/****************************************************************************/
466+
467+
WHEN("Decode the OtaUpdateCmdDown message with corrupted fields 2")
468+
{
469+
CommandDown command;
470+
471+
/*
472+
DA 00010100 # tag(65792)
473+
84 # array(4)
474+
50 # bytes(16)
475+
C73CB045F9C2434585AFFA36A307BFE7"\xC7<\xB0E\xF9\xC2CE\x85\xAF\xFA6\xA3\a\xBF\xE7"
476+
78 72 # text(141)
477+
68747470733A2F2F626F617264732D69
478+
6E742E6F6E69756472612E63632F7374
479+
6F726167652F6669726D776172652F76
480+
312F6466316561633963376264363334
481+
37336666666231313766393837333730
482+
33653465633935353933316532363766
483+
32363236326230393439626331366463
484+
3439 # "https://boards-int.oniudra.cc/storage/firmware/v1/df1eac9c7bd63473fffb117f9873703e4ec955931e267f26262b0949bc16dc49"
485+
58 20 # bytes(32)
486+
DF1EAC9C7BD63473FFFB117F9873703E
487+
4EC955931E267F26262B0949BC16DC49# "\xDF\u001E\xAC\x9C{\xD64s\xFF\xFB\u0011\u007F\x98sp>N\xC9U\x93\u001E&\u007F&&+\tI\xBC\u0016\xDCI"
488+
1A 65DCB821 # unsigned(1708963873)
489+
490+
*/
491+
uint8_t const payload[] = { 0xda, 0x00, 0x01, 0x01, 0x00, 0x84, 0x50, 0xc7,
492+
0x3c, 0xb0, 0x45, 0xf9, 0xc2, 0x43, 0x45, 0x85,
493+
0xaf, 0xfa, 0x36, 0xa3, 0x07, 0xbf, 0xe7, 0x78,
494+
0x72, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f,
495+
0x2f, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x2d,
496+
0x69, 0x6e, 0x74, 0x2e, 0x6f, 0x6e, 0x69, 0x75,
497+
0x64, 0x72, 0x61, 0x2e, 0x63, 0x63, 0x2f, 0x73,
498+
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x66,
499+
0x69, 0x72, 0x6d, 0x77, 0x61, 0x72, 0x65, 0x2f,
500+
0x76, 0x31, 0x2f, 0x64, 0x66, 0x31, 0x65, 0x61,
501+
0x63, 0x39, 0x63, 0x37, 0x62, 0x64, 0x36, 0x33,
502+
0x34, 0x37, 0x33, 0x66, 0x66, 0x66, 0x62, 0x31,
503+
0x31, 0x37, 0x66, 0x39, 0x38, 0x37, 0x33, 0x37,
504+
0x30, 0x33, 0x65, 0x34, 0x65, 0x63, 0x39, 0x35,
505+
0x35, 0x39, 0x33, 0x31, 0x65, 0x32, 0x36, 0x37,
506+
0x66, 0x32, 0x36, 0x32, 0x36, 0x32, 0x62, 0x30,
507+
0x39, 0x34, 0x39, 0x62, 0x63, 0x31, 0x36, 0x64,
508+
0x63, 0x34, 0x39, 0x58, 0x20, 0xdf, 0x1e, 0xac,
509+
0x9c, 0x7b, 0xd6, 0x34, 0x73, 0xff, 0xfb, 0x11,
510+
0x7f, 0x98, 0x73, 0x70, 0x3e, 0x4e, 0xc9, 0x55,
511+
0x93, 0x1e, 0x26, 0x7f, 0x26, 0x26, 0x2b, 0x09,
512+
0x49, 0xbc, 0x16, 0xdc, 0x49, 0x1A, 0x65, 0xDC,
513+
0xB8, 0x21};
514+
size_t payload_length = sizeof(payload) / sizeof(uint8_t);
515+
CBORMessageDecoder decoder;
516+
Decoder::Status err = decoder.decode((Message*)&command, payload, payload_length);
517+
518+
THEN("The decode is successful") {
519+
REQUIRE(err == Decoder::Status::Error);
520+
}
521+
}
522+
407523
/****************************************************************************/
408524

409525
WHEN("Decode the OtaBeginUp message")

0 commit comments

Comments
 (0)