TestLDAPConnectionHandler.java revision ea1068c292e9b341af6d6b563cd8988a96be20a9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
* Portions Copyright 2012-2015 ForgeRock AS.
*/
@SuppressWarnings("javadoc")
public class TestLDAPConnectionHandler extends LdapTestCase {
/**
* Once-only initialization.
*
* @throws Exception
* If an unexpected error occurred.
*/
// This test suite depends on having the schema available, so we'll
// start the server.
}
/**
* Creates two handlers, one which is SSL type. Then change some values via the setter
* methods.
*
* @throws Exception if the handler cannot be instantiated.
*/
@Test
public void testLDAPConnectionHandler() throws Exception {
"dn: cn=LDAP Connection Handler,cn=Connection Handlers,cn=config",
"objectClass: top",
"objectClass: ds-cfg-connection-handler",
"objectClass: ds-cfg-ldap-connection-handler",
"cn: LDAP Connection Handler",
"ds-cfg-java-class: org.opends.server.protocols.ldap.LDAPConnectionHandler",
"ds-cfg-enabled: true",
"ds-cfg-listen-address: 0.0.0.0",
"ds-cfg-accept-backlog: 128",
"ds-cfg-allow-ldap-v2: false",
"ds-cfg-keep-stats: false",
"ds-cfg-use-tcp-keep-alive: true",
"ds-cfg-use-tcp-no-delay: true",
"ds-cfg-allow-tcp-reuse-address: true",
"ds-cfg-send-rejection-notice: true",
"ds-cfg-max-request-size: 5 megabytes",
"ds-cfg-num-request-handlers: 2",
"ds-cfg-allow-start-tls: false",
"ds-cfg-use-ssl: false",
"ds-cfg-ssl-client-auth-policy: optional",
"ds-cfg-ssl-cert-nickname: server-cert",
"ds-cfg-key-manager-provider: cn=JKS,cn=Key Manager Providers,cn=config",
"ds-cfg-trust-manager-provider: cn=JKS,cn=Trust Manager Providers,cn=config");
//Reset some things for the SSL handler
}
/**
* Start a handler an then give its hasAcceptableConfiguration a ConfigEntry with
* numerous invalid cases and single-valued attrs with duplicate values.
*
* @throws Exception if handler cannot be instantiated or the configuration is
* accepted.
*/
public void testBadLDAPConnectionHandlerConfiguration() throws Exception
{
"dn: cn=LDAP Connection Handler,cn=Connection Handlers,cn=config",
"objectClass: top",
"objectClass: ds-cfg-connection-handler",
"objectClass: ds-cfg-ldap-connection-handler",
"cn: LDAP Connection Handler",
"ds-cfg-java-class: org.opends.server.protocols.ldap.LDAPConnectionHandler",
"ds-cfg-enabled: true",
"ds-cfg-listen-address: 0.0.0.0",
"ds-cfg-accept-backlog: 128",
"ds-cfg-allow-ldap-v2: false",
"ds-cfg-keep-stats: false",
"ds-cfg-use-tcp-keep-alive: true",
"ds-cfg-use-tcp-no-delay: true",
"ds-cfg-allow-tcp-reuse-address: true",
"ds-cfg-send-rejection-notice: true",
"ds-cfg-max-request-size: 5 megabytes",
"ds-cfg-num-request-handlers: 2",
"ds-cfg-allow-start-tls: false",
"ds-cfg-use-ssl: false",
"ds-cfg-ssl-client-auth-policy: optional",
"ds-cfg-ssl-cert-nickname: server-cert",
"ds-cfg-key-manager-provider: cn=JKS,cn=Key Manager Providers,cn=config",
"ds-cfg-trust-manager-provider: cn=JKS,cn=Trust Manager Providers,cn=config");
// Add some invalid attrs and some duplicate attrs
}
/**
* Create handler and then change most of its values and see if
* it is acceptable and applied.
* @throws Exception if handler cannot be instantiated.
*/
@Test
public void testGoodLDAPConnectionHandlerConfiguration() throws Exception
{
"dn: cn=LDAP Connection Handler,cn=Connection Handlers,cn=config",
"objectClass: top",
"objectClass: ds-cfg-connection-handler",
"objectClass: ds-cfg-ldap-connection-handler",
"cn: LDAP Connection Handler",
"ds-cfg-java-class: org.opends.server.protocols.ldap.LDAPConnectionHandler",
"ds-cfg-enabled: true",
"ds-cfg-listen-address: 0.0.0.0",
"ds-cfg-accept-backlog: 128",
"ds-cfg-allow-ldap-v2: false",
"ds-cfg-keep-stats: false",
"ds-cfg-use-tcp-keep-alive: true",
"ds-cfg-use-tcp-no-delay: true",
"ds-cfg-allow-tcp-reuse-address: true",
"ds-cfg-send-rejection-notice: true",
"ds-cfg-max-request-size: 5 megabytes",
"ds-cfg-num-request-handlers: 2",
"ds-cfg-allow-start-tls: false",
"ds-cfg-use-ssl: true",
"ds-cfg-ssl-client-auth-policy: optional",
"ds-cfg-ssl-cert-nickname: server-cert",
"ds-cfg-key-manager-provider: cn=JKS,cn=Key Manager Providers,cn=config",
"ds-cfg-trust-manager-provider: cn=JKS,cn=Trust Manager Providers,cn=config");
//Make attrTypes to remove
// AttributeType at1=DirectoryServer.getAttributeType(ATTR_LISTEN_ADDRESS, true);
// Attribute rAttr1=new Attribute(at1);
// GoodHandlerEntry.removeAttribute(rAttr1, null);
//Remove them
//Make new AttrTypes with different values
//uncomment if want to test listen address
// Attribute a3=new Attribute(ATTR_LISTEN_ADDRESS, "localhost");
//Add them
// GoodHandlerEntry.addAttribute(a3, null);
//see if we're ok
//apply it
}
}