|
@@ -81,27 +81,27 @@ datasrcConfigHandler(DatasrcConfigTest* fake_server, const std::string&,
|
|
|
|
|
|
class DatasrcConfigTest : public ::testing::Test {
|
|
|
public:
|
|
|
- // These pretend to be the server
|
|
|
- ListPtr getClientList(const RRClass& rrclass) {
|
|
|
- log_ += "get " + rrclass.toText() + "\n";
|
|
|
- return (lists_[rrclass]);
|
|
|
- }
|
|
|
- void setClientList(const RRClass& rrclass, const ListPtr& list) {
|
|
|
- log_ += "set " + rrclass.toText() + " " +
|
|
|
- (list ? list->getConf() : "") + "\n";
|
|
|
- lists_[rrclass] = list;
|
|
|
- }
|
|
|
- vector<RRClass> getClientListClasses() const {
|
|
|
- vector<RRClass> result;
|
|
|
- for (std::map<RRClass, ListPtr>::const_iterator it(lists_.begin());
|
|
|
- it != lists_.end(); ++it) {
|
|
|
- result.push_back(it->first);
|
|
|
+ // To pretend to be the server:
|
|
|
+ void swapDataSrcClientLists(shared_ptr<std::map<dns::RRClass, ListPtr> >
|
|
|
+ new_lists)
|
|
|
+ {
|
|
|
+ lists_.clear(); // first empty it
|
|
|
+
|
|
|
+ // Record the operation and results. Note that map elements are
|
|
|
+ // sorted by RRClass, so the ordering should be predictable.
|
|
|
+ for (std::map<dns::RRClass, ListPtr>::const_iterator it =
|
|
|
+ new_lists->begin();
|
|
|
+ it != new_lists->end();
|
|
|
+ ++it)
|
|
|
+ {
|
|
|
+ const RRClass rrclass = it->first;
|
|
|
+ ListPtr list = it->second;
|
|
|
+ log_ += "set " + rrclass.toText() + " " +
|
|
|
+ (list ? list->getConf() : "") + "\n";
|
|
|
+ lists_[rrclass] = list;
|
|
|
}
|
|
|
- return (result);
|
|
|
- }
|
|
|
- isc::util::thread::Mutex& getClientListMutex() const {
|
|
|
- return (mutex_);
|
|
|
}
|
|
|
+
|
|
|
protected:
|
|
|
DatasrcConfigTest() :
|
|
|
session(ElementPtr(new ListElement), ElementPtr(new ListElement),
|
|
@@ -147,9 +147,8 @@ protected:
|
|
|
session.addMessage(createCommand("config_update", config),
|
|
|
"data_sources", "*");
|
|
|
mccs->checkCommand();
|
|
|
- // Check it called the correct things (check that there's no IN yet and
|
|
|
- // set a new one.
|
|
|
- EXPECT_EQ("get IN\nset IN xxx\n", log_);
|
|
|
+ // Check that the passed config is stored.
|
|
|
+ EXPECT_EQ("set IN xxx\n", log_);
|
|
|
EXPECT_EQ(1, lists_.size());
|
|
|
}
|
|
|
FakeSession session;
|
|
@@ -166,8 +165,10 @@ TEST_F(DatasrcConfigTest, createList) {
|
|
|
}
|
|
|
|
|
|
TEST_F(DatasrcConfigTest, modifyList) {
|
|
|
- // First, initialize the list
|
|
|
+ // First, initialize the list, and confirm the current config
|
|
|
initializeINList();
|
|
|
+ EXPECT_EQ("xxx", lists_[RRClass::IN()]->getConf());
|
|
|
+
|
|
|
// And now change the configuration of the list
|
|
|
const ElementPtr
|
|
|
config(buildConfig("{\"IN\": [{\"type\": \"yyy\"}]}"));
|
|
@@ -175,9 +176,7 @@ TEST_F(DatasrcConfigTest, modifyList) {
|
|
|
"*");
|
|
|
log_ = "";
|
|
|
mccs->checkCommand();
|
|
|
- // This one does not set
|
|
|
- EXPECT_EQ("get IN\n", log_);
|
|
|
- // But this should contain the yyy configuration
|
|
|
+ // Now the new one should be installed.
|
|
|
EXPECT_EQ("yyy", lists_[RRClass::IN()]->getConf());
|
|
|
EXPECT_EQ(1, lists_.size());
|
|
|
}
|
|
@@ -191,7 +190,7 @@ TEST_F(DatasrcConfigTest, multiple) {
|
|
|
"*");
|
|
|
mccs->checkCommand();
|
|
|
// We have set commands for both classes.
|
|
|
- EXPECT_EQ("get CH\nset CH xxx\nget IN\nset IN yyy\n", log_);
|
|
|
+ EXPECT_EQ("set IN yyy\nset CH xxx\n", log_);
|
|
|
// We should have both there
|
|
|
EXPECT_EQ("yyy", lists_[RRClass::IN()]->getConf());
|
|
|
EXPECT_EQ("xxx", lists_[RRClass::CH()]->getConf());
|
|
@@ -212,9 +211,7 @@ TEST_F(DatasrcConfigTest, updateAdd) {
|
|
|
"*");
|
|
|
log_ = "";
|
|
|
mccs->checkCommand();
|
|
|
- // The CH is set, IN not
|
|
|
- EXPECT_EQ("get CH\nset CH xxx\nget IN\n", log_);
|
|
|
- // But this should contain the yyy configuration
|
|
|
+ EXPECT_EQ("set IN yyy\nset CH xxx\n", log_);
|
|
|
EXPECT_EQ("xxx", lists_[RRClass::CH()]->getConf());
|
|
|
EXPECT_EQ("yyy", lists_[RRClass::IN()]->getConf());
|
|
|
EXPECT_EQ(2, lists_.size());
|
|
@@ -229,12 +226,11 @@ TEST_F(DatasrcConfigTest, updateDelete) {
|
|
|
"*");
|
|
|
log_ = "";
|
|
|
mccs->checkCommand();
|
|
|
- EXPECT_EQ("get IN\nset IN \n", log_);
|
|
|
- EXPECT_FALSE(lists_[RRClass::IN()]);
|
|
|
- // In real auth server, the NULL one would be removed. However, we just
|
|
|
- // store it, so the IN bucket is still in there. This checks there's nothing
|
|
|
- // else.
|
|
|
- EXPECT_EQ(1, lists_.size());
|
|
|
+
|
|
|
+ // No operation takes place in the configuration, and the old one is
|
|
|
+ // just dropped
|
|
|
+ EXPECT_EQ("", log_);
|
|
|
+ EXPECT_TRUE(lists_.empty());
|
|
|
}
|
|
|
|
|
|
// Check that we can rollback an addition if something else fails
|