Search in sources :

Example 46 with PositionDTO

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

the class ITFunnelAccessControl method testNoneUserPutFunnel.

/**
 * Ensures the NONE user cannot put a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testNoneUserPutFunnel() throws Exception {
    final FunnelEntity entity = getRandomFunnel(helper.getNoneUser());
    assertFalse(entity.getPermissions().getCanRead());
    assertFalse(entity.getPermissions().getCanWrite());
    assertNull(entity.getComponent());
    // attempt to update the position
    final FunnelDTO requestDto = new FunnelDTO();
    requestDto.setId(entity.getId());
    requestDto.setPosition(new PositionDTO(0.0, 15.0));
    final long version = entity.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.NONE_CLIENT_ID);
    final FunnelEntity requestEntity = new FunnelEntity();
    requestEntity.setId(entity.getId());
    requestEntity.setRevision(requestRevision);
    requestEntity.setComponent(requestDto);
    // perform the request
    final Response response = updateFunnel(helper.getNoneUser(), requestEntity);
    // ensure forbidden response
    assertEquals(403, response.getStatus());
}
Also used : FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) Response(javax.ws.rs.core.Response) FunnelDTO(org.apache.nifi.web.api.dto.FunnelDTO) PositionDTO(org.apache.nifi.web.api.dto.PositionDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) Test(org.junit.Test)

Example 47 with PositionDTO

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

the class ITFunnelAccessControl method testWriteUserPutFunnel.

/**
 * Ensures the WRITE user can put a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testWriteUserPutFunnel() throws Exception {
    final FunnelEntity entity = getRandomFunnel(helper.getWriteUser());
    assertFalse(entity.getPermissions().getCanRead());
    assertTrue(entity.getPermissions().getCanWrite());
    assertNull(entity.getComponent());
    final double y = 15.0;
    // attempt to update the position
    final FunnelDTO requestDto = new FunnelDTO();
    requestDto.setId(entity.getId());
    requestDto.setPosition(new PositionDTO(0.0, y));
    final long version = entity.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.WRITE_CLIENT_ID);
    final FunnelEntity requestEntity = new FunnelEntity();
    requestEntity.setId(entity.getId());
    requestEntity.setRevision(requestRevision);
    requestEntity.setComponent(requestDto);
    // perform the request
    final Response response = updateFunnel(helper.getWriteUser(), requestEntity);
    // ensure successful response
    assertEquals(200, response.getStatus());
    // get the response
    final FunnelEntity responseEntity = response.readEntity(FunnelEntity.class);
    // verify
    assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
    assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
}
Also used : FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) Response(javax.ws.rs.core.Response) FunnelDTO(org.apache.nifi.web.api.dto.FunnelDTO) PositionDTO(org.apache.nifi.web.api.dto.PositionDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) Test(org.junit.Test)

Example 48 with PositionDTO

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

the class ITFunnelAccessControl method testReadWriteUserPutFunnel.

/**
 * Ensures the READ_WRITE user can put a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testReadWriteUserPutFunnel() throws Exception {
    final FunnelEntity entity = getRandomFunnel(helper.getReadWriteUser());
    assertTrue(entity.getPermissions().getCanRead());
    assertTrue(entity.getPermissions().getCanWrite());
    assertNotNull(entity.getComponent());
    final double y = 15.0;
    // attempt to update the position
    final long version = entity.getRevision().getVersion();
    entity.getRevision().setClientId(AccessControlHelper.READ_WRITE_CLIENT_ID);
    entity.getComponent().setPosition(new PositionDTO(0.0, y));
    // perform the request
    final Response response = updateFunnel(helper.getReadWriteUser(), entity);
    // ensure successful response
    assertEquals(200, response.getStatus());
    // get the response
    final FunnelEntity responseEntity = response.readEntity(FunnelEntity.class);
    // verify
    assertEquals(READ_WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
    assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
    assertEquals(y, responseEntity.getComponent().getPosition().getY().doubleValue(), 0);
}
Also used : FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) Response(javax.ws.rs.core.Response) PositionDTO(org.apache.nifi.web.api.dto.PositionDTO) Test(org.junit.Test)

Aggregations

PositionDTO (org.apache.nifi.web.api.dto.PositionDTO)48 ApiOperation (io.swagger.annotations.ApiOperation)16 ApiResponses (io.swagger.annotations.ApiResponses)16 Consumes (javax.ws.rs.Consumes)16 Path (javax.ws.rs.Path)16 Produces (javax.ws.rs.Produces)16 Revision (org.apache.nifi.web.Revision)16 Authorizable (org.apache.nifi.authorization.resource.Authorizable)15 ArrayList (java.util.ArrayList)10 ComponentAuthorizable (org.apache.nifi.authorization.ComponentAuthorizable)10 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)10 ProcessGroupAuthorizable (org.apache.nifi.authorization.ProcessGroupAuthorizable)9 SnippetAuthorizable (org.apache.nifi.authorization.SnippetAuthorizable)9 TemplateContentsAuthorizable (org.apache.nifi.authorization.TemplateContentsAuthorizable)9 POST (javax.ws.rs.POST)8 PUT (javax.ws.rs.PUT)8 PortDTO (org.apache.nifi.web.api.dto.PortDTO)8 ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)8 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)7 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)7