[svn] commit: r2478 - in /branches/trac221b/src/bin/auth: auth_srv.cc tests/auth_srv_unittest.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Jul 10 18:58:15 UTC 2010
Author: jinmei
Date: Sat Jul 10 18:58:15 2010
New Revision: 2478
Log:
made sure passing the RRClass of notify to the remote process.
added tests about the CC message content for notify.
Modified:
branches/trac221b/src/bin/auth/auth_srv.cc
branches/trac221b/src/bin/auth/tests/auth_srv_unittest.cc
Modified: branches/trac221b/src/bin/auth/auth_srv.cc
==============================================================================
--- branches/trac221b/src/bin/auth/auth_srv.cc (original)
+++ branches/trac221b/src/bin/auth/auth_srv.cc Sat Jul 10 18:58:15 2010
@@ -425,13 +425,15 @@
io_message.getRemoteEndpoint().getAddress().toText();
static const string command_template_start =
"{\"command\": [\"notify\", {\"zone_name\" : \"";
- static const string command_template_mid = "\", \"master\" : \"";
+ static const string command_template_master = "\", \"master\" : \"";
+ static const string command_template_rrclass = "\", \"rrclass\" : \"";
static const string command_template_end = "\"}]}";
try {
ElementPtr notify_command = Element::fromJSON(
command_template_start + question->getName().toText() +
- command_template_mid + remote_ip_address +
+ command_template_master + remote_ip_address +
+ command_template_rrclass + question->getClass().toText() +
command_template_end);
const unsigned int seq =
xfrin_session_->group_sendmsg(notify_command, "Xfrin",
Modified: branches/trac221b/src/bin/auth/tests/auth_srv_unittest.cc
==============================================================================
--- branches/trac221b/src/bin/auth/tests/auth_srv_unittest.cc (original)
+++ branches/trac221b/src/bin/auth/tests/auth_srv_unittest.cc Sat Jul 10 18:58:15 2010
@@ -44,12 +44,13 @@
using namespace asio_link;
namespace {
-const char* CONFIG_TESTDB =
+const char* const CONFIG_TESTDB =
"{\"database_file\": \"" TEST_DATA_DIR "/example.sqlite3\"}";
// The following file must be non existent and must be non"creatable" (see
// the sqlite3 test).
-const char* BADCONFIG_TESTDB =
+const char* const BADCONFIG_TESTDB =
"{ \"database_file\": \"" TEST_DATA_DIR "/nodir/notexist\"}";
+const char* const DEFAULT_REMOTE_ADDRESS = "192.0.2.1";
class AuthSrvTest : public ::testing::Test {
private:
@@ -97,6 +98,9 @@
void setMessage(ElementPtr msg) { msg_ = msg; }
void disableSend() { send_ok_ = false; }
void disableReceive() { receive_ok_ = false; }
+
+ ElementPtr sent_msg;
+ string msg_destination;
private:
ElementPtr msg_;
bool send_ok_;
@@ -180,14 +184,16 @@
}
int
-AuthSrvTest::MockSession::group_sendmsg(ElementPtr msg UNUSED_PARAM,
- string group UNUSED_PARAM,
+AuthSrvTest::MockSession::group_sendmsg(ElementPtr msg, string group,
string instance UNUSED_PARAM,
string to UNUSED_PARAM)
{
if (!send_ok_) {
isc_throw(XfroutError, "mock session send is disabled for test");
}
+
+ sent_msg = msg;
+ msg_destination = group;
return (0);
}
@@ -254,7 +260,8 @@
data.clear();
delete endpoint;
- endpoint = IOEndpoint::create(protocol, IOAddress("192.0.2.1"), 5300);
+ endpoint = IOEndpoint::create(protocol,
+ IOAddress(DEFAULT_REMOTE_ADDRESS), 5300);
UnitTestUtil::readWireData(datafile, data);
io_message = new IOMessage(&data[0], data.size(),
protocol == IPPROTO_UDP ?
@@ -289,7 +296,8 @@
request_message.toWire(request_renderer);
delete io_message;
- endpoint = IOEndpoint::create(protocol, IOAddress("192.0.2.1"), 5300);
+ endpoint = IOEndpoint::create(protocol,
+ IOAddress(DEFAULT_REMOTE_ADDRESS), 5300);
io_message = new IOMessage(request_renderer.getData(),
request_renderer.getLength(),
protocol == IPPROTO_UDP ?
@@ -521,14 +529,42 @@
createRequestPacket(IPPROTO_UDP);
EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
response_renderer));
+
+ // An internal command message should have been created and sent to an
+ // external module. Check them.
+ EXPECT_EQ("Xfrin", notify_session.msg_destination);
+ EXPECT_EQ("notify",
+ notify_session.sent_msg->get("command")->get(0)->stringValue());
+ ElementPtr notify_args = notify_session.sent_msg->get("command")->get(1);
+ EXPECT_EQ("example.com.", notify_args->get("zone_name")->stringValue());
+ EXPECT_EQ(DEFAULT_REMOTE_ADDRESS,
+ notify_args->get("master")->stringValue());
+ EXPECT_EQ("IN", notify_args->get("rrclass")->stringValue());
+
+ // On success, the server should return a response to the notify.
headerCheck(parse_message, default_qid, Rcode::NOERROR(),
Opcode::NOTIFY().getCode(), QR_FLAG | AA_FLAG, 1, 0, 0, 0);
- // The question must be identical of the notify
+ // The question must be identical to that of the received notify
ConstQuestionPtr question = *parse_message.beginQuestion();
EXPECT_EQ(Name("example.com"), question->getName());
EXPECT_EQ(RRClass::IN(), question->getClass());
EXPECT_EQ(RRType::SOA(), question->getType());
+}
+
+TEST_F(AuthSrvTest, notifyForCHClass) {
+ // Same as the previous test, but for the CH RRClass.
+ createRequestMessage(Opcode::NOTIFY(), Name("example.com"), RRClass::CH(),
+ RRType::SOA());
+ request_message.setHeaderFlag(MessageFlag::AA());
+ createRequestPacket(IPPROTO_UDP);
+ EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
+ response_renderer));
+
+ // Other conditions should be the same, so simply confirm the RR class is
+ // set correctly.
+ ElementPtr notify_args = notify_session.sent_msg->get("command")->get(1);
+ EXPECT_EQ("CH", notify_args->get("rrclass")->stringValue());
}
TEST_F(AuthSrvTest, notifyEmptyQuestion) {
More information about the bind10-changes
mailing list