I created a semi-manual test case for QA to exercise this issue a while
ago and thought it would be nice to have it upstream, too.

This patch depends on the resolver TTL patches.
From 57261b8e77244dd35a2a81ed529cf94072175632 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <[email protected]>
Date: Mon, 13 Jun 2011 10:32:14 +0200
Subject: [PATCH] Test NULL server hostname in fail over tests

---
 src/tests/fail_over-tests.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/tests/fail_over-tests.c b/src/tests/fail_over-tests.c
index 84016dd..efd8756 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
-- 
1.7.5.2

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
sssd-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to