Browse Source

built normal requests within the test code and avoid having a separate data file.

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac221@2303 e5f2f494-b856-4b98-b285-d166d9295462
JINMEI Tatuya 15 years ago
parent
commit
f525788126

+ 20 - 5
src/bin/auth/tests/auth_srv_unittest.cc

@@ -75,6 +75,8 @@ protected:
     vector<uint8_t> data;
 
     void createDataFromFile(const char* const datafile);
+    void createRequest(const Opcode& opcode, const Name& request_name,
+                       const RRClass& rrclass, const RRType& rrtype);
 };
 
 // These are flags to indicate whether the corresponding flag bit of the
@@ -101,6 +103,21 @@ AuthSrvTest::createDataFromFile(const char* const datafile) {
 }
 
 void
+AuthSrvTest::createRequest(const Opcode& opcode, const Name& request_name,
+                           const RRClass& rrclass, const RRType& rrtype) 
+{
+    request_message.setOpcode(opcode);
+    request_message.addQuestion(Question(request_name, rrclass, rrtype));
+    request_message.toWire(request_renderer);
+
+    delete io_message;
+    endpoint = IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.1"), 5300);
+    io_message = new IOMessage(request_renderer.getData(),
+                               request_renderer.getLength(),
+                               IOSocket::getDummyUDPSocket(), *endpoint);
+}
+
+void
 headerCheck(const Message& message, const qid_t qid, const Rcode& rcode,
             const uint16_t opcodeval, const unsigned int flags,
             const unsigned int qdcount,
@@ -246,15 +263,13 @@ TEST_F(AuthSrvTest, ednsBadVers) {
 
 // notify-in teset.
 TEST_F(AuthSrvTest, notifyInTest) {
-    createDataFromFile("notifyin_fromwire");
+    createRequest(Opcode::NOTIFY(), Name("example.com"), RRClass::IN(),
+                  RRType::SOA());
     parse_message.clear(Message::PARSE);
     EXPECT_EQ(false, server.processMessage(*io_message, parse_message,
-                                              response_renderer));
-    //headerCheck(parse_message, default_qid, Rcode::SERVFAIL(), Opcode::NOTIFY().getCode(), QR_FLAG,
-    //                1, 0, 0, 0);
+                                           response_renderer));
 }
 
-
 void
 updateConfig(AuthSrv* server, const char* const dbfile,
              const bool expect_success)

+ 0 - 13
src/bin/auth/tests/testdata/notifyin_fromwire

@@ -1,13 +0,0 @@
-###
-### This data file was auto-generated from simplequery_fromWire.spec
-###
-
-# Header Section
-# ID=4149 QR=Query Opcode=NOTIFY(4) Rcode=NOERROR(0)
-1035 2400
-# QDCNT=1, ANCNT=0, NSCNT=0, ARCNT=0
-0001 0000 0000 0000
-
-# Question Section
-# QNAME=example.com. QTYPE=SOA(6) QCLASS=IN(1)
-076578616d706c6503636f6d00 0006 0001