Skip to content
Snippets Groups Projects
Commit 16ff8bff authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Test fix

parent 312305bb
No related branches found
No related tags found
No related merge requests found
......@@ -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.getVosPaths().size());
assertEquals(2, job.getEntryDescriptors().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.setPaths(Arrays.asList("/ignore"));
request.setEntryDescriptors(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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment