Search in sources :

Example 6 with FunnelEntity

use of org.apache.nifi.web.api.entity.FunnelEntity in project nifi by apache.

the class ITFunnelAccessControl method testWriteUserGetFunnel.

/**
 * Ensures the WRITE user can get a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testWriteUserGetFunnel() throws Exception {
    final FunnelEntity entity = getRandomFunnel(helper.getWriteUser());
    assertFalse(entity.getPermissions().getCanRead());
    assertTrue(entity.getPermissions().getCanWrite());
    assertNull(entity.getComponent());
}
Also used : FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) Test(org.junit.Test)

Example 7 with FunnelEntity

use of org.apache.nifi.web.api.entity.FunnelEntity in project nifi by apache.

the class ITFunnelAccessControl method testReadUserGetFunnel.

/**
 * Ensures the READ user can get a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testReadUserGetFunnel() throws Exception {
    final FunnelEntity entity = getRandomFunnel(helper.getReadUser());
    assertTrue(entity.getPermissions().getCanRead());
    assertFalse(entity.getPermissions().getCanWrite());
    assertNotNull(entity.getComponent());
}
Also used : FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) Test(org.junit.Test)

Example 8 with FunnelEntity

use of org.apache.nifi.web.api.entity.FunnelEntity 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 9 with FunnelEntity

use of org.apache.nifi.web.api.entity.FunnelEntity in project nifi by apache.

the class ITFunnelAccessControl method testReadWriteUserGetFunnel.

/**
 * Ensures the READ WRITE user can get a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testReadWriteUserGetFunnel() throws Exception {
    final FunnelEntity entity = getRandomFunnel(helper.getReadWriteUser());
    assertTrue(entity.getPermissions().getCanRead());
    assertTrue(entity.getPermissions().getCanWrite());
    assertNotNull(entity.getComponent());
}
Also used : FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) Test(org.junit.Test)

Example 10 with FunnelEntity

use of org.apache.nifi.web.api.entity.FunnelEntity in project nifi by apache.

the class ITFunnelAccessControl method getRandomFunnel.

private FunnelEntity getRandomFunnel(final NiFiTestUser user) throws Exception {
    final String url = helper.getBaseUrl() + "/flow/process-groups/root";
    // get the flow
    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<FunnelEntity> funnels = flowDto.getFunnels();
    // ensure the correct number of funnels
    assertFalse(funnels.isEmpty());
    // use the first funnel as the target
    Iterator<FunnelEntity> funnelIter = funnels.iterator();
    assertTrue(funnelIter.hasNext());
    return funnelIter.next();
}
Also used : Response(javax.ws.rs.core.Response) FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity)

Aggregations

FunnelEntity (org.apache.nifi.web.api.entity.FunnelEntity)21 Response (javax.ws.rs.core.Response)8 Test (org.junit.Test)8 ApiOperation (io.swagger.annotations.ApiOperation)5 ApiResponses (io.swagger.annotations.ApiResponses)5 Consumes (javax.ws.rs.Consumes)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 Authorizable (org.apache.nifi.authorization.resource.Authorizable)5 FunnelDTO (org.apache.nifi.web.api.dto.FunnelDTO)5 PositionDTO (org.apache.nifi.web.api.dto.PositionDTO)5 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)4 HashMap (java.util.HashMap)3 ConnectionEntity (org.apache.nifi.web.api.entity.ConnectionEntity)3 LabelEntity (org.apache.nifi.web.api.entity.LabelEntity)3 PortEntity (org.apache.nifi.web.api.entity.PortEntity)3 ProcessGroupEntity (org.apache.nifi.web.api.entity.ProcessGroupEntity)3 ProcessorEntity (org.apache.nifi.web.api.entity.ProcessorEntity)3 Map (java.util.Map)2 GET (javax.ws.rs.GET)2