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
97e678bd
Verified
Commit
97e678bd
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: fix some unit tests
parent
aa0032ed
No related branches found
No related tags found
2 merge requests
!58
REL: prepare release 0.7.2
,
!45
F grpc f acm
Pipeline
#17180
passed
3 years ago
Stage: info
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/caosdb/server/accessControl/UserSources.java
+3
-0
3 additions, 0 deletions
...ain/java/org/caosdb/server/accessControl/UserSources.java
src/test/java/org/caosdb/server/permissions/EntityACLTest.java
+60
-0
60 additions, 0 deletions
...est/java/org/caosdb/server/permissions/EntityACLTest.java
with
63 additions
and
0 deletions
src/main/java/org/caosdb/server/accessControl/UserSources.java
+
3
−
0
View file @
97e678bd
...
...
@@ -88,6 +88,9 @@ public class UserSources extends HashMap<String, UserSource> {
* @return true iff the user identified by the given {@link Principal} exists.
*/
public
static
boolean
isUserExisting
(
final
Principal
principal
)
{
if
(
principal
.
getRealm
().
equals
(
OneTimeAuthenticationToken
.
REALM_NAME
))
{
return
true
;
}
UserSource
userSource
=
instance
.
get
(
principal
.
getRealm
());
if
(
userSource
!=
null
)
{
return
userSource
.
isUserExisting
(
principal
.
getUsername
());
...
...
This diff is collapsed.
Click to expand it.
src/test/java/org/caosdb/server/permissions/EntityACLTest.java
+
60
−
0
View file @
97e678bd
...
...
@@ -23,27 +23,36 @@
package
org.caosdb.server.permissions
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.BitSet
;
import
java.util.HashSet
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Set
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.subject.Subject
;
import
org.caosdb.server.CaosDBServer
;
import
org.caosdb.server.accessControl.AnonymousAuthenticationToken
;
import
org.caosdb.server.accessControl.AuthenticationUtils
;
import
org.caosdb.server.accessControl.Config
;
import
org.caosdb.server.accessControl.CredentialsValidator
;
import
org.caosdb.server.accessControl.OneTimeAuthenticationToken
;
import
org.caosdb.server.accessControl.Principal
;
import
org.caosdb.server.accessControl.Role
;
import
org.caosdb.server.database.BackendTransaction
;
import
org.caosdb.server.database.access.Access
;
import
org.caosdb.server.database.backend.interfaces.RetrievePasswordValidatorImpl
;
import
org.caosdb.server.database.backend.interfaces.RetrievePermissionRulesImpl
;
import
org.caosdb.server.database.backend.interfaces.RetrieveRoleImpl
;
import
org.caosdb.server.database.backend.interfaces.RetrieveUserImpl
;
import
org.caosdb.server.database.exceptions.TransactionException
;
import
org.caosdb.server.database.misc.TransactionBenchmark
;
import
org.caosdb.server.database.proto.ProtoUser
;
import
org.caosdb.server.resource.AbstractCaosDBServerResource
;
import
org.caosdb.server.resource.AbstractCaosDBServerResource.XMLParser
;
import
org.caosdb.server.utils.Utils
;
...
...
@@ -101,6 +110,54 @@ public class EntityACLTest {
}
}
public
static
class
RetrievePasswordValidatorMockup
implements
RetrievePasswordValidatorImpl
{
public
RetrievePasswordValidatorMockup
(
Access
a
)
{}
@Override
public
void
setTransactionBenchmark
(
TransactionBenchmark
b
)
{}
@Override
public
TransactionBenchmark
getBenchmark
()
{
return
null
;
}
@Override
public
CredentialsValidator
<
String
>
execute
(
String
name
)
throws
TransactionException
{
if
(
name
.
equals
(
"anonymous"
))
{
return
new
CredentialsValidator
<
String
>()
{
@Override
public
boolean
isValid
(
String
credential
)
{
return
false
;
}
};
}
return
null
;
}
}
public
static
class
RetrieveUserMockup
implements
RetrieveUserImpl
{
public
RetrieveUserMockup
(
Access
a
)
{}
@Override
public
void
setTransactionBenchmark
(
TransactionBenchmark
b
)
{}
@Override
public
TransactionBenchmark
getBenchmark
()
{
return
null
;
}
@Override
public
ProtoUser
execute
(
Principal
principal
)
throws
TransactionException
{
if
(
principal
.
getUsername
().
equals
(
"anonymous"
))
{
return
new
ProtoUser
();
}
return
null
;
}
}
@BeforeClass
public
static
void
init
()
throws
IOException
{
CaosDBServer
.
initServerProperties
();
...
...
@@ -110,6 +167,9 @@ public class EntityACLTest {
BackendTransaction
.
setImpl
(
RetrievePermissionRulesImpl
.
class
,
RetrievePermissionRulesMockup
.
class
);
BackendTransaction
.
setImpl
(
RetrieveRoleImpl
.
class
,
RetrieveRoleMockup
.
class
);
BackendTransaction
.
setImpl
(
RetrievePasswordValidatorImpl
.
class
,
RetrievePasswordValidatorMockup
.
class
);
BackendTransaction
.
setImpl
(
RetrieveUserImpl
.
class
,
RetrieveUserMockup
.
class
);
}
@Test
...
...
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