Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
caosdb
Software
caosdb-server
Commits
be0b606f
Commit
be0b606f
authored
6 years ago
by
Daniel
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Fixes
#23
, a failing test when no usersources.ini exists.
parent
a3a69a69
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/caosdb/server/resource/TestAbstractCaosDBServerResource.java
+33
-1
33 additions, 1 deletion
...sdb/server/resource/TestAbstractCaosDBServerResource.java
with
33 additions
and
1 deletion
src/test/java/caosdb/server/resource/TestAbstractCaosDBServerResource.java
+
33
−
1
View file @
be0b606f
...
...
@@ -5,10 +5,13 @@ import static org.junit.Assert.assertNotNull;
import
caosdb.server.CaosDBException
;
import
caosdb.server.CaosDBServer
;
import
caosdb.server.ServerProperties
;
import
caosdb.server.accessControl.AnonymousAuthenticationToken
;
import
caosdb.server.accessControl.AnonymousRealm
;
import
caosdb.server.database.backend.implementation.MySQL.ConnectionException
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.security.NoSuchAlgorithmException
;
import
java.sql.SQLException
;
import
org.apache.shiro.mgt.DefaultSecurityManager
;
...
...
@@ -16,19 +19,23 @@ import org.apache.shiro.subject.Subject;
import
org.apache.shiro.subject.support.DelegatingSubject
;
import
org.jdom2.Element
;
import
org.junit.BeforeClass
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.TemporaryFolder
;
import
org.restlet.data.Reference
;
import
org.restlet.representation.Representation
;
public
class
TestAbstractCaosDBServerResource
{
@Rule
public
TemporaryFolder
tempFolder
=
new
TemporaryFolder
();
@BeforeClass
public
static
void
initServerProperties
()
throws
IOException
{
CaosDBServer
.
initServerProperties
();
}
@Test
public
void
testReponseRootElement
()
{
public
void
testReponseRootElement
()
throws
IOException
{
final
Subject
user
=
new
DelegatingSubject
(
new
DefaultSecurityManager
(
new
AnonymousRealm
()));
user
.
login
(
AnonymousAuthenticationToken
.
getInstance
());
AbstractCaosDBServerResource
s
=
...
...
@@ -68,6 +75,7 @@ public class TestAbstractCaosDBServerResource {
return
user
;
}
};
provideUserSourcesFile
();
Element
response
=
s
.
generateRootElement
();
assertNotNull
(
response
);
assertEquals
(
"TEST-SRID"
,
response
.
getAttribute
(
"srid"
).
getValue
());
...
...
@@ -77,4 +85,28 @@ public class TestAbstractCaosDBServerResource {
Element
userInfo
=
response
.
getChild
(
"UserInfo"
);
assertNotNull
(
userInfo
);
}
/**
* Creates a dummy usersources.ini and injects it into the server properties.
*/
private
void
provideUserSourcesFile
()
throws
IOException
{
String
usersourcesFileName
=
tempFolder
.
newFile
(
"usersources.ini"
).
getAbsolutePath
();
String
usersourcesContent
=
"realms = PAM\n"
+
"defaultRealm = PAM\n"
+
"\n"
+
"[PAM]\n"
+
"class = caosdb.server.accessControl.Pam\n"
+
"default_status = ACTIVE\n"
+
"include.user = admin\n"
+
";include.group = [uncomment and put your groups here]\n"
+
";exclude.user = [uncomment and put excluded users here]\n"
+
";exclude.group = [uncomment and put excluded groups here]\n"
+
"\n"
+
";it is necessary to add at least one admin\n"
+
"user.admin.roles = administration"
;
Files
.
write
(
Paths
.
get
(
usersourcesFileName
),
usersourcesContent
.
getBytes
());
CaosDBServer
.
setProperty
(
ServerProperties
.
KEY_USER_SOURCES_INI_FILE
,
usersourcesFileName
);
}
}
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