ProxiedAuthV1ControlTestCase.java revision 4134
/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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.
*/
/**
* This class contains a number of test cases for the proxied authorization v1
* control.
*/
public class ProxiedAuthV1ControlTestCase
extends ControlsTestCase
{
/**
* Make sure that the server is running.
*
* @throws Exception If an unexpected problem occurs.
*/
@BeforeClass()
public void startServer()
throws Exception
{
}
/**
* Tests the first constructor, which creates an instance of the control using
* a raw, unprocessed DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testConstructor1()
throws Exception
{
// Try a DN of "null", which is not valid and will fail on the attempt to
// create the control
try
{
throw new AssertionError("Expected a failure when creating a proxied " +
"auth V1 control with a null octet string.");
} catch (Throwable t) {}
// Try an empty DN, which is acceptable.
// Try a valid DN, which is acceptable.
// Try an invalid DN, which will be initally accepted but will fail when
// attempting to get the authorization DN.
try
{
throw new AssertionError("Expected a failure when creating a proxied " +
"auth V1 control with an invalid DN string.");
} catch (Exception e) {}
}
/**
* Tests the second constructor, which creates an instance of the control
* using a processed DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testConstructor2()
throws Exception
{
// Try a DN of "null", which is not valid and will fail on the attempt to
// create the control
try
{
throw new AssertionError("Expected a failure when creating a proxied " +
"auth V1 control with a null octet string.");
} catch (Throwable t) {}
// Try an empty DN, which is acceptable.
// Try a valid DN, which is acceptable.
}
/**
* Tests the {@code decodeControl} method when the provided control has a
* criticality of "false".
*
* @throws Exception If an unexpected problem occurs.
*/
public void testDecodeControlNotCritical()
throws Exception
{
LDAPControl c =
}
/**
* Tests the {@code decodeControl} method when the provided control does not
* have a value.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testDecodeControlNoValue()
throws Exception
{
}
/**
* Tests the {@code decodeControl} method when the control value is not a
* sequence.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testDecodeControlValueNotSequence()
throws Exception
{
LDAPControl c =
new LDAPControl(OID_PROXIED_AUTH_V1, true,
}
/**
* Tests the {@code decodeControl} method when the control value is a sequence
* with zero elements.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testDecodeControlValueEmptySequence()
throws Exception
{
LDAPControl c =
}
/**
* Tests the {@code decodeControl} method when the control value is a sequence
* with multiple elements.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testDecodeControlValueMultiElementSequence()
throws Exception
{
LDAPControl c =
}
/**
* Tests the {@code decodeControl} method when the control value is a valid
* octet string that contains an invalid DN.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testDecodeControlValueInvalidDN()
throws Exception
{
LDAPControl c =
}
/**
* Tests the {@code decodeControl} method when the control value is a valid
* octet string that contains an valid empty DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDecodeControlValueEmptyDN()
throws Exception
{
LDAPControl c =
ProxiedAuthV1Control proxyControl = ProxiedAuthV1Control.DECODER.decode(c.isCritical(), c.getValue());
}
/**
* Tests the {@code decodeControl} method when the control value is a valid
* octet string that contains an valid non-empty DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDecodeControlValueNonEmptyDN()
throws Exception
{
LDAPControl c =
ProxiedAuthV1Control proxyControl = ProxiedAuthV1Control.DECODER.decode(c.isCritical(), c.getValue());
}
/**
* Tests the {@code getRawAuthorizationDN} and {@code setRawAuthorizationDN}
* methods.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testGetAndSetRawAuthorizationDN()
throws Exception
{
}
/**
* Tests the {@code getAuthorizationDN} and {@code setRawAuthorizationDN}
* methods.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testGetAndSetAuthorizationDN()
throws Exception
{
}
/**
* Tests the {@code getValidatedAuthorizationDN} method for the null DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testGetValidatedAuthorizationDNNullDN()
throws Exception
{
}
/**
* Tests the {@code getValidatedAuthorizationDN} method for a normal user
* that exists in the directory data and doesn't have any restrictions on its
* use.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testGetValidatedAuthorizationExistingNormalUser()
throws Exception
{
"dn: uid=test,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test",
"givenName: Test",
"sn: User",
"cn: Test User");
}
/**
* Tests the {@code getValidatedAuthorizationDN} method for a user that
* doesn't exist in the directory data.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testGetValidatedAuthorizationNonExistingNormalUser()
throws Exception
{
}
/**
* Tests the {@code getValidatedAuthorizationDN} method for a disabled user.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testGetValidatedAuthorizationDisabledUser()
throws Exception
{
"dn: uid=test,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test",
"givenName: Test",
"sn: User",
"cn: Test User",
"ds-pwp-account-disabled: true");
}
/**
* Tests the {@code toString} methods.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testToString()
throws Exception
{
// The default toString() calls the version that takes a string builder
// argument, so we only need to use the default version to cover both cases.
}
}