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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-rest
Commits
84f6c57e
Commit
84f6c57e
authored
4 years ago
by
Nicola Fulvio Calabria
Browse files
Options
Downloads
Patches
Plain Diff
Added test cases for PermissionDeniedException and NodeBusyException in
UriServiceTest class
parent
d9a1f20e
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/UriServiceTest.java
+74
-1
74 additions, 1 deletion
src/test/java/it/inaf/oats/vospace/UriServiceTest.java
with
74 additions
and
1 deletion
src/test/java/it/inaf/oats/vospace/UriServiceTest.java
+
74
−
1
View file @
84f6c57e
...
@@ -4,6 +4,8 @@ import it.inaf.ia2.aa.ServletRapClient;
...
@@ -4,6 +4,8 @@ import it.inaf.ia2.aa.ServletRapClient;
import
it.inaf.ia2.aa.data.User
;
import
it.inaf.ia2.aa.data.User
;
import
it.inaf.oats.vospace.datamodel.NodeProperties
;
import
it.inaf.oats.vospace.datamodel.NodeProperties
;
import
it.inaf.oats.vospace.exception.InvalidArgumentException
;
import
it.inaf.oats.vospace.exception.InvalidArgumentException
;
import
it.inaf.oats.vospace.exception.NodeBusyException
;
import
it.inaf.oats.vospace.exception.PermissionDeniedException
;
import
it.inaf.oats.vospace.exception.ProtocolNotSupportedException
;
import
it.inaf.oats.vospace.exception.ProtocolNotSupportedException
;
import
it.inaf.oats.vospace.persistence.LocationDAO
;
import
it.inaf.oats.vospace.persistence.LocationDAO
;
import
it.inaf.oats.vospace.persistence.NodeDAO
;
import
it.inaf.oats.vospace.persistence.NodeDAO
;
...
@@ -19,6 +21,7 @@ import net.ivoa.xml.vospace.v2.Property;
...
@@ -19,6 +21,7 @@ import net.ivoa.xml.vospace.v2.Property;
import
net.ivoa.xml.vospace.v2.Protocol
;
import
net.ivoa.xml.vospace.v2.Protocol
;
import
net.ivoa.xml.vospace.v2.Transfer
;
import
net.ivoa.xml.vospace.v2.Transfer
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
fail
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
fail
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
...
@@ -136,6 +139,76 @@ public class UriServiceTest {
...
@@ -136,6 +139,76 @@ public class UriServiceTest {
assertEquals
(
"http://file-service/mydata1?jobId=job-id&token=<new-token>"
,
job
.
getResults
().
get
(
0
).
getHref
());
assertEquals
(
"http://file-service/mydata1?jobId=job-id&token=<new-token>"
,
job
.
getResults
().
get
(
0
).
getHref
());
}
}
@Test
public
void
testPrivateUrlPermissionDenied
()
{
Node
node
=
new
DataNode
();
Property
creator
=
new
Property
();
creator
.
setUri
(
NodeProperties
.
CREATOR_URI
);
creator
.
setValue
(
"user3"
);
node
.
getProperties
().
add
(
creator
);
Property
readgroup
=
new
Property
();
readgroup
.
setUri
(
NodeProperties
.
GROUP_READ_URI
);
readgroup
.
setValue
(
"group1000"
);
node
.
getProperties
().
add
(
readgroup
);
when
(
nodeDAO
.
listNode
(
eq
(
"/mydata1"
))).
thenReturn
(
Optional
.
of
(
node
));
User
user
=
mock
(
User
.
class
);
when
(
user
.
getAccessToken
()).
thenReturn
(
"<token>"
);
when
(
user
.
getName
()).
thenReturn
(
"user1"
);
when
(
servletRequest
.
getUserPrincipal
()).
thenReturn
(
user
);
when
(
rapClient
.
exchangeToken
(
argThat
(
req
->
{
assertEquals
(
"<token>"
,
req
.
getSubjectToken
());
assertEquals
(
"http://file-service/mydata1"
,
req
.
getResource
());
return
true
;
}),
any
())).
thenReturn
(
"<new-token>"
);
JobSummary
job
=
getJob
();
Transfer
tr
=
uriService
.
getTransfer
(
job
);
assertThrows
(
PermissionDeniedException
.
class
,
()->{
uriService
.
setTransferJobResult
(
job
,
tr
);});
}
@Test
public
void
testPrivateUrlNodeBusy
()
{
DataNode
node
=
new
DataNode
();
Property
creator
=
new
Property
();
creator
.
setUri
(
NodeProperties
.
CREATOR_URI
);
creator
.
setValue
(
"user1"
);
node
.
getProperties
().
add
(
creator
);
Property
readgroup
=
new
Property
();
readgroup
.
setUri
(
NodeProperties
.
GROUP_READ_URI
);
readgroup
.
setValue
(
"group1"
);
node
.
getProperties
().
add
(
readgroup
);
node
.
setBusy
(
Boolean
.
TRUE
);
when
(
nodeDAO
.
listNode
(
eq
(
"/mydata1"
))).
thenReturn
(
Optional
.
of
(
node
));
User
user
=
mock
(
User
.
class
);
when
(
user
.
getAccessToken
()).
thenReturn
(
"<token>"
);
when
(
user
.
getName
()).
thenReturn
(
"user1"
);
when
(
servletRequest
.
getUserPrincipal
()).
thenReturn
(
user
);
when
(
rapClient
.
exchangeToken
(
argThat
(
req
->
{
assertEquals
(
"<token>"
,
req
.
getSubjectToken
());
assertEquals
(
"http://file-service/mydata1"
,
req
.
getResource
());
return
true
;
}),
any
())).
thenReturn
(
"<new-token>"
);
JobSummary
job
=
getJob
();
Transfer
tr
=
uriService
.
getTransfer
(
job
);
assertThrows
(
NodeBusyException
.
class
,
()->{
uriService
.
setTransferJobResult
(
job
,
tr
);});
}
@Test
@Test
public
void
pushToNonexistentNode
()
{
public
void
pushToNonexistentNode
()
{
...
...
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