Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
34cfc02f
Commit
34cfc02f
authored
Jul 27, 2011
by
Michal 'vorner' Vaner
Browse files
[trac1060] Rename MemoryDataSrc to InMemoryClient
And some more similar renaming. Just to match naming conventions.
parent
45dcf93c
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/bin/auth/auth_config.cc
View file @
34cfc02f
...
...
@@ -107,7 +107,7 @@ DatasourcesConfig::commit() {
// server implementation details, and isn't scalable wrt the number of
// data source types, and should eventually be improved.
// Currently memory data source for class IN is the only possibility.
server_
.
setMemory
DataSrc
(
RRClass
::
IN
(),
AuthSrv
::
Memory
DataSrc
Ptr
());
server_
.
set
In
Memory
Client
(
RRClass
::
IN
(),
AuthSrv
::
In
Memory
Client
Ptr
());
BOOST_FOREACH
(
shared_ptr
<
AuthConfigParser
>
datasrc_config
,
datasources_
)
{
datasrc_config
->
commit
();
...
...
@@ -125,12 +125,12 @@ public:
{}
virtual
void
build
(
ConstElementPtr
config_value
);
virtual
void
commit
()
{
server_
.
setMemory
DataSrc
(
rrclass_
,
memory_
datasrc
_
);
server_
.
set
In
Memory
Client
(
rrclass_
,
memory_
client
_
);
}
private:
AuthSrv
&
server_
;
RRClass
rrclass_
;
AuthSrv
::
Memory
DataSrc
Ptr
memory_
datasrc
_
;
AuthSrv
::
In
Memory
Client
Ptr
memory_
client
_
;
};
void
...
...
@@ -143,8 +143,8 @@ MemoryDatasourceConfig::build(ConstElementPtr config_value) {
// We'd eventually optimize building zones (in case of reloading) by
// selectively loading fresh zones. Right now we simply check the
// RR class is supported by the server implementation.
server_
.
getMemory
DataSrc
(
rrclass_
);
memory_
datasrc
_
=
AuthSrv
::
Memory
DataSrc
Ptr
(
new
Memory
DataSrc
());
server_
.
get
In
Memory
Client
(
rrclass_
);
memory_
client
_
=
AuthSrv
::
In
Memory
Client
Ptr
(
new
In
Memory
Client
());
ConstElementPtr
zones_config
=
config_value
->
get
(
"zones"
);
if
(
!
zones_config
)
{
...
...
@@ -165,7 +165,7 @@ MemoryDatasourceConfig::build(ConstElementPtr config_value) {
}
shared_ptr
<
MemoryZoneFinder
>
new_zone
(
new
MemoryZoneFinder
(
rrclass_
,
Name
(
origin
->
stringValue
())));
const
result
::
Result
result
=
memory_
datasrc
_
->
addZone
(
new_zone
);
const
result
::
Result
result
=
memory_
client
_
->
addZone
(
new_zone
);
if
(
result
==
result
::
EXIST
)
{
isc_throw
(
AuthConfigError
,
"zone "
<<
origin
->
str
()
<<
" already exists"
);
...
...
src/bin/auth/auth_srv.cc
View file @
34cfc02f
...
...
@@ -108,8 +108,8 @@ public:
AbstractSession
*
xfrin_session_
;
/// In-memory data source. Currently class IN only for simplicity.
const
RRClass
memory_
datasrc
_class_
;
AuthSrv
::
Memory
DataSrc
Ptr
memory_
datasrc
_
;
const
RRClass
memory_
client
_class_
;
AuthSrv
::
In
Memory
Client
Ptr
memory_
client
_
;
/// Hot spot cache
isc
::
datasrc
::
HotCache
cache_
;
...
...
@@ -145,7 +145,7 @@ AuthSrvImpl::AuthSrvImpl(const bool use_cache,
AbstractXfroutClient
&
xfrout_client
)
:
config_session_
(
NULL
),
xfrin_session_
(
NULL
),
memory_
datasrc
_class_
(
RRClass
::
IN
()),
memory_
client
_class_
(
RRClass
::
IN
()),
statistics_timer_
(
io_service_
),
counters_
(),
keyring_
(
NULL
),
...
...
@@ -329,34 +329,34 @@ AuthSrv::getConfigSession() const {
return
(
impl_
->
config_session_
);
}
AuthSrv
::
Memory
DataSrc
Ptr
AuthSrv
::
getMemory
DataSrc
(
const
RRClass
&
rrclass
)
{
AuthSrv
::
In
Memory
Client
Ptr
AuthSrv
::
get
In
Memory
Client
(
const
RRClass
&
rrclass
)
{
// XXX: for simplicity, we only support the IN class right now.
if
(
rrclass
!=
impl_
->
memory_
datasrc
_class_
)
{
if
(
rrclass
!=
impl_
->
memory_
client
_class_
)
{
isc_throw
(
InvalidParameter
,
"Memory data source is not supported for RR class "
<<
rrclass
);
}
return
(
impl_
->
memory_
datasrc
_
);
return
(
impl_
->
memory_
client
_
);
}
void
AuthSrv
::
setMemory
DataSrc
(
const
isc
::
dns
::
RRClass
&
rrclass
,
Memory
DataSrc
Ptr
memory_
datasrc
)
AuthSrv
::
set
In
Memory
Client
(
const
isc
::
dns
::
RRClass
&
rrclass
,
In
Memory
Client
Ptr
memory_
client
)
{
// XXX: see above
if
(
rrclass
!=
impl_
->
memory_
datasrc
_class_
)
{
if
(
rrclass
!=
impl_
->
memory_
client
_class_
)
{
isc_throw
(
InvalidParameter
,
"Memory data source is not supported for RR class "
<<
rrclass
);
}
else
if
(
!
impl_
->
memory_
datasrc
_
&&
memory_
datasrc
)
{
}
else
if
(
!
impl_
->
memory_
client
_
&&
memory_
client
)
{
LOG_DEBUG
(
auth_logger
,
DBG_AUTH_OPS
,
AUTH_MEM_DATASRC_ENABLED
)
.
arg
(
rrclass
);
}
else
if
(
impl_
->
memory_
datasrc
_
&&
!
memory_
datasrc
)
{
}
else
if
(
impl_
->
memory_
client
_
&&
!
memory_
client
)
{
LOG_DEBUG
(
auth_logger
,
DBG_AUTH_OPS
,
AUTH_MEM_DATASRC_DISABLED
)
.
arg
(
rrclass
);
}
impl_
->
memory_
datasrc
_
=
memory_
datasrc
;
impl_
->
memory_
client
_
=
memory_
client
;
}
uint32_t
...
...
@@ -505,10 +505,10 @@ AuthSrvImpl::processNormalQuery(const IOMessage& io_message, MessagePtr message,
// If a memory data source is configured call the separate
// Query::process()
const
ConstQuestionPtr
question
=
*
message
->
beginQuestion
();
if
(
memory_
datasrc
_
&&
memory_
datasrc
_class_
==
question
->
getClass
())
{
if
(
memory_
client
_
&&
memory_
client
_class_
==
question
->
getClass
())
{
const
RRType
&
qtype
=
question
->
getType
();
const
Name
&
qname
=
question
->
getName
();
auth
::
Query
(
*
memory_
datasrc
_
,
qname
,
qtype
,
*
message
).
process
();
auth
::
Query
(
*
memory_
client
_
,
qname
,
qtype
,
*
message
).
process
();
}
else
{
datasrc
::
Query
query
(
*
message
,
cache_
,
dnssec_ok
);
data_sources_
.
doQuery
(
query
);
...
...
src/bin/auth/auth_srv.h
View file @
34cfc02f
...
...
@@ -17,7 +17,7 @@
#include
<string>
// For Memory
DataSrc
Ptr below. This should be a temporary definition until
// For
In
Memory
Client
Ptr below. This should be a temporary definition until
// we reorganize the data source framework.
#include
<boost/shared_ptr.hpp>
...
...
@@ -39,7 +39,7 @@
namespace
isc
{
namespace
datasrc
{
class
Memory
DataSrc
;
class
In
Memory
Client
;
}
namespace
xfr
{
class
AbstractXfroutClient
;
...
...
@@ -133,7 +133,7 @@ public:
/// If there is a data source installed, it will be replaced with the
/// new one.
///
/// In the current implementation, the SQLite data source and Memory
DataSrc
/// In the current implementation, the SQLite data source and
In
Memory
Client
/// are assumed.
/// We can enable memory data source and get the path of SQLite database by
/// the \c config parameter. If we disabled memory data source, the SQLite
...
...
@@ -233,16 +233,16 @@ public:
///
void
setXfrinSession
(
isc
::
cc
::
AbstractSession
*
xfrin_session
);
/// A shared pointer type for \c Memory
DataSrc
.
/// A shared pointer type for \c
In
Memory
Client
.
///
/// This is defined inside the \c AuthSrv class as it's supposed to be
/// a short term interface until we integrate the in-memory and other
/// data source frameworks.
typedef
boost
::
shared_ptr
<
isc
::
datasrc
::
Memory
DataSrc
>
MemoryDataSrc
Ptr
;
typedef
boost
::
shared_ptr
<
isc
::
datasrc
::
In
Memory
Client
>
InMemoryClient
Ptr
;
/// An immutable shared pointer type for \c Memory
DataSrc
.
typedef
boost
::
shared_ptr
<
const
isc
::
datasrc
::
Memory
DataSrc
>
ConstMemory
DataSrc
Ptr
;
/// An immutable shared pointer type for \c
In
Memory
Client
.
typedef
boost
::
shared_ptr
<
const
isc
::
datasrc
::
In
Memory
Client
>
Const
In
Memory
Client
Ptr
;
/// Returns the in-memory data source configured for the \c AuthSrv,
/// if any.
...
...
@@ -260,11 +260,11 @@ public:
/// \param rrclass The RR class of the requested in-memory data source.
/// \return A pointer to the in-memory data source, if configured;
/// otherwise NULL.
Memory
DataSrc
Ptr
getMemory
DataSrc
(
const
isc
::
dns
::
RRClass
&
rrclass
);
In
Memory
Client
Ptr
get
In
Memory
Client
(
const
isc
::
dns
::
RRClass
&
rrclass
);
/// Sets or replaces the in-memory data source of the specified RR class.
///
/// As noted in \c getMemory
DataSrc
(), some RR classes may not be
/// As noted in \c get
In
Memory
Client
(), some RR classes may not be
/// supported, in which case an exception of class \c InvalidParameter
/// will be thrown.
/// This method never throws an exception otherwise.
...
...
@@ -275,9 +275,9 @@ public:
/// in-memory data source.
///
/// \param rrclass The RR class of the in-memory data source to be set.
/// \param memory_datasrc A (shared) pointer to \c Memory
DataSrc
to be set.
void
setMemory
DataSrc
(
const
isc
::
dns
::
RRClass
&
rrclass
,
Memory
DataSrc
Ptr
memory_
datasrc
);
/// \param memory_datasrc A (shared) pointer to \c
In
Memory
Client
to be set.
void
set
In
Memory
Client
(
const
isc
::
dns
::
RRClass
&
rrclass
,
In
Memory
Client
Ptr
memory_
client
);
/// \brief Set the communication session with Statistics.
///
...
...
src/bin/auth/command.cc
View file @
34cfc02f
...
...
@@ -177,7 +177,7 @@ private:
const
RRClass
zone_class
=
class_elem
?
RRClass
(
class_elem
->
stringValue
())
:
RRClass
::
IN
();
AuthSrv
::
Memory
DataSrc
Ptr
datasrc
(
server
.
getMemory
DataSrc
(
zone_class
));
AuthSrv
::
In
Memory
Client
Ptr
datasrc
(
server
.
get
In
Memory
Client
(
zone_class
));
if
(
datasrc
==
NULL
)
{
isc_throw
(
AuthCommandError
,
"Memory data source is disabled"
);
}
...
...
@@ -189,7 +189,7 @@ private:
const
Name
origin
(
origin_elem
->
stringValue
());
// Get the current zone
const
Memory
DataSrc
::
FindResult
result
=
datasrc
->
findZone
(
origin
);
const
In
Memory
Client
::
FindResult
result
=
datasrc
->
findZone
(
origin
);
if
(
result
.
code
!=
result
::
SUCCESS
)
{
isc_throw
(
AuthCommandError
,
"Zone "
<<
origin
<<
" is not found in data source"
);
...
...
src/bin/auth/query.cc
View file @
34cfc02f
...
...
@@ -126,8 +126,8 @@ Query::process() const {
const
bool
qtype_is_any
=
(
qtype_
==
RRType
::
ANY
());
response_
.
setHeaderFlag
(
Message
::
HEADERFLAG_AA
,
false
);
const
Memory
DataSrc
::
FindResult
result
=
memory_
datasrc
_
.
findZone
(
qname_
);
const
In
Memory
Client
::
FindResult
result
=
memory_
client
_
.
findZone
(
qname_
);
// If we have no matching authoritative zone for the query name, return
// REFUSED. In short, this is to be compatible with BIND 9, but the
...
...
src/bin/auth/query.h
View file @
34cfc02f
...
...
@@ -26,7 +26,7 @@ class RRset;
}
namespace
datasrc
{
class
Memory
DataSrc
;
class
In
Memory
Client
;
}
namespace
auth
{
...
...
@@ -36,7 +36,7 @@ namespace auth {
///
/// Many of the design details for this class are still in flux.
/// We'll revisit and update them as we add more functionality, for example:
/// - memory_
datasrc
parameter of the constructor. It is a data source that
/// - memory_
client
parameter of the constructor. It is a data source that
/// uses in memory dedicated backend.
/// - as a related point, we may have to pass the RR class of the query.
/// in the initial implementation the RR class is an attribute of memory
...
...
@@ -51,7 +51,7 @@ namespace auth {
/// separate attribute setter.
/// - likewise, we'll eventually need to do per zone access control, for which
/// we need querier's information such as its IP address.
/// - memory_
datasrc
and response may better be parameters to process() instead
/// - memory_
client
and response may better be parameters to process() instead
/// of the constructor.
///
/// <b>Note:</b> The class name is intentionally the same as the one used in
...
...
@@ -135,15 +135,15 @@ public:
///
/// This constructor never throws an exception.
///
/// \param memory_
datasrc
The memory datasource wherein the answer to the query is
/// \param memory_
client
The memory datasource wherein the answer to the query is
/// to be found.
/// \param qname The query name
/// \param qtype The RR type of the query
/// \param response The response message to store the answer to the query.
Query
(
const
isc
::
datasrc
::
Memory
DataSrc
&
memory_
datasrc
,
Query
(
const
isc
::
datasrc
::
In
Memory
Client
&
memory_
client
,
const
isc
::
dns
::
Name
&
qname
,
const
isc
::
dns
::
RRType
&
qtype
,
isc
::
dns
::
Message
&
response
)
:
memory_
datasrc
_
(
memory_
datasrc
),
qname_
(
qname
),
qtype_
(
qtype
),
memory_
client
_
(
memory_
client
),
qname_
(
qname
),
qtype_
(
qtype
),
response_
(
response
)
{}
...
...
@@ -208,7 +208,7 @@ public:
};
private:
const
isc
::
datasrc
::
Memory
DataSrc
&
memory_
datasrc
_
;
const
isc
::
datasrc
::
In
Memory
Client
&
memory_
client
_
;
const
isc
::
dns
::
Name
&
qname_
;
const
isc
::
dns
::
RRType
&
qtype_
;
isc
::
dns
::
Message
&
response_
;
...
...
src/bin/auth/tests/auth_srv_unittest.cc
View file @
34cfc02f
...
...
@@ -651,17 +651,17 @@ TEST_F(AuthSrvTest, updateConfigFail) {
QR_FLAG
|
AA_FLAG
,
1
,
1
,
1
,
0
);
}
TEST_F
(
AuthSrvTest
,
updateWithMemory
DataSrc
)
{
TEST_F
(
AuthSrvTest
,
updateWith
In
Memory
Client
)
{
// 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
::
Memory
DataSrc
Ptr
(),
server
.
getMemory
DataSrc
(
rrclass
));
EXPECT_EQ
(
AuthSrv
::
In
Memory
Client
Ptr
(),
server
.
get
In
Memory
Client
(
rrclass
));
updateConfig
(
&
server
,
"{
\"
datasources
\"
: [{
\"
type
\"
:
\"
memory
\"
}]}"
,
true
);
// after successful configuration, we should have one (with empty zoneset).
ASSERT_NE
(
AuthSrv
::
Memory
DataSrc
Ptr
(),
server
.
getMemory
DataSrc
(
rrclass
));
EXPECT_EQ
(
0
,
server
.
getMemory
DataSrc
(
rrclass
)
->
getZoneCount
());
ASSERT_NE
(
AuthSrv
::
In
Memory
Client
Ptr
(),
server
.
get
In
Memory
Client
(
rrclass
));
EXPECT_EQ
(
0
,
server
.
get
In
Memory
Client
(
rrclass
)
->
getZoneCount
());
// The memory data source is empty, should return REFUSED rcode.
createDataFromFile
(
"examplequery_fromWire.wire"
);
...
...
@@ -672,7 +672,7 @@ TEST_F(AuthSrvTest, updateWithMemoryDataSrc) {
opcode
.
getCode
(),
QR_FLAG
,
1
,
0
,
0
,
0
);
}
TEST_F
(
AuthSrvTest
,
chQueryWithMemory
DataSrc
)
{
TEST_F
(
AuthSrvTest
,
chQueryWith
In
Memory
Client
)
{
// Configure memory data source for class IN
updateConfig
(
&
server
,
"{
\"
datasources
\"
: "
"[{
\"
class
\"
:
\"
IN
\"
,
\"
type
\"
:
\"
memory
\"
}]}"
,
true
);
...
...
src/bin/auth/tests/command_unittest.cc
View file @
34cfc02f
...
...
@@ -60,7 +60,6 @@ protected:
MockSession
statistics_session
;
MockXfroutClient
xfrout
;
AuthSrv
server
;
AuthSrv
::
ConstMemoryDataSrcPtr
memory_datasrc
;
ConstElementPtr
result
;
int
rcode
;
public:
...
...
@@ -110,17 +109,17 @@ TEST_F(AuthCommandTest, shutdown) {
// zones, and checks the zones are correctly loaded.
void
zoneChecks
(
AuthSrv
&
server
)
{
EXPECT_TRUE
(
server
.
getMemory
DataSrc
(
RRClass
::
IN
()));
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
getMemory
DataSrc
(
RRClass
::
IN
())
->
EXPECT_TRUE
(
server
.
get
In
Memory
Client
(
RRClass
::
IN
()));
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
get
In
Memory
Client
(
RRClass
::
IN
())
->
findZone
(
Name
(
"ns.test1.example"
)).
zone_finder
->
find
(
Name
(
"ns.test1.example"
),
RRType
::
A
()).
code
);
EXPECT_EQ
(
ZoneFinder
::
NXRRSET
,
server
.
getMemory
DataSrc
(
RRClass
::
IN
())
->
EXPECT_EQ
(
ZoneFinder
::
NXRRSET
,
server
.
get
In
Memory
Client
(
RRClass
::
IN
())
->
findZone
(
Name
(
"ns.test1.example"
)).
zone_finder
->
find
(
Name
(
"ns.test1.example"
),
RRType
::
AAAA
()).
code
);
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
getMemory
DataSrc
(
RRClass
::
IN
())
->
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
get
In
Memory
Client
(
RRClass
::
IN
())
->
findZone
(
Name
(
"ns.test2.example"
)).
zone_finder
->
find
(
Name
(
"ns.test2.example"
),
RRType
::
A
()).
code
);
EXPECT_EQ
(
ZoneFinder
::
NXRRSET
,
server
.
getMemory
DataSrc
(
RRClass
::
IN
())
->
EXPECT_EQ
(
ZoneFinder
::
NXRRSET
,
server
.
get
In
Memory
Client
(
RRClass
::
IN
())
->
findZone
(
Name
(
"ns.test2.example"
)).
zone_finder
->
find
(
Name
(
"ns.test2.example"
),
RRType
::
AAAA
()).
code
);
}
...
...
@@ -147,20 +146,20 @@ configureZones(AuthSrv& server) {
void
newZoneChecks
(
AuthSrv
&
server
)
{
EXPECT_TRUE
(
server
.
getMemory
DataSrc
(
RRClass
::
IN
()));
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
getMemory
DataSrc
(
RRClass
::
IN
())
->
EXPECT_TRUE
(
server
.
get
In
Memory
Client
(
RRClass
::
IN
()));
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
get
In
Memory
Client
(
RRClass
::
IN
())
->
findZone
(
Name
(
"ns.test1.example"
)).
zone_finder
->
find
(
Name
(
"ns.test1.example"
),
RRType
::
A
()).
code
);
// now test1.example should have ns/AAAA
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
getMemory
DataSrc
(
RRClass
::
IN
())
->
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
get
In
Memory
Client
(
RRClass
::
IN
())
->
findZone
(
Name
(
"ns.test1.example"
)).
zone_finder
->
find
(
Name
(
"ns.test1.example"
),
RRType
::
AAAA
()).
code
);
// test2.example shouldn't change
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
getMemory
DataSrc
(
RRClass
::
IN
())
->
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
get
In
Memory
Client
(
RRClass
::
IN
())
->
findZone
(
Name
(
"ns.test2.example"
)).
zone_finder
->
find
(
Name
(
"ns.test2.example"
),
RRType
::
A
()).
code
);
EXPECT_EQ
(
ZoneFinder
::
NXRRSET
,
server
.
getMemory
DataSrc
(
RRClass
::
IN
())
->
EXPECT_EQ
(
ZoneFinder
::
NXRRSET
,
server
.
get
In
Memory
Client
(
RRClass
::
IN
())
->
findZone
(
Name
(
"ns.test2.example"
)).
zone_finder
->
find
(
Name
(
"ns.test2.example"
),
RRType
::
AAAA
()).
code
);
}
...
...
src/bin/auth/tests/config_unittest.cc
View file @
34cfc02f
...
...
@@ -57,12 +57,12 @@ protected:
TEST_F
(
AuthConfigTest
,
datasourceConfig
)
{
// By default, we don't have any in-memory data source.
EXPECT_EQ
(
AuthSrv
::
Memory
DataSrc
Ptr
(),
server
.
getMemory
DataSrc
(
rrclass
));
EXPECT_EQ
(
AuthSrv
::
In
Memory
Client
Ptr
(),
server
.
get
In
Memory
Client
(
rrclass
));
configureAuthServer
(
server
,
Element
::
fromJSON
(
"{
\"
datasources
\"
: [{
\"
type
\"
:
\"
memory
\"
}]}"
));
// after successful configuration, we should have one (with empty zoneset).
ASSERT_NE
(
AuthSrv
::
Memory
DataSrc
Ptr
(),
server
.
getMemory
DataSrc
(
rrclass
));
EXPECT_EQ
(
0
,
server
.
getMemory
DataSrc
(
rrclass
)
->
getZoneCount
());
ASSERT_NE
(
AuthSrv
::
In
Memory
Client
Ptr
(),
server
.
get
In
Memory
Client
(
rrclass
));
EXPECT_EQ
(
0
,
server
.
get
In
Memory
Client
(
rrclass
)
->
getZoneCount
());
}
TEST_F
(
AuthConfigTest
,
databaseConfig
)
{
...
...
@@ -82,7 +82,7 @@ TEST_F(AuthConfigTest, versionConfig) {
}
TEST_F
(
AuthConfigTest
,
exceptionGuarantee
)
{
EXPECT_EQ
(
AuthSrv
::
Memory
DataSrc
Ptr
(),
server
.
getMemory
DataSrc
(
rrclass
));
EXPECT_EQ
(
AuthSrv
::
In
Memory
Client
Ptr
(),
server
.
get
In
Memory
Client
(
rrclass
));
// This configuration contains an invalid item, which will trigger
// an exception.
EXPECT_THROW
(
configureAuthServer
(
...
...
@@ -92,7 +92,7 @@ TEST_F(AuthConfigTest, exceptionGuarantee) {
"
\"
no_such_config_var
\"
: 1}"
)),
AuthConfigError
);
// The server state shouldn't change
EXPECT_EQ
(
AuthSrv
::
Memory
DataSrc
Ptr
(),
server
.
getMemory
DataSrc
(
rrclass
));
EXPECT_EQ
(
AuthSrv
::
In
Memory
Client
Ptr
(),
server
.
get
In
Memory
Client
(
rrclass
));
}
TEST_F
(
AuthConfigTest
,
exceptionConversion
)
{
...
...
@@ -154,22 +154,22 @@ protected:
TEST_F
(
MemoryDatasrcConfigTest
,
addZeroDataSrc
)
{
parser
->
build
(
Element
::
fromJSON
(
"[]"
));
parser
->
commit
();
EXPECT_EQ
(
AuthSrv
::
Memory
DataSrc
Ptr
(),
server
.
getMemory
DataSrc
(
rrclass
));
EXPECT_EQ
(
AuthSrv
::
In
Memory
Client
Ptr
(),
server
.
get
In
Memory
Client
(
rrclass
));
}
TEST_F
(
MemoryDatasrcConfigTest
,
addEmpty
)
{
// By default, we don't have any in-memory data source.
EXPECT_EQ
(
AuthSrv
::
Memory
DataSrc
Ptr
(),
server
.
getMemory
DataSrc
(
rrclass
));
EXPECT_EQ
(
AuthSrv
::
In
Memory
Client
Ptr
(),
server
.
get
In
Memory
Client
(
rrclass
));
parser
->
build
(
Element
::
fromJSON
(
"[{
\"
type
\"
:
\"
memory
\"
}]"
));
parser
->
commit
();
EXPECT_EQ
(
0
,
server
.
getMemory
DataSrc
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
0
,
server
.
get
In
Memory
Client
(
rrclass
)
->
getZoneCount
());
}
TEST_F
(
MemoryDatasrcConfigTest
,
addZeroZone
)
{
parser
->
build
(
Element
::
fromJSON
(
"[{
\"
type
\"
:
\"
memory
\"
,"
"
\"
zones
\"
: []}]"
));
parser
->
commit
();
EXPECT_EQ
(
0
,
server
.
getMemory
DataSrc
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
0
,
server
.
get
In
Memory
Client
(
rrclass
)
->
getZoneCount
());
}
TEST_F
(
MemoryDatasrcConfigTest
,
addOneZone
)
{
...
...
@@ -179,9 +179,9 @@ TEST_F(MemoryDatasrcConfigTest, addOneZone) {
"
\"
file
\"
:
\"
"
TEST_DATA_DIR
"/example.zone
\"
}]}]"
)));
EXPECT_NO_THROW
(
parser
->
commit
());
EXPECT_EQ
(
1
,
server
.
getMemory
DataSrc
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
1
,
server
.
get
In
Memory
Client
(
rrclass
)
->
getZoneCount
());
// Check it actually loaded something
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
getMemory
DataSrc
(
rrclass
)
->
findZone
(
EXPECT_EQ
(
ZoneFinder
::
SUCCESS
,
server
.
get
In
Memory
Client
(
rrclass
)
->
findZone
(
Name
(
"ns.example.com."
)).
zone_finder
->
find
(
Name
(
"ns.example.com."
),
RRType
::
A
()).
code
);
}
...
...
@@ -199,7 +199,7 @@ TEST_F(MemoryDatasrcConfigTest, addMultiZones) {
"
\"
file
\"
:
\"
"
TEST_DATA_DIR
"/example.net.zone
\"
}]}]"
)));
EXPECT_NO_THROW
(
parser
->
commit
());
EXPECT_EQ
(
3
,
server
.
getMemory
DataSrc
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
3
,
server
.
get
In
Memory
Client
(
rrclass
)
->
getZoneCount
());
}
TEST_F
(
MemoryDatasrcConfigTest
,
replace
)
{
...
...
@@ -209,9 +209,9 @@ TEST_F(MemoryDatasrcConfigTest, replace) {
"
\"
file
\"
:
\"
"
TEST_DATA_DIR
"/example.zone
\"
}]}]"
)));
EXPECT_NO_THROW
(
parser
->
commit
());
EXPECT_EQ
(
1
,
server
.
getMemory
DataSrc
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
1
,
server
.
get
In
Memory
Client
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
isc
::
datasrc
::
result
::
SUCCESS
,
server
.
getMemory
DataSrc
(
rrclass
)
->
findZone
(
server
.
get
In
Memory
Client
(
rrclass
)
->
findZone
(
Name
(
"example.com"
)).
code
);
// create a new parser, and install a new set of configuration. It
...
...
@@ -227,9 +227,9 @@ TEST_F(MemoryDatasrcConfigTest, replace) {
"
\"
file
\"
:
\"
"
TEST_DATA_DIR
"/example.net.zone
\"
}]}]"
)));
EXPECT_NO_THROW
(
parser
->
commit
());
EXPECT_EQ
(
2
,
server
.
getMemory
DataSrc
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
2
,
server
.
get
In
Memory
Client
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
isc
::
datasrc
::
result
::
NOTFOUND
,
server
.
getMemory
DataSrc
(
rrclass
)
->
findZone
(
server
.
get
In
Memory
Client
(
rrclass
)
->
findZone
(
Name
(
"example.com"
)).
code
);
}
...
...
@@ -241,9 +241,9 @@ TEST_F(MemoryDatasrcConfigTest, exception) {
"
\"
file
\"
:
\"
"
TEST_DATA_DIR
"/example.zone
\"
}]}]"
)));
EXPECT_NO_THROW
(
parser
->
commit
());
EXPECT_EQ
(
1
,
server
.
getMemory
DataSrc
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
1
,
server
.
get
In
Memory
Client
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
isc
::
datasrc
::
result
::
SUCCESS
,
server
.
getMemory
DataSrc
(
rrclass
)
->
findZone
(
server
.
get
In
Memory
Client
(
rrclass
)
->
findZone
(
Name
(
"example.com"
)).
code
);
// create a new parser, and try to load something. It will throw,
...
...
@@ -262,9 +262,9 @@ TEST_F(MemoryDatasrcConfigTest, exception) {
// commit it
// The original should be untouched
EXPECT_EQ
(
1
,
server
.
getMemory
DataSrc
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
1
,
server
.
get
In
Memory
Client
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
isc
::
datasrc
::
result
::
SUCCESS
,
server
.
getMemory
DataSrc
(
rrclass
)
->
findZone
(
server
.
get
In
Memory
Client
(
rrclass
)
->
findZone
(
Name
(
"example.com"
)).
code
);
}
...
...
@@ -275,13 +275,13 @@ TEST_F(MemoryDatasrcConfigTest, remove) {
"
\"
file
\"
:
\"
"
TEST_DATA_DIR
"/example.zone
\"
}]}]"
)));
EXPECT_NO_THROW
(
parser
->
commit
());
EXPECT_EQ
(
1
,
server
.
getMemory
DataSrc
(
rrclass
)
->
getZoneCount
());
EXPECT_EQ
(
1
,
server
.
get
In
Memory
Client
(
rrclass
)
->
getZoneCount
());
delete
parser
;
parser
=
createAuthConfigParser
(
server
,
"datasources"
);
EXPECT_NO_THROW
(
parser
->
build
(
Element
::
fromJSON
(
"[]"
)));
EXPECT_NO_THROW
(
parser
->
commit
());
EXPECT_EQ
(
AuthSrv
::
Memory
DataSrc
Ptr
(),
server
.
getMemory
DataSrc
(
rrclass
));
EXPECT_EQ
(
AuthSrv
::
In
Memory
Client
Ptr
(),
server
.
get
In
Memory
Client
(
rrclass
));
}
TEST_F
(
MemoryDatasrcConfigTest
,
adDuplicateZones
)
{
...
...
src/bin/auth/tests/query_unittest.cc
View file @
34cfc02f
...
...
@@ -234,10 +234,10 @@ protected:
response
.
setOpcode
(
Opcode
::
QUERY
());
// create and add a matching zone.
mock_finder
=
new
MockZoneFinder
();
memory_
datasrc
.
addZone
(
ZoneFinderPtr
(
mock_finder
));
memory_
client
.
addZone
(
ZoneFinderPtr
(
mock_finder
));
}
MockZoneFinder
*
mock_finder
;
Memory
DataSrc
memory_
datasrc
;
In
Memory
Client
memory_
client
;
const
Name
qname
;
const
RRClass
qclass
;
const
RRType
qtype
;
...
...
@@ -286,14 +286,14 @@ responseCheck(Message& response, const isc::dns::Rcode& rcode,
TEST_F
(
QueryTest
,
noZone
)
{
// There's no zone in the memory datasource. So the response should have
// REFUSED.
Memory
DataSrc
empty_memory_
datasrc
;
Query
nozone_query
(
empty_memory_
datasrc
,
qname
,
qtype
,
response
);
In
Memory
Client
empty_memory_
client
;
Query
nozone_query
(
empty_memory_
client
,
qname
,
qtype
,
response
);
EXPECT_NO_THROW
(
nozone_query
.
process
());
EXPECT_EQ
(
Rcode
::
REFUSED
(),
response
.
getRcode
());
}
TEST_F
(
QueryTest
,
exactMatch
)
{
Query
query
(
memory_
datasrc
,
qname
,
qtype
,
response
);
Query
query
(
memory_
client
,
qname
,
qtype
,
response
);
EXPECT_NO_THROW
(
query
.
process
());
// find match rrset
responseCheck
(
response
,
Rcode
::
NOERROR
(),
AA_FLAG
,
1
,
3
,
3
,
...
...
@@ -303,7 +303,7 @@ TEST_F(QueryTest, exactMatch) {
TEST_F
(
QueryTest
,
exactAddrMatch
)
{
// find match rrset, omit additional data which has already been provided
// in the answer section from the additional.
EXPECT_NO_THROW
(
Query
(
memory_
datasrc
,
Name
(
"noglue.example.com"
),
qtype
,
EXPECT_NO_THROW
(
Query
(
memory_
client
,
Name
(
"noglue.example.com"
),
qtype
,
response
).
process
());
responseCheck
(
response
,
Rcode
::
NOERROR
(),
AA_FLAG
,
1
,
3
,
2
,
...
...
@@ -315,7 +315,7 @@ TEST_F(QueryTest, exactAddrMatch) {
TEST_F
(
QueryTest
,
apexNSMatch
)
{
// find match rrset, omit authority data which has already been provided
// in the answer section from the authority section.
EXPECT_NO_THROW
(
Query
(
memory_
datasrc
,
Name
(
"example.com"
),
RRType
::
NS
(),
EXPECT_NO_THROW
(
Query
(
memory_
client
,
Name
(
"example.com"
),
RRType
::
NS
(),
response
).
process
());
responseCheck
(
response
,
Rcode
::
NOERROR
(),
AA_FLAG
,
3
,
0
,
3
,
...
...
@@ -326,7 +326,7 @@ TEST_F(QueryTest, apexNSMatch) {
TEST_F
(
QueryTest
,
exactAnyMatch
)
{
// find match rrset, omit additional data which has already been provided
// in the answer section from the additional.
EXPECT_NO_THROW
(
Query
(
memory_
datasrc
,
Name
(
"noglue.example.com"
),
EXPECT_NO_THROW
(
Query
(
memory_
client
,
Name
(
"noglue.example.com"
),
RRType
::
ANY
(),
response
).
process
());
responseCheck
(
response
,
Rcode
::
NOERROR
(),
AA_FLAG
,
1
,
3
,
2
,
...
...
@@ -339,7 +339,7 @@ TEST_F(QueryTest, exactAnyMatch) {
TEST_F
(
QueryTest
,
apexAnyMatch
)
{
// find match rrset, omit additional data which has already been provided
// in the answer section from the additional.
EXPECT_NO_THROW
(
Query
(
memory_
datasrc
,
Name
(
"example.com"
),
EXPECT_NO_THROW
(
Query
(
memory_
client
,
Name
(
"example.com"
),
RRType
::
ANY
(),
response
).
process
());
responseCheck
(
response
,
Rcode
::
NOERROR
(),
AA_FLAG
,
4
,
0
,
3
,
"example.com. 3600 IN SOA . . 0 0 0 0 0
\n
"
...
...
@@ -350,7 +350,7 @@ TEST_F(QueryTest, apexAnyMatch) {
}
TEST_F
(
QueryTest
,
mxANYMatch
)
{
EXPECT_NO_THROW
(
Query
(
memory_
datasrc
,
Name
(
"mx.example.com"
),
EXPECT_NO_THROW
(
Query
(
memory_
client
,
Name
(
"mx.example.com"
),
RRType
::
ANY
(),
response
).
process
());
responseCheck
(
response
,
Rcode
::
NOERROR
(),
AA_FLAG
,
3
,
3
,
4
,
mx_txt
,
zone_ns_txt
,
...
...
@@ -358,14 +358,14 @@ TEST_F(QueryTest, mxANYMatch) {
}
TEST_F
(
QueryTest
,
glueANYMatch
)
{
EXPECT_NO_THROW
(
Query
(
memory_
datasrc
,
Name
(
"delegation.example.com"
),
EXPECT_NO_THROW
(
Query
(
memory_
client
,
Name
(
"delegation.example.com"
),
RRType
::
ANY
(),
response
).
process
());
responseCheck
(
response
,
Rcode
::
NOERROR
(),
0
,
0
,
4
,
3
,
NULL
,
delegation_txt
,
ns_addrs_txt
);
}
TEST_F
(
QueryTest
,
nodomainANY
)
{
EXPECT_NO_THROW
(
Query
(
memory_
datasrc
,
Name
(
"nxdomain.example.com"
),
EXPECT_NO_THROW
(
Query
(
memory_
client
,
Name
(
"nxdomain.example.com"
),
RRType
::
ANY
(),
response
).
process
());
responseCheck
(
response
,
Rcode
::
NXDOMAIN
(),
AA_FLAG
,
0
,
1
,
0
,
NULL
,
soa_txt
,
NULL
,
mock_finder
->
getOrigin
());
...
...
@@ -378,13 +378,13 @@ TEST_F(QueryTest, noApexNS) {
// Disable apex NS record