Search in sources :

Example 1 with RepositoryFileAclAdapter

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

the class DataSourceWizardServiceTest method testSetMetadataDatasourceAcl.

@Test
public void testSetMetadataDatasourceAcl() throws Exception {
    String domainId = DOMAIN_ID;
    String domainIdWithoutExt = "domainId";
    final RepositoryFileAclDto aclDto = new RepositoryFileAclDto();
    aclDto.setOwner("owner");
    aclDto.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
    doReturn(true).when(dataSourceWizardService).canManageACL();
    doReturn(new HashMap<String, InputStream>()).when(dataSourceWizardService).doGetDSWFilesAsDownload(domainId);
    dataSourceWizardService.setDSWAcl(domainId, aclDto);
    final RepositoryFileAcl acl = new RepositoryFileAclAdapter().unmarshal(aclDto);
    verify(dataSourceWizardService.aclAwarePentahoMetadataDomainRepositoryImporter).setAclFor(eq(domainId), eq(acl));
    verify(dataSourceWizardService.aclAwareMondrianCatalogService).setAclFor(eq(domainIdWithoutExt), eq(acl));
}
Also used : InputStream(java.io.InputStream) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) Matchers.anyString(org.mockito.Matchers.anyString) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) RepositoryFileAclAdapter(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAdapter) Test(org.junit.Test)

Example 2 with RepositoryFileAclAdapter

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

the class MetadataServiceTest method testSetMetadataDatasourceAcl.

@Test
public void testSetMetadataDatasourceAcl() throws Exception {
    String domainId = DOMAIN_ID;
    final RepositoryFileAclDto aclDto = new RepositoryFileAclDto();
    aclDto.setOwner("owner");
    aclDto.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
    doReturn(true).when(metadataService).canManageACL();
    final Map<String, InputStream> domainFilesData = mock(Map.class);
    when(domainFilesData.isEmpty()).thenReturn(false);
    when(((PentahoMetadataDomainRepository) metadataService.metadataDomainRepository).getDomainFilesData(domainId)).thenReturn(domainFilesData);
    metadataService.setMetadataAcl(domainId, aclDto);
    verify(metadataService.aclAwarePentahoMetadataDomainRepositoryImporter).setAclFor(eq(domainId), eq(new RepositoryFileAclAdapter().unmarshal(aclDto)));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) StringInputStream(org.apache.tools.ant.filters.StringInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) PentahoMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository) Matchers.anyString(org.mockito.Matchers.anyString) RepositoryFileAclAdapter(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAdapter) Test(org.junit.Test)

Example 3 with RepositoryFileAclAdapter

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

the class AnalysisServiceTest method testSetAnalysisDatasourceAcl.

@Test
public void testSetAnalysisDatasourceAcl() throws Exception {
    allAccess();
    final String catalogName = "catalogName";
    final RepositoryFileAclDto aclDto = new RepositoryFileAclDto();
    aclDto.setOwner("owner");
    aclDto.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
    final MondrianCatalog mondrianCatalog = mock(MondrianCatalog.class);
    when(catalogService.getCatalog(eq(catalogName), any(IPentahoSession.class))).thenReturn(mondrianCatalog);
    analysisService.setAnalysisDatasourceAcl(catalogName, aclDto);
    verify(catalogService).setAclFor(eq(catalogName), eq(new RepositoryFileAclAdapter().unmarshal(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) RepositoryFileAclAdapter(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAdapter) Test(org.junit.Test)

Example 4 with RepositoryFileAclAdapter

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

the class AnalysisServiceTest method testGetAnalysisDatasourceAcl.

@Test
public void testGetAnalysisDatasourceAcl() throws Exception {
    allAccess();
    final String catalogName = "SampleData";
    final RepositoryFileAcl expectedAcl = new RepositoryFileAcl.Builder("owner").build();
    when(catalogService.getAclFor(catalogName)).thenReturn(expectedAcl);
    final MondrianCatalog mondrianCatalog = mock(MondrianCatalog.class);
    when(catalogService.getCatalog(eq(catalogName), any(IPentahoSession.class))).thenReturn(mondrianCatalog);
    final RepositoryFileAclDto actualAcl = analysisService.getAnalysisDatasourceAcl(catalogName);
    assertEquals(expectedAcl, new RepositoryFileAclAdapter().unmarshal(actualAcl));
}
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) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) RepositoryFileAclAdapter(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAdapter) Test(org.junit.Test)

Example 5 with RepositoryFileAclAdapter

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

the class DataSourceWizardServiceTest method testGetDSWAcl.

@Test
public void testGetDSWAcl() throws Exception {
    String domainId = "domainId";
    final RepositoryFileAcl acl = new RepositoryFileAcl.Builder("owner").build();
    doReturn(true).when(dataSourceWizardService).canManageACL();
    when(dataSourceWizardService.aclAwarePentahoMetadataDomainRepositoryImporter.getAclFor(domainId)).thenReturn(acl);
    final IUnifiedRepository repository = mock(IUnifiedRepository.class);
    final RepositoryFile repositoryFile = mock(RepositoryFile.class);
    when(repository.getFileById(anyString())).thenReturn(repositoryFile);
    doReturn(new HashMap<String, InputStream>()).when(dataSourceWizardService).doGetDSWFilesAsDownload(domainId);
    final RepositoryFileAclDto aclDto = dataSourceWizardService.getDSWAcl(domainId);
    verify(dataSourceWizardService.aclAwarePentahoMetadataDomainRepositoryImporter).getAclFor(eq(domainId));
    assertEquals(acl, new RepositoryFileAclAdapter().unmarshal(aclDto));
}
Also used : InputStream(java.io.InputStream) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) Matchers.anyString(org.mockito.Matchers.anyString) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) RepositoryFileAclAdapter(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAdapter) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 RepositoryFileAclAdapter (org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAdapter)8 RepositoryFileAclDto (org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto)8 InputStream (java.io.InputStream)6 Matchers.anyString (org.mockito.Matchers.anyString)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 FileInputStream (java.io.FileInputStream)4 StringInputStream (org.apache.tools.ant.filters.StringInputStream)4 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)4 RepositoryFileAcl (org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)4 ArrayList (java.util.ArrayList)2 Response (javax.ws.rs.core.Response)2 ArgumentMatcher (org.mockito.ArgumentMatcher)2 IPlatformImportBundle (org.pentaho.platform.api.repository2.unified.IPlatformImportBundle)2 MondrianCatalog (org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog)2 IPlatformImporter (org.pentaho.platform.plugin.services.importer.IPlatformImporter)2 RepositoryFileImportBundle (org.pentaho.platform.plugin.services.importer.RepositoryFileImportBundle)2 PentahoMetadataDomainRepository (org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository)2 FileResource (org.pentaho.platform.web.http.api.resources.FileResource)2 FormDataContentDisposition (com.sun.jersey.core.header.FormDataContentDisposition)1