use of org.apache.nifi.web.api.entity.PortEntity in project nifi by apache.
the class ITInputPortAccessControl method testReadWriteUserGetInputPort.
/**
* Ensures the READ WRITE user can get an input port.
*
* @throws Exception ex
*/
@Test
public void testReadWriteUserGetInputPort() throws Exception {
final PortEntity entity = getRandomInputPort(helper.getReadWriteUser());
assertTrue(entity.getPermissions().getCanRead());
assertTrue(entity.getPermissions().getCanWrite());
assertNotNull(entity.getComponent());
}
use of org.apache.nifi.web.api.entity.PortEntity in project nifi by apache.
the class ITInputPortAccessControl method testReadUserPutInputPort.
/**
* Ensures the READ user cannot put an input port.
*
* @throws Exception ex
*/
@Test
public void testReadUserPutInputPort() throws Exception {
final PortEntity entity = getRandomInputPort(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 = updateInputPort(helper.getReadUser(), entity);
// ensure forbidden response
assertEquals(403, response.getStatus());
}
use of org.apache.nifi.web.api.entity.PortEntity in project nifi by apache.
the class ITInputPortAccessControl method testReadUserGetInputPort.
/**
* Ensures the READ user can get an input port.
*
* @throws Exception ex
*/
@Test
public void testReadUserGetInputPort() throws Exception {
final PortEntity entity = getRandomInputPort(helper.getReadUser());
assertTrue(entity.getPermissions().getCanRead());
assertFalse(entity.getPermissions().getCanWrite());
assertNotNull(entity.getComponent());
}
use of org.apache.nifi.web.api.entity.PortEntity in project nifi by apache.
the class ITInputPortAccessControl method getRandomInputPort.
private PortEntity getRandomInputPort(final NiFiTestUser user) throws Exception {
final String url = helper.getBaseUrl() + "/flow/process-groups/root";
// get the input ports
final Response response = user.testGet(url);
// ensure the response was successful
assertEquals(200, response.getStatus());
// unmarshal
final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
final Set<PortEntity> inputPorts = flowDto.getInputPorts();
// ensure the correct number of input ports
assertFalse(inputPorts.isEmpty());
// use the first input port as the target
Iterator<PortEntity> inputPortIter = inputPorts.iterator();
assertTrue(inputPortIter.hasNext());
return inputPortIter.next();
}
use of org.apache.nifi.web.api.entity.PortEntity in project nifi by apache.
the class ITInputPortAccessControl method testNoneUserPutInputPort.
/**
* Ensures the NONE user cannot put an input port.
*
* @throws Exception ex
*/
@Test
public void testNoneUserPutInputPort() throws Exception {
final PortEntity entity = getRandomInputPort(helper.getNoneUser());
assertFalse(entity.getPermissions().getCanRead());
assertFalse(entity.getPermissions().getCanWrite());
assertNull(entity.getComponent());
final String updatedName = "Updated Name" + count++;
// attempt to update the name
final PortDTO requestDto = new PortDTO();
requestDto.setId(entity.getId());
requestDto.setName(updatedName);
final long version = entity.getRevision().getVersion();
final RevisionDTO requestRevision = new RevisionDTO();
requestRevision.setVersion(version);
requestRevision.setClientId(AccessControlHelper.NONE_CLIENT_ID);
final PortEntity requestEntity = new PortEntity();
requestEntity.setId(entity.getId());
requestEntity.setRevision(requestRevision);
requestEntity.setComponent(requestDto);
// perform the request
final Response response = updateInputPort(helper.getNoneUser(), requestEntity);
// ensure forbidden response
assertEquals(403, response.getStatus());
}
Aggregations