Commit 1907e7fb authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Minor fixes

parent 023b82fb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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);
@@ -341,6 +339,8 @@ public class UriService {
            } else {
                return targetNode;
            }
        } else {
            return linkNode;
        }
    }

@@ -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 + "://");
        }
+14 −10
Original line number Diff line number Diff line
@@ -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;
@@ -69,6 +70,9 @@ public class UriServiceTest {

    @MockBean
    private CreateNodeService createNodeService;
    
    @MockBean
    private LinkedServiceDAO linkedServiceDAO;

    @MockBean
    private FileServiceClient fileServiceClient;
@@ -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
@@ -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);
        
@@ -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");
    }