|
@@ -31,6 +31,7 @@
|
|
|
#include <exceptions/exceptions.h>
|
|
|
|
|
|
#include <dns/tests/unittest_util.h>
|
|
|
+#include <dns/rcode.h>
|
|
|
|
|
|
#include <dns/buffer.h>
|
|
|
#include <dns/message.h>
|
|
@@ -451,7 +452,8 @@ protected:
|
|
|
size_t length = 0)
|
|
|
{}
|
|
|
|
|
|
- void resume(const bool) { // in our test this shouldn't be called
|
|
|
+ void resume(const bool) {
|
|
|
+ // should never be called in our tests
|
|
|
}
|
|
|
|
|
|
DNSServer* clone() {
|
|
@@ -661,7 +663,7 @@ TEST_F(ASIOLinkTest, recursiveSetupV6) {
|
|
|
// a routine that can do this with variable address family, address, and
|
|
|
// port, and with the various callbacks defined in such a way as to ensure
|
|
|
// full code coverage including error cases.
|
|
|
-TEST_F(ASIOLinkTest, recursiveSend) {
|
|
|
+TEST_F(ASIOLinkTest, forwarderSend) {
|
|
|
setDNSService(true, false);
|
|
|
|
|
|
// Note: We use the test prot plus one to ensure we aren't binding
|
|
@@ -750,6 +752,56 @@ TEST_F(ASIOLinkTest, recursiveTimeout) {
|
|
|
EXPECT_EQ(3, num);
|
|
|
}
|
|
|
|
|
|
+// as mentioned above, we need a more better framework for this,
|
|
|
+// in addition to that, this sends out queries into the world
|
|
|
+// (which we should catch somehow and fake replies for)
|
|
|
+// for the skeleton code, it shouldn't be too much of a problem
|
|
|
+TEST_F(ASIOLinkTest, recursiveSendOk) {
|
|
|
+ setDNSService(true, false);
|
|
|
+ bool done;
|
|
|
+
|
|
|
+ MockServerStop server(*io_service_, &done);
|
|
|
+ vector<pair<string, uint16_t> > empty_vector;
|
|
|
+ RecursiveQuery rq(*dns_service_, empty_vector, 10000, 0);
|
|
|
+
|
|
|
+ Question q(Name("www.isc.org"), RRClass::IN(), RRType::A());
|
|
|
+ OutputBufferPtr buffer(new OutputBuffer(0));
|
|
|
+ MessagePtr answer(new Message(Message::RENDER));
|
|
|
+ rq.sendQuery(q, answer, buffer, &server);
|
|
|
+ io_service_->run();
|
|
|
+
|
|
|
+ // Check that the answer we got matches the one we wanted
|
|
|
+ EXPECT_EQ(Rcode::NOERROR(), answer->getRcode());
|
|
|
+ ASSERT_EQ(1, answer->getRRCount(Message::SECTION_ANSWER));
|
|
|
+ RRsetPtr a = *answer->beginSection(Message::SECTION_ANSWER);
|
|
|
+ EXPECT_EQ(q.getName(), a->getName());
|
|
|
+ EXPECT_EQ(q.getType(), a->getType());
|
|
|
+ EXPECT_EQ(q.getClass(), a->getClass());
|
|
|
+ EXPECT_EQ(1, a->getRdataCount());
|
|
|
+}
|
|
|
+
|
|
|
+// see comments at previous test
|
|
|
+TEST_F(ASIOLinkTest, recursiveSendNXDOMAIN) {
|
|
|
+ setDNSService(true, false);
|
|
|
+ bool done;
|
|
|
+
|
|
|
+ MockServerStop server(*io_service_, &done);
|
|
|
+ vector<pair<string, uint16_t> > empty_vector;
|
|
|
+ RecursiveQuery rq(*dns_service_, empty_vector, 10000, 0);
|
|
|
+
|
|
|
+ Question q(Name("wwwdoesnotexist.isc.org"), RRClass::IN(), RRType::A());
|
|
|
+ OutputBufferPtr buffer(new OutputBuffer(0));
|
|
|
+ MessagePtr answer(new Message(Message::RENDER));
|
|
|
+ rq.sendQuery(q, answer, buffer, &server);
|
|
|
+ io_service_->run();
|
|
|
+
|
|
|
+ // Check that the answer we got matches the one we wanted
|
|
|
+ EXPECT_EQ(Rcode::NXDOMAIN(), answer->getRcode());
|
|
|
+ EXPECT_EQ(0, answer->getRRCount(Message::SECTION_ANSWER));
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// This fixture is for testing IntervalTimer. Some callback functors are
|
|
|
// registered as callback function of the timer to test if they are called
|
|
|
// or not.
|