2165N/A * The contents of this file are subject to the terms of the 2165N/A * Common Development and Distribution License, Version 1.0 only 2165N/A * (the "License"). You may not use this file except in compliance 2165N/A * See the License for the specific language governing permissions 2165N/A * and limitations under the License. 2165N/A * When distributing Covered Code, include this CDDL HEADER in each 6982N/A * If applicable, add the following below this CDDL HEADER, with the 6982N/A * fields enclosed by brackets "[]" replaced with your own identifying 2165N/A * Portions Copyright [yyyy] [name of copyright owner] 3232N/A * Copyright 2008 Sun Microsystems, Inc. 6907N/A * Portions Copyright 2011-2013 ForgeRock AS 2165N/A * Unit test to test the unique attribute plugin. 2165N/A * Ensures that the Directory Server is running. 2165N/A * @throws Exception If an unexpected problem occurs. 2165N/A //Add entries to two backends to test public naming context. 2165N/A * Clears configuration information before each method run. 2165N/A * @throws Exception If an unexpected problem occurs. 2250N/A //Put an attribute type there that won't impact the rest of the unit 2165N/A * Clears things up after the unit test is completed. 2165N/A * @throws Exception If an unexpected problem occurs. 2165N/A * Retrieves a set of valid configuration entries that may be used to 2165N/A * @return An array of config entries. 2165N/A * @throws Exception If an unexpected problem occurs. 2165N/A "dn: cn=UID Unique Attribute,cn=Plugins,cn=config",
2165N/A "objectClass: ds-cfg-plugin",
2165N/A "objectClass: ds-cfg-unique-attribute-plugin",
2165N/A "cn: UID Unique Attribute",
2624N/A "ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
2165N/A "ds-cfg-plugin-type: preOperationAdd",
2165N/A "ds-cfg-plugin-type: preOperationModify",
2165N/A "ds-cfg-plugin-type: preOperationModifyDN",
2165N/A "dn: cn=mail Unique Attribute,cn=Plugins,cn=config",
2165N/A "objectClass: ds-cfg-plugin",
2165N/A "objectClass: ds-cfg-unique-attribute-plugin",
2165N/A "cn: mail Unique Attribute",
2624N/A "ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
2165N/A "ds-cfg-plugin-type: preOperationAdd",
2165N/A "ds-cfg-plugin-type: preOperationModify",
2165N/A "ds-cfg-plugin-type: preOperationModifyDN",
2165N/A "dn: cn=phone Unique Attribute,cn=Plugins,cn=config",
2165N/A "objectClass: ds-cfg-plugin",
2165N/A "objectClass: ds-cfg-unique-attribute-plugin",
2165N/A "cn: phone Unique Attribute",
2624N/A "ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
2165N/A "ds-cfg-plugin-type: preOperationAdd",
2165N/A "ds-cfg-plugin-type: preOperationModify",
2165N/A "ds-cfg-plugin-type: preOperationModifyDN",
2624N/A "ds-cfg-type: telephoneNumber",
2624N/A "ds-cfg-type: facsimileTelephoneNumber",
2624N/A "ds-cfg-base-dn: dc=example,dc=com",
2250N/A "dn: cn=UID0 Unique Attribute,cn=Plugins,cn=config",
2165N/A "objectClass: ds-cfg-plugin",
2165N/A "objectClass: ds-cfg-unique-attribute-plugin",
2250N/A "cn: UUID0 Unique Attribute",
2624N/A "ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
2165N/A "ds-cfg-plugin-type: preOperationAdd",
2250N/A "dn: cn=UID1 Unique Attribute,cn=Plugins,cn=config",
2165N/A "objectClass: ds-cfg-plugin",
2165N/A "objectClass: ds-cfg-unique-attribute-plugin",
2250N/A "cn: UUID1 Unique Attribute",
2624N/A "ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
2165N/A "ds-cfg-plugin-type: preOperationModify",
2250N/A "dn: cn=UID2 Unique Attribute,cn=Plugins,cn=config",
2165N/A "objectClass: ds-cfg-plugin",
2165N/A "objectClass: ds-cfg-unique-attribute-plugin",
2250N/A "cn: UUID2 Unique Attribute",
2624N/A "ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
2250N/A "ds-cfg-plugin-type: preOperationModifyDN",
2165N/A * Tests the process of initializing the server with valid configurations. 2165N/A * @param e The configuration entry to use for the initialization. 2165N/A * @throws Exception If an unexpected problem occurs. 2165N/A * Retrieves a set of valid configuration entries that may be used to 2165N/A * @return An array of config entries. 2165N/A * @throws Exception If an unexpected problem occurs. 2165N/A "dn: cn=UID Unique Attribute,cn=Plugins,cn=config",
2165N/A "objectClass: ds-cfg-plugin",
2165N/A "objectClass: ds-cfg-unique-attribute-plugin",
2165N/A "cn: UID Unique Attribute",
2624N/A "ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
2165N/A "ds-cfg-plugin-type: preOperationAdd",
2165N/A "ds-cfg-plugin-type: preOperationModify",
2250N/A "ds-cfg-plugin-type: preOperationModifyDN",
2250N/A "dn: cn=UID Unique Attribute,cn=Plugins,cn=config",
2250N/A "objectClass: ds-cfg-plugin",
2250N/A "objectClass: ds-cfg-unique-attribute-plugin",
2250N/A "cn: UID Unique Attribute",
2624N/A "ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
2250N/A "ds-cfg-plugin-type: preOperationAdd",
2250N/A "ds-cfg-plugin-type: preOperationModify",
2165N/A "ds-cfg-plugin-type: ldifImport",
2165N/A "dn: cn=phone Unique Attribute,cn=Plugins,cn=config",
2165N/A "objectClass: ds-cfg-plugin",
2165N/A "cn: phone Unique Attribute",
2624N/A "ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
2165N/A "ds-cfg-plugin-type: preOperationAdd",
2165N/A "ds-cfg-plugin-type: preOperationModify",
2165N/A "ds-cfg-plugin-type: preOperationModifyDN",
2624N/A "ds-cfg-base-dn: dc=example,dc=com",
2165N/A "dn: cn=phone Unique Attribute,cn=Plugins,cn=config",
2165N/A "objectClass: ds-cfg-plugin",
2165N/A "objectClass: ds-cfg-unique-attribute-plugin",
2165N/A "cn: phone Unique Attribute",
2624N/A "ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
2165N/A "ds-cfg-plugin-type: preOperationAdd",
2165N/A "ds-cfg-plugin-type: preOperationModify",
2165N/A "ds-cfg-plugin-type: preOperationModifyDN",
2624N/A "ds-cfg-base-dn: dc=example,dc=com",
2250N/A "dn: cn=phone Unique Attribute,cn=Plugins,cn=config",
2250N/A "objectClass: ds-cfg-plugin",
2250N/A "objectClass: ds-cfg-unique-attribute-plugin",
2250N/A "cn: phone Unique Attribute",
2624N/A "ds-cfg-java-class: org.opends.server.plugins.UniqueAttributePlugin",
2250N/A "ds-cfg-plugin-type: preOperationAdd",
2250N/A "ds-cfg-plugin-type: preOperationModify",
2250N/A "ds-cfg-plugin-type: preOperationModifyDN",
2624N/A "ds-cfg-type: badattribute",
2624N/A "ds-cfg-base-dn: dc=example,dc=com" );
2165N/A * Tests the process of initializing the server with invalid configurations. 2165N/A * @param e The configuration entry to use for the initialization. 2165N/A * @throws Exception If an unexpected problem occurs. 2165N/A * Test modify DN operation with various scenerios. See method comments. 2165N/A * @throws Exception If an unexpected result occurs. 2165N/A //Add an entry under the new superior DN that has a value for uid 2165N/A //Setup uid attribute to be unique. Test using public naming contexts 2165N/A //Rename with new rdn, should fail, there is an entry already with that 2165N/A //Rename with multi-valued RDN, should fail there is an entry already with 2165N/A //Now add a base dn to be unique under, so new superior move can be tested. 2165N/A //Try to move the entry to a new superior. 2165N/A //Should fail, there is an entry under the new superior already with 2165N/A //Test again with different superior, should succeed, new superior DN is 5323N/A * Test various modification scenarios using a configuration with no base 2165N/A * DNs defined. Use default of public naming contexts for base DNs. 2165N/A * @throws Exception If an unexpected result occurs. 2165N/A //Fail because user1t@test already exists under "o=people,o=test". 2165N/A //Fail because user1t@test already exists under "o=people,o=test". 2165N/A //Ok because adding mail value user1t@test to entry that already 2165N/A //contains mail value user1t@test. 2250N/A //Replace employeenumber as the unique attribute. 2165N/A //Test modify increment extension. 2165N/A //Fail because incremented value of employeenumber (2) already exists. 2165N/A * Test setting the plugins up to get DSEE behavior. Basically two or more 2165N/A * base DNs can have the same value, but not within the trees. This uses two 2165N/A * plugins to accomplish this. 2165N/A * @throws Exception If an unexpected result occurs. 2165N/A //Set up one plugin with mail attribute and a suffix. 2165N/A //Set up another plugin with the mail attribute and a different suffix. 2165N/A //Add two entries with same mail attribute value into the different 2165N/A //Now try to add two more entries with the same mail attribute value. 2165N/A * Test various add operation scenerios using defined base DNs. 2165N/A * @throws Exception If an unexpected result occurs. 2165N/A //Fail because mail attribute already exists under "ou=people,o=test". 2250N/A //Replace mobile, pager, telephonenumber to config. 2250N/A "pager",
"telephonenumber");
2165N/A //Fail because "2-333-9012" already exists in "ou=people,o=test" in 2165N/A //telephonenumber attribute. 2165N/A //Fail because "2-111-9012" already exists in "ou=people1,o=test" in 2165N/A //Test two plugin configuration. Add mail attribute to second plugin 2165N/A //instance, leave the first instance as it is. 2165N/A //Add suffix to second plugin. 2165N/A //Add some values that will pass the first plugin. 2165N/A //Add a value that will fail the second plugin. 2165N/A //Should pass frirail through second plugin configuration. 2165N/A * Test attempting to add entries using a configuration with no base 2165N/A * DNs defined. Use default of public naming contexts for base DNs. 2165N/A * @throws Exception If an unexpected result occurs. 2165N/A //Fail because mail value "user77x@test" is a value under the 2165N/A //"dc=example,dc=com" naming context. 2165N/A "pager",
"telephonenumber");
2165N/A //Fail because "2-777-9012" is a telephone value under the 2165N/A //"dc=example,dc=com" naming context. 2165N/A //Fail because "2-777-9012" is a telephone value under the 2165N/A //"dc=example,dc=com" naming context. 2165N/A * Create entries under the specified suffix and add them to the server. 2165N/A * The character argument is used to make the mail attribute unique. 2165N/A * @param suffix The suffix to use in building the entries. 2165N/A * @param c Character used to make the mail attribute unique. 2165N/A * @throws Exception If a problem occurs. 2165N/A "objectClass: organizationalUnit",
2165N/A "aci: (targetattr= \"*\")" +
2165N/A "(version 3.0; acl \"allow all\";" +
2165N/A "allow(all) userdn=\"ldap:///anyone\";)",
2165N/A "objectClass: organizationalUnit",
2165N/A "aci: (targetattr= \"*\")" +
2165N/A "(version 3.0; acl \"allow all\";" +
2165N/A "allow(all) userdn=\"ldap:///anyone\";)",
2165N/A "objectClass: organizationalUnit",
2165N/A "objectClass: organizationalUnit",
2165N/A "objectClass: organizationalPerson",
2165N/A "objectClass: inetOrgPerson",
2165N/A "mail: user1" + c +
"@test",
2165N/A "telephoneNumber: 1-111-9012",
2165N/A "objectClass: organizationalPerson",
2165N/A "objectClass: inetOrgPerson",
2165N/A "mail: user2" + c +
"@test",
2165N/A "telephoneNumber: 1-222-9012",
2165N/A "objectClass: organizationalPerson",
2165N/A "objectClass: inetOrgPerson",
2165N/A "mail: user3" + c +
"@test",
2165N/A "telephoneNumber: 1-333-9012",
2165N/A "objectClass: organizationalPerson",
2165N/A "objectClass: inetOrgPerson",
2165N/A "mail: user4" + c +
"@test",
2165N/A "telephoneNumber: 1-444-9012",
2165N/A "objectClass: organizationalPerson",
2165N/A "objectClass: inetOrgPerson",
2165N/A "mail: user5" + c +
"@test",
2165N/A "telephoneNumber: 1-555-9012",
2165N/A "objectClass: organizationalPerson",
2165N/A "objectClass: inetOrgPerson",
2165N/A "mail: user11" + c +
"@test",
2165N/A "telephoneNumber: 2-111-9012",
2165N/A "objectClass: organizationalPerson",
2165N/A "objectClass: inetOrgPerson",
2165N/A "mail: user22" + c +
"@test",
2165N/A "telephoneNumber: 2-222-9012",
2165N/A "objectClass: organizationalPerson",
2165N/A "objectClass: inetOrgPerson",
2165N/A "mail: user33" + c +
"@test",
2165N/A "telephoneNumber: 2-333-9012" 2165N/A //Add an additional entry if the suffix is "dc=example,dc=com". 2165N/A "objectClass: organizationalPerson",
2165N/A "objectClass: inetOrgPerson",
2165N/A "mail: user77" + c +
"@test",
2165N/A "telephoneNumber: 2-777-9012" 2165N/A * Remove the attributes specified by the attribute type strings from the 2165N/A * entry corresponding to the dn argument. 2165N/A * @param dn The entry to remove the attributes from. 2165N/A * @param attrTypeStrings The attribute type string list to remove from the 2165N/A * @throws Exception If an error occurs. 2165N/A * Try to add an entry to the server checking for the expected return 2165N/A * @param e The entry to add. 2165N/A * @param rc The expected return code. 2165N/A * @throws Exception If an error occurs. 2165N/A * Make a entry with the specified dn. 2165N/A * @param dn The dn of the entry. 2165N/A * @return The created entry. 2165N/A * @throws Exception If the entry can't be created. 2165N/A "objectClass: organizationalPerson",
2165N/A "objectClass: inetOrgPerson",
2165N/A * Remove an attribute from the specified entry. 2165N/A * @param entry The entry to remove the attribute from. 2165N/A * @param attrTypeString The attribute type string to remove. 2165N/A * Add an attribute to an entry with specified values. 2165N/A * @param entry The entry to add the attribute to. 2165N/A * @param attrTypeString The attribute type string name. 2165N/A * @param attrValues The values use in building the attribute. 2165N/A * Add a new modification for attribute type string and values of modification 2165N/A * type to a list of modifications. 2165N/A * @param mods The modification list to add to. 2165N/A * @param attrTypeString The attribute type string name. 2165N/A * @param modificationType The modification type. 2165N/A * @param attrValues The values to build the modification from. 2165N/A * Return the attribute type corresponding to the attribute type string. 2165N/A * @param attrTypeString The attribute type string name. 2165N/A * @return An attribute type object pertaining to the string. 2165N/A * Perform modify operation with list of modifications. Expect return code 2165N/A * @param mods The modification list to use. 2165N/A * @param dn The DN of the entry to modify. 2165N/A * @param rc The expected return code. 2165N/A * Perform modify DN operation. Expect return value of rc. 2165N/A * @param dn The DN to renmame or move. 2165N/A * @param delOld Delete old flag. 2165N/A * @param newSuperior New superior to move to. 2165N/A * @param rc Expected return code from operation.