Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-file-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Environments
Terraform modules
Monitor
Incidents
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-file-service
Commits
16ff8bff
Commit
16ff8bff
authored
3 years ago
by
Nicola Fulvio Calabria
Browse files
Options
Downloads
Patches
Plain Diff
Test fix
parent
312305bb
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/ia2/transfer/controller/ArchiveFileControllerTest.java
+16
-13
16 additions, 13 deletions
...af/ia2/transfer/controller/ArchiveFileControllerTest.java
with
16 additions
and
13 deletions
src/test/java/it/inaf/ia2/transfer/controller/ArchiveFileControllerTest.java
+
16
−
13
View file @
16ff8bff
...
...
@@ -9,9 +9,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
it.inaf.ia2.transfer.auth.TokenPrincipal
;
import
it.inaf.ia2.transfer.service.ArchiveJob
;
import
it.inaf.ia2.transfer.service.ArchiveService
;
import
it.inaf.oats.vospace.parent.exchange.ArchiveEntryDescriptor
;
import
java.io.File
;
import
java.nio.file.Files
;
import
java.util.Arrays
;
import
java.util.List
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
...
...
@@ -44,15 +46,14 @@ public class ArchiveFileControllerTest {
@Autowired
private
MockMvc
mockMvc
;
// TODO: refactor tests
/*
@Test
public
void
testCreateTarArchive
()
throws
Exception
{
ArchiveRequest
request
=
new
ArchiveRequest
();
request
.
setJobId
(
"123"
);
request
.
setType
(
"TAR"
);
request.setPaths(Arrays.asList("/path/to/file1", "/path/to/file2"));
request
.
setEntryDescriptors
(
List
.
of
(
this
.
getArchiveEntryDescriptor
(
"/path/to/file1"
),
this
.
getArchiveEntryDescriptor
(
"/path/to/file2"
)));
mockMvc
.
perform
(
post
(
"/archive"
)
.
principal
(
fakePrincipal
(
"user1"
))
...
...
@@ -65,10 +66,10 @@ public class ArchiveFileControllerTest {
assertEquals
(
"123"
,
job
.
getJobId
());
assertEquals
(
ArchiveJob
.
Type
.
TAR
,
job
.
getType
());
assertEquals
(
"user1"
,
job
.
getPrincipal
().
getName
());
assertEquals(2, job.get
VosPath
s().size());
assertEquals
(
2
,
job
.
get
EntryDescriptor
s
().
size
());
return
true
;
}),
any
());
}
*/
}
@Test
public
void
testGetArchive
()
throws
Exception
{
...
...
@@ -90,14 +91,13 @@ public class ArchiveFileControllerTest {
}
}
/*
@Test
//@Test
public
void
testAnonymousCantCreateArchive
()
throws
Exception
{
ArchiveRequest
request
=
new
ArchiveRequest
();
request
.
setJobId
(
"123"
);
request
.
setType
(
"ZIP"
);
request.set
Paths(Arrays.asList
("/ignore"));
request
.
set
EntryDescriptors
(
List
.
of
(
this
.
getArchiveEntryDescriptor
(
"/ignore"
))
)
;
mockMvc
.
perform
(
post
(
"/archive"
)
.
principal
(
fakePrincipal
(
"anonymous"
))
...
...
@@ -105,9 +105,8 @@ public class ArchiveFileControllerTest {
.
content
(
MAPPER
.
writeValueAsString
(
request
)))
.
andDo
(
print
())
.
andExpect
(
status
().
isForbidden
());
}
*/
}
@Test
public
void
testAnonymousCantGetArchive
()
throws
Exception
{
mockMvc
.
perform
(
get
(
"/archive/123.zip"
)
...
...
@@ -121,4 +120,8 @@ public class ArchiveFileControllerTest {
when
(
principal
.
getName
()).
thenReturn
(
name
);
return
principal
;
}
private
ArchiveEntryDescriptor
getArchiveEntryDescriptor
(
String
vosPath
)
{
return
new
ArchiveEntryDescriptor
(
vosPath
);
}
}
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