5 static int test_login(const isds_error error
, struct isds_ctx
*context
,
6 const char *url
, const char *username
, const char *password
,
7 const struct isds_pki_credentials
*pki_credentials
,
8 struct isds_otp
*otp
) {
11 err
= isds_login(context
, url
, username
, password
, pki_credentials
, otp
);
13 FAIL_TEST("Wrong return code: expected=%s, returned=%s (%s)",
14 isds_strerror(error
), isds_strerror(err
),
15 isds_long_message(context
));
21 static int test_login2(const isds_error error1
, const isds_error error2
,
22 struct isds_ctx
*context
,
23 const char *url
, const char *username
, const char *password
,
24 const struct isds_pki_credentials
*pki_credentials
,
25 struct isds_otp
*otp
) {
28 isds_login(context
, url
, username
, password
, pki_credentials
, otp
);
29 if (err
!= error1
&& err
!= error2
)
30 FAIL_TEST("Wrong return code: must_differ=%s, must_differ=%s, "
32 isds_strerror(error1
), isds_strerror(error2
),
33 isds_strerror(err
), isds_long_message(context
));
40 int main(int argc
, char **argv
) {
43 struct isds_ctx
*context
= NULL
;
44 const char *url
= isds_testing_locator
;
47 ABORT_UNIT("isds_init() failed\n");
48 context
= isds_ctx_create();
50 ABORT_UNIT("isds_ctx_create() failed\n");
53 TEST("invalid context", test_login
, IE_INVALID_CONTEXT
, NULL
,
54 url
, username(), password(), NULL
, NULL
);
55 TEST("NULL url with invalid credentials", test_login
, IE_NOT_LOGGED_IN
,
56 context
, NULL
, username(), password(), NULL
, NULL
);
57 TEST("NULL username", test_login
, IE_INVAL
, context
,
58 url
, NULL
, password(), NULL
, NULL
);
59 TEST("NULL password", test_login
, IE_INVAL
, context
,
60 url
, username(), NULL
, NULL
, NULL
);
62 TEST("invalid URL", test_login
, IE_NETWORK
, context
,
63 "invalid://", username(), password(), NULL
, NULL
);
64 /* Direct connection fails on local resolution, connection trough proxy
65 * failes on HTTP code */
66 TEST("unresolvable host name", test_login2
, IE_NETWORK
, IE_HTTP
, context
,
67 "http://unresolvable.example.com/", username(), password(),
70 TEST("invalid credentials", test_login
, IE_NOT_LOGGED_IN
, context
,
71 url
, "7777777", "nbuusr1", NULL
, NULL
);
73 TEST("valid login", test_login
, IE_SUCCESS
, context
,
74 url
, username(), password(), NULL
, NULL
);
76 isds_ctx_free(&context
);