use of org.apache.nifi.web.api.entity.ProcessGroupEntity in project nifi by apache.
the class ITProcessGroupAccessControl method testReadWriteUserPutProcessGroupThroughInheritedPolicy.
/**
* Ensures the READ_WRITE user can put a process grup.
*
* @throws Exception ex
*/
@Test
public void testReadWriteUserPutProcessGroupThroughInheritedPolicy() throws Exception {
final ProcessGroupEntity entity = createProcessGroup(NiFiTestAuthorizer.NO_POLICY_COMPONENT_NAME);
final String updatedName = "Updated name" + count++;
// attempt to update the name
final long version = entity.getRevision().getVersion();
entity.getRevision().setClientId(READ_WRITE_CLIENT_ID);
entity.getComponent().setName(updatedName);
// perform the request
final Response response = updateProcessGroup(helper.getReadWriteUser(), entity);
// ensure successful response
assertEquals(200, response.getStatus());
// get the response
final ProcessGroupEntity responseEntity = response.readEntity(ProcessGroupEntity.class);
// verify
assertEquals(AccessControlHelper.READ_WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
assertEquals(updatedName, responseEntity.getComponent().getName());
}
use of org.apache.nifi.web.api.entity.ProcessGroupEntity in project nifi by apache.
the class ITProcessGroupAccessControl method testReadWriteUserGetProcessGroup.
/**
* Ensures the READ WRITE user can get a process group.
*
* @throws Exception ex
*/
@Test
public void testReadWriteUserGetProcessGroup() throws Exception {
final ProcessGroupEntity entity = getRandomProcessGroup(helper.getReadWriteUser());
assertTrue(entity.getPermissions().getCanRead());
assertTrue(entity.getPermissions().getCanWrite());
assertNotNull(entity.getComponent());
}
use of org.apache.nifi.web.api.entity.ProcessGroupEntity in project nifi by apache.
the class ITProcessGroupAccessControl method createProcessGroup.
private ProcessGroupEntity createProcessGroup(final String name) throws Exception {
String url = helper.getBaseUrl() + "/process-groups/root/process-groups";
final String updatedName = name + count++;
// create the process group
ProcessGroupDTO processor = new ProcessGroupDTO();
processor.setName(updatedName);
// create the revision
final RevisionDTO revision = new RevisionDTO();
revision.setClientId(READ_WRITE_CLIENT_ID);
revision.setVersion(0L);
// create the entity body
ProcessGroupEntity entity = new ProcessGroupEntity();
entity.setRevision(revision);
entity.setComponent(processor);
// perform the request
Response response = helper.getReadWriteUser().testPost(url, entity);
// ensure the request is successful
assertEquals(201, response.getStatus());
// get the entity body
entity = response.readEntity(ProcessGroupEntity.class);
// verify creation
processor = entity.getComponent();
assertEquals(updatedName, processor.getName());
// get the processor
return entity;
}
use of org.apache.nifi.web.api.entity.ProcessGroupEntity in project nifi by apache.
the class ITProcessGroupAccessControl method testReadUserPutProcessGroup.
/**
* Ensures the READ user cannot put a processor.
*
* @throws Exception ex
*/
@Test
public void testReadUserPutProcessGroup() throws Exception {
final ProcessGroupEntity entity = getRandomProcessGroup(helper.getReadUser());
assertTrue(entity.getPermissions().getCanRead());
assertFalse(entity.getPermissions().getCanWrite());
assertNotNull(entity.getComponent());
// attempt update the name
entity.getRevision().setClientId(READ_CLIENT_ID);
entity.getComponent().setName("Updated Name" + count++);
// perform the request
final Response response = updateProcessGroup(helper.getReadUser(), entity);
// ensure forbidden response
assertEquals(403, response.getStatus());
}
use of org.apache.nifi.web.api.entity.ProcessGroupEntity in project nifi by apache.
the class ProcessGroupEntityMerger method merge.
@Override
public void merge(ProcessGroupEntity clientEntity, Map<NodeIdentifier, ProcessGroupEntity> entityMap) {
ComponentEntityMerger.super.merge(clientEntity, entityMap);
for (Map.Entry<NodeIdentifier, ProcessGroupEntity> entry : entityMap.entrySet()) {
final ProcessGroupEntity entityStatus = entry.getValue();
if (entityStatus != clientEntity) {
mergeStatus(clientEntity.getStatus(), clientEntity.getPermissions().getCanRead(), entry.getValue().getStatus(), entry.getValue().getPermissions().getCanRead(), entry.getKey());
mergeVersionControlInformation(clientEntity, entityStatus);
}
}
}
Aggregations