api/src/test/java/edu/utexas/tacc/tapis/files/api/resources/ITestPermissionsResource.java
@Test
    public void testPermissionsWithServiceJwtShould403() throws Exception {
        testSystem.setOwner("testuser1");
        when(serviceClients.getClient(anyString(), anyString(), eq(SystemsClient.class))).thenReturn(systemsClient);
        when(systemsClient.getUserCredential(any(), any())).thenReturn(creds);
        when(systemsClient.getSystemWithCredentials(any(), any())).thenReturn(testSystem);
        when(skClient.isPermitted(any(), any(), any())).thenReturn(true);
        FilePermissionResponse response = target("/v3/files/permissions/testSystem/a/")
            .queryParam("username", "testuser2")
            .request()
            .header("X-Tapis-Token", getServiceJwt())
            .header("x-tapis-tenant", "dev")
            .header("x-tapis-user", "testuser2")
            .get(FilePermissionResponse.class);
        Assert.assertEquals(response.getResult().getPermission(), Permission.MODIFY);
    }
/**
     * This test uses a serviceJWT to make a request to the permissions GET route
     * OBO testuser2, but for a system that is mocked to be owned by testuser1
     * so this should throw a 403 since testuser2 has no access to the system.
     * @throws Exception
     */
This test uses a serviceJWT to make a request to the permissions GET route
OBO testuser2, but for a system that is mocked to be owned by testuser1
so this should throw a 403 since testuser2 has no access to the system.
@throws Exception
This test uses a serviceJWT to make a request to the permissions GET route OBO testuser2 but for a system that is mocked to be owned by testuser1 so this should throw a 403 since testuser2 has no access to the system . @throws Exception
@Test
    public void testPermissionsWithServiceJwtShould403() throws Exception {
        testSystem.setOwner("testuser1");
        when(serviceClients.getClient(anyString(), anyString(), eq(SystemsClient.class))).thenReturn(systemsClient);
        when(systemsClient.getUserCredential(any(), any())).thenReturn(creds);
        when(systemsClient.getSystemWithCredentials(any(), any())).thenReturn(testSystem);
        when(skClient.isPermitted(any(), any(), any())).thenReturn(true);
        FilePermissionResponse response = target("/v3/files/permissions/testSystem/a/")
            .queryParam("username", "testuser2")
            .request()
            .header("X-Tapis-Token", getServiceJwt())
            .header("x-tapis-tenant", "dev")
            .header("x-tapis-user", "testuser2")
            .get(FilePermissionResponse.class);
        Assert.assertEquals(response.getResult().getPermission(), Permission.MODIFY);
    }
@ Test public void testPermissionsWithServiceJwtShould403 ( ) throws Exception { testSystem . setOwner ( "testuser1" ) ; when ( serviceClients . getClient ( anyString ( ) , anyString ( ) , eq ( SystemsClient . class ) ) ) . thenReturn ( systemsClient ) ; when ( systemsClient . getUserCredential ( any ( ) , any ( ) ) ) . thenReturn ( creds ) ; when ( systemsClient . getSystemWithCredentials ( any ( ) , any ( ) ) ) . thenReturn ( testSystem ) ; when ( skClient . isPermitted ( any ( ) , any ( ) , any ( ) ) ) . thenReturn ( true ) ; FilePermissionResponse response = target ( "/v3/files/permissions/testSystem/a/" ) . queryParam ( "username" , "testuser2" ) . request ( ) . header ( "X-Tapis-Token" , getServiceJwt ( ) ) . header ( "x-tapis-tenant" , "dev" ) . header ( "x-tapis-user" , "testuser2" ) . get ( FilePermissionResponse . class ) ; Assert . assertEquals ( response . getResult ( ) . getPermission ( ) , Permission . MODIFY ) ; }
This test uses a serviceJWT to make a request to the permissions GET route
 OBO testuser2, but for a system that is mocked to be owned by testuser1
 so this should throw a 403 since testuser2 has no access to the system.
This test uses a serviceJWT to make a request to the permissions GET route OBO testuser2 but for a system that is mocked to be owned by testuser1 so this should throw a 403 since testuser2 has no access to the system .