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
ce4a272d
Commit
ce4a272d
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
TST: update getCacheKey test
parent
fd014207
No related branches found
No related tags found
1 merge request
!65
F permission checks
Pipeline
#26230
failed
2 years ago
Stage: info
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/org/caosdb/server/query/QueryTest.java
+16
-0
16 additions, 0 deletions
src/test/java/org/caosdb/server/query/QueryTest.java
with
16 additions
and
0 deletions
src/test/java/org/caosdb/server/query/QueryTest.java
+
16
−
0
View file @
ce4a272d
...
@@ -26,7 +26,11 @@ import static org.junit.Assert.assertNull;
...
@@ -26,7 +26,11 @@ import static org.junit.Assert.assertNull;
import
static
org
.
junit
.
Assert
.
fail
;
import
static
org
.
junit
.
Assert
.
fail
;
import
java.io.IOException
;
import
java.io.IOException
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.subject.Subject
;
import
org.caosdb.server.CaosDBServer
;
import
org.caosdb.server.CaosDBServer
;
import
org.caosdb.server.ServerProperties
;
import
org.caosdb.server.accessControl.AnonymousAuthenticationToken
;
import
org.caosdb.server.database.access.InitAccess
;
import
org.caosdb.server.database.access.InitAccess
;
import
org.caosdb.server.transaction.WriteTransaction
;
import
org.caosdb.server.transaction.WriteTransaction
;
import
org.junit.BeforeClass
;
import
org.junit.BeforeClass
;
...
@@ -37,6 +41,7 @@ public class QueryTest {
...
@@ -37,6 +41,7 @@ public class QueryTest {
@BeforeClass
@BeforeClass
public
static
void
initServerProperties
()
throws
IOException
{
public
static
void
initServerProperties
()
throws
IOException
{
CaosDBServer
.
initServerProperties
();
CaosDBServer
.
initServerProperties
();
CaosDBServer
.
initShiro
();
}
}
String
getCacheKey
(
String
query
)
{
String
getCacheKey
(
String
query
)
{
...
@@ -45,6 +50,15 @@ public class QueryTest {
...
@@ -45,6 +50,15 @@ public class QueryTest {
return
q
.
getCacheKey
(
true
);
return
q
.
getCacheKey
(
true
);
}
}
String
getCacheKeyWithUser
(
String
query
)
{
Subject
anonymous
=
SecurityUtils
.
getSubject
();
CaosDBServer
.
setProperty
(
ServerProperties
.
KEY_AUTH_OPTIONAL
,
"true"
);
anonymous
.
login
(
AnonymousAuthenticationToken
.
getInstance
());
Query
q
=
new
Query
(
query
,
anonymous
);
q
.
parse
();
return
q
.
getCacheKey
(
true
);
}
@Test
@Test
public
void
testGetKey
()
{
public
void
testGetKey
()
{
assertEquals
(
"enamePOV(pname,=,val1)"
,
getCacheKey
(
"FIND ename WITH pname = val1"
));
assertEquals
(
"enamePOV(pname,=,val1)"
,
getCacheKey
(
"FIND ename WITH pname = val1"
));
...
@@ -72,6 +86,8 @@ public class QueryTest {
...
@@ -72,6 +86,8 @@ public class QueryTest {
assertEquals
(
assertEquals
(
"ename@(ref1,null)SUB(POV(pname,>,val1)"
,
"ename@(ref1,null)SUB(POV(pname,>,val1)"
,
getCacheKey
(
"FIND ename WHICH IS REFERENCED BY ref1 WITH pname > val1 "
));
getCacheKey
(
"FIND ename WHICH IS REFERENCED BY ref1 WITH pname > val1 "
));
assertEquals
(
"anonymous@anonymous@enamePOV(pname,=,val1)"
,
getCacheKeyWithUser
(
"FIND ename WITH pname = val1"
));
}
}
@Test
@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