Search in sources :

Example 56 with ServiceConfiguration

use of org.apache.pulsar.broker.ServiceConfiguration in project incubator-pulsar by apache.

the class AuthenticationServiceTest method testAuthenticationHttp.

@Test(timeOut = 10000)
public void testAuthenticationHttp() throws Exception {
    ServiceConfiguration config = new ServiceConfiguration();
    Set<String> providersClassNames = Sets.newHashSet(MockAuthenticationProvider.class.getName());
    config.setAuthenticationProviders(providersClassNames);
    config.setAuthenticationEnabled(true);
    AuthenticationService service = new AuthenticationService(config);
    HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getRemoteAddr()).thenReturn("192.168.1.1");
    when(request.getRemotePort()).thenReturn(8080);
    when(request.getHeader(anyString())).thenReturn("data");
    String result = service.authenticateHttpRequest(request);
    assertEquals(result, s_authentication_success);
    service.close();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) Matchers.anyString(org.mockito.Matchers.anyString) AuthenticationService(org.apache.pulsar.broker.authentication.AuthenticationService) Test(org.testng.annotations.Test)

Example 57 with ServiceConfiguration

use of org.apache.pulsar.broker.ServiceConfiguration in project incubator-pulsar by apache.

the class MockedPulsarServiceBaseTest method resetConfig.

protected void resetConfig() {
    this.conf = new ServiceConfiguration();
    this.conf.setBrokerServicePort(BROKER_PORT);
    this.conf.setBrokerServicePortTls(BROKER_PORT_TLS);
    this.conf.setAdvertisedAddress("localhost");
    this.conf.setWebServicePort(BROKER_WEBSERVICE_PORT);
    this.conf.setWebServicePortTls(BROKER_WEBSERVICE_PORT_TLS);
    this.conf.setClusterName(configClusterName);
    // there are TLS tests in here, they need to use localhost because of the certificate
    this.conf.setAdvertisedAddress("localhost");
    this.conf.setManagedLedgerCacheSizeMB(8);
    this.conf.setActiveConsumerFailoverDelayTimeMillis(0);
    this.conf.setDefaultNumberOfNamespaceBundles(1);
    this.conf.setZookeeperServers("localhost:2181");
    this.conf.setGlobalZookeeperServers("localhost:3181");
}
Also used : ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration)

Aggregations

ServiceConfiguration (org.apache.pulsar.broker.ServiceConfiguration)57 Test (org.testng.annotations.Test)28 PulsarService (org.apache.pulsar.broker.PulsarService)23 BeforeMethod (org.testng.annotations.BeforeMethod)14 URL (java.net.URL)11 Field (java.lang.reflect.Field)9 TopicName (org.apache.pulsar.common.naming.TopicName)9 ClusterData (org.apache.pulsar.common.policies.data.ClusterData)9 LoadManager (org.apache.pulsar.broker.loadbalance.LoadManager)8 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)8 Authentication (org.apache.pulsar.client.api.Authentication)8 NamespaceBundle (org.apache.pulsar.common.naming.NamespaceBundle)8 Policies (org.apache.pulsar.common.policies.data.Policies)8 LocalBookkeeperEnsemble (org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble)8 InputStream (java.io.InputStream)7 URI (java.net.URI)7 NamespaceService (org.apache.pulsar.broker.namespace.NamespaceService)7 ManagedLedgerFactory (org.apache.bookkeeper.mledger.ManagedLedgerFactory)6 IOException (java.io.IOException)5 Map (java.util.Map)5