i18n: Update POT template
[libisds.git] / test / login.c
blob2f8147dbf86aa8a3c0e1c05c80e7336b7e45b274
1 #include "test.h"
2 #include "isds.h"
4 static int test_login(const isds_error error, struct isds_ctx *context,
5 const char *url, const char *username, const char *password,
6 const char *certificate, const char *key) {
8 if (error !=
9 isds_login(context, url, username, password, certificate, key))
10 FAIL_TEST("Wrong return code");
12 isds_logout(context);
13 PASS_TEST;
16 static int test_login2(const isds_error error1, const isds_error error2,
17 struct isds_ctx *context,
18 const char *url, const char *username, const char *password,
19 const char *certificate, const char *key) {
21 isds_error err =
22 isds_login(context, url, username, password, certificate, key);
23 if (err != error1 && err != error2)
24 FAIL_TEST("Wrong return code");
26 isds_logout(context);
27 PASS_TEST;
31 int main(int argc, char **argv) {
32 INIT_TEST("login");
34 struct isds_ctx *context = NULL;
35 char url[] = "https://www.czebox.cz/DS/";
36 char username[] = "5s59sd";
37 char password[] = "Ac123456";
39 if (isds_init())
40 ABORT_UNIT("isds_init() failed\n");
41 context = isds_ctx_create();
42 if (!context)
43 ABORT_UNIT("isds_ctx_create() failed\n");
46 TEST("invalid context", test_login, IE_INVALID_CONTEXT, NULL,
47 url, username, password, NULL, NULL);
48 TEST("NULL url", test_login, IE_INVAL, context,
49 NULL, username, password, NULL, NULL);
50 TEST("NULL username", test_login, IE_INVAL, context,
51 url, NULL, password, NULL, NULL);
52 TEST("NULL password", test_login, IE_INVAL, context,
53 url, username, NULL, NULL, NULL);
55 TEST("invalid URL", test_login, IE_NETWORK, context,
56 "invalid://", username, password, NULL, NULL);
57 /* Direct connection fails on local resolution, connection trough proxy
58 * failes on HTTP code */
59 TEST("unresolvable host name", test_login2, IE_NETWORK, IE_SOAP, context,
60 "http://unresolvable.example.com/", username, password,
61 NULL, NULL);
63 TEST("invalid credentials", test_login, IE_NOT_LOGGED_IN, context,
64 url, "7777777", "nbuusr1", NULL, NULL);
66 TEST("valid login", test_login, IE_SUCCESS, context,
67 url, username, password, NULL, NULL);
69 isds_ctx_free(&context);
70 isds_cleanup();
72 SUM_TEST();