Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-rest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
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
VOSpace INAF
vospace-rest
Commits
732a7ded
Commit
732a7ded
authored
4 years ago
by
Sonia Zorba
Browse files
Options
Downloads
Patches
Plain Diff
Added test case for task #3636
parent
b10011cc
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/it/inaf/oats/vospace/ListNodeControllerTest.java
+39
-0
39 additions, 0 deletions
...est/java/it/inaf/oats/vospace/ListNodeControllerTest.java
with
39 additions
and
0 deletions
src/test/java/it/inaf/oats/vospace/ListNodeControllerTest.java
+
39
−
0
View file @
732a7ded
package
it.inaf.oats.vospace
;
package
it.inaf.oats.vospace
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
static
it
.
inaf
.
oats
.
vospace
.
VOSpaceXmlTestUtil
.
loadDocument
;
import
static
it
.
inaf
.
oats
.
vospace
.
VOSpaceXmlTestUtil
.
loadDocument
;
import
it.inaf.oats.vospace.datamodel.NodeProperties
;
import
it.inaf.oats.vospace.datamodel.NodeProperties
;
import
it.inaf.oats.vospace.persistence.NodeDAO
;
import
it.inaf.oats.vospace.persistence.NodeDAO
;
...
@@ -35,6 +36,8 @@ public class ListNodeControllerTest {
...
@@ -35,6 +36,8 @@ public class ListNodeControllerTest {
private
static
final
String
URI_PREFIX
=
"vos://example.com!vospace"
;
private
static
final
String
URI_PREFIX
=
"vos://example.com!vospace"
;
private
static
final
ObjectMapper
MAPPER
=
new
ObjectMapper
();
@MockBean
@MockBean
private
NodeDAO
dao
;
private
NodeDAO
dao
;
...
@@ -108,6 +111,42 @@ public class ListNodeControllerTest {
...
@@ -108,6 +111,42 @@ public class ListNodeControllerTest {
.
andExpect
(
status
().
is2xxSuccessful
());
.
andExpect
(
status
().
is2xxSuccessful
());
}
}
//@Test
public
void
testListOnlyReadableChildren
()
throws
Exception
{
ContainerNode
node
=
new
ContainerNode
();
node
.
setUri
(
URI_PREFIX
+
"/mynode"
);
Property
creator
=
new
Property
();
creator
.
setUri
(
NodeProperties
.
CREATOR_URI
);
creator
.
setValue
(
"user1"
);
node
.
getProperties
().
add
(
creator
);
// hidden node
Node
child1
=
getDataNodeByOwnership
(
"user2"
,
"group5"
);
child1
.
setUri
(
URI_PREFIX
+
"/mynode/child1"
);
node
.
getNodes
().
add
(
child1
);
// visible node
Node
child2
=
getDataNodeByOwnership
(
"user1"
,
"group1"
);
child2
.
setUri
(
URI_PREFIX
+
"/mynode/child2"
);
node
.
getNodes
().
add
(
child2
);
assertEquals
(
2
,
node
.
getNodes
().
size
());
when
(
dao
.
listNode
(
eq
(
"/mynode"
))).
thenReturn
(
Optional
.
of
(
node
));
String
response
=
mockMvc
.
perform
(
get
(
"/nodes/mynode"
)
.
header
(
"Authorization"
,
"Bearer user1_token"
)
.
accept
(
MediaType
.
APPLICATION_JSON
))
.
andExpect
(
status
().
is2xxSuccessful
())
.
andReturn
().
getResponse
().
getContentAsString
();
ContainerNode
result
=
MAPPER
.
readValue
(
response
,
ContainerNode
.
class
);
assertEquals
(
1
,
result
.
getNodes
().
size
());
assertEquals
(
URI_PREFIX
+
"/mynode/child2"
,
result
.
getNodes
().
get
(
0
).
getUri
());
}
private
Optional
<
Node
>
getRootNode
()
{
private
Optional
<
Node
>
getRootNode
()
{
ContainerNode
root
=
new
ContainerNode
();
ContainerNode
root
=
new
ContainerNode
();
root
.
setUri
(
URI_PREFIX
+
"/"
);
root
.
setUri
(
URI_PREFIX
+
"/"
);
...
...
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