Search in sources :

Example 6 with AuthenticationService

use of com.yahoo.pulsar.broker.authentication.AuthenticationService in project pulsar by yahoo.

the class AuthenticationServiceTest method testAuthentication.

@Test
public void testAuthentication() 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);
    String result = service.authenticate(null, "auth");
    assertEquals(result, s_authentication_success);
}
Also used : ServiceConfiguration(com.yahoo.pulsar.broker.ServiceConfiguration) Matchers.anyString(org.mockito.Matchers.anyString) AuthenticationService(com.yahoo.pulsar.broker.authentication.AuthenticationService) Test(org.testng.annotations.Test)

Example 7 with AuthenticationService

use of com.yahoo.pulsar.broker.authentication.AuthenticationService 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)

Example 8 with AuthenticationService

use of com.yahoo.pulsar.broker.authentication.AuthenticationService 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)

Example 9 with AuthenticationService

use of com.yahoo.pulsar.broker.authentication.AuthenticationService in project pulsar by yahoo.

the class AuthenticationServiceTest method testAuthentication.

@Test
public void testAuthentication() 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);
    String result = service.authenticate(null, "auth");
    assertEquals(result, s_authentication_success);
}
Also used : 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

AuthenticationService (com.yahoo.pulsar.broker.authentication.AuthenticationService)9 Test (org.testng.annotations.Test)7 ServiceConfiguration (com.yahoo.pulsar.broker.ServiceConfiguration)5 Matchers.anyString (org.mockito.Matchers.anyString)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 AuthenticationDataCommand (com.yahoo.pulsar.broker.authentication.AuthenticationDataCommand)2 AuthorizationManager (com.yahoo.pulsar.broker.authorization.AuthorizationManager)2 ConfigurationCacheService (com.yahoo.pulsar.broker.cache.ConfigurationCacheService)2 ByteBuf (io.netty.buffer.ByteBuf)2 PulsarServerException (com.yahoo.pulsar.broker.PulsarServerException)1 BrokerService (com.yahoo.pulsar.broker.service.BrokerService)1 CommandConnected (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandConnected)1 CommandError (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandError)1 GlobalZooKeeperCache (com.yahoo.pulsar.zookeeper.GlobalZooKeeperCache)1 IOException (java.io.IOException)1 AuthenticationException (javax.naming.AuthenticationException)1 ServletResponse (javax.servlet.ServletResponse)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1