use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.
the class DataSourceWizardResourceTest method doGetAnalysisAcl.
@Test
public void doGetAnalysisAcl() throws Exception {
String domainId = "domainId";
doReturn(new RepositoryFileAclDto()).when(dataSourceWizardResource.service).getDSWAcl(domainId);
// no exception thrown
dataSourceWizardResource.doGetDSWAcl(domainId);
//
doThrow(new PentahoAccessControlException()).when(dataSourceWizardResource.service).getDSWAcl(domainId);
try {
dataSourceWizardResource.doGetDSWAcl(domainId);
fail();
} catch (WebApplicationException e) {
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), e.getResponse().getStatus());
}
//
doThrow(new FileNotFoundException()).when(dataSourceWizardResource.service).getDSWAcl(domainId);
try {
dataSourceWizardResource.doGetDSWAcl(domainId);
fail();
} catch (WebApplicationException e) {
assertEquals(Response.Status.CONFLICT.getStatusCode(), e.getResponse().getStatus());
}
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.
the class MetadataResourceTest method doGetMetadataAcl.
@Test
public void doGetMetadataAcl() throws Exception {
String domainId = "domainId";
doReturn(new HashMap<String, InputStream>() {
{
put("test", null);
}
}).when(metadataResource).getDomainFilesData(domainId);
doReturn(new RepositoryFileAclDto()).when(metadataResource.service).getMetadataAcl(domainId);
// no exception thrown
metadataResource.doGetMetadataAcl(domainId);
//
doThrow(new PentahoAccessControlException()).when(metadataResource.service).getMetadataAcl(domainId);
try {
metadataResource.doGetMetadataAcl(domainId);
fail();
} catch (WebApplicationException e) {
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), e.getResponse().getStatus());
}
//
doThrow(new FileNotFoundException()).when(metadataResource.service).getMetadataAcl(domainId);
try {
metadataResource.doGetMetadataAcl(domainId);
fail();
} catch (WebApplicationException e) {
assertEquals(Response.Status.CONFLICT.getStatusCode(), e.getResponse().getStatus());
}
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto 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)));
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto 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));
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto 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));
}
Aggregations