IdleTimeLimitTestCase.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 2008 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS.
*/
/**
* A set of test cases that involve disconnecting clients due to the idle time
* limit.
*/
public class IdleTimeLimitTestCase
extends CoreTestCase
{
/**
* Ensures that the Directory Server is running.
*
* @throws Exception If an unexpected problem occurs.
*/
public void startServer()
throws Exception
{
}
/**
* Tests the server-wide idle time limit for an anonymous connection.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testServerWideAnonymousIdleTimeLimit()
throws Exception
{
"set-global-configuration-prop",
"--set", "idle-time-limit:5 seconds");
try
{
LDAPWriter w = new LDAPWriter(s);
LDAPMessage m = r.readMessage();
assertNull(r.readMessage());
}
finally
{
StaticUtils.close(s);
"set-global-configuration-prop",
"--set", "idle-time-limit:0 seconds");
}
}
/**
* Tests the server-wide idle time limit for an authenticated connection.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testServerWideAuthenticatedIdleTimeLimit()
throws Exception
{
"dn: uid=test.user,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test.user",
"givenName: Test",
"sn: User",
"cn: Test User",
"userPassword: password"
);
"set-global-configuration-prop",
"--set", "idle-time-limit:5 seconds");
try
{
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(m);
m = r.readMessage();
m = r.readMessage();
assertNull(r.readMessage());
}
finally
{
StaticUtils.close(s);
"set-global-configuration-prop",
"--set", "idle-time-limit:0 seconds");
}
}
/**
* Tests a user-specific idle time limit.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testUserSpecificIdleTimeLimit()
throws Exception
{
"dn: uid=test.user,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test.user",
"givenName: Test",
"sn: User",
"cn: Test User",
"userPassword: password",
"ds-rlim-idle-time-limit: 5"
);
try
{
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(m);
m = r.readMessage();
m = r.readMessage();
assertNull(r.readMessage());
}
finally
{
StaticUtils.close(s);
}
}
}