Search in sources :

Example 21 with ConnectionEntity

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

the class ITConnectionAccessControl method testNoneUserGetConnection.

/**
 * Ensures the NONE user can get a connection.
 *
 * @throws Exception ex
 */
@Test
public void testNoneUserGetConnection() throws Exception {
    final ConnectionEntity entity = getRandomConnection(helper.getNoneUser());
    assertFalse(entity.getPermissions().getCanRead());
    assertFalse(entity.getPermissions().getCanWrite());
    assertNull(entity.getComponent());
}
Also used : ConnectionEntity(org.apache.nifi.web.api.entity.ConnectionEntity) Test(org.junit.Test)

Example 22 with ConnectionEntity

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

the class ITConnectionAccessControl method testReadUserGetConnection.

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

Example 23 with ConnectionEntity

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

the class ITConnectionAccessControl method testReadWriteUserGetConnection.

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

Example 24 with ConnectionEntity

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

the class ITConnectionAccessControl method getRandomConnection.

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

Example 25 with ConnectionEntity

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

the class ITConnectionAccessControl method verifyDelete.

private void verifyDelete(final NiFiTestUser user, final String clientId, final int responseCode) throws Exception {
    final ConnectionEntity entity = createConnection("Copy");
    // create the entity body
    final Map<String, String> queryParams = new HashMap<>();
    queryParams.put("version", String.valueOf(entity.getRevision().getVersion()));
    queryParams.put("clientId", clientId);
    // perform the request
    Response response = user.testDelete(entity.getUri(), queryParams);
    // ensure the request is failed with a forbidden status code
    assertEquals(responseCode, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) ConnectionEntity(org.apache.nifi.web.api.entity.ConnectionEntity)

Aggregations

ConnectionEntity (org.apache.nifi.web.api.entity.ConnectionEntity)25 Response (javax.ws.rs.core.Response)9 Test (org.junit.Test)9 ApiOperation (io.swagger.annotations.ApiOperation)7 ApiResponses (io.swagger.annotations.ApiResponses)7 Consumes (javax.ws.rs.Consumes)7 Path (javax.ws.rs.Path)7 Produces (javax.ws.rs.Produces)7 Authorizable (org.apache.nifi.authorization.resource.Authorizable)7 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)7 ConnectionAuthorizable (org.apache.nifi.authorization.ConnectionAuthorizable)5 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)5 ProcessorEntity (org.apache.nifi.web.api.entity.ProcessorEntity)4 URI (java.net.URI)3 HashMap (java.util.HashMap)3 POST (javax.ws.rs.POST)3 Revision (org.apache.nifi.web.Revision)3 FunnelEntity (org.apache.nifi.web.api.entity.FunnelEntity)3 LabelEntity (org.apache.nifi.web.api.entity.LabelEntity)3 PortEntity (org.apache.nifi.web.api.entity.PortEntity)3