From b892b0038d7dc619ee4fac7058189736d2d73f0d Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 07 Apr 2011 12:41:00 +0000
Subject: [PATCH] Fix OPENDJ-112 - The Changelog virtual attribute appears in al entries, should only apply to rootDSE. The changes introduce a scope in the VirtualAttributeRule. The default is Whole_Subtree. The changelog virtual attributes are now registered with a BASE_OBJECT scope and "" base DNs, meaning the rootDSE only. Also each virtual attribute provider override the hasValue() method for optimization and avoiding computing the values and throwing them away.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java | 67 +++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 1 deletions(-)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
index 1d56757..0a55d0b 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
@@ -243,10 +243,15 @@
// Test all types of ops.
ECLAllOps(); // Do not clean the db for the next test
+ // Test that ECL Operational, virtual attributes are not visible
+ // outside rootDSE. Next test will test access in RootDSE.
+ // This one checks in data.
+ ECLOperationalAttributesFailTest();
+
// First and last should be ok whenever a request has been done or not
// in compat mode.
ECLCompatTestLimits(1,4,true);replicationServer.clearDb();
-
+
// Test with a mix of domains, a mix of DSes
ECLTwoDomains(); replicationServer.clearDb();
@@ -285,6 +290,11 @@
// Test all types of ops.
ECLAllOps(); // Do not clean the db for the next test
+ // Test that ECL Operational, virtual attributes are not visible
+ // outside rootDSE. Next test will test access in RootDSE.
+ // This one checks in data.
+ ECLOperationalAttributesFailTest();
+
// First and last should be ok whenever a request has been done or not
// in compat mode.
ECLCompatTestLimits(1,4, true);replicationServer.clearDb();
@@ -3510,6 +3520,61 @@
}
debugInfo(tn, "Ending test with success");
}
+
+ private void ECLOperationalAttributesFailTest()
+ {
+ String tn = "ECLOperationalAttributesFailTest";
+ // The goal is to verify that the Changelog attributes are not
+ // available in other entries. We u
+ debugInfo(tn, "Starting test \n\n");
+ try
+ {
+ LinkedHashSet<String> attributes = new LinkedHashSet<String>();
+
+ attributes.add("firstchangenumber");
+ attributes.add("lastchangenumber");
+ attributes.add("changelog");
+ attributes.add("lastExternalChangelogCookie");
+
+ debugInfo(tn, " Search: "+ TEST_ROOT_DN_STRING);
+ InternalSearchOperation searchOp =
+ connection.processSearch(
+ ByteString.valueOf(TEST_ROOT_DN_STRING),
+ SearchScope.BASE_OBJECT,
+ DereferencePolicy.NEVER_DEREF_ALIASES,
+ 0, // Size limit
+ 0, // Time limit
+ false, // Types only
+ LDAPFilter.decode("(objectclass=*)"),
+ attributes,
+ NO_CONTROL,
+ null);
+ waitOpResult(searchOp, ResultCode.SUCCESS);
+ assertEquals(searchOp.getSearchEntries().size(), 1);
+
+ LinkedList<SearchResultEntry> entries = searchOp.getSearchEntries();
+ assertEquals(entries.size(), 1);
+ for (SearchResultEntry resultEntry : entries)
+ {
+ debugInfo(tn, "Result entry returned:" + resultEntry.toLDIFString());
+ assertEquals(getAttributeValue(resultEntry, "firstchangenumber"),
+ null);
+ assertEquals(getAttributeValue(resultEntry, "lastchangenumber"),
+ null);
+ assertEquals(getAttributeValue(resultEntry, "changelog"),
+ null);
+ assertEquals(getAttributeValue(resultEntry, "lastExternalChangelogCookie"),
+ null);
+ }
+
+ debugInfo(tn, "Ending test with success");
+ }
+ catch(Exception e)
+ {
+ fail("Ending "+tn+" test with exception:\n"
+ + stackTraceToSingleLineString(e));
+ }
+ }
private void ECLCompatTestLimits(int expectedFirst, int expectedLast,
boolean eclEnabled)
--
Gitblit v1.10.0