summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-06-13 10:32:14 +0200
committerStephen Gallagher <sgallagh@redhat.com>2011-06-16 18:18:01 -0400
commit2ba3a41e392b5322a1da459800bf5dbdff26db41 (patch)
treeff415d1f1db272743f0f07513ea9915e3161220d
parentfde4194a9bc18932c6cfdc44e69a4376feb26208 (diff)
downloadsssd-2ba3a41e392b5322a1da459800bf5dbdff26db41.tar.gz
sssd-2ba3a41e392b5322a1da459800bf5dbdff26db41.tar.bz2
sssd-2ba3a41e392b5322a1da459800bf5dbdff26db41.zip
Test NULL server hostname in fail over tests
-rw-r--r--src/tests/fail_over-tests.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/tests/fail_over-tests.c b/src/tests/fail_over-tests.c
index 84016dd9..efd8756d 100644
--- a/src/tests/fail_over-tests.c
+++ b/src/tests/fail_over-tests.c
@@ -170,13 +170,15 @@ test_resolve_service_callback(struct tevent_req *req)
if (task->new_server_status >= 0)
fo_set_server_status(server, task->new_server_status);
- he = fo_get_server_hostent(server);
- fail_if(he == NULL, "%s: fo_get_server_hostent() returned NULL");
- for (i = 0; he->addr_list[i]; i++) {
- char buf[256];
-
- inet_ntop(he->family, he->addr_list[i]->ipaddr, buf, sizeof(buf));
- fail_if(strcmp(buf, "127.0.0.1") != 0 && strcmp(buf, "::1") != 0);
+ if (strcmp(fo_get_server_name(server), "unknown name")) {
+ he = fo_get_server_hostent(server);
+ fail_if(he == NULL, "%s: fo_get_server_hostent() returned NULL");
+ for (i = 0; he->addr_list[i]; i++) {
+ char buf[256];
+
+ inet_ntop(he->family, he->addr_list[i]->ipaddr, buf, sizeof(buf));
+ fail_if(strcmp(buf, "127.0.0.1") != 0 && strcmp(buf, "::1") != 0);
+ }
}
}
@@ -215,7 +217,7 @@ _get_request(struct test_ctx *test_ctx, struct fo_service *service,
START_TEST(test_fo_resolve_service)
{
struct test_ctx *ctx;
- struct fo_service *service[2];
+ struct fo_service *service[3];
ctx = setup_test();
fail_if(ctx == NULL);
@@ -225,6 +227,8 @@ START_TEST(test_fo_resolve_service)
fail_if(fo_new_service(ctx->fo_ctx, "ldap", &service[1]) != EOK);
+ fail_if(fo_new_service(ctx->fo_ctx, "ntp", &service[2]) != EOK);
+
/* Add servers. */
fail_if(fo_add_server(service[0], "localhost", 20, NULL) != EOK);
fail_if(fo_add_server(service[0], "127.0.0.1", 80, NULL) != EOK);
@@ -233,6 +237,8 @@ START_TEST(test_fo_resolve_service)
fail_if(fo_add_server(service[1], "127.0.0.1", 389, NULL) != EOK);
fail_if(fo_add_server(service[1], "127.0.0.1", 389, NULL) != EEXIST);
+ fail_if(fo_add_server(service[2], NULL, 123, NULL) != EOK);
+
/* Make requests. */
get_request(ctx, service[0], EOK, 20, PORT_WORKING, -1);
get_request(ctx, service[0], EOK, 20, -1, SERVER_NOT_WORKING);
@@ -244,6 +250,8 @@ START_TEST(test_fo_resolve_service)
get_request(ctx, service[1], EOK, 389, -1, SERVER_NOT_WORKING);
get_request(ctx, service[1], ENOENT, 0, -1, -1);
+ get_request(ctx, service[2], EOK, 123, -1, -1);
+
talloc_free(ctx);
}
END_TEST