LDAPDeleteTestCase.java revision 2efcb9667318c099d8723dd578f198c16b4a22c4
/*
* 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 2006-2008 Sun Microsystems, Inc.
*/
/**
* A set of test cases for the LDAPDelete tool.
*/
public class LDAPDeleteTestCase
extends ToolsTestCase
{
// The path to a file containing an invalid bind password.
private String invalidPasswordFile;
// The path to a file containing a valid bind password.
private String validPasswordFile;
/**
* Ensures that the Directory Server is running and performs other necessary
* setup.
*
* @throws Exception If an unexpected problem occurs.
*/
@BeforeClass()
public void startServerAndCreatePasswordFiles()
throws Exception
{
fileWriter.close();
fileWriter.close();
}
/**
* Retrieves sets of invalid arguments that may not be used to initialize
* the LDAPDelete tool.
*
* @return Sets of invalid arguments that may not be used to initialize the
* LDAPDelete tool.
*/
public Object[][] getInvalidArgumentLists()
{
{
"-D",
};
{
"-w",
};
{
"-j",
};
{
"-i",
};
{
"-K",
};
{
"-P",
};
{
"-W",
};
{
"-h",
};
{
"-p",
};
{
"-V",
};
{
"-f",
};
{
"-J",
};
{
"-o",
};
{
"-I"
};
{
"--invalidLongArgument"
};
{
"-D", "cn=Directory Manager",
"-j", "no.such.file",
"o=test"
};
{
"-D", "cn=Directory Manager",
"-w", "password",
"-j", validPasswordFile,
"o=test"
};
{
"-V", "nonnumeric",
"o=test"
};
{
"-V", "1",
"o=test"
};
{
"-f", "no.such.file",
"o=test"
};
{
"-J", "1.2.3.4:invalidcriticality",
"o=test"
};
{
"-p", "nonnumeric",
"o=test"
};
{
"-p", "999999",
"o=test"
};
{
"-r",
"-K", "key.store.file",
"o=test"
};
{
"-Z",
"-r",
"o=test"
};
{
}
return returnArray;
}
/**
* Tests the LDAPDelete tool with sets of invalid arguments.
*
* @param args The set of arguments to use for the LDAPDelete tool.
* @param invalidReason The reason the provided set of arguments was
* invalid.
*/
{
"Should have been invalid because: " + invalidReason);
}
/**
* Tests a simple LDAPv2 delete.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testSimpleLDAPv2Delete()
throws Exception
{
{
"-h", "127.0.0.1",
"-V", "2",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests a simple LDAPv3 delete.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testSimpleLDAPv3Delete()
throws Exception
{
{
"-h", "127.0.0.1",
"-V", "3",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests the LDAPDelete tool using SSL with blind trust.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteSSLBlindTrust()
throws Exception
{
{
"-h", "127.0.0.1",
"-Z",
"-X",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests the LDAPDelete tool using SSL with a trust store.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteSSLTrustStore()
throws Exception
{
{
"-h", "127.0.0.1",
"-Z",
"-P", trustStorePath,
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests the LDAPDelete tool using StartTLS with blind trust.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteStartTLSBlindTrust()
throws Exception
{
{
"-h", "127.0.0.1",
"-q",
"-X",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests the LDAPDelete tool using StartTLS with a trust store.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteStartTLSTrustStore()
throws Exception
{
{
"-h", "127.0.0.1",
"-q",
"-P", trustStorePath,
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests the LDAPDelete tool using SASL PLAIN authentication.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeletePLAIN()
throws Exception
{
{
"-h", "127.0.0.1",
"-o", "mech=PLAIN",
"-o", "authid=dn:cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests deleting an entry that doesn't exist.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteNonExistent()
throws Exception
{
{
"-h", "127.0.0.1",
"-V", "3",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"cn=Does Not Exist,o=test"
};
}
/**
* Tests deleting with a malformed DN.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteMalformedDN()
throws Exception
{
{
"-h", "127.0.0.1",
"-V", "3",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"malformed"
};
}
/**
* Tests deleting an entry with one or more children but not including the
* subtree delete control.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteParentNoSubtreeDeleteControl()
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");
e.getOperationalAttributes());
{
"-h", "127.0.0.1",
"-V", "3",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests the LDAPDelete tool reading a valid bind password from a file.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteValidPasswordFile()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-j", validPasswordFile,
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests the LDAPDelete tool reading an invalid bind password from a file.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteInvalidPasswordFile()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-j", invalidPasswordFile,
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests the LDAPDelete tool reading the bind password from a nonexistent
* file.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteNonExistentPasswordFile()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-j", "does.not.exist",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests the LDAPDelete tool reading the DNs to delete from a file. Some of
* the deletes will succeed and some will fail.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteDNsFromFile()
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");
e.getOperationalAttributes());
"o=test",
"uid=test.user,o=test",
"malformed",
"o=suffix does not exist",
"uid=entry does not exist,o=test",
"o=test");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-j", validPasswordFile,
"-c",
"-f", path,
"--noPropertiesFile"
};
}
/**
* Tests a subtree delete operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSubtreeDelete()
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");
e.getOperationalAttributes());
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-x",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests a subtree delete operation using an alternate name for the control.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testSubtreeDeleteAltName()
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");
e.getOperationalAttributes());
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-J", "subtreedelete:true",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests a simple delete using the client-side no-op option.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteClientSideNoOp()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-n",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests a simple delete using the server-side no-op control.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteServerSideNoOp()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests a simple delete using the server-side no-op control with an alternate
* name for the no-op control.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testDeleteServerSideNoOpAltName()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-J", "no-op:true",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests the inclusion of multiple arbitrary controls in the request to the
* server.
*
* @throws Exception If an unexpectd problem occurs.
*/
@Test()
public void testMultipleRequestControls()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"o=test"
};
}
/**
* Tests the LDAPDelete tool with the "--help" option.
*/
@Test()
public void testHelp()
{
}
}