Search in sources :

Example 6 with WebSocketProxyConfiguration

use of org.apache.pulsar.websocket.service.WebSocketProxyConfiguration in project incubator-pulsar by apache.

the class ProxyAuthenticationTest method setup.

@BeforeMethod
public void setup() throws Exception {
    super.internalSetup();
    super.producerBaseSetup();
    port = PortManager.nextFreePort();
    WebSocketProxyConfiguration config = new WebSocketProxyConfiguration();
    config.setWebServicePort(port);
    config.setClusterName("use");
    config.setAuthenticationEnabled(true);
    config.setGlobalZookeeperServers("dummy-zk-servers");
    config.setSuperUserRoles(Sets.newHashSet("pulsar.super_user"));
    // If this is not set, 500 error occurs.
    config.setGlobalZookeeperServers("dummy");
    if (methodName.equals("authenticatedSocketTest") || methodName.equals("statsTest")) {
        config.setAuthenticationProviders(Sets.newHashSet("org.apache.pulsar.websocket.proxy.MockAuthenticationProvider"));
    } else {
        config.setAuthenticationProviders(Sets.newHashSet("org.apache.pulsar.websocket.proxy.MockUnauthenticationProvider"));
    }
    if (methodName.equals("anonymousSocketTest")) {
        config.setAnonymousUserRole("anonymousUser");
    }
    service = spy(new WebSocketService(config));
    doReturn(mockZooKeeperClientFactory).when(service).getZooKeeperClientFactory();
    proxyServer = new ProxyServer(config);
    WebSocketServiceStarter.start(proxyServer, service);
    log.info("Proxy Server Started");
}
Also used : WebSocketProxyConfiguration(org.apache.pulsar.websocket.service.WebSocketProxyConfiguration) WebSocketService(org.apache.pulsar.websocket.WebSocketService) ProxyServer(org.apache.pulsar.websocket.service.ProxyServer) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 7 with WebSocketProxyConfiguration

use of org.apache.pulsar.websocket.service.WebSocketProxyConfiguration in project incubator-pulsar by apache.

the class ProxyAuthorizationTest method setup.

@BeforeClass
@Override
protected void setup() throws Exception {
    conf.setClusterName(configClusterName);
    internalSetup();
    WebSocketProxyConfiguration config = new WebSocketProxyConfiguration();
    Set<String> superUser = Sets.newHashSet("");
    config.setAuthorizationEnabled(true);
    config.setGlobalZookeeperServers("dummy-zk-servers");
    config.setSuperUserRoles(superUser);
    config.setClusterName("c1");
    config.setWebServicePort(TEST_PORT);
    service = spy(new WebSocketService(config));
    doReturn(mockZooKeeperClientFactory).when(service).getZooKeeperClientFactory();
    service.start();
}
Also used : WebSocketProxyConfiguration(org.apache.pulsar.websocket.service.WebSocketProxyConfiguration) WebSocketService(org.apache.pulsar.websocket.WebSocketService) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with WebSocketProxyConfiguration

use of org.apache.pulsar.websocket.service.WebSocketProxyConfiguration in project incubator-pulsar by apache.

the class ProxyPublishConsumeTest method setup.

@BeforeMethod
public void setup() throws Exception {
    conf.setBacklogQuotaCheckIntervalInSeconds(TIME_TO_CHECK_BACKLOG_QUOTA);
    super.internalSetup();
    super.producerBaseSetup();
    port = PortManager.nextFreePort();
    WebSocketProxyConfiguration config = new WebSocketProxyConfiguration();
    config.setWebServicePort(port);
    config.setClusterName("use");
    config.setGlobalZookeeperServers("dummy-zk-servers");
    service = spy(new WebSocketService(config));
    doReturn(mockZooKeeperClientFactory).when(service).getZooKeeperClientFactory();
    proxyServer = new ProxyServer(config);
    WebSocketServiceStarter.start(proxyServer, service);
    log.info("Proxy Server Started");
}
Also used : WebSocketProxyConfiguration(org.apache.pulsar.websocket.service.WebSocketProxyConfiguration) WebSocketService(org.apache.pulsar.websocket.WebSocketService) ProxyServer(org.apache.pulsar.websocket.service.ProxyServer) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 9 with WebSocketProxyConfiguration

use of org.apache.pulsar.websocket.service.WebSocketProxyConfiguration in project incubator-pulsar by apache.

the class ProxyPublishConsumeTlsTest method setup.

@BeforeMethod
public void setup() throws Exception {
    super.setup();
    super.internalSetUpForNamespace();
    port = PortManager.nextFreePort();
    tlsPort = PortManager.nextFreePort();
    WebSocketProxyConfiguration config = new WebSocketProxyConfiguration();
    config.setWebServicePort(port);
    config.setWebServicePortTls(tlsPort);
    config.setTlsEnabled(true);
    config.setTlsKeyFilePath(TLS_SERVER_KEY_FILE_PATH);
    config.setTlsCertificateFilePath(TLS_SERVER_CERT_FILE_PATH);
    config.setTlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setBrokerClientTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setClusterName("use");
    config.setGlobalZookeeperServers("dummy-zk-servers");
    config.setBrokerClientAuthenticationParameters("tlsCertFile:" + TLS_CLIENT_CERT_FILE_PATH + ",tlsKeyFile:" + TLS_CLIENT_KEY_FILE_PATH);
    config.setBrokerClientAuthenticationPlugin(AuthenticationTls.class.getName());
    String lookupUrl = new URI("pulsar://localhost:" + BROKER_PORT_TLS).toString();
    service = spy(new WebSocketService(config));
    doReturn(mockZooKeeperClientFactory).when(service).getZooKeeperClientFactory();
    proxyServer = new ProxyServer(config);
    WebSocketServiceStarter.start(proxyServer, service);
    log.info("Proxy Server Started");
}
Also used : AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) WebSocketProxyConfiguration(org.apache.pulsar.websocket.service.WebSocketProxyConfiguration) WebSocketService(org.apache.pulsar.websocket.WebSocketService) URI(java.net.URI) ProxyServer(org.apache.pulsar.websocket.service.ProxyServer) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

WebSocketService (org.apache.pulsar.websocket.WebSocketService)9 WebSocketProxyConfiguration (org.apache.pulsar.websocket.service.WebSocketProxyConfiguration)9 Field (java.lang.reflect.Field)4 PulsarClientImpl (org.apache.pulsar.client.impl.PulsarClientImpl)4 ProxyServer (org.apache.pulsar.websocket.service.ProxyServer)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 Test (org.testng.annotations.Test)4 URI (java.net.URI)1 AuthenticationTls (org.apache.pulsar.client.impl.auth.AuthenticationTls)1 BeforeClass (org.testng.annotations.BeforeClass)1