| | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.config.server.AdminTestCaseUtils; |
| | | import org.forgerock.opendj.server.config.meta.AttributeCleanupPluginCfgDefn; |
| | | import org.forgerock.opendj.server.config.server.AttributeCleanupPluginCfg; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.core.AddOperationBasis; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.extensions.InitializationUtils; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.RawAttribute; |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | public void testInitializeWithValidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | | Set<PluginType> pluginTypes = getPluginTypes(e); |
| | | assertFalse(pluginTypes.isEmpty()); |
| | | |
| | | AttributeCleanupPluginCfg config = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | AttributeCleanupPluginCfgDefn.getInstance(),e); |
| | | |
| | | assertNotNull(config); |
| | | |
| | | AttributeCleanupPlugin plugin = new AttributeCleanupPlugin(); |
| | | |
| | | plugin.initializePlugin(pluginTypes, config); |
| | | AttributeCleanupPlugin plugin = initializePlugin(e); |
| | | plugin.finalizePlugin(); |
| | | } |
| | | |
| | |
| | | public void testInitializeWithInvalidConfigs(Entry e) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | Set<PluginType> pluginTypes = getPluginTypes(e); |
| | | assertFalse(pluginTypes.isEmpty()); |
| | | |
| | | AttributeCleanupPluginCfg config = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | AttributeCleanupPluginCfgDefn.getInstance(),e); |
| | | |
| | | assertNotNull(config); |
| | | |
| | | AttributeCleanupPlugin plugin = new AttributeCleanupPlugin(); |
| | | |
| | | plugin.initializePlugin(pluginTypes, config); |
| | | AttributeCleanupPlugin plugin = initializePlugin(e); |
| | | plugin.finalizePlugin(); |
| | | } |
| | | |
| | |
| | | "ds-cfg-rename-inbound-attributes: cn:description", |
| | | "ds-cfg-java-class: org.opends.server.plugins.AttributeCleanupPlugin"); |
| | | |
| | | Set<PluginType> pluginTypes = getPluginTypes(confEntry); |
| | | |
| | | AttributeCleanupPluginCfg config = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | AttributeCleanupPluginCfgDefn.getInstance(),confEntry); |
| | | |
| | | AttributeCleanupPlugin plugin = new AttributeCleanupPlugin(); |
| | | |
| | | plugin.initializePlugin(pluginTypes, config); |
| | | AttributeCleanupPlugin plugin = initializePlugin(confEntry); |
| | | |
| | | /* Construct the ADD operation as follows: |
| | | * |
| | |
| | | "ds-cfg-remove-inbound-attributes: createTimeStamp", |
| | | "ds-cfg-java-class: org.opends.server.plugins.AttributeCleanupPlugin"); |
| | | |
| | | Set<PluginType> pluginTypes = getPluginTypes(confEntry); |
| | | |
| | | AttributeCleanupPluginCfg config = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | AttributeCleanupPluginCfgDefn.getInstance(),confEntry); |
| | | |
| | | AttributeCleanupPlugin plugin = new AttributeCleanupPlugin(); |
| | | |
| | | plugin.initializePlugin(pluginTypes, config); |
| | | AttributeCleanupPlugin plugin = initializePlugin(confEntry); |
| | | |
| | | /* Create the ADD operation as follows: |
| | | * |
| | |
| | | "ds-cfg-remove-inbound-attributes: createTimeStamp", |
| | | "ds-cfg-java-class: org.opends.server.plugins.AttributeCleanupPlugin"); |
| | | |
| | | Set<PluginType> pluginTypes = getPluginTypes(confEntry); |
| | | |
| | | AttributeCleanupPluginCfg config = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | AttributeCleanupPluginCfgDefn.getInstance(),confEntry); |
| | | |
| | | AttributeCleanupPlugin plugin = new AttributeCleanupPlugin(); |
| | | |
| | | plugin.initializePlugin(pluginTypes, config); |
| | | AttributeCleanupPlugin plugin = initializePlugin(confEntry); |
| | | |
| | | /* Create the MODIFY request as follows: |
| | | * |
| | |
| | | assertSame(res.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | plugin.finalizePlugin(); |
| | | } |
| | | |
| | | private AttributeCleanupPlugin initializePlugin(Entry confEntry) throws ConfigException, InitializationException { |
| | | return InitializationUtils.initializePlugin( |
| | | new AttributeCleanupPlugin(), confEntry, AttributeCleanupPluginCfgDefn.getInstance()); |
| | | } |
| | | |
| | | private ModifyOperationBasis modify(String entryDN, RawModification... rawMods) |
| | |
| | | "ds-cfg-remove-inbound-attributes: createTimeStamp", |
| | | "ds-cfg-java-class: org.opends.server.plugins.AttributeCleanupPlugin"); |
| | | |
| | | Set<PluginType> pluginTypes = getPluginTypes(confEntry); |
| | | |
| | | AttributeCleanupPluginCfg config = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | AttributeCleanupPluginCfgDefn.getInstance(),confEntry); |
| | | |
| | | AttributeCleanupPlugin plugin = new AttributeCleanupPlugin(); |
| | | |
| | | plugin.initializePlugin(pluginTypes, config); |
| | | AttributeCleanupPlugin plugin = initializePlugin(confEntry); |
| | | |
| | | /* Create the MODIFY operation as follows: |
| | | * |
| | |
| | | "ds-cfg-rename-inbound-attributes: modifyTimeStamp:description", |
| | | "ds-cfg-java-class: org.opends.server.plugins.AttributeCleanupPlugin"); |
| | | |
| | | Set<PluginType> pluginTypes = getPluginTypes(confEntry); |
| | | |
| | | AttributeCleanupPluginCfg config = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | AttributeCleanupPluginCfgDefn.getInstance(),confEntry); |
| | | |
| | | AttributeCleanupPlugin plugin = new AttributeCleanupPlugin(); |
| | | |
| | | plugin.initializePlugin(pluginTypes, config); |
| | | AttributeCleanupPlugin plugin = initializePlugin(confEntry); |
| | | |
| | | /* Create the MODIFY operation as follows: |
| | | * |