Search in sources :

Example 11 with RepositoryFileAclDto

use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project pentaho-platform by pentaho.

the class FileResourceTest method usersOrRolesExist_RecipientIsBlank.

@Test
public void usersOrRolesExist_RecipientIsBlank() {
    RepositoryFileAclDto acl = new RepositoryFileAclDto();
    acl.setOwner(ACL_OWNER);
    RepositoryFileAclAceDto recipient = mock(RepositoryFileAclAceDto.class);
    doReturn("").when(recipient).getRecipient();
    acl.setAces(Arrays.asList(new RepositoryFileAclAceDto[] { recipient }), false);
    assertFalse(fileResource.validateUsersAndRoles(acl));
}
Also used : RepositoryFileAclAceDto(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclAceDto) RepositoryFileAclDto(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto) Test(org.junit.Test)

Example 12 with RepositoryFileAclDto

use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project pentaho-platform by pentaho.

the class FileResourceTest method usersOrRolesExist_RecipientRoleExists.

@Test
public void usersOrRolesExist_RecipientRoleExists() {
    RepositoryFileAclDto acl = new RepositoryFileAclDto();
    acl.setOwner(ACL_OWNER);
    RepositoryFileAclAceDto recipient = mock(RepositoryFileAclAceDto.class);
    doReturn(ROLENAME).when(recipient).getRecipient();
    acl.setAces(Arrays.asList(new RepositoryFileAclAceDto[] { recipient }), false);
    assertTrue(fileResource.validateUsersAndRoles(acl));
}
Also used : RepositoryFileAclAceDto(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclAceDto) RepositoryFileAclDto(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto) Test(org.junit.Test)

Example 13 with RepositoryFileAclDto

use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project pentaho-platform by pentaho.

the class FileResourceTest method testDoGetFileAcl.

@Test
public void testDoGetFileAcl() {
    RepositoryFileAclDto mockRepositoryFileAclDto = mock(RepositoryFileAclDto.class);
    doReturn(mockRepositoryFileAclDto).when(fileResource.fileService).doGetFileAcl(PATH_ID);
    RepositoryFileAclDto testResult = fileResource.doGetFileAcl(PATH_ID);
    assertEquals(mockRepositoryFileAclDto, testResult);
}
Also used : RepositoryFileAclDto(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto) Test(org.junit.Test)

Example 14 with RepositoryFileAclDto

use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project pentaho-platform by pentaho.

the class FileResourceTest method testSetFileAclsOK.

@Test
public void testSetFileAclsOK() {
    RepositoryFileAclDto repository = mock(RepositoryFileAclDto.class);
    doReturn(true).when(fileResource).validateUsersAndRoles(any());
    assertEquals(OK.getStatusCode(), fileResource.setFileAcls(PATH_ID, repository).getStatus());
}
Also used : RepositoryFileAclDto(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto) Test(org.junit.Test)

Example 15 with RepositoryFileAclDto

use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.

the class AnalysisServiceTest method testGetAnalysisDatasourceAclNoAcl.

@Test
public void testGetAnalysisDatasourceAclNoAcl() throws Exception {
    allAccess();
    final String catalogName = "catalogName";
    final MondrianCatalog mondrianCatalog = mock(MondrianCatalog.class);
    when(catalogService.getCatalog(eq(catalogName), any(IPentahoSession.class))).thenReturn(mondrianCatalog);
    when(catalogService.getAclFor(catalogName)).thenReturn(null);
    final RepositoryFileAclDto aclDto = analysisService.getAnalysisDatasourceAcl(catalogName);
    assertNull(aclDto);
}
Also used : MondrianCatalog(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)41 RepositoryFileAclDto (org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto)26 RepositoryFileAclDto (org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto)20 Matchers.anyString (org.mockito.Matchers.anyString)16 InputStream (java.io.InputStream)14 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)13 RepositoryFileAcl (org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)11 RepositoryFileAclAceDto (org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclAceDto)11 FileInputStream (java.io.FileInputStream)9 IPlatformImportBundle (org.pentaho.platform.api.repository2.unified.IPlatformImportBundle)9 RepositoryFileDto (org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto)9 ArrayList (java.util.ArrayList)8 RepositoryFileAclAdapter (org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAdapter)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 FileNotFoundException (java.io.FileNotFoundException)7 Serializable (java.io.Serializable)7 GeneralSecurityException (java.security.GeneralSecurityException)6 IPlatformImporter (org.pentaho.platform.plugin.services.importer.IPlatformImporter)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 ClientResponse (com.sun.jersey.api.client.ClientResponse)4