Search in sources :

Example 36 with ServiceConfiguration

use of com.yahoo.pulsar.broker.ServiceConfiguration in project pulsar by yahoo.

the class AuthenticationServiceTest method testAuthenticationHttp.

@Test
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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServiceConfiguration(com.yahoo.pulsar.broker.ServiceConfiguration) Matchers.anyString(org.mockito.Matchers.anyString) AuthenticationService(com.yahoo.pulsar.broker.authentication.AuthenticationService) Test(org.testng.annotations.Test)

Aggregations

ServiceConfiguration (com.yahoo.pulsar.broker.ServiceConfiguration)36 PulsarService (com.yahoo.pulsar.broker.PulsarService)18 Test (org.testng.annotations.Test)15 ClusterData (com.yahoo.pulsar.common.policies.data.ClusterData)8 BeforeMethod (org.testng.annotations.BeforeMethod)8 AuthenticationService (com.yahoo.pulsar.broker.authentication.AuthenticationService)7 DestinationName (com.yahoo.pulsar.common.naming.DestinationName)7 URL (java.net.URL)7 PulsarAdmin (com.yahoo.pulsar.client.admin.PulsarAdmin)6 Authentication (com.yahoo.pulsar.client.api.Authentication)6 NamespaceBundle (com.yahoo.pulsar.common.naming.NamespaceBundle)6 Field (java.lang.reflect.Field)6 ConfigurationCacheService (com.yahoo.pulsar.broker.cache.ConfigurationCacheService)5 NamespaceService (com.yahoo.pulsar.broker.namespace.NamespaceService)5 Policies (com.yahoo.pulsar.common.policies.data.Policies)5 LocalBookkeeperEnsemble (com.yahoo.pulsar.zookeeper.LocalBookkeeperEnsemble)5 InetSocketAddress (java.net.InetSocketAddress)5 URI (java.net.URI)5 ManagedLedgerFactory (org.apache.bookkeeper.mledger.ManagedLedgerFactory)5 AuthorizationManager (com.yahoo.pulsar.broker.authorization.AuthorizationManager)4