Browse Source

[805] Make the resolver tests pass

The same problem as with the auth ones - the socket requestor needs to
be faked.
Michal 'vorner' Vaner 13 years ago
parent
commit
0524cba147
1 changed files with 19 additions and 2 deletions
  1. 19 2
      src/bin/resolver/tests/resolver_config_unittest.cc

+ 19 - 2
src/bin/resolver/tests/resolver_config_unittest.cc

@@ -39,6 +39,7 @@
 #include <dns/tests/unittest_util.h>
 #include <testutils/srv_test.h>
 #include <testutils/portconfig.h>
+#include <testutils/socket_request.h>
 
 using namespace std;
 using boost::scoped_ptr;
@@ -52,7 +53,7 @@ using namespace isc::server_common;
 using isc::UnitTestUtil;
 
 namespace {
-class ResolverConfig : public ::testing::Test {
+class ResolverConfig : public TestSocketRequestor {
 protected:
     IOService ios;
     DNSService dnss;
@@ -61,7 +62,10 @@ protected:
     scoped_ptr<const IOMessage> query_message;
     scoped_ptr<const Client> client;
     scoped_ptr<const RequestContext> request;
-    ResolverConfig() : dnss(ios, NULL, NULL, NULL) {
+    ResolverConfig() :
+        TestSocketRequestor(dnss, address_store_, 53210),
+        dnss(ios, NULL, NULL, NULL)
+    {
         server.setDNSService(dnss);
         server.setConfigured();
     }
@@ -77,6 +81,7 @@ protected:
         return (*request);
     }
     void invalidTest(const string &JSON, const string& name);
+    isc::server_common::portconfig::AddressList address_store_;
 };
 
 TEST_F(ResolverConfig, forwardAddresses) {
@@ -188,6 +193,18 @@ TEST_F(ResolverConfig, invalidForwardAddresses) {
 // Try setting the addresses directly
 TEST_F(ResolverConfig, listenAddresses) {
     isc::testutils::portconfig::listenAddresses(server);
+    // Check it requests the correct addresses
+    const char* tokens[] = {
+        "TCP:127.0.0.1:53210:1",
+        "UDP:127.0.0.1:53210:2",
+        "TCP:::1:53210:3",
+        "UDP:::1:53210:4",
+        NULL
+    };
+    checkTokens(tokens, given_tokens_, "Given tokens");
+    // It returns back to empty set of addresses afterwards, so
+    // they should be released
+    checkTokens(tokens, released_tokens_, "Released tokens");
 }
 
 // Try setting some addresses and a rollback