Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
6906362b
Commit
6906362b
authored
Sep 07, 2011
by
JINMEI Tatuya
Browse files
[1068] used google test's TYPED_TEST to share many of the test cases
with the mock accessor and sqlite3 accessor.
parent
c6d2a365
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/tests/Makefile.am
View file @
6906362b
...
...
@@ -65,3 +65,4 @@ EXTRA_DIST += testdata/sql1.example.com.signed
EXTRA_DIST
+=
testdata/sql2.example.com.signed
EXTRA_DIST
+=
testdata/test-root.sqlite3
EXTRA_DIST
+=
testdata/test.sqlite3
EXTRA_DIST
+=
testdata/rwtest.sqlite3
src/lib/datasrc/tests/database_unittest.cc
View file @
6906362b
...
...
@@ -25,6 +25,7 @@
#include <datasrc/zone.h>
#include <datasrc/data_source.h>
#include <datasrc/iterator.h>
#include <datasrc/sqlite3_accessor.h>
#include <testutils/dnsmessage_test.h>
...
...
@@ -610,155 +611,17 @@ private:
// might not come in 'normal' order)
// It shall immediately fail if you try to add the same name twice.
void
fillData
()
{
// some plain data
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"AAAA"
,
"3600"
,
""
,
"2001:db8::1"
);
addRecord
(
"AAAA"
,
"3600"
,
""
,
"2001:db8::2"
);
addCurName
(
"www.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"AAAA"
,
"3600"
,
""
,
"2001:db8::1"
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.2"
);
addCurName
(
"www2.example.org."
);
addRecord
(
"CNAME"
,
"3600"
,
""
,
"www.example.org."
);
addCurName
(
"cname.example.org."
);
// some DNSSEC-'signed' data
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"A 5 3 3600 20000101000000 20000201000000 12346 example.org. FAKEFAKEFAKE"
);
addRecord
(
"AAAA"
,
"3600"
,
""
,
"2001:db8::1"
);
addRecord
(
"AAAA"
,
"3600"
,
""
,
"2001:db8::2"
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"AAAA 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addCurName
(
"signed1.example.org."
);
addRecord
(
"CNAME"
,
"3600"
,
""
,
"www.example.org."
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"CNAME 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addCurName
(
"signedcname1.example.org."
);
// special case might fail; sig is for cname, which isn't there (should be ignored)
// (ignoring of 'normal' other type is done above by www.)
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"CNAME 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addCurName
(
"acnamesig1.example.org."
);
// let's pretend we have a database that is not careful
// about the order in which it returns data
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addRecord
(
"AAAA"
,
"3600"
,
""
,
"2001:db8::2"
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"A 5 3 3600 20000101000000 20000201000000 12346 example.org. FAKEFAKEFAKE"
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"AAAA 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addRecord
(
"AAAA"
,
"3600"
,
""
,
"2001:db8::1"
);
addCurName
(
"signed2.example.org."
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"CNAME 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addRecord
(
"CNAME"
,
"3600"
,
""
,
"www.example.org."
);
addCurName
(
"signedcname2.example.org."
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"CNAME 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addCurName
(
"acnamesig2.example.org."
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"CNAME 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addCurName
(
"acnamesig3.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"A"
,
"360"
,
""
,
"192.0.2.2"
);
addCurName
(
"ttldiff1.example.org."
);
addRecord
(
"A"
,
"360"
,
""
,
"192.0.2.1"
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.2"
);
addCurName
(
"ttldiff2.example.org."
);
// also add some intentionally bad data
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"CNAME"
,
"3600"
,
""
,
"www.example.org."
);
addCurName
(
"badcname1.example.org."
);
addRecord
(
"CNAME"
,
"3600"
,
""
,
"www.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addCurName
(
"badcname2.example.org."
);
addRecord
(
"CNAME"
,
"3600"
,
""
,
"www.example.org."
);
addRecord
(
"CNAME"
,
"3600"
,
""
,
"www.example2.org."
);
addCurName
(
"badcname3.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"bad"
);
addCurName
(
"badrdata.example.org."
);
addRecord
(
"BAD_TYPE"
,
"3600"
,
""
,
"192.0.2.1"
);
addCurName
(
"badtype.example.org."
);
addRecord
(
"A"
,
"badttl"
,
""
,
"192.0.2.1"
);
addCurName
(
"badttl.example.org."
);
addRecord
(
"A"
,
"badttl"
,
""
,
"192.0.2.1"
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"A 5 3 3600 somebaddata 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addCurName
(
"badsig.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"RRSIG"
,
"3600"
,
"TXT"
,
"A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addCurName
(
"badsigtype.example.org."
);
// Data for testing delegation (with NS and DNAME)
addRecord
(
"NS"
,
"3600"
,
""
,
"ns.example.com."
);
addRecord
(
"NS"
,
"3600"
,
""
,
"ns.delegation.example.org."
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"NS 5 3 3600 20000101000000 "
"20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addCurName
(
"delegation.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addCurName
(
"ns.delegation.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addCurName
(
"deep.below.delegation.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"DNAME"
,
"3600"
,
""
,
"dname.example.com."
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"DNAME 5 3 3600 20000101000000 "
"20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addCurName
(
"dname.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addCurName
(
"below.dname.example.org."
);
// Broken NS
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"NS"
,
"3600"
,
""
,
"ns.example.com."
);
addCurName
(
"brokenns1.example.org."
);
addRecord
(
"NS"
,
"3600"
,
""
,
"ns.example.com."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addCurName
(
"brokenns2.example.org."
);
// Now double DNAME, to test failure mode
addRecord
(
"DNAME"
,
"3600"
,
""
,
"dname1.example.com."
);
addRecord
(
"DNAME"
,
"3600"
,
""
,
"dname2.example.com."
);
addCurName
(
"baddname.example.org."
);
// Put some data into apex (including NS) so we can check our NS
// doesn't break anything
addRecord
(
"NS"
,
"3600"
,
""
,
"ns.example.com."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addRecord
(
"RRSIG"
,
"3600"
,
""
,
"NS 5 3 3600 20000101000000 "
"20000201000000 12345 example.org. FAKEFAKEFAKE"
);
addCurName
(
"example.org."
);
// This is because of empty domain test
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.1"
);
addCurName
(
"a.b.example.org."
);
// Something for wildcards
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.5"
);
addCurName
(
"*.wild.example.org."
);
addRecord
(
"AAAA"
,
"3600"
,
""
,
"2001:db8::5"
);
addCurName
(
"cancel.here.wild.example.org."
);
addRecord
(
"NS"
,
"3600"
,
""
,
"ns.example.com."
);
addCurName
(
"delegatedwild.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.5"
);
addCurName
(
"*.delegatedwild.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.5"
);
addCurName
(
"wild.*.foo.example.org."
);
addRecord
(
"A"
,
"3600"
,
""
,
"192.0.2.5"
);
addCurName
(
"wild.*.foo.*.bar.example.org."
);
const
char
*
prev_name
=
NULL
;
for
(
int
i
=
0
;
TEST_RECORDS
[
i
][
0
]
!=
NULL
;
++
i
)
{
if
(
prev_name
!=
NULL
&&
strcmp
(
prev_name
,
TEST_RECORDS
[
i
][
0
])
!=
0
)
{
addCurName
(
prev_name
);
}
prev_name
=
TEST_RECORDS
[
i
][
0
];
addRecord
(
TEST_RECORDS
[
i
][
1
],
TEST_RECORDS
[
i
][
2
],
TEST_RECORDS
[
i
][
3
],
TEST_RECORDS
[
i
][
4
]);
}
addCurName
(
prev_name
);
}
};
...
...
@@ -775,6 +638,10 @@ TEST(DatabaseConnectionTest, getAllRecords) {
isc
::
NotImplemented
);
}
// This test fixture is templated so that we can share (most of) the test
// cases with different types of data sources. Note that in test cases
// we need to use 'this' to refer to member variables of the test class.
template
<
typename
ACCESSOR_TYPE
>
class
DatabaseClientTest
:
public
::
testing
::
Test
{
public:
DatabaseClientTest
()
:
zname_
(
"example.org"
),
qname_
(
"www.example.org"
),
...
...
@@ -810,9 +677,10 @@ public:
* times per test.
*/
void
createClient
()
{
current_accessor_
=
new
MockAccessor
();
current_accessor_
=
new
ACCESSOR_TYPE
();
is_mock_
=
(
dynamic_cast
<
MockAccessor
*>
(
current_accessor_
)
!=
NULL
);
client_
.
reset
(
new
DatabaseClient
(
qclass_
,
shared_ptr
<
DatabaseAccessor
>
(
shared_ptr
<
ACCESSOR_TYPE
>
(
current_accessor_
)));
}
...
...
@@ -826,7 +694,9 @@ public:
dynamic_pointer_cast
<
DatabaseClient
::
Finder
>
(
zone
.
zone_finder
));
ASSERT_NE
(
shared_ptr
<
DatabaseClient
::
Finder
>
(),
finder
)
<<
"Wrong type of finder"
;
EXPECT_EQ
(
READONLY_ZONE_ID
,
finder
->
zone_id
());
if
(
is_mock_
)
{
EXPECT_EQ
(
READONLY_ZONE_ID
,
finder
->
zone_id
());
}
EXPECT_EQ
(
current_accessor_
,
&
finder
->
getAccessor
());
}
...
...
@@ -835,30 +705,49 @@ public:
EXPECT_EQ
(
result
::
SUCCESS
,
zone
.
code
);
shared_ptr
<
DatabaseClient
::
Finder
>
finder
(
dynamic_pointer_cast
<
DatabaseClient
::
Finder
>
(
zone
.
zone_finder
));
EXPECT_EQ
(
READONLY_ZONE_ID
,
finder
->
zone_id
());
if
(
is_mock_
)
{
EXPECT_EQ
(
READONLY_ZONE_ID
,
finder
->
zone_id
());
}
return
(
finder
);
}
// Helper methods for update tests
//bool isRollbacked(bool expected = false) const {
bool
isRollbacked
()
const
{
return
(
update_accessor_
->
isRollbacked
());
bool
isRollbacked
(
bool
expected
=
false
)
const
{
if
(
is_mock_
)
{
const
MockAccessor
&
mock_accessor
=
dynamic_cast
<
const
MockAccessor
&>
(
*
update_accessor_
);
return
(
mock_accessor
.
isRollbacked
());
}
else
{
return
(
expected
);
}
}
void
checkLastAdded
(
const
char
*
const
expected
[])
const
{
for
(
int
i
=
0
;
i
<
DatabaseAccessor
::
ADD_COLUMN_COUNT
;
++
i
)
{
EXPECT_EQ
(
expected
[
i
],
current_accessor_
->
getLatestClone
()
->
getLastAdded
()[
i
]);
if
(
is_mock_
)
{
const
MockAccessor
*
mock_accessor
=
dynamic_cast
<
const
MockAccessor
*>
(
current_accessor_
);
for
(
int
i
=
0
;
i
<
DatabaseAccessor
::
ADD_COLUMN_COUNT
;
++
i
)
{
EXPECT_EQ
(
expected
[
i
],
mock_accessor
->
getLatestClone
()
->
getLastAdded
()[
i
]);
}
}
}
void
setUpdateAccessor
()
{
update_accessor_
=
current_accessor_
->
getLatestClone
();
if
(
is_mock_
)
{
const
MockAccessor
*
mock_accessor
=
dynamic_cast
<
const
MockAccessor
*>
(
current_accessor_
);
update_accessor_
=
mock_accessor
->
getLatestClone
();
}
}
// Some tests only work for MockAccessor. We remember whether our accessor
// is of that type.
bool
is_mock_
;
// Will be deleted by client_, just keep the current value for comparison.
MockAccessor
*
current_accessor_
;
ACCESSOR_TYPE
*
current_accessor_
;
shared_ptr
<
DatabaseClient
>
client_
;
const
std
::
string
database_name_
;
...
...
@@ -876,7 +765,7 @@ public:
// update related objects to be tested
ZoneUpdaterPtr
updater_
;
shared_ptr
<
const
Mock
Accessor
>
update_accessor_
;
shared_ptr
<
const
Database
Accessor
>
update_accessor_
;
// placeholders
const
std
::
vector
<
std
::
string
>
empty_rdatas_
;
// for NXRRSET/NXDOMAIN
...
...
@@ -884,25 +773,55 @@ public:
std
::
vector
<
std
::
string
>
expected_sig_rdatas_
;
};
TEST_F
(
DatabaseClientTest
,
zoneNotFound
)
{
DataSourceClient
::
FindResult
zone
(
client_
->
findZone
(
Name
(
"example.com"
)));
class
TestSQLite3Accessor
:
public
SQLite3Accessor
{
public:
TestSQLite3Accessor
()
:
SQLite3Accessor
(
TEST_DATA_BUILDDIR
"/rwtest.sqlite3.copied"
,
RRClass
::
IN
())
{
startUpdateZone
(
"example.org."
,
true
);
string
columns
[
ADD_COLUMN_COUNT
];
for
(
int
i
=
0
;
TEST_RECORDS
[
i
][
0
]
!=
NULL
;
++
i
)
{
columns
[
ADD_NAME
]
=
TEST_RECORDS
[
i
][
0
];
columns
[
ADD_REV_NAME
]
=
Name
(
columns
[
ADD_NAME
]).
reverse
().
toText
();
columns
[
ADD_TYPE
]
=
TEST_RECORDS
[
i
][
1
];
columns
[
ADD_TTL
]
=
TEST_RECORDS
[
i
][
2
];
columns
[
ADD_SIGTYPE
]
=
TEST_RECORDS
[
i
][
3
];
columns
[
ADD_RDATA
]
=
TEST_RECORDS
[
i
][
4
];
addRecordToZone
(
columns
);
}
commitUpdateZone
();
}
};
// The following two lines instantiate test cases with concrete accessor
// classes to be tested.
typedef
::
testing
::
Types
<
MockAccessor
,
TestSQLite3Accessor
>
TestAccessorTypes
;
TYPED_TEST_CASE
(
DatabaseClientTest
,
TestAccessorTypes
);
TYPED_TEST
(
DatabaseClientTest
,
zoneNotFound
)
{
DataSourceClient
::
FindResult
zone
(
this
->
client_
->
findZone
(
Name
(
"example.com"
)));
EXPECT_EQ
(
result
::
NOTFOUND
,
zone
.
code
);
}
TEST_F
(
DatabaseClientTest
,
exactZone
)
{
DataSourceClient
::
FindResult
zone
(
client_
->
findZone
(
Name
(
"example.org"
)));
TYPED_TEST
(
DatabaseClientTest
,
exactZone
)
{
DataSourceClient
::
FindResult
zone
(
this
->
client_
->
findZone
(
Name
(
"example.org"
)));
EXPECT_EQ
(
result
::
SUCCESS
,
zone
.
code
);
checkZoneFinder
(
zone
);
this
->
checkZoneFinder
(
zone
);
}
TEST
_F
(
DatabaseClientTest
,
superZone
)
{
DataSourceClient
::
FindResult
zone
(
client_
->
findZone
(
Name
(
TYPED_
TEST
(
DatabaseClientTest
,
superZone
)
{
DataSourceClient
::
FindResult
zone
(
this
->
client_
->
findZone
(
Name
(
"sub.example.org"
)));
EXPECT_EQ
(
result
::
PARTIALMATCH
,
zone
.
code
);
checkZoneFinder
(
zone
);
this
->
checkZoneFinder
(
zone
);
}
TEST_F
(
DatabaseClientTest
,
noAccessorException
)
{
// This test doesn't depend on derived accessor class, so we use TEST().
TEST
(
GenericDatabaseClientTest
,
noAccessorException
)
{
// We need a dummy variable here; some compiler would regard it a mere
// declaration instead of an instantiation and make the test fail.
EXPECT_THROW
(
DatabaseClient
dummy
(
RRClass
::
IN
(),
...
...
@@ -911,13 +830,14 @@ TEST_F(DatabaseClientTest, noAccessorException) {
}
// If the zone doesn't exist, exception is thrown
TEST_F
(
DatabaseClientTest
,
noZoneIterator
)
{
EXPECT_THROW
(
client_
->
getIterator
(
Name
(
"example.com"
)),
DataSourceError
);
TYPED_TEST
(
DatabaseClientTest
,
noZoneIterator
)
{
EXPECT_THROW
(
this
->
client_
->
getIterator
(
Name
(
"example.com"
)),
DataSourceError
);
}
// If the zone doesn't exist and iteration is not implemented, it still throws
// the exception it doesn't exist
TEST
_F
(
DatabaseClientTest
,
noZoneNotImplementedIterator
)
{
TEST
(
Generic
DatabaseClientTest
,
noZoneNotImplementedIterator
)
{
EXPECT_THROW
(
DatabaseClient
(
RRClass
::
IN
(),
boost
::
shared_ptr
<
DatabaseAccessor
>
(
new
NopAccessor
())).
getIterator
(
...
...
@@ -925,32 +845,44 @@ TEST_F(DatabaseClientTest, noZoneNotImplementedIterator) {
DataSourceError
);
}
TEST
_F
(
DatabaseClientTest
,
notImplementedIterator
)
{
TEST
(
Generic
DatabaseClientTest
,
notImplementedIterator
)
{
EXPECT_THROW
(
DatabaseClient
(
RRClass
::
IN
(),
shared_ptr
<
DatabaseAccessor
>
(
new
NopAccessor
())).
getIterator
(
Name
(
"example.org"
)),
isc
::
NotImplemented
);
}
// Pretend a bug in the connection and pass NULL as the context
// Should not crash, but gracefully throw
TEST_F
(
DatabaseClientTest
,
nullIteratorContext
)
{
EXPECT_THROW
(
client_
->
getIterator
(
Name
(
"null.example.org"
)),
isc
::
Unexpected
);
// Should not crash, but gracefully throw. Works for the mock accessor only.
TYPED_TEST
(
DatabaseClientTest
,
nullIteratorContext
)
{
if
(
this
->
is_mock_
)
{
EXPECT_THROW
(
this
->
client_
->
getIterator
(
Name
(
"null.example.org"
)),
isc
::
Unexpected
);
}
}
// It doesn't crash or anything if the zone is completely empty
TEST_F
(
DatabaseClientTest
,
emptyIterator
)
{
ZoneIteratorPtr
it
(
client_
->
getIterator
(
Name
(
"empty.example.org"
)));
// It doesn't crash or anything if the zone is completely empty.
// Works for the mock accessor only.
TYPED_TEST
(
DatabaseClientTest
,
emptyIterator
)
{
if
(
!
this
->
is_mock_
)
{
return
;
}
ZoneIteratorPtr
it
(
this
->
client_
->
getIterator
(
Name
(
"empty.example.org"
)));
EXPECT_EQ
(
ConstRRsetPtr
(),
it
->
getNextRRset
());
// This is past the end, it should throw
EXPECT_THROW
(
it
->
getNextRRset
(),
isc
::
Unexpected
);
}
// Iterate trough a zone
TEST
_F
(
DatabaseClientTest
,
iterator
)
{
ZoneIteratorPtr
it
(
client_
->
getIterator
(
Name
(
"example.org"
)));
// Iterate t
h
rough a zone
TYPED_
TEST
(
DatabaseClientTest
,
iterator
)
{
ZoneIteratorPtr
it
(
this
->
client_
->
getIterator
(
Name
(
"example.org"
)));
ConstRRsetPtr
rrset
(
it
->
getNextRRset
());
ASSERT_NE
(
ConstRRsetPtr
(),
rrset
);
// The rest of the checks work only for the mock accessor.
if
(
!
this
->
is_mock_
)
{
return
;
}
EXPECT_EQ
(
Name
(
"example.org"
),
rrset
->
getName
());
EXPECT_EQ
(
RRClass
::
IN
(),
rrset
->
getClass
());
EXPECT_EQ
(
RRType
::
SOA
(),
rrset
->
getType
());
...
...
@@ -993,10 +925,14 @@ TEST_F(DatabaseClientTest, iterator) {
}
// This has inconsistent TTL in the set (the rest, like nonsense in
// the data is handled in rdata itself).
TEST_F
(
DatabaseClientTest
,
badIterator
)
{
// the data is handled in rdata itself). Work for mock iterator only.
TYPED_TEST
(
DatabaseClientTest
,
badIterator
)
{
if
(
!
this
->
is_mock_
)
{
return
;
}
// It should not throw, but get the lowest one of them
ZoneIteratorPtr
it
(
client_
->
getIterator
(
Name
(
"bad.example.org"
)));
ZoneIteratorPtr
it
(
this
->
client_
->
getIterator
(
Name
(
"bad.example.org"
)));
EXPECT_EQ
(
it
->
getNextRRset
()
->
getTTL
(),
isc
::
dns
::
RRTTL
(
300
));
}
...
...
@@ -1053,544 +989,511 @@ doFindTest(ZoneFinder& finder,
}
}
TEST
_F
(
DatabaseClientTest
,
find
)
{
shared_ptr
<
DatabaseClient
::
Finder
>
finder
(
getFinder
());
TYPED_
TEST
(
DatabaseClientTest
,
find
)
{
shared_ptr
<
DatabaseClient
::
Finder
>
finder
(
this
->
getFinder
());
expected_rdatas_
.
clear
();
expected_sig_rdatas_
.
clear
();
expected_rdatas_
.
push_back
(
"192.0.2.1"
);
this
->
expected_rdatas_
.
clear
();
this
->
expected_sig_rdatas_
.
clear
();
this
->
expected_rdatas_
.
push_back
(
"192.0.2.1"
);
doFindTest
(
*
finder
,
isc
::
dns
::
Name
(
"www.example.org."
),
isc
::
dns
::
RRType
::
A
(),
isc
::
dns
::
RRType
::
A
(),
isc
::
dns
::
RRTTL
(
3600
),
ZoneFinder
::
SUCCESS
,
expected_rdatas_
,
expected_sig_rdatas_
);
this
->
qtype_
,
this
->
qtype_
,
this
->
rrttl_
,
ZoneFinder
::
SUCCESS
,
this
->
expected_rdatas_
,
this
->
expected_sig_rdatas_
);
expected_rdatas_
.
clear
();
expected_sig_rdatas_
.
clear
();
expected_rdatas_
.
push_back
(
"192.0.2.1"
);
expected_rdatas_
.
push_back
(
"192.0.2.2"
);
this
->
expected_rdatas_
.
clear
();
this
->
expected_sig_rdatas_
.
clear
();
this
->
expected_rdatas_
.
push_back
(
"192.0.2.1"
);
this
->
expected_rdatas_
.
push_back
(
"192.0.2.2"
);
doFindTest
(
*
finder
,
isc
::
dns
::
Name
(
"www2.example.org."
),
isc
::
dns
::
RRType
::
A
(),
isc
::
dns
::
RRType
::
A
(),
isc
::
dns
::
RRTTL
(
3600
),
ZoneFinder
::
SUCCESS
,
expected_rdatas_
,
expected_sig_rdatas_
);
this
->
qtype_
,
this
->
qtype_
,
this
->
rrttl_
,
ZoneFinder
::
SUCCESS
,
this
->
expected_rdatas_
,
this
->
expected_sig_rdatas_
);
expected_rdatas_
.
clear
();
expected_sig_rdatas_
.
clear
();
expected_rdatas_
.
push_back
(
"2001:db8::1"
);
expected_rdatas_
.
push_back
(
"2001:db8::2"
);
this
->
expected_rdatas_
.
clear
();
this
->
expected_sig_rdatas_
.
clear
();
this
->
expected_rdatas_
.
push_back
(
"2001:db8::1"
);
this
->
expected_rdatas_
.
push_back
(
"2001:db8::2"
);
doFindTest
(
*
finder
,
isc
::
dns
::
Name
(
"www.example.org."
),
isc
::
dns
::
RRType
::
AAAA
(),
isc
::
dns
::
RRType
::
AAAA
(),
isc
::
dns
::
RRTTL
(
3600
)
,
this
->
rrttl_
,
ZoneFinder
::
SUCCESS
,
expected_rdatas_
,
expected_sig_rdatas_
);
this
->
expected_rdatas_
,
this
->
expected_sig_rdatas_
);
expected_rdatas_
.
clear
();
expected_sig_rdatas_
.
clear
();
this
->
expected_rdatas_
.
clear
();
this
->
expected_sig_rdatas_
.
clear
();
doFindTest
(
*
finder
,
isc
::
dns
::
Name
(
"www.example.org."
),
isc
::
dns
::
RRType
::
TXT
(),
isc
::
dns
::
RRType
::
TXT
(),
isc
::
dns
::
RRTTL
(
3600
)
,
this
->
rrttl_
,
ZoneFinder
::
NXRRSET
,
expected_rdatas_
,
expected_sig_rdatas_
);
this
->
expected_rdatas_
,
this
->
expected_sig_rdatas_
);
expected_rdatas_
.
clear
();
expected_sig_rdatas_
.
clear
();
expected_rdatas_
.
push_back
(
"www.example.org."
);
this
->
expected_rdatas_
.
clear
();
this
->
expected_sig_rdatas_
.
clear
();
this
->
expected_rdatas_
.
push_back
(
"www.example.org."
);
doFindTest
(
*
finder
,
isc
::
dns
::
Name
(
"cname.example.org."
),
isc
::
dns
::
RRType
::
A
(),
isc
::
dns
::
RRType
::
CNAME
(),
isc
::
dns
::
RRTTL
(
3600
),
ZoneFinder
::
CNAME
,
expected_rdatas_
,
expected_sig_rdatas_
);
expected_rdatas_
.
clear
();
expected_sig_rdatas_
.
clear
();
expected_rdatas_
.
push_back
(
"www.example.org."
);
this
->
qtype_
,
isc
::
dns
::
RRType
::
CNAME
(),
this
->
rrttl_
,
ZoneFinder
::
CNAME
,
this
->
expected_rdatas_
,
this
->
expected_sig_rdatas_
);
this
->
expected_rdatas_
.
clear
();
this
->
expected_sig_rdatas_
.
clear
();
this
->
expected_rdatas_
.
push_back
(
"www.example.org."
);
doFindTest
(
*
finder
,
isc
::
dns
::
Name
(
"cname.example.org."
),
isc
::
dns
::
RRType
::
CNAME
(),
isc
::
dns
::
RRType
::
CNAME
(),
isc
::
dns
::
RRTTL
(
3600
),
ZoneFinder
::
SUCCESS
,
expected_rdatas_
,
expected_sig_rdatas_
);
this
->
rrttl_
,
ZoneFinder
::
SUCCESS
,
this
->
expected_rdatas_
,
this
->
expected_sig_rdatas_
);
expected_rdatas_
.
clear
();
expected_sig_rdatas_
.
clear
();
this
->
expected_rdatas_
.
clear
();
this
->
expected_sig_rdatas_
.
clear
();
doFindTest
(
*
finder
,
isc
::
dns
::
Name
(
"doesnotexist.example.org."
),
isc
::
dns
::
RRType
::
A
(),
isc
::
dns
::
RRType
::
A
(),
isc
::
dns
::
RRTTL
(
3600
),
ZoneFinder
::
NXDOMAIN
,
expected_rdatas_
,
expected_sig_rdatas_
);
expected_rdatas_
.
clear
();
expected_sig_rdatas_
.
clear
();
expected_rdatas_
.
push_back
(
"192.0.2.1"
);
expected_sig_rdatas_
.
push_back
(
"A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
expected_sig_rdatas_
.
push_back
(
"A 5 3 3600 20000101000000 20000201000000 12346 example.org. FAKEFAKEFAKE"
);
this
->
qtype_
,
this
->
qtype_
,
this
->
rrttl_
,
ZoneFinder
::
NXDOMAIN
,
this
->
expected_rdatas_
,
this
->
expected_sig_rdatas_
);
this
->
expected_rdatas_
.
clear
();
this
->
expected_sig_rdatas_
.
clear
();
this
->
expected_rdatas_
.
push_back
(
"192.0.2.1"
);
this
->
expected_sig_rdatas_
.
push_back
(
"A 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
this
->
expected_sig_rdatas_
.
push_back
(
"A 5 3 3600 20000101000000 20000201000000 12346 example.org. FAKEFAKEFAKE"
);
doFindTest
(
*
finder
,
isc
::
dns
::
Name
(
"signed1.example.org."
),
isc
::
dns
::
RRType
::
A
(),
isc
::
dns
::
RRType
::
A
(),
isc
::
dns
::
RRTTL
(
3600
),
ZoneFinder
::
SUCCESS
,
expected_rdatas_
,
expected_sig_rdatas_
);
expected_rdatas_
.
clear
();
expected_sig_rdatas_
.
clear
();
expected_rdatas_
.
push_back
(
"2001:db8::1"
);
expected_rdatas_
.
push_back
(
"2001:db8::2"
);
expected_sig_rdatas_
.
push_back
(
"AAAA 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
this
->
qtype_
,
this
->
qtype_
,
this
->
rrttl_
,
ZoneFinder
::
SUCCESS
,
this
->
expected_rdatas_
,
this
->
expected_sig_rdatas_
);
this
->
expected_rdatas_
.
clear
();
this
->
expected_sig_rdatas_
.
clear
();
this
->
expected_rdatas_
.
push_back
(
"2001:db8::1"
);
this
->
expected_rdatas_
.
push_back
(
"2001:db8::2"
);
this
->
expected_sig_rdatas_
.
push_back
(
"AAAA 5 3 3600 20000101000000 20000201000000 12345 example.org. FAKEFAKEFAKE"
);
doFindTest
(
*
finder
,
isc
::
dns
::
Name
(
"signed1.example.org."
),
isc
::
dns
::
RRType
::
AAAA
(),
isc
::
dns
::
RRType
::
AAAA
(),
isc
::
dns
::
RRTTL
(
3600
),
ZoneFinder
::
SUCCESS
,
expected_rdatas_
,
expected_sig_rdatas_
);
this
->
rrttl_
,
ZoneFinder
::
SUCCESS
,
this
->
expected_rdatas_
,
this
->
expected_sig_rdatas_
);
expected_rdatas_
.
clear
();
expected_sig_rdatas_
.
clear
();
this
->
expected_rdatas_
.
clear
();
this
->
expected_sig_rdatas_
.
clear
();
doFindTest
(
*
finder
,
isc
::
dns
::
Name
(
"signed1.example.org."
),
isc
::
dns
::
RRType
::
TXT
(),
isc
::
dns
::
RRType
::
TXT
(),
isc
::