14 static int test_load_message(struct isds_ctx
*context
,
15 const struct test
*test
) {
20 struct isds_message
*message
= NULL
;
24 if (test_mmap_file(test
->file
, &fd
, &buffer
, &length
))
25 FAIL_TEST("Could not load test data from `%s' file", test
->file
);
27 if (!test
->should_pass
)
28 /* Do not log expected XML parser failures */
29 isds_set_logging(ILF_XML
, ILL_NONE
);
31 isds_set_logging(ILF_ALL
, ILL_WARNING
);
33 err
= isds_load_message(context
, test
->type
, buffer
, length
,
34 &message
, BUFFER_DONT_STORE
);
35 isds_message_free(&message
);
36 test_munmap_file(fd
, buffer
, length
);
38 if (test
->should_pass
) {
40 FAIL_TEST("Message loading should succeded: got=%s",
44 FAIL_TEST("Message loading should fail: got=%s",
52 static int test_load_delivery(struct isds_ctx
*context
,
53 const struct test
*test
) {
58 struct isds_message
*message
= NULL
;
62 if (test_mmap_file(test
->file
, &fd
, &buffer
, &length
))
63 FAIL_TEST("Could not load test data from `%s' file", test
->file
);
65 err
= isds_load_delivery_info(context
, test
->type
, buffer
, length
,
66 &message
, BUFFER_DONT_STORE
);
67 isds_message_free(&message
);
68 test_munmap_file(fd
, buffer
, length
);
70 if (test
->should_pass
) {
72 FAIL_TEST("Message loading should succeded: got=%s",
76 FAIL_TEST("Message loading should fail: got=%s",
85 struct test messages
[] = {
87 .name
= "unsigned incoming message",
88 .file
= SRCDIR
"/server/messages/received_message-151916.xml",
89 .type
= RAWTYPE_INCOMING_MESSAGE
,
93 .name
= "plain signed incoming message",
95 "/server/messages/received_signed_message-330141.xml",
96 .type
= RAWTYPE_PLAIN_SIGNED_INCOMING_MESSAGE
,
100 .name
= "CMS signed incoming message",
101 .file
= SRCDIR
"/server/messages/received_message-330141.zfo",
102 .type
= RAWTYPE_CMS_SIGNED_INCOMING_MESSAGE
,
106 .name
= "plain signed sent message",
107 .file
= SRCDIR
"/server/messages/sent_message-206720.xml",
108 .type
= RAWTYPE_PLAIN_SIGNED_OUTGOING_MESSAGE
,
112 .name
= "CMS signed sent message",
113 .file
= SRCDIR
"/server/messages/signed_sent_message-151874.zfo",
114 .type
= RAWTYPE_CMS_SIGNED_OUTGOING_MESSAGE
,
118 .name
= "plain signed sent message with XML documents",
119 .file
= SRCDIR
"/server/messages/signed_sent_xml_message-376701.xml",
120 .type
= RAWTYPE_PLAIN_SIGNED_OUTGOING_MESSAGE
,
124 .name
= "text file is not an incoming message",
126 .type
= RAWTYPE_INCOMING_MESSAGE
,
134 struct test deliveries
[] = {
136 .name
= "unsigned delivery info",
137 .file
= SRCDIR
"/server/messages/delivery_info-316590.xml",
138 .type
= RAWTYPE_DELIVERYINFO
,
142 .name
= "plain signed delivery info",
143 .file
= SRCDIR
"/server/messages/signed_delivered-DD_170272.xml",
144 .type
= RAWTYPE_PLAIN_SIGNED_DELIVERYINFO
,
148 .name
= "CMS signed delivery info",
149 .file
= SRCDIR
"/server/messages/signed_delivered-DD_170272.zfo",
150 .type
= RAWTYPE_CMS_SIGNED_DELIVERYINFO
,
154 .name
= "text file is not a delivery info",
156 .type
= RAWTYPE_INCOMING_MESSAGE
,
163 struct isds_ctx
*context
= NULL
;
165 INIT_TEST("load_raw");
168 ABORT_UNIT("init_isds() failed");
170 context
= isds_ctx_create();
172 ABORT_UNIT("isds_ctx_create() failed");
174 for (int i
= 0; messages
[i
].name
; i
++)
175 TEST(messages
[i
].name
, test_load_message
, context
, &messages
[i
]);
176 for (int i
= 0; deliveries
[i
].name
; i
++)
177 TEST(deliveries
[i
].name
, test_load_delivery
, context
, &deliveries
[i
]);
179 isds_ctx_free(&context
);