|
@@ -99,8 +99,9 @@ TEST_F(ZoneEntryTest, DefaultConstructor) {
|
|
}
|
|
}
|
|
|
|
|
|
/// Tests of constructor from referral data
|
|
/// Tests of constructor from referral data
|
|
-TEST_F(ZoneEntryTest, ReferralConstructor) {
|
|
|
|
- InheritedZoneEntry alpha(resolver_, rr_single_, nameserver_table_,
|
|
|
|
|
|
+/// Disabled, as this one will probably go away soon
|
|
|
|
+TEST_F(ZoneEntryTest, DISABLED_ReferralConstructor) {
|
|
|
|
+ InheritedZoneEntry alpha(resolver_, *rr_single_, nameserver_table_,
|
|
nameserver_lru_);
|
|
nameserver_lru_);
|
|
// It should load the name and class from the referral info
|
|
// It should load the name and class from the referral info
|
|
EXPECT_EQ(EXAMPLE_CO_UK, alpha.getName());
|
|
EXPECT_EQ(EXAMPLE_CO_UK, alpha.getName());
|
|
@@ -113,7 +114,7 @@ TEST_F(ZoneEntryTest, ReferralConstructor) {
|
|
// It should answer negatively right away if there are no nameservers
|
|
// It should answer negatively right away if there are no nameservers
|
|
TEST_F(ZoneEntryTest, CallbackNoNS) {
|
|
TEST_F(ZoneEntryTest, CallbackNoNS) {
|
|
shared_ptr<InheritedZoneEntry> zone(new InheritedZoneEntry(resolver_,
|
|
shared_ptr<InheritedZoneEntry> zone(new InheritedZoneEntry(resolver_,
|
|
- rr_empty_, nameserver_table_, nameserver_lru_));
|
|
|
|
|
|
+ *rr_empty_, nameserver_table_, nameserver_lru_));
|
|
// It should accept the callback
|
|
// It should accept the callback
|
|
EXPECT_TRUE(zone->addCallback(callback_, ANY_OK, zone));
|
|
EXPECT_TRUE(zone->addCallback(callback_, ANY_OK, zone));
|
|
// And tell imediatelly that it is unreachable (when it has no nameservers)
|
|
// And tell imediatelly that it is unreachable (when it has no nameservers)
|
|
@@ -124,9 +125,9 @@ TEST_F(ZoneEntryTest, CallbackNoNS) {
|
|
// Check it accepts the first callback with 0 TTL
|
|
// Check it accepts the first callback with 0 TTL
|
|
TEST_F(ZoneEntryTest, CallbackZeroTTL) {
|
|
TEST_F(ZoneEntryTest, CallbackZeroTTL) {
|
|
// Make it zero TTL, so it expires right away
|
|
// Make it zero TTL, so it expires right away
|
|
- rr_single_.setTTL(RRTTL(0));
|
|
|
|
|
|
+ rr_single_->setTTL(RRTTL(0));
|
|
shared_ptr<InheritedZoneEntry> zone(new InheritedZoneEntry(resolver_,
|
|
shared_ptr<InheritedZoneEntry> zone(new InheritedZoneEntry(resolver_,
|
|
- rr_single_, nameserver_table_, nameserver_lru_));
|
|
|
|
|
|
+ *rr_single_, nameserver_table_, nameserver_lru_));
|
|
// It should accept the callback
|
|
// It should accept the callback
|
|
EXPECT_TRUE(zone->addCallback(callback_, ANY_OK, zone));
|
|
EXPECT_TRUE(zone->addCallback(callback_, ANY_OK, zone));
|
|
// It should not be answered yet, it should ask for the IP addresses
|
|
// It should not be answered yet, it should ask for the IP addresses
|
|
@@ -140,7 +141,7 @@ TEST_F(ZoneEntryTest, CallbackZeroTTL) {
|
|
// Check it answers callbacks when we give it addresses
|
|
// Check it answers callbacks when we give it addresses
|
|
TEST_F(ZoneEntryTest, CallbacksAnswered) {
|
|
TEST_F(ZoneEntryTest, CallbacksAnswered) {
|
|
shared_ptr<InheritedZoneEntry> zone(new InheritedZoneEntry(resolver_,
|
|
shared_ptr<InheritedZoneEntry> zone(new InheritedZoneEntry(resolver_,
|
|
- rr_single_, nameserver_table_, nameserver_lru_));
|
|
|
|
|
|
+ *rr_single_, nameserver_table_, nameserver_lru_));
|
|
// It should be in NOT_ASKED state
|
|
// It should be in NOT_ASKED state
|
|
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
|
|
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
|
|
// It should accept the callback
|
|
// It should accept the callback
|
|
@@ -156,7 +157,8 @@ TEST_F(ZoneEntryTest, CallbacksAnswered) {
|
|
EXPECT_TRUE(zone->addCallback(callback_, V6_ONLY, zone));
|
|
EXPECT_TRUE(zone->addCallback(callback_, V6_ONLY, zone));
|
|
// Nothing more is asked
|
|
// Nothing more is asked
|
|
EXPECT_EQ(2, resolver_->requests.size());
|
|
EXPECT_EQ(2, resolver_->requests.size());
|
|
- resolver_->answer(0, ns_name_, RRType::A(), rdata::in::A("192.0.2.1"));
|
|
|
|
|
|
+ EXPECT_NO_THROW(resolver_->answer(0, ns_name_, RRType::A(),
|
|
|
|
+ rdata::in::A("192.0.2.1")));
|
|
// Two are answered (ANY and V4)
|
|
// Two are answered (ANY and V4)
|
|
ASSERT_EQ(2, callback_->successes_.size());
|
|
ASSERT_EQ(2, callback_->successes_.size());
|
|
EXPECT_TRUE(IOAddress("192.0.2.1").equal(callback_->successes_[0]));
|
|
EXPECT_TRUE(IOAddress("192.0.2.1").equal(callback_->successes_[0]));
|
|
@@ -165,8 +167,8 @@ TEST_F(ZoneEntryTest, CallbacksAnswered) {
|
|
EXPECT_EQ(0, callback_->unreachable_count_);
|
|
EXPECT_EQ(0, callback_->unreachable_count_);
|
|
// We are still in progress, not everything arrived
|
|
// We are still in progress, not everything arrived
|
|
EXPECT_EQ(Fetchable::IN_PROGRESS, zone->getState());
|
|
EXPECT_EQ(Fetchable::IN_PROGRESS, zone->getState());
|
|
- resolver_->answer(1, ns_name_, RRType::AAAA(),
|
|
|
|
- rdata::in::AAAA("2001:db8::1"));
|
|
|
|
|
|
+ EXPECT_NO_THROW(resolver_->answer(1, ns_name_, RRType::AAAA(),
|
|
|
|
+ rdata::in::AAAA("2001:db8::1")));
|
|
// This should answer the third callback
|
|
// This should answer the third callback
|
|
ASSERT_EQ(3, callback_->successes_.size());
|
|
ASSERT_EQ(3, callback_->successes_.size());
|
|
EXPECT_TRUE(IOAddress("2001:db8::1").equal(callback_->successes_[2]));
|
|
EXPECT_TRUE(IOAddress("2001:db8::1").equal(callback_->successes_[2]));
|
|
@@ -184,7 +186,7 @@ TEST_F(ZoneEntryTest, CallbacksAnswered) {
|
|
// Pretend the server can be reached only by IPv4
|
|
// Pretend the server can be reached only by IPv4
|
|
TEST_F(ZoneEntryTest, CallbacksAOnly) {
|
|
TEST_F(ZoneEntryTest, CallbacksAOnly) {
|
|
shared_ptr<InheritedZoneEntry> zone(new InheritedZoneEntry(resolver_,
|
|
shared_ptr<InheritedZoneEntry> zone(new InheritedZoneEntry(resolver_,
|
|
- rr_single_, nameserver_table_, nameserver_lru_));
|
|
|
|
|
|
+ *rr_single_, nameserver_table_, nameserver_lru_));
|
|
// It should be in NOT_ASKED state
|
|
// It should be in NOT_ASKED state
|
|
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
|
|
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
|
|
// It should accept the callback
|
|
// It should accept the callback
|
|
@@ -198,6 +200,7 @@ TEST_F(ZoneEntryTest, CallbacksAOnly) {
|
|
// Give two more callbacks, with different address families
|
|
// Give two more callbacks, with different address families
|
|
EXPECT_TRUE(zone->addCallback(callback_, V4_ONLY, zone));
|
|
EXPECT_TRUE(zone->addCallback(callback_, V4_ONLY, zone));
|
|
EXPECT_TRUE(zone->addCallback(callback_, V6_ONLY, zone));
|
|
EXPECT_TRUE(zone->addCallback(callback_, V6_ONLY, zone));
|
|
|
|
+ ASSERT_GE(resolver_->requests.size(), 2);
|
|
resolver_->requests[1].second->failure();
|
|
resolver_->requests[1].second->failure();
|
|
// One should be rejected, but two still stay, they have chance
|
|
// One should be rejected, but two still stay, they have chance
|
|
EXPECT_EQ(0, callback_->successes_.size());
|
|
EXPECT_EQ(0, callback_->successes_.size());
|
|
@@ -205,7 +208,8 @@ TEST_F(ZoneEntryTest, CallbacksAOnly) {
|
|
EXPECT_EQ(Fetchable::IN_PROGRESS, zone->getState());
|
|
EXPECT_EQ(Fetchable::IN_PROGRESS, zone->getState());
|
|
// Answer the A one and see it answers what can be answered
|
|
// Answer the A one and see it answers what can be answered
|
|
ASSERT_EQ(2, callback_->successes_.size());
|
|
ASSERT_EQ(2, callback_->successes_.size());
|
|
- resolver_->answer(0, ns_name_, RRType::A(), rdata::in::A("192.0.2.1"));
|
|
|
|
|
|
+ EXPECT_NO_THROW(resolver_->answer(0, ns_name_, RRType::A(),
|
|
|
|
+ rdata::in::A("192.0.2.1")));
|
|
EXPECT_TRUE(IOAddress("192.0.2.1").equal(callback_->successes_[0]));
|
|
EXPECT_TRUE(IOAddress("192.0.2.1").equal(callback_->successes_[0]));
|
|
EXPECT_TRUE(IOAddress("192.0.2.1").equal(callback_->successes_[1]));
|
|
EXPECT_TRUE(IOAddress("192.0.2.1").equal(callback_->successes_[1]));
|
|
EXPECT_EQ(1, callback_->unreachable_count_);
|
|
EXPECT_EQ(1, callback_->unreachable_count_);
|
|
@@ -227,14 +231,16 @@ TEST_F(ZoneEntryTest, CallbacksAOnly) {
|
|
// See it tries hard enough to get address and tries both nameservers
|
|
// See it tries hard enough to get address and tries both nameservers
|
|
TEST_F(ZoneEntryTest, CallbackTwoNS) {
|
|
TEST_F(ZoneEntryTest, CallbackTwoNS) {
|
|
shared_ptr<InheritedZoneEntry> zone(new InheritedZoneEntry(resolver_,
|
|
shared_ptr<InheritedZoneEntry> zone(new InheritedZoneEntry(resolver_,
|
|
- rrns_, nameserver_table_, nameserver_lru_));
|
|
|
|
|
|
+ *rrns_, nameserver_table_, nameserver_lru_));
|
|
// It should be in NOT_ASKED state
|
|
// It should be in NOT_ASKED state
|
|
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
|
|
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
|
|
// It should accept the callback
|
|
// It should accept the callback
|
|
EXPECT_TRUE(zone->addCallback(callback_, V4_ONLY, zone));
|
|
EXPECT_TRUE(zone->addCallback(callback_, V4_ONLY, zone));
|
|
EXPECT_EQ(Fetchable::IN_PROGRESS, zone->getState());
|
|
EXPECT_EQ(Fetchable::IN_PROGRESS, zone->getState());
|
|
// It asks a question (we do not know which nameserver)
|
|
// It asks a question (we do not know which nameserver)
|
|
- resolver_->asksIPs((*resolver_)[0]->getName(), 0, 1);
|
|
|
|
|
|
+ shared_ptr<Name> name;
|
|
|
|
+ ASSERT_NO_THROW(name.reset(new Name((*resolver_)[0]->getName())));
|
|
|
|
+ ASSERT_TRUE(resolver_->asksIPs(*name, 0, 1));
|
|
resolver_->requests[0].second->failure();
|
|
resolver_->requests[0].second->failure();
|
|
// Nothing should be answered or failed yet
|
|
// Nothing should be answered or failed yet
|
|
EXPECT_EQ(0, callback_->unreachable_count_);
|
|
EXPECT_EQ(0, callback_->unreachable_count_);
|
|
@@ -242,7 +248,7 @@ TEST_F(ZoneEntryTest, CallbackTwoNS) {
|
|
// It should be still IN_PROGRESS and ask the second nameserver
|
|
// It should be still IN_PROGRESS and ask the second nameserver
|
|
// (at last now, if not before)
|
|
// (at last now, if not before)
|
|
EXPECT_EQ(Fetchable::IN_PROGRESS, zone->getState());
|
|
EXPECT_EQ(Fetchable::IN_PROGRESS, zone->getState());
|
|
- resolver_->asksIPs((*resolver_)[2]->getName(), 2, 3);
|
|
|
|
|
|
+ ASSERT_TRUE(resolver_->asksIPs((*resolver_)[2]->getName(), 2, 3));
|
|
// Fail the second one
|
|
// Fail the second one
|
|
resolver_->requests[2].second->failure();
|
|
resolver_->requests[2].second->failure();
|
|
// The callback should be failed now, as there is no chance of getting
|
|
// The callback should be failed now, as there is no chance of getting
|
|
@@ -265,8 +271,8 @@ TEST_F(ZoneEntryTest, CallbackTwoNS) {
|
|
EXPECT_EQ(2, callback_->unreachable_count_);
|
|
EXPECT_EQ(2, callback_->unreachable_count_);
|
|
EXPECT_EQ(0, callback_->successes_.size());
|
|
EXPECT_EQ(0, callback_->successes_.size());
|
|
// Answer the IPv6 one
|
|
// Answer the IPv6 one
|
|
- resolver_->answer(1, (*resolver_)[1]->getName(), RRType::AAAA(),
|
|
|
|
- rdata::in::AAAA("2001:db8::1"));
|
|
|
|
|
|
+ EXPECT_NO_THROW(resolver_->answer(1, (*resolver_)[1]->getName(),
|
|
|
|
+ RRType::AAAA(), rdata::in::AAAA("2001:db8::1")));
|
|
|
|
|
|
// Ready, as we have at last some address
|
|
// Ready, as we have at last some address
|
|
EXPECT_EQ(Fetchable::READY, zone->getState());
|
|
EXPECT_EQ(Fetchable::READY, zone->getState());
|