Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
cec1d784
Commit
cec1d784
authored
9 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Added SqliteCatalogue::createAdminHost
parent
e36b1f5d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
catalogue/SqliteCatalogue.cpp
+140
-34
140 additions, 34 deletions
catalogue/SqliteCatalogue.cpp
catalogue/SqliteCatalogueTest.cpp
+175
-42
175 additions, 42 deletions
catalogue/SqliteCatalogueTest.cpp
with
315 additions
and
76 deletions
catalogue/SqliteCatalogue.cpp
+
140
−
34
View file @
cec1d784
...
...
@@ -45,10 +45,10 @@ void cta::catalogue::SqliteCatalogue::createDbSchema() {
"CREATION_LOG_HOST_NAME TEXT,"
"CREATION_LOG_TIME INTEGER,"
"LAST_MOD
IFICATION
_USER_NAME TEXT,"
"LAST_MOD
IFICATION
_GROUP_NAME TEXT,"
"LAST_MOD
IFICATION
_HOST_NAME TEXT,"
"LAST_MOD
IFICATION
_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_MOD
IFICATION
_USER_NAME TEXT,"
"LAST_MOD
IFICATION
_GROUP_NAME TEXT,"
"LAST_MOD
IFICATION
_HOST_NAME TEXT,"
"LAST_MOD
IFICATION
_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_MOD
IFICATION
_USER_NAME,"
"LAST_MOD
IFICATION
_GROUP_NAME,"
"LAST_MOD
IFICATION
_HOST_NAME,"
"LAST_MOD
IFICATION
_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_MOD
IFICATION
_USER_NAME,"
"LAST_MOD
IFICATION
_GROUP_NAME,"
"LAST_MOD
IFICATION
_HOST_NAME,"
"LAST_MOD
IFICATION
_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_MOD
IFICATION
_USER_NAME,"
"LAST_MOD
IFICATION
_GROUP_NAME,"
"LAST_MOD
IFICATION
_HOST_NAME,"
"LAST_MOD
IFICATION
_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_MOD
IFICATION
_USER_NAME AS LAST_MOD
IFICATION
_USER_NAME,"
"LAST_MOD
IFICATION
_GROUP_NAME AS LAST_MOD
IFICATION
_GROUP_NAME,"
"LAST_MOD
IFICATION
_HOST_NAME AS LAST_MOD
IFICATION
_HOST_NAME,"
"LAST_MOD
IFICATION
_TIME AS LAST_MOD
IFICATION
_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_MOD
IFICATION
_USER_NAME"
]);
updaterUI
.
group
=
stmt
.
columnText
(
nameToIdx
[
"LAST_MOD
IFICATION
_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
...
...
This diff is collapsed.
Click to expand it.
catalogue/SqliteCatalogueTest.cpp
+
175
−
42
View file @
cec1d784
...
...
@@ -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
>
admin
List
;
admin
List
=
catalogue
->
getAdminUsers
(
m_bootstrapAdminSI
);
ASSERT_EQ
(
2
,
admin
List
.
size
());
const
common
::
dataStructures
::
AdminUser
elem
1
=
admin
List
.
front
();
admin
List
.
pop_front
();
const
common
::
dataStructures
::
AdminUser
elem
2
=
admin
List
.
front
();
ASSERT_NE
(
elem1
,
elem
2
);
ASSERT_TRUE
((
elem
1
.
user
==
m_bootstrapAdminUI
&&
elem
2
.
user
==
m_adminUI
)
||
(
elem
2
.
user
==
m_bootstrapAdminUI
&&
elem
1
.
user
==
m_adminUI
));
if
(
elem
1
.
user
==
m_bootstrapAdminUI
)
{
ASSERT_EQ
(
m_bootstrapAdminUI
,
elem
1
.
user
);
ASSERT_EQ
(
m_bootstrapComment
,
elem
1
.
comment
);
ASSERT_EQ
(
m_cliSI
.
user
,
elem
1
.
creationLog
.
user
);
ASSERT_EQ
(
m_cliSI
.
host
,
elem
1
.
creationLog
.
host
);
ASSERT_EQ
(
m_cliSI
.
user
,
elem
1
.
lastModificationLog
.
user
);
ASSERT_EQ
(
m_cliSI
.
host
,
elem
1
.
lastModificationLog
.
host
);
ASSERT_EQ
(
m_adminUI
,
elem
2
.
user
);
ASSERT_EQ
(
createAdminUserComment
,
elem
2
.
comment
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
user
,
elem
2
.
creationLog
.
user
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
host
,
elem
2
.
creationLog
.
host
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
user
,
elem
2
.
lastModificationLog
.
user
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
host
,
elem
2
.
lastModificationLog
.
host
);
std
::
list
<
common
::
dataStructures
::
AdminUser
>
admin
s
;
admin
s
=
catalogue
->
getAdminUsers
(
m_bootstrapAdminSI
);
ASSERT_EQ
(
2
,
admin
s
.
size
());
const
common
::
dataStructures
::
AdminUser
a
1
=
admin
s
.
front
();
admin
s
.
pop_front
();
const
common
::
dataStructures
::
AdminUser
a
2
=
admin
s
.
front
();
ASSERT_NE
(
a1
,
a
2
);
ASSERT_TRUE
((
a
1
.
user
==
m_bootstrapAdminUI
&&
a
2
.
user
==
m_adminUI
)
||
(
a
2
.
user
==
m_bootstrapAdminUI
&&
a
1
.
user
==
m_adminUI
));
if
(
a
1
.
user
==
m_bootstrapAdminUI
)
{
ASSERT_EQ
(
m_bootstrapAdminUI
,
a
1
.
user
);
ASSERT_EQ
(
m_bootstrapComment
,
a
1
.
comment
);
ASSERT_EQ
(
m_cliSI
.
user
,
a
1
.
creationLog
.
user
);
ASSERT_EQ
(
m_cliSI
.
host
,
a
1
.
creationLog
.
host
);
ASSERT_EQ
(
m_cliSI
.
user
,
a
1
.
lastModificationLog
.
user
);
ASSERT_EQ
(
m_cliSI
.
host
,
a
1
.
lastModificationLog
.
host
);
ASSERT_EQ
(
m_adminUI
,
a
2
.
user
);
ASSERT_EQ
(
createAdminUserComment
,
a
2
.
comment
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
user
,
a
2
.
creationLog
.
user
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
host
,
a
2
.
creationLog
.
host
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
user
,
a
2
.
lastModificationLog
.
user
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
host
,
a
2
.
lastModificationLog
.
host
);
}
else
{
ASSERT_EQ
(
m_bootstrapAdminUI
,
elem
2
.
user
);
ASSERT_EQ
(
m_bootstrapComment
,
elem
2
.
comment
);
ASSERT_EQ
(
m_cliSI
.
user
,
elem
2
.
creationLog
.
user
);
ASSERT_EQ
(
m_cliSI
.
host
,
elem
2
.
creationLog
.
host
);
ASSERT_EQ
(
m_cliSI
.
user
,
elem
2
.
lastModificationLog
.
user
);
ASSERT_EQ
(
m_cliSI
.
host
,
elem
2
.
lastModificationLog
.
host
);
ASSERT_EQ
(
m_adminUI
,
elem
1
.
user
);
ASSERT_EQ
(
createAdminUserComment
,
elem
1
.
comment
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
user
,
elem
1
.
creationLog
.
user
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
host
,
elem
1
.
creationLog
.
host
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
user
,
elem
1
.
lastModificationLog
.
user
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
host
,
elem
1
.
lastModificationLog
.
host
);
ASSERT_EQ
(
m_bootstrapAdminUI
,
a
2
.
user
);
ASSERT_EQ
(
m_bootstrapComment
,
a
2
.
comment
);
ASSERT_EQ
(
m_cliSI
.
user
,
a
2
.
creationLog
.
user
);
ASSERT_EQ
(
m_cliSI
.
host
,
a
2
.
creationLog
.
host
);
ASSERT_EQ
(
m_cliSI
.
user
,
a
2
.
lastModificationLog
.
user
);
ASSERT_EQ
(
m_cliSI
.
host
,
a
2
.
lastModificationLog
.
host
);
ASSERT_EQ
(
m_adminUI
,
a
1
.
user
);
ASSERT_EQ
(
createAdminUserComment
,
a
1
.
comment
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
user
,
a
1
.
creationLog
.
user
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
host
,
a
1
.
creationLog
.
host
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
user
,
a
1
.
lastModificationLog
.
user
);
ASSERT_EQ
(
m_bootstrapAdminSI
.
host
,
a
1
.
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
,
c
reateAdminUserC
omment
));
"
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
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment