Search in sources :

Example 16 with RepositoryFileAclDto

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

the class DataSourceWizardServiceTest method testPublishDswFromTemp.

@Test
public void testPublishDswFromTemp() throws Exception {
    InputStream metadataFile = getClass().getClassLoader().getResourceAsStream(TEST_XMI_FILE_PATH);
    boolean overwrite = true;
    boolean checkConnection = false;
    XmiParser mockXmiParser = mock(XmiParser.class);
    Domain mockDomain = mock(Domain.class);
    InputStream mockInputStream = mock(InputStream.class);
    IPlatformImportBundle mockMetadataBundle = mock(IPlatformImportBundle.class);
    IPlatformImportBundle mockMondrianBundle = mock(IPlatformImportBundle.class);
    IPlatformImporter mockIPlatformImporter = mock(IPlatformImporter.class);
    IPentahoSession mockIPentahoSession = mock(IPentahoSession.class);
    final RepositoryFileAclDto aclDto = new RepositoryFileAclDto();
    aclDto.setOwner("owner");
    aclDto.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
    doReturn(true).when(dataSourceWizardService).hasManageAccessCheck();
    doReturn(true).when(dataSourceWizardService).endsWith(anyString(), anyString());
    doReturn(mockXmiParser).when(dataSourceWizardService).createXmiParser();
    doReturn(mockDomain).when(mockXmiParser).parseXmi(metadataFile);
    doReturn(mockInputStream).when(dataSourceWizardService).toInputStreamWrapper(mockDomain, mockXmiParser);
    doReturn(mockMetadataBundle).when(dataSourceWizardService).createMetadataDswBundle(mockDomain, mockInputStream, overwrite, aclDto);
    doReturn(mockMondrianBundle).when(dataSourceWizardService).createMondrianDswBundle(mockDomain, aclDto);
    doReturn(mockIPlatformImporter).when(dataSourceWizardService).getIPlatformImporter();
    doReturn(mockIPentahoSession).when(dataSourceWizardService).getSession();
    doReturn(metadataFile).when(dataSourceWizardService).createInputStreamFromFile(anyString());
    MetadataTempFilesListDto fileList = new MetadataTempFilesListDto();
    fileList.setXmiFileName(XMI_TEMP_FILE_NAME);
    String list = "{\"xmiFileName\":\"" + XMI_TEMP_FILE_NAME + "\"}";
    String response = dataSourceWizardService.publishDswFromTemp(DOMAIN_ID, fileList, overwrite, checkConnection, aclDto);
    assertEquals(DOMAIN_ID + DataSourceWizardService.METADATA_EXT, response);
}
Also used : IPlatformImportBundle(org.pentaho.platform.api.repository2.unified.IPlatformImportBundle) MetadataTempFilesListDto(org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListDto) InputStream(java.io.InputStream) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) XmiParser(org.pentaho.metadata.util.XmiParser) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) IPlatformImporter(org.pentaho.platform.plugin.services.importer.IPlatformImporter) Matchers.anyString(org.mockito.Matchers.anyString) Domain(org.pentaho.metadata.model.Domain) Test(org.junit.Test)

Example 17 with RepositoryFileAclDto

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

the class DataSourceWizardServiceTest method testGetDSWAclNoAcl.

@Test
public void testGetDSWAclNoAcl() throws Exception {
    String domainId = "domainId";
    doReturn(true).when(dataSourceWizardService).canManageACL();
    when(dataSourceWizardService.aclAwarePentahoMetadataDomainRepositoryImporter.getAclFor(domainId)).thenReturn(null);
    doReturn(new HashMap<String, InputStream>()).when(dataSourceWizardService).doGetDSWFilesAsDownload(domainId);
    final RepositoryFileAclDto aclDto = dataSourceWizardService.getDSWAcl(domainId);
    verify(dataSourceWizardService.aclAwarePentahoMetadataDomainRepositoryImporter).getAclFor(eq(domainId));
    assertNull(aclDto);
}
Also used : InputStream(java.io.InputStream) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 18 with RepositoryFileAclDto

use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto 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 19 with RepositoryFileAclDto

use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto 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 20 with RepositoryFileAclDto

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

the class AnalysisService method setAnalysisDatasourceAcl.

public void setAnalysisDatasourceAcl(String analysisId, RepositoryFileAclDto aclDto) throws PentahoAccessControlException, FileNotFoundException {
    checkAnalysisExists(analysisId);
    final RepositoryFileAcl acl = aclDto == null ? null : repositoryFileAclAdapter.unmarshal(aclDto);
    if (aclAwareMondrianCatalogService != null) {
        aclAwareMondrianCatalogService.setAclFor(analysisId, acl);
    }
    flushDataSources();
}
Also used : RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)

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