Commit 1d0b6efd authored by Marcin Siodelski's avatar Marcin Siodelski

[#642,!373] Do not allow to update the logical server 'all'.

parent 72bc8cc9
......@@ -329,6 +329,8 @@ public:
/// @brief Creates or updates a server.
///
/// @param server Instance of the server to be stored.
/// @throw InvalidOperation when trying to create a duplicate or
/// update the logical server 'all'.
virtual void
createUpdateServer4(const db::ServerPtr& server);
......
......@@ -344,6 +344,8 @@ public:
/// @brief Creates or updates a server.
///
/// @param server Instance of the server to be stored.
/// @throw InvalidOperation when trying to create a duplicate or
/// update the logical server 'all'.
virtual void
createUpdateServer6(const db::ServerPtr& server);
......
......@@ -934,6 +934,13 @@ MySqlConfigBackendImpl::createUpdateServer(const int& create_audit_revision,
const int& create_index,
const int& update_index,
const ServerPtr& server) {
// The server tag 'all' is reserved.
if (server->getServerTag().amAll()) {
isc_throw(InvalidOperation, "'all' is a name reserved for the server tag which"
" associates the configuration elements with all servers connecting"
" to the database and a server with this name can't be created");
}
// Create scoped audit revision. As long as this instance exists
// no new audit revisions are created in any subsequent calls.
ScopedAuditRevision audit_revision(this,
......
......@@ -643,6 +643,8 @@ public:
/// @param create_index Index of the INSERT query to be used.
/// @param update_index Index of the UPDATE query to be used.
/// @param server Pointer to the server to be inserted or updated.
/// @throw InvalidOperation when trying to create a duplicate or
/// update the logical server 'all'.
void createUpdateServer(const int& create_audit_revision,
const int& create_index,
const int& update_index,
......
......@@ -468,6 +468,11 @@ TEST_F(MySqlConfigBackendDHCPv4Test, createUpdateDeleteServer) {
"server set");
}
// It should not be possible to create a duplicate of the logical
// server 'all'.
auto all_server = Server::create(ServerTag("all"), "this is logical server all");
EXPECT_THROW(cbptr_->createUpdateServer4(all_server), isc::InvalidOperation);
ServerPtr returned_server;
// An attempt to fetch the server that hasn't been inserted should return
......
......@@ -509,6 +509,11 @@ TEST_F(MySqlConfigBackendDHCPv6Test, createUpdateDeleteServer) {
"server set");
}
// It should not be possible to create a duplicate of the logical
// server 'all'.
auto all_server = Server::create(ServerTag("all"), "this is logical server all");
EXPECT_THROW(cbptr_->createUpdateServer6(all_server), isc::InvalidOperation);
ServerPtr returned_server;
// An attempt to fetch the server that hasn't been inserted should return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment