Skip to content
Snippets Groups Projects
Commit cec1d784 authored by Steven Murray's avatar Steven Murray
Browse files

Added SqliteCatalogue::createAdminHost

parent e36b1f5d
No related branches found
No related tags found
No related merge requests found
......@@ -45,10 +45,10 @@ void cta::catalogue::SqliteCatalogue::createDbSchema() {
"CREATION_LOG_HOST_NAME TEXT,"
"CREATION_LOG_TIME INTEGER,"
"LAST_MODIFICATION_USER_NAME TEXT,"
"LAST_MODIFICATION_GROUP_NAME TEXT,"
"LAST_MODIFICATION_HOST_NAME TEXT,"
"LAST_MODIFICATION_TIME INTEGER,"
"LAST_MOD_USER_NAME TEXT,"
"LAST_MOD_GROUP_NAME TEXT,"
"LAST_MOD_HOST_NAME TEXT,"
"LAST_MOD_TIME INTEGER,"
"PRIMARY KEY(USER_NAME)"
");"
......@@ -62,10 +62,10 @@ void cta::catalogue::SqliteCatalogue::createDbSchema() {
"CREATION_LOG_HOST_NAME TEXT,"
"CREATION_LOG_TIME INTEGER,"
"LAST_MODIFICATION_USER_NAME TEXT,"
"LAST_MODIFICATION_GROUP_NAME TEXT,"
"LAST_MODIFICATION_HOST_NAME TEXT,"
"LAST_MODIFICATION_TIME INTEGER,"
"LAST_MOD_USER_NAME TEXT,"
"LAST_MOD_GROUP_NAME TEXT,"
"LAST_MOD_HOST_NAME TEXT,"
"LAST_MOD_TIME INTEGER,"
"PRIMARY KEY(HOST_NAME)"
");";
......@@ -101,10 +101,10 @@ void cta::catalogue::SqliteCatalogue::createBootstrapAdminAndHostNoAuth(
"CREATION_LOG_HOST_NAME,"
"CREATION_LOG_TIME,"
"LAST_MODIFICATION_USER_NAME,"
"LAST_MODIFICATION_GROUP_NAME,"
"LAST_MODIFICATION_HOST_NAME,"
"LAST_MODIFICATION_TIME)"
"LAST_MOD_USER_NAME,"
"LAST_MOD_GROUP_NAME,"
"LAST_MOD_HOST_NAME,"
"LAST_MOD_TIME)"
"VALUES("
":USER_NAME,"
":GROUP_NAME,"
......@@ -144,10 +144,10 @@ void cta::catalogue::SqliteCatalogue::createBootstrapAdminAndHostNoAuth(
"CREATION_LOG_HOST_NAME,"
"CREATION_LOG_TIME,"
"LAST_MODIFICATION_USER_NAME,"
"LAST_MODIFICATION_GROUP_NAME,"
"LAST_MODIFICATION_HOST_NAME,"
"LAST_MODIFICATION_TIME)"
"LAST_MOD_USER_NAME,"
"LAST_MOD_GROUP_NAME,"
"LAST_MOD_HOST_NAME,"
"LAST_MOD_TIME)"
"VALUES("
":HOST_NAME,"
":COMMENT,"
......@@ -178,7 +178,10 @@ void cta::catalogue::SqliteCatalogue::createBootstrapAdminAndHostNoAuth(
//------------------------------------------------------------------------------
// createAdminUser
//------------------------------------------------------------------------------
void cta::catalogue::SqliteCatalogue::createAdminUser(const common::dataStructures::SecurityIdentity &cliIdentity, const common::dataStructures::UserIdentity &user, const std::string &comment) {
void cta::catalogue::SqliteCatalogue::createAdminUser(
const common::dataStructures::SecurityIdentity &cliIdentity,
const common::dataStructures::UserIdentity &user,
const std::string &comment) {
const uint64_t now = time(NULL);
const char *const sql =
"INSERT INTO ADMIN_USER("
......@@ -191,10 +194,10 @@ void cta::catalogue::SqliteCatalogue::createAdminUser(const common::dataStructur
"CREATION_LOG_HOST_NAME,"
"CREATION_LOG_TIME,"
"LAST_MODIFICATION_USER_NAME,"
"LAST_MODIFICATION_GROUP_NAME,"
"LAST_MODIFICATION_HOST_NAME,"
"LAST_MODIFICATION_TIME)"
"LAST_MOD_USER_NAME,"
"LAST_MOD_GROUP_NAME,"
"LAST_MOD_HOST_NAME,"
"LAST_MOD_TIME)"
"VALUES("
":USER_NAME,"
":GROUP_NAME,"
......@@ -231,8 +234,10 @@ void cta::catalogue::SqliteCatalogue::deleteAdminUser(const common::dataStructur
//------------------------------------------------------------------------------
// getAdminUsers
//------------------------------------------------------------------------------
std::list<cta::common::dataStructures::AdminUser> cta::catalogue::SqliteCatalogue::getAdminUsers(const common::dataStructures::SecurityIdentity &requester) const {
std::list<cta::common::dataStructures::AdminUser> admins;
std::list<cta::common::dataStructures::AdminUser>
cta::catalogue::SqliteCatalogue::getAdminUsers(
const common::dataStructures::SecurityIdentity &requester) const {
std::list<common::dataStructures::AdminUser> admins;
const char *const sql =
"SELECT "
"USER_NAME AS USER_NAME,"
......@@ -242,12 +247,12 @@ std::list<cta::common::dataStructures::AdminUser> cta::catalogue::SqliteCatalogu
"CREATION_LOG_USER_NAME AS CREATION_LOG_USER_NAME,"
"CREATION_LOG_GROUP_NAME AS CREATION_LOG_GROUP_NAME,"
"CREATION_LOG_HOST_NAME AS CREATION_LOG_HOST_NAME,"
"CREATION_LOG_TIME AS CREATION_LOG_TIME,"
"CREATION_LOG_TIME AS CREATION_LOG_TIME,"
"LAST_MODIFICATION_USER_NAME AS LAST_MODIFICATION_USER_NAME,"
"LAST_MODIFICATION_GROUP_NAME AS LAST_MODIFICATION_GROUP_NAME,"
"LAST_MODIFICATION_HOST_NAME AS LAST_MODIFICATION_HOST_NAME,"
"LAST_MODIFICATION_TIME AS LAST_MODIFICATION_TIME "
"LAST_MOD_USER_NAME AS LAST_MOD_USER_NAME,"
"LAST_MOD_GROUP_NAME AS LAST_MOD_GROUP_NAME,"
"LAST_MOD_HOST_NAME AS LAST_MOD_HOST_NAME,"
"LAST_MOD_TIME AS LAST_MOD_TIME "
"FROM ADMIN_USER";
SqliteStmt stmt(m_conn, sql);
ColumnNameToIdx nameToIdx;
......@@ -260,6 +265,7 @@ std::list<cta::common::dataStructures::AdminUser> cta::catalogue::SqliteCatalogu
common::dataStructures::UserIdentity adminUI;
adminUI.name = stmt.columnText(nameToIdx["USER_NAME"]);
adminUI.group = stmt.columnText(nameToIdx["GROUP_NAME"]);
admin.user = adminUI;
admin.comment = stmt.columnText(nameToIdx["COMMENT"]);
......@@ -272,17 +278,20 @@ std::list<cta::common::dataStructures::AdminUser> cta::catalogue::SqliteCatalogu
creationLog.user = creatorUI;
creationLog.host = stmt.columnText(nameToIdx["CREATION_LOG_HOST_NAME"]);
creationLog.time = stmt.columnUint64(nameToIdx["CREATION_LOG_TIME"]);
admin.creationLog = creationLog;
common::dataStructures::UserIdentity updaterUI;
updaterUI.name = stmt.columnText(nameToIdx["LAST_MODIFICATION_USER_NAME"]);
updaterUI.group = stmt.columnText(nameToIdx["LAST_MODIFICATION_GROUP_NAME"]);
updaterUI.name = stmt.columnText(nameToIdx["LAST_MOD_USER_NAME"]);
updaterUI.group = stmt.columnText(nameToIdx["LAST_MOD_GROUP_NAME"]);
common::dataStructures::EntryLog updateLog;
updateLog.user = updaterUI;
updateLog.host = stmt.columnText(nameToIdx["LAST_MODIFICATION_HOST_NAME"]);
updateLog.time = stmt.columnUint64(nameToIdx["LAST_MODIFICATION_TIME"]);
updateLog.host = stmt.columnText(nameToIdx["LAST_MOD_HOST_NAME"]);
updateLog.time = stmt.columnUint64(nameToIdx["LAST_MOD_TIME"]);
admin.lastModificationLog = updateLog;
admins.push_back(admin);
}
......@@ -297,7 +306,50 @@ void cta::catalogue::SqliteCatalogue::modifyAdminUserComment(const common::dataS
//------------------------------------------------------------------------------
// createAdminHost
//------------------------------------------------------------------------------
void cta::catalogue::SqliteCatalogue::createAdminHost(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &hostName, const std::string &comment) {}
void cta::catalogue::SqliteCatalogue::createAdminHost(
const common::dataStructures::SecurityIdentity &cliIdentity,
const std::string &hostName,
const std::string &comment) {
const uint64_t now = time(NULL);
const char *const sql =
"INSERT INTO ADMIN_HOST("
"HOST_NAME,"
"COMMENT,"
"CREATION_LOG_USER_NAME,"
"CREATION_LOG_GROUP_NAME,"
"CREATION_LOG_HOST_NAME,"
"CREATION_LOG_TIME,"
"LAST_MOD_USER_NAME,"
"LAST_MOD_GROUP_NAME,"
"LAST_MOD_HOST_NAME,"
"LAST_MOD_TIME)"
"VALUES("
":HOST_NAME,"
":COMMENT,"
":CREATION_LOG_USER_NAME,"
":CREATION_LOG_GROUP_NAME,"
":CREATION_LOG_HOST_NAME,"
":CREATION_LOG_TIME,"
":CREATION_LOG_USER_NAME,"
":CREATION_LOG_GROUP_NAME,"
":CREATION_LOG_HOST_NAME,"
":CREATION_LOG_TIME);";
SqliteStmt stmt(m_conn, sql);
stmt.bind(":HOST_NAME", hostName);
stmt.bind(":COMMENT", comment);
stmt.bind(":CREATION_LOG_USER_NAME", cliIdentity.user.name);
stmt.bind(":CREATION_LOG_GROUP_NAME", cliIdentity.user.group);
stmt.bind(":CREATION_LOG_HOST_NAME", cliIdentity.host);
stmt.bind(":CREATION_LOG_TIME", now);
stmt.step();
}
//------------------------------------------------------------------------------
// deleteAdminHost
......@@ -307,7 +359,61 @@ void cta::catalogue::SqliteCatalogue::deleteAdminHost(const common::dataStructur
//------------------------------------------------------------------------------
// getAdminHosts
//------------------------------------------------------------------------------
std::list<cta::common::dataStructures::AdminHost> cta::catalogue::SqliteCatalogue::getAdminHosts(const common::dataStructures::SecurityIdentity &requester) const { return std::list<cta::common::dataStructures::AdminHost>();}
std::list<cta::common::dataStructures::AdminHost> cta::catalogue::SqliteCatalogue::getAdminHosts(const common::dataStructures::SecurityIdentity &requester) const {
std::list<common::dataStructures::AdminHost> hosts;
const char *const sql =
"SELECT "
"HOST_NAME AS HOST_NAME,"
"COMMENT AS COMMENT,"
"CREATION_LOG_USER_NAME AS CREATION_LOG_USER_NAME,"
"CREATION_LOG_GROUP_NAME AS CREATION_LOG_GROUP_NAME,"
"CREATION_LOG_HOST_NAME AS CREATION_LOG_HOST_NAME,"
"CREATION_LOG_TIME AS CREATION_LOG_TIME,"
"LAST_MOD_USER_NAME AS LAST_MOD_USER_NAME,"
"LAST_MOD_GROUP_NAME AS LAST_MOD_GROUP_NAME,"
"LAST_MOD_HOST_NAME AS LAST_MOD_HOST_NAME,"
"LAST_MOD_TIME AS LAST_MOD_TIME "
"FROM ADMIN_HOST";
SqliteStmt stmt(m_conn, sql);
ColumnNameToIdx nameToIdx;
while(SQLITE_ROW == stmt.step()) {
if(nameToIdx.empty()) {
nameToIdx = stmt.getColumnNameToIdx();
}
common::dataStructures::AdminHost host;
host.name = stmt.columnText(nameToIdx["HOST_NAME"]);
host.comment = stmt.columnText(nameToIdx["COMMENT"]);
common::dataStructures::UserIdentity creatorUI;
creatorUI.name = stmt.columnText(nameToIdx["CREATION_LOG_USER_NAME"]);
creatorUI.group = stmt.columnText(nameToIdx["CREATION_LOG_GROUP_NAME"]);
common::dataStructures::EntryLog creationLog;
creationLog.user = creatorUI;
creationLog.host = stmt.columnText(nameToIdx["CREATION_LOG_HOST_NAME"]);
creationLog.time = stmt.columnUint64(nameToIdx["CREATION_LOG_TIME"]);
host.creationLog = creationLog;
common::dataStructures::UserIdentity updaterUI;
updaterUI.name = stmt.columnText(nameToIdx["LAST_MOD_USER_NAME"]);
updaterUI.group = stmt.columnText(nameToIdx["LAST_MOD_GROUP_NAME"]);
common::dataStructures::EntryLog updateLog;
updateLog.user = updaterUI;
updateLog.host = stmt.columnText(nameToIdx["LAST_MOD_HOST_NAME"]);
updateLog.time = stmt.columnUint64(nameToIdx["LAST_MOD_TIME"]);
host.lastModificationLog = updateLog;
hosts.push_back(host);
}
return hosts;
}
//------------------------------------------------------------------------------
// modifyAdminHostComment
......
......@@ -96,6 +96,24 @@ TEST_F(cta_catalogue_SqliteCatalogueTest, createBootstrapAdminAndHostNoAuth) {
admin.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
}
{
std::list<common::dataStructures::AdminHost> hosts;
ASSERT_NO_THROW(hosts = catalogue->getAdminHosts(m_bootstrapAdminSI));
ASSERT_EQ(1, hosts.size());
const common::dataStructures::AdminHost host = hosts.front();
ASSERT_EQ(m_bootstrapComment, host.comment);
const common::dataStructures::EntryLog creationLog = host.creationLog;
ASSERT_EQ(m_cliSI.user.name, creationLog.user.name);
ASSERT_EQ(m_cliSI.user.group, creationLog.user.group);
ASSERT_EQ(m_cliSI.host, creationLog.host);
const common::dataStructures::EntryLog lastModificationLog =
host.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
}
}
TEST_F(cta_catalogue_SqliteCatalogueTest, createAdminUser) {
......@@ -130,46 +148,46 @@ TEST_F(cta_catalogue_SqliteCatalogueTest, createAdminUser) {
createAdminUserComment));
{
std::list<common::dataStructures::AdminUser> adminList;
adminList = catalogue->getAdminUsers(m_bootstrapAdminSI);
ASSERT_EQ(2, adminList.size());
const common::dataStructures::AdminUser elem1 = adminList.front();
adminList.pop_front();
const common::dataStructures::AdminUser elem2 = adminList.front();
ASSERT_NE(elem1, elem2);
ASSERT_TRUE((elem1.user == m_bootstrapAdminUI && elem2.user == m_adminUI) ||
(elem2.user == m_bootstrapAdminUI && elem1.user == m_adminUI));
if(elem1.user == m_bootstrapAdminUI) {
ASSERT_EQ(m_bootstrapAdminUI, elem1.user);
ASSERT_EQ(m_bootstrapComment, elem1.comment);
ASSERT_EQ(m_cliSI.user, elem1.creationLog.user);
ASSERT_EQ(m_cliSI.host, elem1.creationLog.host);
ASSERT_EQ(m_cliSI.user, elem1.lastModificationLog.user);
ASSERT_EQ(m_cliSI.host, elem1.lastModificationLog.host);
ASSERT_EQ(m_adminUI, elem2.user);
ASSERT_EQ(createAdminUserComment, elem2.comment);
ASSERT_EQ(m_bootstrapAdminSI.user, elem2.creationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, elem2.creationLog.host);
ASSERT_EQ(m_bootstrapAdminSI.user, elem2.lastModificationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, elem2.lastModificationLog.host);
std::list<common::dataStructures::AdminUser> admins;
admins = catalogue->getAdminUsers(m_bootstrapAdminSI);
ASSERT_EQ(2, admins.size());
const common::dataStructures::AdminUser a1 = admins.front();
admins.pop_front();
const common::dataStructures::AdminUser a2 = admins.front();
ASSERT_NE(a1, a2);
ASSERT_TRUE((a1.user == m_bootstrapAdminUI && a2.user == m_adminUI) ||
(a2.user == m_bootstrapAdminUI && a1.user == m_adminUI));
if(a1.user == m_bootstrapAdminUI) {
ASSERT_EQ(m_bootstrapAdminUI, a1.user);
ASSERT_EQ(m_bootstrapComment, a1.comment);
ASSERT_EQ(m_cliSI.user, a1.creationLog.user);
ASSERT_EQ(m_cliSI.host, a1.creationLog.host);
ASSERT_EQ(m_cliSI.user, a1.lastModificationLog.user);
ASSERT_EQ(m_cliSI.host, a1.lastModificationLog.host);
ASSERT_EQ(m_adminUI, a2.user);
ASSERT_EQ(createAdminUserComment, a2.comment);
ASSERT_EQ(m_bootstrapAdminSI.user, a2.creationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, a2.creationLog.host);
ASSERT_EQ(m_bootstrapAdminSI.user, a2.lastModificationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, a2.lastModificationLog.host);
} else {
ASSERT_EQ(m_bootstrapAdminUI, elem2.user);
ASSERT_EQ(m_bootstrapComment, elem2.comment);
ASSERT_EQ(m_cliSI.user, elem2.creationLog.user);
ASSERT_EQ(m_cliSI.host, elem2.creationLog.host);
ASSERT_EQ(m_cliSI.user, elem2.lastModificationLog.user);
ASSERT_EQ(m_cliSI.host, elem2.lastModificationLog.host);
ASSERT_EQ(m_adminUI, elem1.user);
ASSERT_EQ(createAdminUserComment, elem1.comment);
ASSERT_EQ(m_bootstrapAdminSI.user, elem1.creationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, elem1.creationLog.host);
ASSERT_EQ(m_bootstrapAdminSI.user, elem1.lastModificationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, elem1.lastModificationLog.host);
ASSERT_EQ(m_bootstrapAdminUI, a2.user);
ASSERT_EQ(m_bootstrapComment, a2.comment);
ASSERT_EQ(m_cliSI.user, a2.creationLog.user);
ASSERT_EQ(m_cliSI.host, a2.creationLog.host);
ASSERT_EQ(m_cliSI.user, a2.lastModificationLog.user);
ASSERT_EQ(m_cliSI.host, a2.lastModificationLog.host);
ASSERT_EQ(m_adminUI, a1.user);
ASSERT_EQ(createAdminUserComment, a1.comment);
ASSERT_EQ(m_bootstrapAdminSI.user, a1.creationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, a1.creationLog.host);
ASSERT_EQ(m_bootstrapAdminSI.user, a1.lastModificationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, a1.lastModificationLog.host);
}
}
}
......@@ -201,12 +219,127 @@ TEST_F(cta_catalogue_SqliteCatalogueTest, createAdminUser_same_admin_twice) {
ASSERT_EQ(creationLog, lastModificationLog);
}
const std::string createAdminUserComment = "create admin user comment";
ASSERT_NO_THROW(catalogue->createAdminUser(m_bootstrapAdminSI, m_adminUI,
createAdminUserComment));
"comment 1"));
ASSERT_THROW(catalogue->createAdminUser(m_bootstrapAdminSI, m_adminUI,
createAdminUserComment), exception::Exception);
"comment 2"), exception::Exception);
}
TEST_F(cta_catalogue_SqliteCatalogueTest, createAdminHost) {
using namespace cta;
std::unique_ptr<catalogue::Catalogue> catalogue;
ASSERT_NO_THROW(catalogue.reset(new catalogue::SqliteCatalogue()));
ASSERT_NO_THROW(catalogue->createBootstrapAdminAndHostNoAuth(
m_cliSI, m_bootstrapAdminUI, m_bootstrapAdminSI.host, m_bootstrapComment));
{
std::list<common::dataStructures::AdminUser> admins;
ASSERT_NO_THROW(admins = catalogue->getAdminUsers(m_bootstrapAdminSI));
ASSERT_EQ(1, admins.size());
const common::dataStructures::AdminUser admin = admins.front();
ASSERT_EQ(m_bootstrapComment, admin.comment);
const common::dataStructures::EntryLog creationLog = admin.creationLog;
ASSERT_EQ(m_cliSI.user.name, creationLog.user.name);
ASSERT_EQ(m_cliSI.user.group, creationLog.user.group);
ASSERT_EQ(m_cliSI.host, creationLog.host);
const common::dataStructures::EntryLog lastModificationLog =
admin.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
}
const std::string createAdminHostComment = "create host user comment";
const std::string anotherAdminHost = "another_admin_host";
ASSERT_NO_THROW(catalogue->createAdminHost(m_bootstrapAdminSI,
anotherAdminHost, createAdminHostComment));
{
std::list<common::dataStructures::AdminHost> hosts;
hosts = catalogue->getAdminHosts(m_bootstrapAdminSI);
ASSERT_EQ(2, hosts.size());
const common::dataStructures::AdminHost h1 = hosts.front();
hosts.pop_front();
const common::dataStructures::AdminHost h2 = hosts.front();
ASSERT_NE(h1, h2);
ASSERT_TRUE(
(h1.name == m_bootstrapAdminSI.host && h2.name == anotherAdminHost)
||
(h2.name == anotherAdminHost && h1.name == m_bootstrapAdminSI.host)
);
if(h1.name == m_bootstrapAdminSI.host) {
ASSERT_EQ(m_bootstrapAdminSI.host, h1.name);
ASSERT_EQ(m_bootstrapComment, h1.comment);
ASSERT_EQ(m_cliSI.user, h1.creationLog.user);
ASSERT_EQ(m_cliSI.host, h1.creationLog.host);
ASSERT_EQ(m_cliSI.user, h1.lastModificationLog.user);
ASSERT_EQ(m_cliSI.host, h1.lastModificationLog.host);
ASSERT_EQ(anotherAdminHost, h2.name);
ASSERT_EQ(createAdminHostComment, h2.comment);
ASSERT_EQ(m_bootstrapAdminSI.user, h2.creationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, h2.creationLog.host);
ASSERT_EQ(m_bootstrapAdminSI.user, h2.lastModificationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, h2.lastModificationLog.host);
} else {
ASSERT_EQ(m_bootstrapAdminSI.host, h2.name);
ASSERT_EQ(m_bootstrapComment, h2.comment);
ASSERT_EQ(m_cliSI.user, h2.creationLog.user);
ASSERT_EQ(m_cliSI.host, h2.creationLog.host);
ASSERT_EQ(m_cliSI.user, h2.lastModificationLog.user);
ASSERT_EQ(m_cliSI.host, h2.lastModificationLog.host);
ASSERT_EQ(anotherAdminHost, h1.name);
ASSERT_EQ(createAdminHostComment, h1.comment);
ASSERT_EQ(m_bootstrapAdminSI.user, h1.creationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, h1.creationLog.host);
ASSERT_EQ(m_bootstrapAdminSI.user, h1.lastModificationLog.user);
ASSERT_EQ(m_bootstrapAdminSI.host, h1.lastModificationLog.host);
}
}
}
TEST_F(cta_catalogue_SqliteCatalogueTest, createAdminHost_same_host_twice) {
using namespace cta;
std::unique_ptr<catalogue::Catalogue> catalogue;
ASSERT_NO_THROW(catalogue.reset(new catalogue::SqliteCatalogue()));
ASSERT_NO_THROW(catalogue->createBootstrapAdminAndHostNoAuth(
m_cliSI, m_bootstrapAdminUI, m_bootstrapAdminSI.host, m_bootstrapComment));
{
std::list<common::dataStructures::AdminUser> admins;
ASSERT_NO_THROW(admins = catalogue->getAdminUsers(m_bootstrapAdminSI));
ASSERT_EQ(1, admins.size());
const common::dataStructures::AdminUser admin = admins.front();
ASSERT_EQ(m_bootstrapComment, admin.comment);
const common::dataStructures::EntryLog creationLog = admin.creationLog;
ASSERT_EQ(m_cliSI.user.name, creationLog.user.name);
ASSERT_EQ(m_cliSI.user.group, creationLog.user.group);
ASSERT_EQ(m_cliSI.host, creationLog.host);
const common::dataStructures::EntryLog lastModificationLog =
admin.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
}
const std::string anotherAdminHost = "another_admin_host";
ASSERT_NO_THROW(catalogue->createAdminHost(m_bootstrapAdminSI,
anotherAdminHost, "comment 1"));
ASSERT_THROW(catalogue->createAdminHost(m_bootstrapAdminSI,
anotherAdminHost, "coment 2"), exception::Exception);
}
TEST_F(cta_catalogue_SqliteCatalogueTest, isAdmin_notAdmin) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment