Skip to content

Commit b4cdd57

Browse files
committed
Add OtaUpdateCmdDown with out of order fields test 1 e 2
1 parent 3a2a97b commit b4cdd57

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

extras/test/src/test_command_decode.cpp

+126
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,132 @@ SCENARIO("Test the decoding of command messages") {
278278
}
279279
}
280280

281+
/****************************************************************************/
282+
283+
WHEN("Decode the OtaUpdateCmdDown message with out of order fields 1")
284+
{
285+
CommandDown command;
286+
287+
/*
288+
DA 00010100 # tag(65792)
289+
84 # array(4)
290+
78 72 # text(141)
291+
68747470733A2F2F626F617264732D69
292+
6E742E6F6E69756472612E63632F7374
293+
6F726167652F6669726D776172652F76
294+
312F6466316561633963376264363334
295+
37336666666231313766393837333730
296+
33653465633935353933316532363766
297+
32363236326230393439626331366463
298+
3439 # "https://boards-int.oniudra.cc/storage/firmware/v1/df1eac9c7bd63473fffb117f9873703e4ec955931e267f26262b0949bc16dc49"
299+
50 # bytes(16)
300+
C73CB045F9C2434585AFFA36A307BFE7"\xC7<\xB0E\xF9\xC2CE\x85\xAF\xFA6\xA3\a\xBF\xE7"
301+
58 20 # bytes(32)
302+
00000000000000000000000000000000
303+
00000000000000000000000000000000# "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
304+
58 20 # bytes(32)
305+
DF1EAC9C7BD63473FFFB117F9873703E
306+
4EC955931E267F26262B0949BC16DC49# "\xDF\u001E\xAC\x9C{\xD64s\xFF\xFB\u0011\u007F\x98sp>N\xC9U\x93\u001E&\u007F&&+\tI\xBC\u0016\xDCI"
307+
308+
*/
309+
uint8_t const payload[] = { 0xda, 0x00, 0x01, 0x01, 0x00, 0x84, 0x78, 0x72,
310+
0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f,
311+
0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x2d, 0x69,
312+
0x6e, 0x74, 0x2e, 0x6f, 0x6e, 0x69, 0x75, 0x64,
313+
0x72, 0x61, 0x2e, 0x63, 0x63, 0x2f, 0x73, 0x74,
314+
0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x66, 0x69,
315+
0x72, 0x6d, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x76,
316+
0x31, 0x2f, 0x64, 0x66, 0x31, 0x65, 0x61, 0x63,
317+
0x39, 0x63, 0x37, 0x62, 0x64, 0x36, 0x33, 0x34,
318+
0x37, 0x33, 0x66, 0x66, 0x66, 0x62, 0x31, 0x31,
319+
0x37, 0x66, 0x39, 0x38, 0x37, 0x33, 0x37, 0x30,
320+
0x33, 0x65, 0x34, 0x65, 0x63, 0x39, 0x35, 0x35,
321+
0x39, 0x33, 0x31, 0x65, 0x32, 0x36, 0x37, 0x66,
322+
0x32, 0x36, 0x32, 0x36, 0x32, 0x62, 0x30, 0x39,
323+
0x34, 0x39, 0x62, 0x63, 0x31, 0x36, 0x64, 0x63,
324+
0x34, 0x39, 0x50, 0xc7, 0x3c, 0xb0, 0x45, 0xf9,
325+
0xc2, 0x43, 0x45, 0x85, 0xaf, 0xfa, 0x36, 0xa3,
326+
0x07, 0xbf, 0xe7, 0x58, 0x20, 0x00, 0x00, 0x00,
327+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
328+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
329+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
330+
0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x20, 0xdf,
331+
0x1e, 0xac, 0x9c, 0x7b, 0xd6, 0x34, 0x73, 0xff,
332+
0xfb, 0x11, 0x7f, 0x98, 0x73, 0x70, 0x3e, 0x4e,
333+
0xc9, 0x55, 0x93, 0x1e, 0x26, 0x7f, 0x26, 0x26,
334+
0x2b, 0x09, 0x49, 0xbc, 0x16, 0xdc, 0x49};
335+
size_t payload_length = sizeof(payload) / sizeof(uint8_t);
336+
CBORMessageDecoder decoder;
337+
Decoder::Status err = decoder.decode((Message*)&command, payload, payload_length);
338+
339+
THEN("The decode is successful") {
340+
REQUIRE(err == Decoder::Status::Error);
341+
}
342+
}
343+
344+
/****************************************************************************/
345+
346+
WHEN("Decode the OtaUpdateCmdDown message with out of order fields 2")
347+
{
348+
CommandDown command;
349+
350+
/*
351+
DA 00010100 # tag(65792)
352+
84 # array(4)
353+
50 # bytes(16)
354+
C73CB045F9C2434585AFFA36A307BFE7"\xC7<\xB0E\xF9\xC2CE\x85\xAF\xFA6\xA3\a\xBF\xE7"
355+
58 20 # bytes(32)
356+
00000000000000000000000000000000
357+
00000000000000000000000000000000# "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
358+
78 72 # text(141)
359+
68747470733A2F2F626F617264732D69
360+
6E742E6F6E69756472612E63632F7374
361+
6F726167652F6669726D776172652F76
362+
312F6466316561633963376264363334
363+
37336666666231313766393837333730
364+
33653465633935353933316532363766
365+
32363236326230393439626331366463
366+
3439 # "https://boards-int.oniudra.cc/storage/firmware/v1/df1eac9c7bd63473fffb117f9873703e4ec955931e267f26262b0949bc16dc49"
367+
58 20 # bytes(32)
368+
DF1EAC9C7BD63473FFFB117F9873703E
369+
4EC955931E267F26262B0949BC16DC49# "\xDF\u001E\xAC\x9C{\xD64s\xFF\xFB\u0011\u007F\x98sp>N\xC9U\x93\u001E&\u007F&&+\tI\xBC\u0016\xDCI"
370+
371+
*/
372+
uint8_t const payload[] = { 0xda, 0x00, 0x01, 0x01, 0x00, 0x84, 0x50, 0xc7,
373+
0x3c, 0xb0, 0x45, 0xf9, 0xc2, 0x43, 0x45, 0x85,
374+
0xaf, 0xfa, 0x36, 0xa3, 0x07, 0xbf, 0xe7, 0x58,
375+
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
376+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
377+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
378+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
379+
0x00, 0x78, 0x72, 0x68, 0x74, 0x74, 0x70, 0x73,
380+
0x3a, 0x2f, 0x2f, 0x62, 0x6f, 0x61, 0x72, 0x64,
381+
0x73, 0x2d, 0x69, 0x6e, 0x74, 0x2e, 0x6f, 0x6e,
382+
0x69, 0x75, 0x64, 0x72, 0x61, 0x2e, 0x63, 0x63,
383+
0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65,
384+
0x2f, 0x66, 0x69, 0x72, 0x6d, 0x77, 0x61, 0x72,
385+
0x65, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x66, 0x31,
386+
0x65, 0x61, 0x63, 0x39, 0x63, 0x37, 0x62, 0x64,
387+
0x36, 0x33, 0x34, 0x37, 0x33, 0x66, 0x66, 0x66,
388+
0x62, 0x31, 0x31, 0x37, 0x66, 0x39, 0x38, 0x37,
389+
0x33, 0x37, 0x30, 0x33, 0x65, 0x34, 0x65, 0x63,
390+
0x39, 0x35, 0x35, 0x39, 0x33, 0x31, 0x65, 0x32,
391+
0x36, 0x37, 0x66, 0x32, 0x36, 0x32, 0x36, 0x32,
392+
0x62, 0x30, 0x39, 0x34, 0x39, 0x62, 0x63, 0x31,
393+
0x36, 0x64, 0x63, 0x34, 0x39, 0x58, 0x20, 0xdf,
394+
0x1e, 0xac, 0x9c, 0x7b, 0xd6, 0x34, 0x73, 0xff,
395+
0xfb, 0x11, 0x7f, 0x98, 0x73, 0x70, 0x3e, 0x4e,
396+
0xc9, 0x55, 0x93, 0x1e, 0x26, 0x7f, 0x26, 0x26,
397+
0x2b, 0x09, 0x49, 0xbc, 0x16, 0xdc, 0x49};
398+
size_t payload_length = sizeof(payload) / sizeof(uint8_t);
399+
CBORMessageDecoder decoder;
400+
Decoder::Status err = decoder.decode((Message*)&command, payload, payload_length);
401+
402+
THEN("The decode is successful") {
403+
REQUIRE(err == Decoder::Status::Error);
404+
}
405+
}
406+
281407
/****************************************************************************/
282408

283409
WHEN("Decode the OtaBeginUp message")

0 commit comments

Comments
 (0)