use of org.apache.nifi.web.api.entity.ProcessorEntity in project nifi by apache.
the class ITProcessorAccessControl method testReadWriteUserPutProcessorThroughInheritedPolicy.
/**
* Ensures the READ_WRITE user can put a processor.
*
* @throws Exception ex
*/
@Test
public void testReadWriteUserPutProcessorThroughInheritedPolicy() throws Exception {
final ProcessorEntity entity = createProcessor(helper, NiFiTestAuthorizer.NO_POLICY_COMPONENT_NAME);
final String updatedName = "Updated name";
// 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 = updateProcessor(helper.getReadWriteUser(), entity);
// ensure successful response
assertEquals(200, response.getStatus());
// get the response
final ProcessorEntity responseEntity = response.readEntity(ProcessorEntity.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.ProcessorEntity in project nifi by apache.
the class ITProcessorAccessControl method createExecuteCodeRestrictedProcessor.
private void createExecuteCodeRestrictedProcessor(final NiFiTestUser user) throws Exception {
String url = helper.getBaseUrl() + "/process-groups/root/processors";
// create the processor
ProcessorDTO processor = new ProcessorDTO();
processor.setName("execute code restricted");
processor.setType(ExecuteCodeRestrictedProcessor.class.getName());
// create the revision
final RevisionDTO revision = new RevisionDTO();
revision.setClientId(READ_WRITE_CLIENT_ID);
revision.setVersion(0L);
// create the entity body
ProcessorEntity entity = new ProcessorEntity();
entity.setRevision(revision);
entity.setComponent(processor);
// perform the request as a user with read/write but no restricted access
Response response = helper.getReadWriteUser().testPost(url, entity);
// ensure the request is successful
assertEquals(403, response.getStatus());
// perform the request as a user with read/write and restricted access
response = user.testPost(url, entity);
// ensure the request is successful
assertEquals(201, response.getStatus());
final ProcessorEntity responseEntity = response.readEntity(ProcessorEntity.class);
// remove the restricted component
deleteRestrictedComponent(responseEntity, user);
}
use of org.apache.nifi.web.api.entity.ProcessorEntity in project nifi by apache.
the class ITProcessorAccessControl method testReadWriteUserGetProcessor.
/**
* Ensures the READ WRITE user can get a processor.
*
* @throws Exception ex
*/
@Test
public void testReadWriteUserGetProcessor() throws Exception {
final ProcessorEntity entity = getRandomProcessor(helper.getReadWriteUser());
assertTrue(entity.getPermissions().getCanRead());
assertTrue(entity.getPermissions().getCanWrite());
assertNotNull(entity.getComponent());
}
use of org.apache.nifi.web.api.entity.ProcessorEntity in project nifi by apache.
the class ITProcessorAccessControl method testReadUserGetProcessor.
/**
* Ensures the READ user can get a processor.
*
* @throws Exception ex
*/
@Test
public void testReadUserGetProcessor() throws Exception {
final ProcessorEntity entity = getRandomProcessor(helper.getReadUser());
assertTrue(entity.getPermissions().getCanRead());
assertFalse(entity.getPermissions().getCanWrite());
assertNotNull(entity.getComponent());
}
use of org.apache.nifi.web.api.entity.ProcessorEntity in project nifi by apache.
the class ITProcessorAccessControl method testNoneUserClearState.
/**
* Ensures the NONE user cannot clear state.
*
* @throws Exception ex
*/
@Test
public void testNoneUserClearState() throws Exception {
final ProcessorEntity entity = getRandomProcessor(helper.getReadUser());
assertTrue(entity.getPermissions().getCanRead());
assertFalse(entity.getPermissions().getCanWrite());
assertNotNull(entity.getComponent());
final String url = helper.getBaseUrl() + "/processors/" + entity.getId() + "/state/clear-requests";
// perform the request
final Response response = helper.getNoneUser().testPost(url);
// ensure forbidden response
assertEquals(403, response.getStatus());
}
Aggregations