use of org.pentaho.platform.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));
}
use of org.pentaho.platform.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)));
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.
the class DataSourcePublishIT method testPublishDSW.
@Test
public void testPublishDSW() throws Exception {
repositoryBase.login(singleTenantAdminUserName, defaultTenant, new String[] { repositoryBase.getTenantAdminRoleName(), AUTHENTICATED_ROLE_NAME });
final String domainID = "test.xmi";
final FileInputStream metadataFile = new FileInputStream("target/test-classes/test.xmi");
final boolean overwrite = true;
final RepositoryFileAclDto acl = generateACL(USERNAME_SUZY, RepositoryFileSid.Type.USER);
MultiPart part = new FormDataMultiPart().field("domainId", domainID).field("overwrite", String.valueOf(overwrite)).field("acl", marshalACL(acl)).bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("metadataFile").fileName("test.xmi").size(metadataFile.available()).build(), metadataFile, MediaType.TEXT_XML_TYPE));
WebResource webResource = resource();
ClientResponse postAnalysis = webResource.path(DATA_ACCESS_API_DATASOURCE_DSW + "import").type(MediaType.MULTIPART_FORM_DATA_TYPE).put(ClientResponse.class, part);
assertEquals(Response.Status.OK.getStatusCode(), postAnalysis.getStatus());
final RepositoryFileAclDto savedACL = webResource.path(DATA_ACCESS_API_DATASOURCE_DSW + domainID + "/acl").get(ClientResponse.class).getEntity(RepositoryFileAclDto.class);
assertNotNull(savedACL);
repositoryBase.login(USERNAME_SUZY, defaultTenant, new String[] { AUTHENTICATED_ROLE_NAME });
checkDSW(webResource, domainID, true);
repositoryBase.login(USERNAME_TIFFANY, defaultTenant, new String[] { AUTHENTICATED_ROLE_NAME });
checkDSW(webResource, domainID, false);
repositoryBase.login(singleTenantAdminUserName, defaultTenant, new String[] { repositoryBase.getTenantAdminRoleName(), AUTHENTICATED_ROLE_NAME });
final ClientResponse changeACL = webResource.path(DATA_ACCESS_API_DATASOURCE_DSW + domainID + "/acl").put(ClientResponse.class, generateACL(AUTHENTICATED_ROLE_NAME, RepositoryFileSid.Type.ROLE));
assertEquals(Response.Status.OK.getStatusCode(), changeACL.getStatus());
repositoryBase.login(USERNAME_TIFFANY, defaultTenant, new String[] { AUTHENTICATED_ROLE_NAME });
checkDSW(webResource, domainID, true);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.
the class DataSourcePublishIT method testPublishAnalysis.
@Test
public void testPublishAnalysis() throws Exception {
repositoryBase.login(singleTenantAdminUserName, defaultTenant, new String[] { repositoryBase.getTenantAdminRoleName(), AUTHENTICATED_ROLE_NAME });
final String catalogID = "FoodMart";
final InputStream uploadAnalysis = new FileInputStream("target/test-classes/schema.xml");
final boolean overwrite = true;
final boolean xmlaEnabledFlag = false;
final String parameters = "DataSource=" + catalogID + ";EnableXmla=" + xmlaEnabledFlag + ";overwrite=" + overwrite;
final RepositoryFileAclDto acl = generateACL(USERNAME_SUZY, RepositoryFileSid.Type.USER);
MultiPart part = new FormDataMultiPart().field("catalogName", catalogID).field("datasourceName", catalogID).field("overwrite", String.valueOf(overwrite)).field("xmlaEnabledFlag", String.valueOf(xmlaEnabledFlag)).field("acl", marshalACL(acl)).field("parameters", parameters).bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("uploadAnalysis").fileName("schema.xml").size(uploadAnalysis.available()).build(), uploadAnalysis, MediaType.TEXT_XML_TYPE));
WebResource webResource = resource();
ClientResponse postAnalysis = webResource.path("data-access/api/mondrian/postAnalysis").type(MediaType.MULTIPART_FORM_DATA_TYPE).post(ClientResponse.class, part);
assertEquals(Response.Status.OK.getStatusCode(), postAnalysis.getStatus());
final RepositoryFileAclDto savedACL = webResource.path("data-access/api/datasource/analysis/" + catalogID + "/acl").get(ClientResponse.class).getEntity(RepositoryFileAclDto.class);
assertNotNull(savedACL);
repositoryBase.login(USERNAME_SUZY, defaultTenant, new String[] { AUTHENTICATED_ROLE_NAME });
checkAnalysis(webResource, catalogID, true);
repositoryBase.login(USERNAME_TIFFANY, defaultTenant, new String[] { AUTHENTICATED_ROLE_NAME });
checkAnalysis(webResource, catalogID, false);
repositoryBase.login(singleTenantAdminUserName, defaultTenant, new String[] { repositoryBase.getTenantAdminRoleName(), AUTHENTICATED_ROLE_NAME });
final ClientResponse changeACL = webResource.path("data-access/api/datasource/analysis/" + catalogID + "/acl").put(ClientResponse.class, generateACL(AUTHENTICATED_ROLE_NAME, RepositoryFileSid.Type.ROLE));
assertEquals(Response.Status.OK.getStatusCode(), changeACL.getStatus());
repositoryBase.login(USERNAME_TIFFANY, defaultTenant, new String[] { AUTHENTICATED_ROLE_NAME });
checkAnalysis(webResource, catalogID, true);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.
the class DataSourcePublishIT method testPublishMetadata.
@Test
public void testPublishMetadata() throws Exception {
repositoryBase.login(singleTenantAdminUserName, defaultTenant, new String[] { repositoryBase.getTenantAdminRoleName(), AUTHENTICATED_ROLE_NAME });
final String domainID = "domainID.xmi";
final FileInputStream metadataFile = new FileInputStream("target/test-classes/Sample_SQL_Query.xmi");
final String overwrite = "true";
final RepositoryFileAclDto acl = generateACL(USERNAME_SUZY, RepositoryFileSid.Type.USER);
MultiPart part = new FormDataMultiPart().field("domainId", domainID).field("overwrite", String.valueOf(overwrite)).field("acl", marshalACL(acl)).bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("metadataFile").fileName("Sample_SQL_Query.xmi").size(metadataFile.available()).build(), metadataFile, MediaType.TEXT_XML_TYPE));
WebResource webResource = resource();
ClientResponse postAnalysis = webResource.path("data-access/api/metadata/import").type(MediaType.MULTIPART_FORM_DATA_TYPE).put(ClientResponse.class, part);
assertEquals(3, postAnalysis.getStatus());
final RepositoryFileAclDto savedACL = webResource.path(DATA_ACCESS_API_DATASOURCE_METADATA + domainID + "/acl").get(ClientResponse.class).getEntity(RepositoryFileAclDto.class);
assertNotNull(savedACL);
repositoryBase.login(USERNAME_SUZY, defaultTenant, new String[] { AUTHENTICATED_ROLE_NAME });
checkMetadata(webResource, domainID, true);
repositoryBase.login(USERNAME_TIFFANY, defaultTenant, new String[] { AUTHENTICATED_ROLE_NAME });
checkMetadata(webResource, domainID, false);
repositoryBase.login(singleTenantAdminUserName, defaultTenant, new String[] { repositoryBase.getTenantAdminRoleName(), AUTHENTICATED_ROLE_NAME });
final ClientResponse changeACL = webResource.path(DATA_ACCESS_API_DATASOURCE_METADATA + domainID + "/acl").put(ClientResponse.class, generateACL(AUTHENTICATED_ROLE_NAME, RepositoryFileSid.Type.ROLE));
assertEquals(Response.Status.OK.getStatusCode(), changeACL.getStatus());
repositoryBase.login(USERNAME_TIFFANY, defaultTenant, new String[] { AUTHENTICATED_ROLE_NAME });
checkMetadata(webResource, domainID, true);
}
Aggregations