auth_srv_unittest.cc 18.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.

// $Id$

17
#include <config.h>
JINMEI Tatuya's avatar
JINMEI Tatuya committed
18
#include <datasrc/memory_datasrc.h>
19
#include <auth/auth_srv.h>
20 21 22

#include <dns/tests/unittest_util.h>
#include <testutils/srv_test.h>
23

24
using namespace isc::cc;
25
using namespace isc::dns;
26
using namespace isc::data;
27
using namespace isc::xfr;
28
using namespace asiolink;
29
using namespace isc::testutils;
Evan Hunt's avatar
Evan Hunt committed
30
using isc::UnitTestUtil;
31 32

namespace {
33
const char* const CONFIG_TESTDB =
34
    "{\"database_file\": \"" TEST_DATA_DIR "/example.sqlite3\"}";
35 36
// The following file must be non existent and must be non"creatable" (see
// the sqlite3 test).
37
const char* const BADCONFIG_TESTDB =
38
    "{ \"database_file\": \"" TEST_DATA_DIR "/nodir/notexist\"}";
39

40
class AuthSrvTest : public SrvTestBase {
41
protected:
JINMEI Tatuya's avatar
JINMEI Tatuya committed
42
    AuthSrvTest() : server(true, xfrout), rrclass(RRClass::IN()) {
43
        server.setXfrinSession(&notify_session);
44
    }
45 46 47 48
    virtual void processMessage() {
        server.processMessage(*io_message, parse_message, response_obuffer,
                              &dnsserv);
    }
49
    MockXfroutClient xfrout;
50
    AuthSrv server;
JINMEI Tatuya's avatar
JINMEI Tatuya committed
51
    const RRClass rrclass;
52 53
};

54 55
// Unsupported requests.  Should result in NOTIMP.
TEST_F(AuthSrvTest, unsupportedRequest) {
56
    unsupportedRequest();
57
}
58

59 60
// Simple API check
TEST_F(AuthSrvTest, verbose) {
61 62 63 64 65
    EXPECT_FALSE(server.getVerbose());
    server.setVerbose(true);
    EXPECT_TRUE(server.getVerbose());
    server.setVerbose(false);
    EXPECT_FALSE(server.getVerbose());
66 67
}

68 69
// Multiple questions.  Should result in FORMERR.
TEST_F(AuthSrvTest, multiQuestion) {
70
    multiQuestion();
71 72
}

73 74 75
// Incoming data doesn't even contain the complete header.  Must be silently
// dropped.
TEST_F(AuthSrvTest, shortMessage) {
76
    shortMessage();
77 78 79 80 81
}

// Response messages.  Must be silently dropped, whether it's a valid response
// or malformed or could otherwise cause a protocol error.
TEST_F(AuthSrvTest, response) {
82
    response();
83 84 85 86
}

// Query with a broken question
TEST_F(AuthSrvTest, shortQuestion) {
87
    shortQuestion();
88
}
89

90 91
// Query with a broken answer section
TEST_F(AuthSrvTest, shortAnswer) {
92
    shortAnswer();
93 94
}

95 96
// Query with unsupported version of EDNS.
TEST_F(AuthSrvTest, ednsBadVers) {
97
    ednsBadVers();
98 99
}

JINMEI Tatuya's avatar
JINMEI Tatuya committed
100
TEST_F(AuthSrvTest, AXFROverUDP) {
101
    axfrOverUDP();
JINMEI Tatuya's avatar
JINMEI Tatuya committed
102 103
}

104 105
TEST_F(AuthSrvTest, AXFRSuccess) {
    EXPECT_FALSE(xfrout.isConnected());
Evan Hunt's avatar
Evan Hunt committed
106 107 108
    UnitTestUtil::createRequestMessage(request_message, opcode, default_qid,
                         Name("example.com"), RRClass::IN(), RRType::AXFR());
    createRequestPacket(request_message, IPPROTO_TCP);
109 110
    // On success, the AXFR query has been passed to a separate process,
    // so we shouldn't have to respond.
Evan Hunt's avatar
Evan Hunt committed
111 112
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_FALSE(dnsserv.hasAnswer());
113
    EXPECT_TRUE(xfrout.isConnected());
114 115 116 117 118
}

TEST_F(AuthSrvTest, AXFRConnectFail) {
    EXPECT_FALSE(xfrout.isConnected()); // check prerequisite
    xfrout.disableConnect();
Evan Hunt's avatar
Evan Hunt committed
119 120 121 122 123
    UnitTestUtil::createRequestMessage(request_message, opcode, default_qid,
                         Name("example.com"), RRClass::IN(), RRType::AXFR());
    createRequestPacket(request_message, IPPROTO_TCP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
124
    headerCheck(*parse_message, default_qid, Rcode::SERVFAIL(),
125 126 127 128 129 130 131
                opcode.getCode(), QR_FLAG, 1, 0, 0, 0);
    EXPECT_FALSE(xfrout.isConnected());
}

TEST_F(AuthSrvTest, AXFRSendFail) {
    // first send a valid query, making the connection with the xfr process
    // open.
Evan Hunt's avatar
Evan Hunt committed
132 133 134 135
    UnitTestUtil::createRequestMessage(request_message, opcode, default_qid,
                         Name("example.com"), RRClass::IN(), RRType::AXFR());
    createRequestPacket(request_message, IPPROTO_TCP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
136
    EXPECT_TRUE(xfrout.isConnected());
137 138

    xfrout.disableSend();
139 140
    parse_message->clear(Message::PARSE);
    response_obuffer->clear();
Evan Hunt's avatar
Evan Hunt committed
141 142 143 144 145
    UnitTestUtil::createRequestMessage(request_message, opcode, default_qid,
                         Name("example.com"), RRClass::IN(), RRType::AXFR());
    createRequestPacket(request_message, IPPROTO_TCP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
146
    headerCheck(*parse_message, default_qid, Rcode::SERVFAIL(),
147 148 149 150 151 152 153 154 155 156 157
                opcode.getCode(), QR_FLAG, 1, 0, 0, 0);

    // The connection should have been closed due to the send failure.
    EXPECT_FALSE(xfrout.isConnected());
}

TEST_F(AuthSrvTest, AXFRDisconnectFail) {
    // In our usage disconnect() shouldn't fail.  So we'll see the exception
    // should it be thrown.
    xfrout.disableSend();
    xfrout.disableDisconnect();
Evan Hunt's avatar
Evan Hunt committed
158 159 160
    UnitTestUtil::createRequestMessage(request_message, opcode, default_qid,
                         Name("example.com"), RRClass::IN(), RRType::AXFR());
    createRequestPacket(request_message, IPPROTO_TCP);
161
    EXPECT_THROW(server.processMessage(*io_message, parse_message,
Evan Hunt's avatar
Evan Hunt committed
162
                                       response_obuffer, &dnsserv),
163 164 165 166 167 168 169
                 XfroutError);
    EXPECT_TRUE(xfrout.isConnected());
    // XXX: we need to re-enable disconnect.  otherwise an exception would be
    // thrown via the destructor of the server.
    xfrout.enableDisconnect();
}

170
TEST_F(AuthSrvTest, notify) {
Evan Hunt's avatar
Evan Hunt committed
171 172
    UnitTestUtil::createRequestMessage(request_message, Opcode::NOTIFY(), default_qid,
                         Name("example.com"), RRClass::IN(), RRType::SOA());
173
    request_message.setHeaderFlag(Message::HEADERFLAG_AA);
Evan Hunt's avatar
Evan Hunt committed
174 175 176
    createRequestPacket(request_message, IPPROTO_UDP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
177 178 179

    // An internal command message should have been created and sent to an
    // external module.  Check them.
Evan Hunt's avatar
Evan Hunt committed
180
    EXPECT_EQ("Zonemgr", notify_session.getMessageDest());
181
    EXPECT_EQ("notify",
Evan Hunt's avatar
Evan Hunt committed
182
              notify_session.getSentMessage()->get("command")->get(0)->stringValue());
183
    ConstElementPtr notify_args =
Evan Hunt's avatar
Evan Hunt committed
184
        notify_session.getSentMessage()->get("command")->get(1);
185 186 187
    EXPECT_EQ("example.com.", notify_args->get("zone_name")->stringValue());
    EXPECT_EQ(DEFAULT_REMOTE_ADDRESS,
              notify_args->get("master")->stringValue());
188
    EXPECT_EQ("IN", notify_args->get("zone_class")->stringValue());
189 190

    // On success, the server should return a response to the notify.
191
    headerCheck(*parse_message, default_qid, Rcode::NOERROR(),
192 193
                Opcode::NOTIFY().getCode(), QR_FLAG | AA_FLAG, 1, 0, 0, 0);

194
    // The question must be identical to that of the received notify
195
    ConstQuestionPtr question = *parse_message->beginQuestion();
196 197 198 199 200
    EXPECT_EQ(Name("example.com"), question->getName());
    EXPECT_EQ(RRClass::IN(), question->getClass());
    EXPECT_EQ(RRType::SOA(), question->getType());
}

201 202
TEST_F(AuthSrvTest, notifyForCHClass) {
    // Same as the previous test, but for the CH RRClass.
Evan Hunt's avatar
Evan Hunt committed
203 204
    UnitTestUtil::createRequestMessage(request_message, Opcode::NOTIFY(), default_qid,
                         Name("example.com"), RRClass::CH(), RRType::SOA());
205
    request_message.setHeaderFlag(Message::HEADERFLAG_AA);
Evan Hunt's avatar
Evan Hunt committed
206 207 208
    createRequestPacket(request_message, IPPROTO_UDP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
209 210 211

    // Other conditions should be the same, so simply confirm the RR class is
    // set correctly.
212
    ConstElementPtr notify_args =
Evan Hunt's avatar
Evan Hunt committed
213
        notify_session.getSentMessage()->get("command")->get(1);
214
    EXPECT_EQ("CH", notify_args->get("zone_class")->stringValue());
215 216
}

217 218 219
TEST_F(AuthSrvTest, notifyEmptyQuestion) {
    request_message.clear(Message::RENDER);
    request_message.setOpcode(Opcode::NOTIFY());
220
    request_message.setRcode(Rcode::NOERROR());
221
    request_message.setHeaderFlag(Message::HEADERFLAG_AA);
222 223
    request_message.setQid(default_qid);
    request_message.toWire(request_renderer);
Evan Hunt's avatar
Evan Hunt committed
224 225 226
    createRequestPacket(request_message, IPPROTO_UDP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
227
    headerCheck(*parse_message, default_qid, Rcode::FORMERR(),
228 229 230 231
                Opcode::NOTIFY().getCode(), QR_FLAG, 0, 0, 0, 0);
}

TEST_F(AuthSrvTest, notifyMultiQuestions) {
Evan Hunt's avatar
Evan Hunt committed
232 233
    UnitTestUtil::createRequestMessage(request_message, Opcode::NOTIFY(), default_qid,
                         Name("example.com"), RRClass::IN(), RRType::SOA());
234 235 236
    // add one more SOA question
    request_message.addQuestion(Question(Name("example.com"), RRClass::IN(),
                                         RRType::SOA()));
237
    request_message.setHeaderFlag(Message::HEADERFLAG_AA);
Evan Hunt's avatar
Evan Hunt committed
238 239 240
    createRequestPacket(request_message, IPPROTO_UDP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
241
    headerCheck(*parse_message, default_qid, Rcode::FORMERR(),
242 243 244 245
                Opcode::NOTIFY().getCode(), QR_FLAG, 2, 0, 0, 0);
}

TEST_F(AuthSrvTest, notifyNonSOAQuestion) {
Evan Hunt's avatar
Evan Hunt committed
246 247
    UnitTestUtil::createRequestMessage(request_message, Opcode::NOTIFY(), default_qid,
                         Name("example.com"), RRClass::IN(), RRType::NS());
248
    request_message.setHeaderFlag(Message::HEADERFLAG_AA);
Evan Hunt's avatar
Evan Hunt committed
249 250 251
    createRequestPacket(request_message, IPPROTO_UDP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
252
    headerCheck(*parse_message, default_qid, Rcode::FORMERR(),
253 254 255 256 257
                Opcode::NOTIFY().getCode(), QR_FLAG, 1, 0, 0, 0);
}

TEST_F(AuthSrvTest, notifyWithoutAA) {
    // implicitly leave the AA bit off.  our implementation will accept it.
Evan Hunt's avatar
Evan Hunt committed
258 259 260 261 262
    UnitTestUtil::createRequestMessage(request_message, Opcode::NOTIFY(), default_qid,
                         Name("example.com"), RRClass::IN(), RRType::SOA());
    createRequestPacket(request_message, IPPROTO_UDP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
263
    headerCheck(*parse_message, default_qid, Rcode::NOERROR(),
264 265 266 267
                Opcode::NOTIFY().getCode(), QR_FLAG | AA_FLAG, 1, 0, 0, 0);
}

TEST_F(AuthSrvTest, notifyWithErrorRcode) {
Evan Hunt's avatar
Evan Hunt committed
268 269
    UnitTestUtil::createRequestMessage(request_message, Opcode::NOTIFY(), default_qid,
                         Name("example.com"), RRClass::IN(), RRType::SOA());
270
    request_message.setHeaderFlag(Message::HEADERFLAG_AA);
271
    request_message.setRcode(Rcode::SERVFAIL());
Evan Hunt's avatar
Evan Hunt committed
272 273 274
    createRequestPacket(request_message, IPPROTO_UDP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
275
    headerCheck(*parse_message, default_qid, Rcode::NOERROR(),
276
                Opcode::NOTIFY().getCode(), QR_FLAG | AA_FLAG, 1, 0, 0, 0);
Han Feng's avatar
Han Feng committed
277 278
}

279
TEST_F(AuthSrvTest, notifyWithoutSession) {
280
    server.setXfrinSession(NULL);
281

Evan Hunt's avatar
Evan Hunt committed
282 283
    UnitTestUtil::createRequestMessage(request_message, Opcode::NOTIFY(), default_qid,
                         Name("example.com"), RRClass::IN(), RRType::SOA());
284
    request_message.setHeaderFlag(Message::HEADERFLAG_AA);
Evan Hunt's avatar
Evan Hunt committed
285
    createRequestPacket(request_message, IPPROTO_UDP);
286 287 288

    // we simply ignore the notify and let it be resent if an internal error
    // happens.
Evan Hunt's avatar
Evan Hunt committed
289 290
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_FALSE(dnsserv.hasAnswer());
291 292 293 294 295
}

TEST_F(AuthSrvTest, notifySendFail) {
    notify_session.disableSend();

Evan Hunt's avatar
Evan Hunt committed
296 297
    UnitTestUtil::createRequestMessage(request_message, Opcode::NOTIFY(), default_qid,
                         Name("example.com"), RRClass::IN(), RRType::SOA());
298
    request_message.setHeaderFlag(Message::HEADERFLAG_AA);
Evan Hunt's avatar
Evan Hunt committed
299
    createRequestPacket(request_message, IPPROTO_UDP);
300

Evan Hunt's avatar
Evan Hunt committed
301 302
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_FALSE(dnsserv.hasAnswer());
303 304 305 306 307
}

TEST_F(AuthSrvTest, notifyReceiveFail) {
    notify_session.disableReceive();

Evan Hunt's avatar
Evan Hunt committed
308 309
    UnitTestUtil::createRequestMessage(request_message, Opcode::NOTIFY(), default_qid,
                         Name("example.com"), RRClass::IN(), RRType::SOA());
310
    request_message.setHeaderFlag(Message::HEADERFLAG_AA);
Evan Hunt's avatar
Evan Hunt committed
311 312 313
    createRequestPacket(request_message, IPPROTO_UDP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_FALSE(dnsserv.hasAnswer());
314 315 316
}

TEST_F(AuthSrvTest, notifyWithBogusSessionMessage) {
317
    notify_session.setMessage(Element::fromJSON("{\"foo\": 1}"));
318

Evan Hunt's avatar
Evan Hunt committed
319 320
    UnitTestUtil::createRequestMessage(request_message, Opcode::NOTIFY(), default_qid,
                         Name("example.com"), RRClass::IN(), RRType::SOA());
321
    request_message.setHeaderFlag(Message::HEADERFLAG_AA);
Evan Hunt's avatar
Evan Hunt committed
322 323 324
    createRequestPacket(request_message, IPPROTO_UDP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_FALSE(dnsserv.hasAnswer());
325 326 327 328
}

TEST_F(AuthSrvTest, notifyWithSessionMessageError) {
    notify_session.setMessage(
329
        Element::fromJSON("{\"result\": [1, \"FAIL\"]}"));
330

Evan Hunt's avatar
Evan Hunt committed
331 332
    UnitTestUtil::createRequestMessage(request_message, Opcode::NOTIFY(), default_qid,
                         Name("example.com"), RRClass::IN(), RRType::SOA());
333
    request_message.setHeaderFlag(Message::HEADERFLAG_AA);
Evan Hunt's avatar
Evan Hunt committed
334 335 336
    createRequestPacket(request_message, IPPROTO_UDP);
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_FALSE(dnsserv.hasAnswer());
337 338
}

339
void
JINMEI Tatuya's avatar
JINMEI Tatuya committed
340
updateConfig(AuthSrv* server, const char* const config_data,
341 342
             const bool expect_success)
{
343
    ConstElementPtr config_answer =
JINMEI Tatuya's avatar
JINMEI Tatuya committed
344
        server->updateConfig(Element::fromJSON(config_data));
345 346 347
    EXPECT_EQ(Element::map, config_answer->getType());
    EXPECT_TRUE(config_answer->contains("result"));

348
    ConstElementPtr result = config_answer->get("result");
349
    EXPECT_EQ(Element::list, result->getType());
350
    EXPECT_EQ(expect_success ? 0 : 1, result->get(0)->intValue());
351 352 353 354
}

// Install a Sqlite3 data source with testing data.
TEST_F(AuthSrvTest, updateConfig) {
355
    updateConfig(&server, CONFIG_TESTDB, true);
356 357 358 359

    // query for existent data in the installed data source.  The resulting
    // response should have the AA flag on, and have an RR in each answer
    // and authority section.
360
    createDataFromFile("examplequery_fromWire.wire");
Evan Hunt's avatar
Evan Hunt committed
361 362
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
363
    headerCheck(*parse_message, default_qid, Rcode::NOERROR(), opcode.getCode(),
364 365 366 367
                QR_FLAG | AA_FLAG, 1, 1, 1, 0);
}

TEST_F(AuthSrvTest, datasourceFail) {
368
    updateConfig(&server, CONFIG_TESTDB, true);
369 370 371 372 373

    // This query will hit a corrupted entry of the data source (the zoneload
    // tool and the data source itself naively accept it).  This will result
    // in a SERVFAIL response, and the answer and authority sections should
    // be empty.
374
    createDataFromFile("badExampleQuery_fromWire.wire");
Evan Hunt's avatar
Evan Hunt committed
375 376
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
377
    headerCheck(*parse_message, default_qid, Rcode::SERVFAIL(),
378
                opcode.getCode(), QR_FLAG, 1, 0, 0, 0);
379
}
380 381 382 383 384 385 386 387 388

TEST_F(AuthSrvTest, updateConfigFail) {
    // First, load a valid data source.
    updateConfig(&server, CONFIG_TESTDB, true);

    // Next, try to update it with a non-existent one.  This should fail.
    updateConfig(&server, BADCONFIG_TESTDB, false);

    // The original data source should still exist.
389
    createDataFromFile("examplequery_fromWire.wire");
Evan Hunt's avatar
Evan Hunt committed
390 391
    server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
392
    headerCheck(*parse_message, default_qid, Rcode::NOERROR(), opcode.getCode(),
393 394
                QR_FLAG | AA_FLAG, 1, 1, 1, 0);
}
JINMEI Tatuya's avatar
JINMEI Tatuya committed
395

JINMEI Tatuya's avatar
JINMEI Tatuya committed
396 397 398 399 400 401 402 403 404 405 406
TEST_F(AuthSrvTest, updateWithMemoryDataSrc) {
    // Test configuring memory data source.  Detailed test cases are covered
    // in the configuration tests.  We only check the AuthSrv interface here.

    // By default memory data source isn't enabled
    EXPECT_EQ(AuthSrv::MemoryDataSrcPtr(), server.getMemoryDataSrc(rrclass));
    updateConfig(&server,
                 "{\"datasources\": [{\"type\": \"memory\"}]}", true);
    // after successful configuration, we should have one (with empty zoneset).
    ASSERT_NE(AuthSrv::MemoryDataSrcPtr(), server.getMemoryDataSrc(rrclass));
    EXPECT_EQ(0, server.getMemoryDataSrc(rrclass)->getZoneCount());
Jerry's avatar
Jerry committed
407

408
    // The memory data source is empty, should return REFUSED rcode.
Jerry's avatar
Jerry committed
409
    createDataFromFile("examplequery_fromWire.wire");
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
    server.processMessage(*io_message, parse_message, response_obuffer,
                          &dnsserv);
    EXPECT_TRUE(dnsserv.hasAnswer());
    headerCheck(*parse_message, default_qid, Rcode::REFUSED(),
                opcode.getCode(), QR_FLAG, 1, 0, 0, 0);
}

TEST_F(AuthSrvTest, chQueryWithMemoryDataSrc) {
    // Configure memory data source for class IN
    updateConfig(&server, "{\"datasources\": "
                 "[{\"class\": \"IN\", \"type\": \"memory\"}]}", true);

    // This shouldn't affect the result of class CH query
    UnitTestUtil::createRequestMessage(request_message, Opcode::QUERY(),
                                       default_qid, Name("version.bind"),
                                       RRClass::CH(), RRType::TXT());
    createRequestPacket(request_message, IPPROTO_UDP);
    server.processMessage(*io_message, parse_message, response_obuffer,
                          &dnsserv);
429
    EXPECT_TRUE(dnsserv.hasAnswer());
430 431
    headerCheck(*parse_message, default_qid, Rcode::NOERROR(),
                opcode.getCode(), QR_FLAG | AA_FLAG, 1, 1, 1, 0);
JINMEI Tatuya's avatar
JINMEI Tatuya committed
432 433
}

JINMEI Tatuya's avatar
JINMEI Tatuya committed
434 435 436 437 438 439 440 441 442
TEST_F(AuthSrvTest, cacheSlots) {
    // simple check for the get/set operations
    server.setCacheSlots(10);    // 10 = arbitrary choice
    EXPECT_EQ(10, server.getCacheSlots());

    // 0 is a valid size
    server.setCacheSlots(0);
    EXPECT_EQ(00, server.getCacheSlots());
}
443
}