Search in sources :

Example 36 with ProcessGroupEntity

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

the class ITProcessGroupAccessControl method testWriteUserGetProcessGroup.

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

Example 37 with ProcessGroupEntity

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

the class ITProcessGroupAccessControl method testWriteUserPutProcessGroup.

/**
 * Ensures the WRITE user can put a process group.
 *
 * @throws Exception ex
 */
@Test
public void testWriteUserPutProcessGroup() throws Exception {
    final ProcessGroupEntity entity = getRandomProcessGroup(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 ProcessGroupDTO requestDto = new ProcessGroupDTO();
    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 ProcessGroupEntity requestEntity = new ProcessGroupEntity();
    requestEntity.setId(entity.getId());
    requestEntity.setRevision(requestRevision);
    requestEntity.setComponent(requestDto);
    // perform the request
    final Response response = updateProcessGroup(helper.getWriteUser(), requestEntity);
    // ensure successful response
    assertEquals(200, response.getStatus());
    // get the response
    final ProcessGroupEntity responseEntity = response.readEntity(ProcessGroupEntity.class);
    // verify
    assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
    assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
}
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) Test(org.junit.Test)

Aggregations

ProcessGroupEntity (org.apache.nifi.web.api.entity.ProcessGroupEntity)37 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)17 Response (javax.ws.rs.core.Response)15 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)15 RemoteProcessGroupEntity (org.apache.nifi.web.api.entity.RemoteProcessGroupEntity)15 Authorizable (org.apache.nifi.authorization.resource.Authorizable)14 ApiOperation (io.swagger.annotations.ApiOperation)11 ApiResponses (io.swagger.annotations.ApiResponses)11 Consumes (javax.ws.rs.Consumes)11 Path (javax.ws.rs.Path)11 Produces (javax.ws.rs.Produces)11 ComponentAuthorizable (org.apache.nifi.authorization.ComponentAuthorizable)10 ProcessGroupAuthorizable (org.apache.nifi.authorization.ProcessGroupAuthorizable)10 HashMap (java.util.HashMap)9 Map (java.util.Map)9 Test (org.junit.Test)9 VersionControlInformationDTO (org.apache.nifi.web.api.dto.VersionControlInformationDTO)8 FlowDTO (org.apache.nifi.web.api.dto.flow.FlowDTO)8 Set (java.util.Set)7 Bucket (org.apache.nifi.registry.bucket.Bucket)7