Search in sources :

Example 1 with LdapServer

use of opengrok.auth.plugin.ldap.LdapServer in project OpenGrok by OpenGrok.

the class LdapServerTest method testEmptyAddressArray.

@Test
void testEmptyAddressArray() throws UnknownHostException {
    LdapServer server = new LdapServer("ldaps://foo.bar.com");
    LdapServer serverSpy = Mockito.spy(server);
    doReturn(new InetAddress[] {}).when(serverSpy).getAddresses(any());
    assertFalse(serverSpy.isReachable());
}
Also used : LdapServer(opengrok.auth.plugin.ldap.LdapServer) Test(org.junit.jupiter.api.Test)

Example 2 with LdapServer

use of opengrok.auth.plugin.ldap.LdapServer in project OpenGrok by OpenGrok.

the class LdapServerTest method testSetGetUsername.

@Test
void testSetGetUsername() {
    LdapServer server = new LdapServer();
    assertNull(server.getUsername());
    assertNull(server.getPassword());
    final String testUsername = "foo";
    server.setUsername(testUsername);
    assertEquals(testUsername, server.getUsername());
    final String testPassword = "bar";
    server.setPassword(testPassword);
    assertEquals(testPassword, server.getPassword());
}
Also used : LdapServer(opengrok.auth.plugin.ldap.LdapServer) Test(org.junit.jupiter.api.Test)

Example 3 with LdapServer

use of opengrok.auth.plugin.ldap.LdapServer in project OpenGrok by OpenGrok.

the class LdapServerTest method testToString.

@Test
void testToString() {
    LdapServer server = new LdapServer("ldaps://foo.bar.com", "foo", "bar");
    server.setConnectTimeout(2000);
    server.setReadTimeout(1000);
    assertEquals("ldaps://foo.bar.com, connect timeout: 2000, read timeout: 1000, username: foo", server.toString());
}
Also used : LdapServer(opengrok.auth.plugin.ldap.LdapServer) Test(org.junit.jupiter.api.Test)

Example 4 with LdapServer

use of opengrok.auth.plugin.ldap.LdapServer in project OpenGrok by OpenGrok.

the class LdapServerTest method testInvalidURI.

@Test
void testInvalidURI() {
    LdapServer server = new LdapServer("foo:/\\/\\foo.bar");
    assertFalse(server.isReachable());
}
Also used : LdapServer(opengrok.auth.plugin.ldap.LdapServer) Test(org.junit.jupiter.api.Test)

Example 5 with LdapServer

use of opengrok.auth.plugin.ldap.LdapServer in project OpenGrok by OpenGrok.

the class LdapServerTest method testGetPort.

@Test
void testGetPort() throws URISyntaxException {
    LdapServer server = new LdapServer("ldaps://foo.bar");
    assertEquals(636, server.getPort());
    server = new LdapServer("ldap://foo.bar");
    assertEquals(389, server.getPort());
    server = new LdapServer("crumble://foo.bar");
    assertEquals(-1, server.getPort());
}
Also used : LdapServer(opengrok.auth.plugin.ldap.LdapServer) Test(org.junit.jupiter.api.Test)

Aggregations

LdapServer (opengrok.auth.plugin.ldap.LdapServer)8 Test (org.junit.jupiter.api.Test)8 InetAddress (java.net.InetAddress)2 ExceptionListener (java.beans.ExceptionListener)1 XMLDecoder (java.beans.XMLDecoder)1 XMLEncoder (java.beans.XMLEncoder)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ServerSocket (java.net.ServerSocket)1 LinkedList (java.util.LinkedList)1 WebHook (opengrok.auth.plugin.util.WebHook)1 WebHooks (opengrok.auth.plugin.util.WebHooks)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1