2 #define _POSIX_SOURCE /* For getaddrinfo(3) */
6 #define _BSD_SOURCE /* For NI_MAXHOST up to glibc-2.19 */
8 #ifndef _DEFAULT_SOURCE
9 #define _DEFAULT_SOURCE /* For NI_MAXHOST since glibc-2.20 */
13 #define _XOPEN_SOURCE 600 /* For unsetenv(3) */
20 static const char *username
= "Doug1as$";
21 static const char *password
= "42aA#bc8";
24 static int test_login(const isds_error error
, struct isds_ctx
*context
,
25 const char *url
, const char *username
, const char *password
,
26 const struct isds_pki_credentials
*pki_credentials
,
27 struct isds_otp
*otp
) {
30 err
= isds_login(context
, url
, username
, password
, pki_credentials
, otp
);
32 FAIL_TEST("Wrong return code: expected=%s, returned=%s (%s)",
33 isds_strerror(error
), isds_strerror(err
),
34 isds_long_message(context
));
39 static int test_isds_delete_message_from_storage(const isds_error error
,
40 struct isds_ctx
*context
, const char *message_id
, _Bool incoming
) {
43 err
= isds_delete_message_from_storage(context
, message_id
, incoming
);
45 FAIL_TEST("Wrong return code: expected=%s, returned=%s (%s)",
46 isds_strerror(error
), isds_strerror(err
),
47 isds_long_message(context
));
55 struct isds_ctx
*context
= NULL
;
58 INIT_TEST("isds_delete_message_from_storage");
60 if (unsetenv("http_proxy")) {
61 ABORT_UNIT("Could not remove http_proxy variable from environment\n");
65 ABORT_UNIT("isds_init() failed\n");
67 context
= isds_ctx_create();
70 ABORT_UNIT("isds_ctx_create() failed\n");
74 const struct arguments_DS_Dx_EraseMessage service_arguments
= {
75 .message_id
= "1234567",
78 const struct service_configuration services
[] = {
79 { SERVICE_DS_Dz_DummyOperation
, NULL
},
80 { SERVICE_DS_Dx_EraseMessage
, &service_arguments
},
83 const struct arguments_basic_authentication server_arguments
= {
89 error
= start_server(&server_process
, &url
,
90 server_basic_authentication
, &server_arguments
, NULL
);
92 isds_ctx_free(&context
);
94 ABORT_UNIT(server_error
);
97 TEST("prior logging in", test_isds_delete_message_from_storage
,
98 IE_CONNECTION_CLOSED
, context
, "1234567", 1);
99 TEST("login", test_login
, IE_SUCCESS
,
100 context
, url
, username
, password
, NULL
, NULL
);
101 TEST("bad message ID", test_isds_delete_message_from_storage
, IE_INVAL
,
102 context
, "1000000", 1);
103 TEST("bad direction", test_isds_delete_message_from_storage
, IE_INVAL
,
104 context
, "1234567", 0);
105 TEST("good ID and direction", test_isds_delete_message_from_storage
,
106 IE_SUCCESS
, context
, "1234567", 1);
108 if (stop_server(server_process
)) {
109 isds_ctx_free(&context
);
111 ABORT_UNIT(server_error
);
119 isds_logout(context
);
120 isds_ctx_free(&context
);