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
= "douglas";
21 static const char *password
= "42";
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
));
43 struct isds_ctx
*context
= NULL
;
46 INIT_TEST("basic authentication");
48 if (unsetenv("http_proxy")) {
49 ABORT_UNIT("Could not remove http_proxy variable from environment\n");
53 ABORT_UNIT("isds_init() failed\n");
55 context
= isds_ctx_create();
58 ABORT_UNIT("isds_ctx_create() failed\n");
62 const struct service_configuration services
[] = {
63 { SERVICE_DS_Dz_DummyOperation
, NULL
},
66 const struct arguments_basic_authentication server_arguments
= {
72 error
= start_server(&server_process
, &url
,
73 server_basic_authentication
, &server_arguments
, NULL
);
75 isds_ctx_free(&context
);
77 ABORT_UNIT(server_error
);
80 TEST("invalid credentials", test_login
, IE_NOT_LOGGED_IN
, context
,
81 url
, "7777777", "nbuusr1", NULL
, NULL
);
83 TEST("valid login", test_login
, IE_SUCCESS
, context
,
84 url
, username
, password
, NULL
, NULL
);
86 if (stop_server(server_process
)) {
87 isds_ctx_free(&context
);
89 ABORT_UNIT(server_error
);
97 error
= start_server(&server_process
, &url
,
98 server_out_of_order
, NULL
, NULL
);
100 isds_ctx_free(&context
);
102 ABORT_UNIT(server_error
);
105 TEST("log into out-of-order server", test_login
, IE_SOAP
, context
,
106 url
, username
, password
, NULL
, NULL
);
108 if (stop_server(server_process
)) {
109 isds_ctx_free(&context
);
111 ABORT_UNIT(server_error
);
118 isds_ctx_free(&context
);