Loading src/main/java/it/inaf/oats/vospace/UriService.java +3 −3 Original line number Diff line number Diff line Loading @@ -329,8 +329,6 @@ public class UriService { String linkTarget = linkNode.getTarget(); if (URIUtils.isURIInternal(linkTarget)) { return linkNode; } else { String targetPath = URIUtils.returnVosPathFromNodeURI(linkTarget, authority); Optional<Node> targetNodeOpt = nodeDao.listNode(targetPath); Loading @@ -341,6 +339,8 @@ public class UriService { } else { return targetNode; } } else { return linkNode; } } Loading @@ -364,7 +364,7 @@ public class UriService { return this.uri; } public boolean isEndpointCompliant(String endpoint) { public boolean isEndpointCompliant(String endpoint) { return endpoint.toLowerCase() .startsWith(this.protocolString + "://"); } Loading src/test/java/it/inaf/oats/vospace/UriServiceTest.java +14 −10 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ 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.persistence.LinkedServiceDAO; import it.inaf.oats.vospace.persistence.LocationDAO; import it.inaf.oats.vospace.persistence.NodeDAO; import it.inaf.oats.vospace.persistence.model.Location; Loading Loading @@ -69,6 +70,9 @@ public class UriServiceTest { @MockBean private CreateNodeService createNodeService; @MockBean private LinkedServiceDAO linkedServiceDAO; @MockBean private FileServiceClient fileServiceClient; Loading @@ -94,12 +98,15 @@ public class UriServiceTest { return request; } } public final static String PORTAL_URL = "http://portalurl.ia2.inaf.it/portal/files"; @BeforeEach public void init() { Location location = new Location(); location.setType(LocationType.ASYNC); when(locationDAO.getNodeLocation(any())).thenReturn(Optional.of(location)); when(linkedServiceDAO.isLinkedServiceUrl(eq(PORTAL_URL))).thenReturn(Boolean.TRUE); } @Test Loading Loading @@ -381,14 +388,7 @@ public class UriServiceTest { when(user.getName()).thenReturn("user1"); when(servletRequest.getUserPrincipal()).thenReturn(user); when(rapClient.exchangeToken(argThat(req -> { assertEquals("<token>", req.getSubjectToken()); assertEquals("http://file-service/mydummydata1", req.getResource()); return true; }), any())).thenReturn("<new-token>"); JobSummary job = getPullFromVoSpaceJob(targetOfPull); Transfer tr = uriService.getTransfer(job); Loading Loading @@ -589,9 +589,13 @@ public class UriServiceTest { mockPublicNode("parent_dir"); mockPublicNode("parent_dir/file1"); mockPublicNode("parent_dir/file2"); when(fileServiceClient.startArchiveJob(any(), any())) .thenReturn("http://file-service/mockarchive"); uriService.getNegotiatedTransfer(job, transfer); verify(fileServiceClient, times(1)).startArchiveJob(transfer, "archive-job-id"); } Loading Loading
src/main/java/it/inaf/oats/vospace/UriService.java +3 −3 Original line number Diff line number Diff line Loading @@ -329,8 +329,6 @@ public class UriService { String linkTarget = linkNode.getTarget(); if (URIUtils.isURIInternal(linkTarget)) { return linkNode; } else { String targetPath = URIUtils.returnVosPathFromNodeURI(linkTarget, authority); Optional<Node> targetNodeOpt = nodeDao.listNode(targetPath); Loading @@ -341,6 +339,8 @@ public class UriService { } else { return targetNode; } } else { return linkNode; } } Loading @@ -364,7 +364,7 @@ public class UriService { return this.uri; } public boolean isEndpointCompliant(String endpoint) { public boolean isEndpointCompliant(String endpoint) { return endpoint.toLowerCase() .startsWith(this.protocolString + "://"); } Loading
src/test/java/it/inaf/oats/vospace/UriServiceTest.java +14 −10 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ 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.persistence.LinkedServiceDAO; import it.inaf.oats.vospace.persistence.LocationDAO; import it.inaf.oats.vospace.persistence.NodeDAO; import it.inaf.oats.vospace.persistence.model.Location; Loading Loading @@ -69,6 +70,9 @@ public class UriServiceTest { @MockBean private CreateNodeService createNodeService; @MockBean private LinkedServiceDAO linkedServiceDAO; @MockBean private FileServiceClient fileServiceClient; Loading @@ -94,12 +98,15 @@ public class UriServiceTest { return request; } } public final static String PORTAL_URL = "http://portalurl.ia2.inaf.it/portal/files"; @BeforeEach public void init() { Location location = new Location(); location.setType(LocationType.ASYNC); when(locationDAO.getNodeLocation(any())).thenReturn(Optional.of(location)); when(linkedServiceDAO.isLinkedServiceUrl(eq(PORTAL_URL))).thenReturn(Boolean.TRUE); } @Test Loading Loading @@ -381,14 +388,7 @@ public class UriServiceTest { when(user.getName()).thenReturn("user1"); when(servletRequest.getUserPrincipal()).thenReturn(user); when(rapClient.exchangeToken(argThat(req -> { assertEquals("<token>", req.getSubjectToken()); assertEquals("http://file-service/mydummydata1", req.getResource()); return true; }), any())).thenReturn("<new-token>"); JobSummary job = getPullFromVoSpaceJob(targetOfPull); Transfer tr = uriService.getTransfer(job); Loading Loading @@ -589,9 +589,13 @@ public class UriServiceTest { mockPublicNode("parent_dir"); mockPublicNode("parent_dir/file1"); mockPublicNode("parent_dir/file2"); when(fileServiceClient.startArchiveJob(any(), any())) .thenReturn("http://file-service/mockarchive"); uriService.getNegotiatedTransfer(job, transfer); verify(fileServiceClient, times(1)).startArchiveJob(transfer, "archive-job-id"); } Loading