Search in sources :

Example 31 with RevisionDTO

use of org.apache.nifi.web.api.dto.RevisionDTO in project nifi by apache.

the class ITFunnelAccessControl method createFunnel.

private FunnelEntity createFunnel() throws Exception {
    String url = helper.getBaseUrl() + "/process-groups/root/funnels";
    // create the funnel
    FunnelDTO funnel = new FunnelDTO();
    // create the revision
    final RevisionDTO revision = new RevisionDTO();
    revision.setClientId(READ_WRITE_CLIENT_ID);
    revision.setVersion(0L);
    // create the entity body
    FunnelEntity entity = new FunnelEntity();
    entity.setRevision(revision);
    entity.setComponent(funnel);
    // perform the request
    Response response = helper.getReadWriteUser().testPost(url, entity);
    // ensure the request is successful
    assertEquals(201, response.getStatus());
    // get the entity body
    return response.readEntity(FunnelEntity.class);
}
Also used : FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) Response(javax.ws.rs.core.Response) FunnelDTO(org.apache.nifi.web.api.dto.FunnelDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO)

Example 32 with RevisionDTO

use of org.apache.nifi.web.api.dto.RevisionDTO in project nifi by apache.

the class ITInputPortAccessControl method createInputPort.

private PortEntity createInputPort(final String name) throws Exception {
    String url = helper.getBaseUrl() + "/process-groups/root/input-ports";
    final String updatedName = name + count++;
    // create the input port
    PortDTO inputPort = new PortDTO();
    inputPort.setName(updatedName);
    // create the revision
    final RevisionDTO revision = new RevisionDTO();
    revision.setClientId(READ_WRITE_CLIENT_ID);
    revision.setVersion(0L);
    // create the entity body
    PortEntity entity = new PortEntity();
    entity.setRevision(revision);
    entity.setComponent(inputPort);
    // 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(PortEntity.class);
    // verify creation
    inputPort = entity.getComponent();
    assertEquals(updatedName, inputPort.getName());
    // get the input port
    return entity;
}
Also used : Response(javax.ws.rs.core.Response) PortDTO(org.apache.nifi.web.api.dto.PortDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) PortEntity(org.apache.nifi.web.api.entity.PortEntity)

Example 33 with RevisionDTO

use of org.apache.nifi.web.api.dto.RevisionDTO in project nifi by apache.

the class ITInputPortAccessControl method testWriteUserPutInputPort.

/**
 * Ensures the WRITE user can put an input port.
 *
 * @throws Exception ex
 */
@Test
public void testWriteUserPutInputPort() throws Exception {
    final PortEntity entity = getRandomInputPort(helper.getWriteUser());
    assertFalse(entity.getPermissions().getCanRead());
    assertTrue(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.WRITE_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.getWriteUser(), requestEntity);
    // ensure successful response
    assertEquals(200, response.getStatus());
    // get the response
    final PortEntity responseEntity = response.readEntity(PortEntity.class);
    // verify
    assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
    assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
}
Also used : Response(javax.ws.rs.core.Response) PortDTO(org.apache.nifi.web.api.dto.PortDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) PortEntity(org.apache.nifi.web.api.entity.PortEntity) Test(org.junit.Test)

Example 34 with RevisionDTO

use of org.apache.nifi.web.api.dto.RevisionDTO in project nifi by apache.

the class ITOutputPortAccessControl method testWriteUserPutOutputPort.

/**
 * Ensures the WRITE user can put an output port.
 *
 * @throws Exception ex
 */
@Test
public void testWriteUserPutOutputPort() throws Exception {
    final PortEntity entity = getRandomOutputPort(helper.getWriteUser());
    assertFalse(entity.getPermissions().getCanRead());
    assertTrue(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.WRITE_CLIENT_ID);
    final PortEntity requestEntity = new PortEntity();
    requestEntity.setId(entity.getId());
    requestEntity.setRevision(requestRevision);
    requestEntity.setComponent(requestDto);
    // perform the request
    final Response response = updateOutputPort(helper.getWriteUser(), requestEntity);
    // ensure successful response
    assertEquals(200, response.getStatus());
    // get the response
    final PortEntity responseEntity = response.readEntity(PortEntity.class);
    // verify
    assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
    assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
}
Also used : Response(javax.ws.rs.core.Response) PortDTO(org.apache.nifi.web.api.dto.PortDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) PortEntity(org.apache.nifi.web.api.entity.PortEntity) Test(org.junit.Test)

Example 35 with RevisionDTO

use of org.apache.nifi.web.api.dto.RevisionDTO 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;
}
Also used : Response(javax.ws.rs.core.Response) ProcessGroupEntity(org.apache.nifi.web.api.entity.ProcessGroupEntity) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO)

Aggregations

RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)96 Response (javax.ws.rs.core.Response)45 Authorizable (org.apache.nifi.authorization.resource.Authorizable)30 PermissionsDTO (org.apache.nifi.web.api.dto.PermissionsDTO)29 PortEntity (org.apache.nifi.web.api.entity.PortEntity)27 ProcessGroupEntity (org.apache.nifi.web.api.entity.ProcessGroupEntity)27 ProcessorEntity (org.apache.nifi.web.api.entity.ProcessorEntity)26 HashMap (java.util.HashMap)24 Set (java.util.Set)24 NiFiUser (org.apache.nifi.authorization.user.NiFiUser)24 Map (java.util.Map)23 ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)23 HashSet (java.util.HashSet)22 Collectors (java.util.stream.Collectors)22 ControllerServiceEntity (org.apache.nifi.web.api.entity.ControllerServiceEntity)22 ScheduledState (org.apache.nifi.controller.ScheduledState)21 ControllerServiceState (org.apache.nifi.controller.service.ControllerServiceState)21 VersionControlInformationDTO (org.apache.nifi.web.api.dto.VersionControlInformationDTO)21 Authorizer (org.apache.nifi.authorization.Authorizer)19 RequestAction (org.apache.nifi.authorization.RequestAction)19