UniqueAttributePluginTestCase.java revision 6906
* Clears configuration information before each method run. * @throws Exception If an unexpected problem occurs. //Put an attribute type there that won't impact the rest of the unit * Clears things up after the unit test is completed. * @throws Exception If an unexpected problem occurs. * Retrieves a set of valid configuration entries that may be used to * @return An array of config entries. * @throws Exception If an unexpected problem occurs. "dn: cn=UID Unique Attribute,cn=Plugins,cn=config",
"objectClass: ds-cfg-plugin",
"objectClass: ds-cfg-unique-attribute-plugin",
"cn: UID Unique Attribute",
"ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
"ds-cfg-plugin-type: preOperationAdd",
"ds-cfg-plugin-type: preOperationModify",
"ds-cfg-plugin-type: preOperationModifyDN",
"dn: cn=mail Unique Attribute,cn=Plugins,cn=config",
"objectClass: ds-cfg-plugin",
"objectClass: ds-cfg-unique-attribute-plugin",
"cn: mail Unique Attribute",
"ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
"ds-cfg-plugin-type: preOperationAdd",
"ds-cfg-plugin-type: preOperationModify",
"ds-cfg-plugin-type: preOperationModifyDN",
"dn: cn=phone Unique Attribute,cn=Plugins,cn=config",
"objectClass: ds-cfg-plugin",
"objectClass: ds-cfg-unique-attribute-plugin",
"cn: phone Unique Attribute",
"ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
"ds-cfg-plugin-type: preOperationAdd",
"ds-cfg-plugin-type: preOperationModify",
"ds-cfg-plugin-type: preOperationModifyDN",
"ds-cfg-type: telephoneNumber",
"ds-cfg-type: facsimileTelephoneNumber",
"ds-cfg-base-dn: dc=example,dc=com",
"ds-cfg-base-dn: o=test",
"dn: cn=UID0 Unique Attribute,cn=Plugins,cn=config",
"objectClass: ds-cfg-plugin",
"objectClass: ds-cfg-unique-attribute-plugin",
"cn: UUID0 Unique Attribute",
"ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
"ds-cfg-plugin-type: preOperationAdd",
"dn: cn=UID1 Unique Attribute,cn=Plugins,cn=config",
"objectClass: ds-cfg-plugin",
"objectClass: ds-cfg-unique-attribute-plugin",
"cn: UUID1 Unique Attribute",
"ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
"ds-cfg-plugin-type: preOperationModify",
"dn: cn=UID2 Unique Attribute,cn=Plugins,cn=config",
"objectClass: ds-cfg-plugin",
"objectClass: ds-cfg-unique-attribute-plugin",
"cn: UUID2 Unique Attribute",
"ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
"ds-cfg-plugin-type: preOperationModifyDN",
* Tests the process of initializing the server with valid configurations. * @param e The configuration entry to use for the initialization. * @throws Exception If an unexpected problem occurs. * Retrieves a set of valid configuration entries that may be used to * @return An array of config entries. * @throws Exception If an unexpected problem occurs. "dn: cn=UID Unique Attribute,cn=Plugins,cn=config",
"objectClass: ds-cfg-plugin",
"objectClass: ds-cfg-unique-attribute-plugin",
"cn: UID Unique Attribute",
"ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
"ds-cfg-plugin-type: preOperationAdd",
"ds-cfg-plugin-type: preOperationModify",
"ds-cfg-plugin-type: preOperationModifyDN",
"dn: cn=UID Unique Attribute,cn=Plugins,cn=config",
"objectClass: ds-cfg-plugin",
"objectClass: ds-cfg-unique-attribute-plugin",
"cn: UID Unique Attribute",
"ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
"ds-cfg-plugin-type: preOperationAdd",
"ds-cfg-plugin-type: preOperationModify",
"ds-cfg-plugin-type: ldifImport",
"dn: cn=phone Unique Attribute,cn=Plugins,cn=config",
"objectClass: ds-cfg-plugin",
"cn: phone Unique Attribute",
"ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
"ds-cfg-plugin-type: preOperationAdd",
"ds-cfg-plugin-type: preOperationModify",
"ds-cfg-plugin-type: preOperationModifyDN",
"ds-cfg-type: telephone",
"ds-cfg-base-dn: dc=example,dc=com",
"dn: cn=phone Unique Attribute,cn=Plugins,cn=config",
"objectClass: ds-cfg-plugin",
"objectClass: ds-cfg-unique-attribute-plugin",
"cn: phone Unique Attribute",
"ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
"ds-cfg-plugin-type: preOperationAdd",
"ds-cfg-plugin-type: preOperationModify",
"ds-cfg-plugin-type: preOperationModifyDN",
"ds-cfg-type: telephone",
"ds-cfg-base-dn: dc=example,dc=com",
"dn: cn=phone Unique Attribute,cn=Plugins,cn=config",
"objectClass: ds-cfg-plugin",
"objectClass: ds-cfg-unique-attribute-plugin",
"cn: phone Unique Attribute",
"ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
"ds-cfg-plugin-type: preOperationAdd",
"ds-cfg-plugin-type: preOperationModify",
"ds-cfg-plugin-type: preOperationModifyDN",
"ds-cfg-type: telephone",
"ds-cfg-type: badattribute",
"ds-cfg-base-dn: dc=example,dc=com" );
* Tests the process of initializing the server with invalid configurations. * @param e The configuration entry to use for the initialization. * @throws Exception If an unexpected problem occurs. * Test modify DN operation with various scenerios. See method comments. * @throws Exception If an unexpected result occurs. //Add an entry under the new superior DN that has a value for uid //that will be tested for. //Setup uid attribute to be unique. Test using public naming contexts //Rename with new rdn, should fail, there is an entry already with that //Rename with multi-valued RDN, should fail there is an entry already with //Now add a base dn to be unique under, so new superior move can be tested. //Try to move the entry to a new superior. //Should fail, there is an entry under the new superior already with //Test again with different superior, should succeed, new superior DN is * Test various modification scenarios using a configuration with no base * DNs defined. Use default of public naming contexts for base DNs. * @throws Exception If an unexpected result occurs. //Fail because user1t@test already exists under "o=people,o=test". //Fail because user1t@test already exists under "o=people,o=test". //Ok because adding mail value user1t@test to entry that already //contains mail value user1t@test. //Replace employeenumber as the unique attribute. //Test modify increment extension. //Fail because incremented value of employeenumber (2) already exists. * Test setting the plugins up to get DSEE behavior. Basically two or more * base DNs can have the same value, but not within the trees. This uses two * plugins to accomplish this. * @throws Exception If an unexpected result occurs. //Set up one plugin with mail attribute and a suffix. //Set up another plugin with the mail attribute and a different suffix. //Add two entries with same mail attribute value into the different //Now try to add two more entries with the same mail attribute value. * Test various add operation scenerios using defined base DNs. * See comments in method. * @throws Exception If an unexpected result occurs. //Fail because mail attribute already exists under "ou=people,o=test". //Replace mobile, pager, telephonenumber to config. "pager",
"telephonenumber");
addAttribute(e,
"mobile",
"1-999-1234",
"1-999-5678",
"1-444-9012");
//Fail because "2-333-9012" already exists in "ou=people,o=test" in //telephonenumber attribute. addAttribute(e,
"pager",
"2-111-1234",
"1-999-5678",
"1-999-9012");
//Fail because "2-111-9012" already exists in "ou=people1,o=test" in //Test two plugin configuration. Add mail attribute to second plugin //instance, leave the first instance as it is. //Add suffix to second plugin. //Add some values that will pass the first plugin. addAttribute(e,
"telephonenumber",
"2-999-1234",
"1-999-5678",
"1-999-9012");
//Add a value that will fail the second plugin. //Should pass frirail through second plugin configuration. * Test attempting to add entries using a configuration with no base * DNs defined. Use default of public naming contexts for base DNs. * @throws Exception If an unexpected result occurs. //Fail because mail value "user77x@test" is a value under the //"dc=example,dc=com" naming context. "pager",
"telephonenumber");
addAttribute(e,
"mobile",
"1-999-1234",
"1-999-5678",
"2-777-9012");
//Fail because "2-777-9012" is a telephone value under the //"dc=example,dc=com" naming context. addAttribute(e,
"pager",
"2-777-1234",
"1-999-5678",
"1-999-9012");
//Fail because "2-777-9012" is a telephone value under the //"dc=example,dc=com" naming context. * Create entries under the specified suffix and add them to the server. * The character argument is used to make the mail attribute unique. * @param suffix The suffix to use in building the entries. * @param c Character used to make the mail attribute unique. * @throws Exception If a problem occurs. "objectClass: organizationalUnit",
"aci: (targetattr= \"*\")" +
"(version 3.0; acl \"allow all\";" +
"allow(all) userdn=\"ldap:///anyone\";)",
"objectClass: organizationalUnit",
"aci: (targetattr= \"*\")" +
"(version 3.0; acl \"allow all\";" +
"allow(all) userdn=\"ldap:///anyone\";)",
"dn: ou=New People1," +
suffix,
"objectClass: organizationalUnit",
"dn: ou=New People," +
suffix,
"objectClass: organizationalUnit",
"dn: uid=1user.1,ou=People," +
suffix,
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"userPassword: password",
"mail: user1" + c +
"@test",
"telephoneNumber: 1-111-9012",
"dn: uid=2user.2,ou=People," +
suffix,
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"mail: user2" + c +
"@test",
"userPassword: password",
"telephoneNumber: 1-222-9012",
"dn: uid=3user.3,ou=People," +
suffix,
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"mail: user3" + c +
"@test",
"userPassword: password",
"telephoneNumber: 1-333-9012",
"dn: uid=4user.4,ou=People," +
suffix,
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"mail: user4" + c +
"@test",
"userPassword: password",
"telephoneNumber: 1-444-9012",
"dn: uid=5user.5,ou=People," +
suffix,
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"mail: user5" + c +
"@test",
"userPassword: password",
"telephoneNumber: 1-555-9012",
"dn: uid=1user.1,ou=People1," +
suffix,
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"userPassword: password",
"mail: user11" + c +
"@test",
"telephoneNumber: 2-111-9012",
"dn: uid=2user.22,ou=People1," +
suffix,
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"mail: user22" + c +
"@test",
"userPassword: password",
"telephoneNumber: 2-222-9012",
"dn: uid=3user.33,ou=People1," +
suffix,
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"mail: user33" + c +
"@test",
"userPassword: password",
"telephoneNumber: 2-333-9012" //Add an additional entry if the suffix is "dc=example,dc=com". "dn: uid=2user.77,ou=People," +
suffix,
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"mail: user77" + c +
"@test",
"userPassword: password",
"telephoneNumber: 2-777-9012" * Remove the attributes specified by the attribute type strings from the * entry corresponding to the dn argument. * @param dn The entry to remove the attributes from. * @param attrTypeStrings The attribute type string list to remove from the * @throws Exception If an error occurs. * Try to add an entry to the server checking for the expected return * @param e The entry to add. * @param rc The expected return code. * @throws Exception If an error occurs. * Make a entry with the specified dn. * @param dn The dn of the entry. * @return The created entry. * @throws Exception If the entry can't be created. "objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
* Remove an attribute from the specified entry. * @param entry The entry to remove the attribute from. * @param attrTypeString The attribute type string to remove. * Add an attribute to an entry with specified values. * @param entry The entry to add the attribute to. * @param attrTypeString The attribute type string name. * @param attrValues The values use in building the attribute. * Add a new modification for attribute type string and values of modification * type to a list of modifications. * @param mods The modification list to add to. * @param attrTypeString The attribute type string name. * @param modificationType The modification type. * @param attrValues The values to build the modification from. * Return the attribute type corresponding to the attribute type string. * @param attrTypeString The attribute type string name. * @return An attribute type object pertaining to the string. * Perform modify operation with list of modifications. Expect return code * @param mods The modification list to use. * @param dn The DN of the entry to modify. * @param rc The expected return code. * Perform modify DN operation. Expect return value of rc. * @param dn The DN to renmame or move. * @param delOld Delete old flag. * @param newSuperior New superior to move to. * @param rc Expected return code from operation.