Search in sources :

Example 6 with NiFiServiceFacade

use of org.apache.nifi.web.NiFiServiceFacade in project nifi by apache.

the class TestSiteToSiteResource method testPeersVersionNegotiationDowngrade.

@Test
public void testPeersVersionNegotiationDowngrade() throws Exception {
    final HttpServletRequest req = mock(HttpServletRequest.class);
    doReturn("999").when(req).getHeader(eq(HttpHeaders.PROTOCOL_VERSION));
    final NiFiServiceFacade serviceFacade = mock(NiFiServiceFacade.class);
    final SiteToSiteResource resource = getSiteToSiteResource(serviceFacade);
    final Response response = resource.getPeers(req);
    PeersEntity resultEntity = (PeersEntity) response.getEntity();
    assertEquals(200, response.getStatus());
    assertEquals(1, resultEntity.getPeers().size());
    assertEquals(new Integer(1), response.getMetadata().getFirst(HttpHeaders.PROTOCOL_VERSION));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Response(javax.ws.rs.core.Response) NiFiServiceFacade(org.apache.nifi.web.NiFiServiceFacade) PeersEntity(org.apache.nifi.web.api.entity.PeersEntity) Test(org.junit.Test)

Example 7 with NiFiServiceFacade

use of org.apache.nifi.web.NiFiServiceFacade in project nifi by apache.

the class TestSiteToSiteResource method testPeers.

@Test
public void testPeers() throws Exception {
    final HttpServletRequest req = createCommonHttpServletRequest();
    final NiFiServiceFacade serviceFacade = mock(NiFiServiceFacade.class);
    final SiteToSiteResource resource = getSiteToSiteResource(serviceFacade);
    final Response response = resource.getPeers(req);
    PeersEntity resultEntity = (PeersEntity) response.getEntity();
    assertEquals(200, response.getStatus());
    assertEquals(1, resultEntity.getPeers().size());
    final PeerDTO peer = resultEntity.getPeers().iterator().next();
    assertEquals(8080, peer.getPort());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Response(javax.ws.rs.core.Response) NiFiServiceFacade(org.apache.nifi.web.NiFiServiceFacade) PeersEntity(org.apache.nifi.web.api.entity.PeersEntity) PeerDTO(org.apache.nifi.web.api.dto.remote.PeerDTO) Test(org.junit.Test)

Example 8 with NiFiServiceFacade

use of org.apache.nifi.web.NiFiServiceFacade in project nifi by apache.

the class TestSiteToSiteResource method testPeersPortForwarding.

@Test
public void testPeersPortForwarding() throws Exception {
    final HttpServletRequest req = createCommonHttpServletRequest();
    final NiFiServiceFacade serviceFacade = mock(NiFiServiceFacade.class);
    final Map<String, String> additionalProperties = new HashMap<>();
    additionalProperties.put(NiFiProperties.WEB_HTTP_PORT_FORWARDING, "80");
    final SiteToSiteResource resource = getSiteToSiteResource(serviceFacade, additionalProperties);
    final Response response = resource.getPeers(req);
    PeersEntity resultEntity = (PeersEntity) response.getEntity();
    assertEquals(200, response.getStatus());
    assertEquals(1, resultEntity.getPeers().size());
    final PeerDTO peer = resultEntity.getPeers().iterator().next();
    assertEquals(80, peer.getPort());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Response(javax.ws.rs.core.Response) NiFiServiceFacade(org.apache.nifi.web.NiFiServiceFacade) PeersEntity(org.apache.nifi.web.api.entity.PeersEntity) HashMap(java.util.HashMap) PeerDTO(org.apache.nifi.web.api.dto.remote.PeerDTO) Test(org.junit.Test)

Aggregations

NiFiServiceFacade (org.apache.nifi.web.NiFiServiceFacade)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 Response (javax.ws.rs.core.Response)7 Test (org.junit.Test)7 PeersEntity (org.apache.nifi.web.api.entity.PeersEntity)4 HashMap (java.util.HashMap)2 ControllerDTO (org.apache.nifi.web.api.dto.ControllerDTO)2 PeerDTO (org.apache.nifi.web.api.dto.remote.PeerDTO)2 ControllerEntity (org.apache.nifi.web.api.entity.ControllerEntity)2 AuthorizableLookup (org.apache.nifi.authorization.AuthorizableLookup)1 ResourceType (org.apache.nifi.authorization.resource.ResourceType)1 ClusterCoordinator (org.apache.nifi.cluster.coordination.ClusterCoordinator)1 NodeWorkload (org.apache.nifi.cluster.coordination.node.NodeWorkload)1 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)1 VersionNegotiator (org.apache.nifi.remote.VersionNegotiator)1 HttpFlowFileServerProtocol (org.apache.nifi.remote.protocol.http.HttpFlowFileServerProtocol)1 TransactionResultEntity (org.apache.nifi.web.api.entity.TransactionResultEntity)1