You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/02/20 04:58:21 UTC
svn commit: r379013 [26/45] - in /directory/trunks/apacheds: ./ core-plugin/
core-plugin/src/main/java/org/apache/directory/server/core/tools/schema/
core-plugin/src/test/java/org/apache/directory/server/core/tools/schema/
core-shared/ core-shared/src/...
Modified: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificUserClassFilterTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificUserClassFilterTest.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificUserClassFilterTest.java (original)
+++ directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificUserClassFilterTest.java Sun Feb 19 19:57:02 2006
@@ -1,194 +1,181 @@
-/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.directory.server.core.authz.support;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.directory.server.core.authz.support.MostSpecificUserClassFilter;
-import org.apache.directory.server.core.authz.support.OperationScope;
-import org.apache.directory.shared.ldap.aci.ACITuple;
-import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
-import org.apache.directory.shared.ldap.aci.UserClass;
-
-/**
- * Tests {@link MostSpecificUserClassFilter}.
- *
- * @author The Apache Directory Project
- * @version $Rev$, $Date$
- */
-public class MostSpecificUserClassFilterTest extends TestCase
-{
- private static final Collection EMPTY_COLLECTION =
- Collections.unmodifiableCollection( new ArrayList() );
- private static final Set EMPTY_SET =
- Collections.unmodifiableSet( new HashSet() );
-
- private static final List TUPLES_A = new ArrayList();
- private static final List TUPLES_B = new ArrayList();
- private static final List TUPLES_C = new ArrayList();
- private static final List TUPLES_D = new ArrayList();
- private static final List TUPLES_E = new ArrayList();
-
- static
- {
- Collection name = new ArrayList();
- Collection thisEntry = new ArrayList();
- Collection userGroup = new ArrayList();
- Collection subtree = new ArrayList();
- Collection allUsers = new ArrayList();
-
- name.add( new UserClass.Name( EMPTY_SET ) );
- thisEntry.add( UserClass.THIS_ENTRY );
- userGroup.add( new UserClass.UserGroup( EMPTY_SET ) );
- subtree.add( new UserClass.Subtree( EMPTY_COLLECTION ) );
- allUsers.add( UserClass.ALL_USERS );
-
- ACITuple nameTuple = new ACITuple(
- name, AuthenticationLevel.NONE, EMPTY_COLLECTION,
- EMPTY_SET, true, 0 );
- ACITuple thisEntryTuple = new ACITuple(
- thisEntry, AuthenticationLevel.NONE, EMPTY_COLLECTION,
- EMPTY_SET, true, 0 );
- ACITuple userGroupTuple = new ACITuple(
- userGroup, AuthenticationLevel.NONE, EMPTY_COLLECTION,
- EMPTY_SET, true, 0 );
- ACITuple subtreeTuple = new ACITuple(
- subtree, AuthenticationLevel.NONE, EMPTY_COLLECTION,
- EMPTY_SET, true, 0 );
- ACITuple allUsersTuple = new ACITuple(
- allUsers, AuthenticationLevel.NONE, EMPTY_COLLECTION,
- EMPTY_SET, true, 0 );
-
- TUPLES_A.add( nameTuple );
- TUPLES_A.add( thisEntryTuple );
- TUPLES_A.add( userGroupTuple );
- TUPLES_A.add( subtreeTuple );
- TUPLES_A.add( allUsersTuple );
-
- TUPLES_B.add( thisEntryTuple );
- TUPLES_B.add( userGroupTuple );
- TUPLES_B.add( subtreeTuple );
- TUPLES_B.add( allUsersTuple );
-
- TUPLES_C.add( userGroupTuple );
- TUPLES_C.add( subtreeTuple );
- TUPLES_C.add( allUsersTuple );
-
- TUPLES_D.add( subtreeTuple );
- TUPLES_D.add( allUsersTuple );
-
- TUPLES_E.add( allUsersTuple );
- TUPLES_E.add( allUsersTuple );
- }
-
- public void testZeroOrOneTuple() throws Exception
- {
- MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
-
- Assert.assertEquals(
- 0, filter.filter(
- EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE,
- null, null, null, null, null, null, null, null, null, null ).size() );
-
- Collection tuples = new ArrayList();
- tuples.add( new ACITuple(
- EMPTY_COLLECTION, AuthenticationLevel.NONE, EMPTY_COLLECTION,
- EMPTY_SET, false, 0 ) );
-
- Assert.assertEquals(
- 1, filter.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE,
- null, null, null, null, null, null, null, null, null, null ).size() );
- }
-
- public void testNameAndThisEntry() throws Exception
- {
- MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
-
- List tuples = new ArrayList( TUPLES_A );
- tuples = ( List ) filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, null, null, null, null, null, null );
-
- Assert.assertEquals( 2, tuples.size() );
- Assert.assertSame( TUPLES_A.get( 0 ), tuples.get( 0 ) );
- Assert.assertSame( TUPLES_A.get( 1 ), tuples.get( 1 ) );
- }
-
- public void testThisEntry() throws Exception
- {
- MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
-
- List tuples = new ArrayList( TUPLES_B );
- tuples = ( List ) filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, null, null, null, null, null, null );
-
- Assert.assertEquals( 1, tuples.size() );
- Assert.assertSame( TUPLES_B.get( 0 ), tuples.get( 0 ) );
- }
-
- public void testUserGroup() throws Exception
- {
- MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
-
- List tuples = new ArrayList( TUPLES_C );
- tuples = ( List ) filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, null, null, null, null, null, null );
-
- Assert.assertEquals( 1, tuples.size() );
- Assert.assertSame( TUPLES_C.get( 0 ), tuples.get( 0 ) );
- }
-
- public void testSubtree() throws Exception
- {
- MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
-
- List tuples = new ArrayList( TUPLES_D );
- tuples = ( List ) filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, null, null, null, null, null, null );
-
- Assert.assertEquals( 1, tuples.size() );
- Assert.assertSame( TUPLES_D.get( 0 ), tuples.get( 0 ) );
- }
-
- public void testOthers() throws Exception
- {
- MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
-
- List tuples = new ArrayList( TUPLES_E );
- tuples = ( List ) filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, null, null, null, null, null, null );
-
- Assert.assertEquals( 2, tuples.size() );
- Assert.assertSame( TUPLES_E.get( 0 ), tuples.get( 0 ) );
- Assert.assertSame( TUPLES_E.get( 1 ), tuples.get( 1 ) );
- }
-}
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.directory.server.core.authz.support;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.directory.server.core.authz.support.MostSpecificUserClassFilter;
+import org.apache.directory.server.core.authz.support.OperationScope;
+import org.apache.directory.shared.ldap.aci.ACITuple;
+import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
+import org.apache.directory.shared.ldap.aci.UserClass;
+
+
+/**
+ * Tests {@link MostSpecificUserClassFilter}.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
+public class MostSpecificUserClassFilterTest extends TestCase
+{
+ private static final Collection EMPTY_COLLECTION = Collections.unmodifiableCollection( new ArrayList() );
+ private static final Set EMPTY_SET = Collections.unmodifiableSet( new HashSet() );
+
+ private static final List TUPLES_A = new ArrayList();
+ private static final List TUPLES_B = new ArrayList();
+ private static final List TUPLES_C = new ArrayList();
+ private static final List TUPLES_D = new ArrayList();
+ private static final List TUPLES_E = new ArrayList();
+
+ static
+ {
+ Collection name = new ArrayList();
+ Collection thisEntry = new ArrayList();
+ Collection userGroup = new ArrayList();
+ Collection subtree = new ArrayList();
+ Collection allUsers = new ArrayList();
+
+ name.add( new UserClass.Name( EMPTY_SET ) );
+ thisEntry.add( UserClass.THIS_ENTRY );
+ userGroup.add( new UserClass.UserGroup( EMPTY_SET ) );
+ subtree.add( new UserClass.Subtree( EMPTY_COLLECTION ) );
+ allUsers.add( UserClass.ALL_USERS );
+
+ ACITuple nameTuple = new ACITuple( name, AuthenticationLevel.NONE, EMPTY_COLLECTION, EMPTY_SET, true, 0 );
+ ACITuple thisEntryTuple = new ACITuple( thisEntry, AuthenticationLevel.NONE, EMPTY_COLLECTION, EMPTY_SET, true,
+ 0 );
+ ACITuple userGroupTuple = new ACITuple( userGroup, AuthenticationLevel.NONE, EMPTY_COLLECTION, EMPTY_SET, true,
+ 0 );
+ ACITuple subtreeTuple = new ACITuple( subtree, AuthenticationLevel.NONE, EMPTY_COLLECTION, EMPTY_SET, true, 0 );
+ ACITuple allUsersTuple = new ACITuple( allUsers, AuthenticationLevel.NONE, EMPTY_COLLECTION, EMPTY_SET, true, 0 );
+
+ TUPLES_A.add( nameTuple );
+ TUPLES_A.add( thisEntryTuple );
+ TUPLES_A.add( userGroupTuple );
+ TUPLES_A.add( subtreeTuple );
+ TUPLES_A.add( allUsersTuple );
+
+ TUPLES_B.add( thisEntryTuple );
+ TUPLES_B.add( userGroupTuple );
+ TUPLES_B.add( subtreeTuple );
+ TUPLES_B.add( allUsersTuple );
+
+ TUPLES_C.add( userGroupTuple );
+ TUPLES_C.add( subtreeTuple );
+ TUPLES_C.add( allUsersTuple );
+
+ TUPLES_D.add( subtreeTuple );
+ TUPLES_D.add( allUsersTuple );
+
+ TUPLES_E.add( allUsersTuple );
+ TUPLES_E.add( allUsersTuple );
+ }
+
+
+ public void testZeroOrOneTuple() throws Exception
+ {
+ MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
+
+ Assert.assertEquals( 0, filter.filter( EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
+ null, null, null, null, null, null, null, null ).size() );
+
+ Collection tuples = new ArrayList();
+ tuples.add( new ACITuple( EMPTY_COLLECTION, AuthenticationLevel.NONE, EMPTY_COLLECTION, EMPTY_SET, false, 0 ) );
+
+ Assert.assertEquals( 1, filter.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+ null, null, null, null, null, null ).size() );
+ }
+
+
+ public void testNameAndThisEntry() throws Exception
+ {
+ MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
+
+ List tuples = new ArrayList( TUPLES_A );
+ tuples = ( List ) filter.filter( tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
+ null, null );
+
+ Assert.assertEquals( 2, tuples.size() );
+ Assert.assertSame( TUPLES_A.get( 0 ), tuples.get( 0 ) );
+ Assert.assertSame( TUPLES_A.get( 1 ), tuples.get( 1 ) );
+ }
+
+
+ public void testThisEntry() throws Exception
+ {
+ MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
+
+ List tuples = new ArrayList( TUPLES_B );
+ tuples = ( List ) filter.filter( tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
+ null, null );
+
+ Assert.assertEquals( 1, tuples.size() );
+ Assert.assertSame( TUPLES_B.get( 0 ), tuples.get( 0 ) );
+ }
+
+
+ public void testUserGroup() throws Exception
+ {
+ MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
+
+ List tuples = new ArrayList( TUPLES_C );
+ tuples = ( List ) filter.filter( tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
+ null, null );
+
+ Assert.assertEquals( 1, tuples.size() );
+ Assert.assertSame( TUPLES_C.get( 0 ), tuples.get( 0 ) );
+ }
+
+
+ public void testSubtree() throws Exception
+ {
+ MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
+
+ List tuples = new ArrayList( TUPLES_D );
+ tuples = ( List ) filter.filter( tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
+ null, null );
+
+ Assert.assertEquals( 1, tuples.size() );
+ Assert.assertSame( TUPLES_D.get( 0 ), tuples.get( 0 ) );
+ }
+
+
+ public void testOthers() throws Exception
+ {
+ MostSpecificUserClassFilter filter = new MostSpecificUserClassFilter();
+
+ List tuples = new ArrayList( TUPLES_E );
+ tuples = ( List ) filter.filter( tuples, OperationScope.ENTRY, null, null, null, null, null, null, null, null,
+ null, null );
+
+ Assert.assertEquals( 2, tuples.size() );
+ Assert.assertSame( TUPLES_E.get( 0 ), tuples.get( 0 ) );
+ Assert.assertSame( TUPLES_E.get( 1 ), tuples.get( 1 ) );
+ }
+}
Propchange: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificUserClassFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MostSpecificUserClassFilterTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/OperationScopeTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/OperationScopeTest.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/OperationScopeTest.java (original)
+++ directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/OperationScopeTest.java Sun Feb 19 19:57:02 2006
@@ -1,48 +1,52 @@
-/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.directory.server.core.authz.support;
-
-import org.apache.directory.server.core.authz.support.OperationScope;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-/**
- * Tests {@link OperationScope}.
- *
- * @author The Apache Directory Project
- * @version $Rev$, $Date$
- *
- */
-public class OperationScopeTest extends TestCase
-{
- public void testGetName() throws Exception
- {
- Assert.assertEquals( "Entry", OperationScope.ENTRY.getName() );
- Assert.assertEquals( "Attribute Type", OperationScope.ATTRIBUTE_TYPE.getName() );
- Assert.assertEquals( "Attribute Type & Value", OperationScope.ATTRIBUTE_TYPE_AND_VALUE.getName() );
- }
-
- public void testGetNameAndToStringEquality()
- {
- Assert.assertEquals( OperationScope.ENTRY.getName(), OperationScope.ENTRY.toString() );
- Assert.assertEquals( OperationScope.ATTRIBUTE_TYPE.getName(), OperationScope.ATTRIBUTE_TYPE.toString() );
- Assert.assertEquals( OperationScope.ATTRIBUTE_TYPE_AND_VALUE.getName(), OperationScope.ATTRIBUTE_TYPE_AND_VALUE.toString() );
- }
-}
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.directory.server.core.authz.support;
+
+
+import org.apache.directory.server.core.authz.support.OperationScope;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+
+/**
+ * Tests {@link OperationScope}.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ *
+ */
+public class OperationScopeTest extends TestCase
+{
+ public void testGetName() throws Exception
+ {
+ Assert.assertEquals( "Entry", OperationScope.ENTRY.getName() );
+ Assert.assertEquals( "Attribute Type", OperationScope.ATTRIBUTE_TYPE.getName() );
+ Assert.assertEquals( "Attribute Type & Value", OperationScope.ATTRIBUTE_TYPE_AND_VALUE.getName() );
+ }
+
+
+ public void testGetNameAndToStringEquality()
+ {
+ Assert.assertEquals( OperationScope.ENTRY.getName(), OperationScope.ENTRY.toString() );
+ Assert.assertEquals( OperationScope.ATTRIBUTE_TYPE.getName(), OperationScope.ATTRIBUTE_TYPE.toString() );
+ Assert.assertEquals( OperationScope.ATTRIBUTE_TYPE_AND_VALUE.getName(), OperationScope.ATTRIBUTE_TYPE_AND_VALUE
+ .toString() );
+ }
+}
Propchange: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/OperationScopeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/OperationScopeTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java (original)
+++ directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java Sun Feb 19 19:57:02 2006
@@ -1,433 +1,345 @@
-/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.directory.server.core.authz.support;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.directory.server.core.authz.support.OperationScope;
-import org.apache.directory.server.core.authz.support.RelatedProtectedItemFilter;
-import org.apache.directory.server.core.authz.support.RelatedUserClassFilter;
-import org.apache.directory.server.core.event.ExpressionEvaluator;
-import org.apache.directory.server.core.schema.AttributeTypeRegistry;
-import org.apache.directory.server.core.schema.OidRegistry;
-import org.apache.directory.server.core.subtree.RefinementEvaluator;
-import org.apache.directory.server.core.subtree.RefinementLeafEvaluator;
-import org.apache.directory.shared.ldap.aci.ACITuple;
-import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
-import org.apache.directory.shared.ldap.aci.ProtectedItem;
-import org.apache.directory.shared.ldap.aci.ProtectedItem.MaxValueCountItem;
-import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedByItem;
-import org.apache.directory.shared.ldap.filter.PresenceNode;
-import org.apache.directory.shared.ldap.name.LdapName;
-
-/**
- * Tests {@link RelatedUserClassFilter}.
- *
- * @author The Apache Directory Project
- * @version $Rev$, $Date$
- */
-public class RelatedProtectedItemFilterTest extends TestCase
-{
- private static final Collection EMPTY_COLLECTION =
- Collections.unmodifiableCollection( new ArrayList() );
- private static final Set EMPTY_SET =
- Collections.unmodifiableSet( new HashSet() );
-
- private static final Name GROUP_NAME;
- private static final Name USER_NAME;
- private static final Set USER_NAMES = new HashSet();
- private static final Set GROUP_NAMES = new HashSet();
-
- private static final AttributeTypeRegistry ATTR_TYPE_REGISTRY_A = new DummyAttributeTypeRegistry( false );
- private static final AttributeTypeRegistry ATTR_TYPE_REGISTRY_B = new DummyAttributeTypeRegistry( true );
- private static final OidRegistry OID_REGISTRY = new DummyOidRegistry();
-
- private static final RelatedProtectedItemFilter filterA;
- private static final RelatedProtectedItemFilter filterB;
-
-
- static
- {
- try
- {
- GROUP_NAME = new LdapName( "ou=test,ou=groups,ou=system" );
- USER_NAME = new LdapName( "ou=test, ou=users, ou=system" );
-
- filterA = new RelatedProtectedItemFilter(
- new RefinementEvaluator(
- new RefinementLeafEvaluator( OID_REGISTRY ) ),
- new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_A ) );
-
- filterB = new RelatedProtectedItemFilter(
- new RefinementEvaluator(
- new RefinementLeafEvaluator( OID_REGISTRY ) ),
- new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_B ) );
- }
- catch( NamingException e )
- {
- throw new Error();
- }
-
- USER_NAMES.add( USER_NAME );
- GROUP_NAMES.add( GROUP_NAME );
- }
-
- public void testZeroTuple() throws Exception
- {
- Assert.assertEquals(
- 0, filterA.filter(
- EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE,
- null, null, null, null, null, null, null, null, null, null ).size() );
- }
-
- public void testEntry() throws Exception
- {
- Collection tuples = getTuples( ProtectedItem.ENTRY );
-
- Assert.assertEquals(
- 1, filterA.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, AuthenticationLevel.NONE, null, null, null, null, null ).size() );
- }
-
- public void testAllUserAttributeTypes() throws Exception
- {
- Collection tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES );
-
- // Test wrong scope
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, null, null,
- "userAttr", null, null, null ).size() );
-
- tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES );
-
- Assert.assertEquals(
- 1, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
- null, null, null,
- "userAttr", null, null, null ).size() );
-
- /* Not used anymore
- Assert.assertEquals(
- 0, filterB.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
- null, null, null,
- "opAttr", null, null, null ).size() );
- */
- }
-
- public void testAllUserAttributeTypesAndValues() throws Exception
- {
- Collection tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES );
-
- // Test wrong scope
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, null, null,
- "userAttr", null, null, null ).size() );
-
- tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES );
-
- Assert.assertEquals(
- 1, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
- null, null, null,
- "userAttr", null, null, null ).size() );
-
- /* Not used anymore
- Assert.assertEquals(
- 0, filterB.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
- null, null, null,
- "opAttr", null, null, null ).size() );
- */
- }
-
- public void testAllAttributeValues() throws Exception
- {
- Collection attrTypes = new ArrayList();
- attrTypes.add( "attrA" );
- Collection tuples = getTuples( new ProtectedItem.AllAttributeValues( attrTypes ) );
-
- // Test wrong scope
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
-
- tuples = getTuples( new ProtectedItem.AllAttributeValues( attrTypes ) );
-
- Assert.assertEquals(
- 1, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
-
- Assert.assertEquals(
- 0, filterB.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
- null, null, null,
- "attrB", null, null, null ).size() );
- }
-
- public void testAttributeType() throws Exception
- {
- Collection attrTypes = new ArrayList();
- attrTypes.add( "attrA" );
- Collection tuples = getTuples( new ProtectedItem.AttributeType( attrTypes ) );
-
- // Test wrong scope
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
-
- tuples = getTuples( new ProtectedItem.AttributeType( attrTypes ) );
-
- Assert.assertEquals(
- 1, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
-
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
- null, null, null,
- "attrB", null, null, null ).size() );
- }
-
- public void testAttributeValue() throws Exception
- {
- Collection attributes = new ArrayList();
- attributes.add( new BasicAttribute( "attrA", "valueA" ) );
- Collection tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
-
- // Test wrong scope
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
- tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
-
-
- tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
-
- Assert.assertEquals(
- 1, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
- null, null, null,
- "attrA", "valueA", null, null ).size() );
-
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
- null, null, null,
- "attrA", "valueB", null, null ).size() );
-
- tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
-
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
- null, null, null,
- "attrB", "valueA", null, null ).size() );
- }
-
- public void testClasses() throws Exception
- {
- // TODO I don't know how to test with Refinement yet.
- }
-
- public void testMaxImmSub() throws Exception
- {
- Collection tuples = getTuples( new ProtectedItem.MaxImmSub( 2 ) );
-
- // Should always retain ruples.
- Assert.assertEquals(
- 1, filterA.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
- }
-
- public void testMaxValueCount() throws Exception
- {
- Collection mvcItems = new ArrayList();
- mvcItems.add( new MaxValueCountItem( "attrA", 3 ) );
- Collection tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
-
- // Test wrong scope
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
- tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
-
- tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
-
- Assert.assertEquals(
- 1, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
-
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
- null, null, null,
- "attrB", null, null, null ).size() );
- }
-
- public void testRangeOfValues() throws Exception
- {
- Attributes entry = new BasicAttributes();
- entry.put( "attrA", "valueA" );
- Collection tuples = getTuples( new ProtectedItem.RangeOfValues( new PresenceNode( "attrA" ) ) );
-
- Assert.assertEquals(
- 1, filterA.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, null, new LdapName( "ou=testEntry" ),
- null, null, entry, null ).size() );
-
- entry.remove( "attrA" );
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
- null, null, new LdapName( "ou=testEntry" ),
- null, null, entry, null ).size() );
- }
-
- public void testRestrictedBy() throws Exception
- {
- Collection rbItems = new ArrayList();
- rbItems.add( new RestrictedByItem( "attrA", "attrB" ) );
- Collection tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
-
- // Test wrong scope
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
- tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
-
- tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
-
- Assert.assertEquals(
- 1, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
- null, null, null,
- "attrA", null, null, null ).size() );
-
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
- null, null, null,
- "attrB", null, null, null ).size() );
- }
-
- public void testSelfValue() throws Exception
- {
- Collection attrTypes = new ArrayList();
- attrTypes.add( "attrA" );
- Collection tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
-
- Attributes entry = new BasicAttributes();
- entry.put( "attrA", USER_NAME );
-
- // Test wrong scope
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, null, null,
- "attrA", null, entry, null ).size() );
-
- tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
-
- Assert.assertEquals(
- 1, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
- null, null, null,
- "attrA", null, entry, null ).size() );
-
- entry.remove( "attrA" );
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
- null, null, null,
- "attrA", null, entry, null ).size() );
-
- tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
- Assert.assertEquals(
- 0, filterA.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
- null, null, null,
- "attrB", null, entry, null ).size() );
- }
-
- private static Collection getTuples( ProtectedItem protectedItem )
- {
- Collection protectedItems = new ArrayList();
- protectedItems.add( protectedItem );
-
- Collection tuples = new ArrayList();
- tuples.add( new ACITuple(
- EMPTY_COLLECTION, AuthenticationLevel.NONE, protectedItems,
- EMPTY_SET, true, 0 ) );
-
- return tuples;
- }
-}
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.directory.server.core.authz.support;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.directory.server.core.authz.support.OperationScope;
+import org.apache.directory.server.core.authz.support.RelatedProtectedItemFilter;
+import org.apache.directory.server.core.authz.support.RelatedUserClassFilter;
+import org.apache.directory.server.core.event.ExpressionEvaluator;
+import org.apache.directory.server.core.schema.AttributeTypeRegistry;
+import org.apache.directory.server.core.schema.OidRegistry;
+import org.apache.directory.server.core.subtree.RefinementEvaluator;
+import org.apache.directory.server.core.subtree.RefinementLeafEvaluator;
+import org.apache.directory.shared.ldap.aci.ACITuple;
+import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
+import org.apache.directory.shared.ldap.aci.ProtectedItem;
+import org.apache.directory.shared.ldap.aci.ProtectedItem.MaxValueCountItem;
+import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedByItem;
+import org.apache.directory.shared.ldap.filter.PresenceNode;
+import org.apache.directory.shared.ldap.name.LdapName;
+
+
+/**
+ * Tests {@link RelatedUserClassFilter}.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
+public class RelatedProtectedItemFilterTest extends TestCase
+{
+ private static final Collection EMPTY_COLLECTION = Collections.unmodifiableCollection( new ArrayList() );
+ private static final Set EMPTY_SET = Collections.unmodifiableSet( new HashSet() );
+
+ private static final Name GROUP_NAME;
+ private static final Name USER_NAME;
+ private static final Set USER_NAMES = new HashSet();
+ private static final Set GROUP_NAMES = new HashSet();
+
+ private static final AttributeTypeRegistry ATTR_TYPE_REGISTRY_A = new DummyAttributeTypeRegistry( false );
+ private static final AttributeTypeRegistry ATTR_TYPE_REGISTRY_B = new DummyAttributeTypeRegistry( true );
+ private static final OidRegistry OID_REGISTRY = new DummyOidRegistry();
+
+ private static final RelatedProtectedItemFilter filterA;
+ private static final RelatedProtectedItemFilter filterB;
+
+ static
+ {
+ try
+ {
+ GROUP_NAME = new LdapName( "ou=test,ou=groups,ou=system" );
+ USER_NAME = new LdapName( "ou=test, ou=users, ou=system" );
+
+ filterA = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
+ OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_A ) );
+
+ filterB = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
+ OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_B ) );
+ }
+ catch ( NamingException e )
+ {
+ throw new Error();
+ }
+
+ USER_NAMES.add( USER_NAME );
+ GROUP_NAMES.add( GROUP_NAME );
+ }
+
+
+ public void testZeroTuple() throws Exception
+ {
+ Assert.assertEquals( 0, filterA.filter( EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
+ null, null, null, null, null, null, null, null ).size() );
+ }
+
+
+ public void testEntry() throws Exception
+ {
+ Collection tuples = getTuples( ProtectedItem.ENTRY );
+
+ Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ENTRY, null, null, null, null,
+ AuthenticationLevel.NONE, null, null, null, null, null ).size() );
+ }
+
+
+ public void testAllUserAttributeTypes() throws Exception
+ {
+ Collection tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES );
+
+ // Test wrong scope
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+ "userAttr", null, null, null ).size() );
+
+ tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES );
+
+ Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+ null, null, "userAttr", null, null, null ).size() );
+
+ /* Not used anymore
+ Assert.assertEquals(
+ 0, filterB.filter(
+ tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
+ null, null, null,
+ "opAttr", null, null, null ).size() );
+ */
+ }
+
+
+ public void testAllUserAttributeTypesAndValues() throws Exception
+ {
+ Collection tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES );
+
+ // Test wrong scope
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+ "userAttr", null, null, null ).size() );
+
+ tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES );
+
+ Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+ null, null, "userAttr", null, null, null ).size() );
+
+ /* Not used anymore
+ Assert.assertEquals(
+ 0, filterB.filter(
+ tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME,
+ null, null, null,
+ "opAttr", null, null, null ).size() );
+ */
+ }
+
+
+ public void testAllAttributeValues() throws Exception
+ {
+ Collection attrTypes = new ArrayList();
+ attrTypes.add( "attrA" );
+ Collection tuples = getTuples( new ProtectedItem.AllAttributeValues( attrTypes ) );
+
+ // Test wrong scope
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+ "attrA", null, null, null ).size() );
+
+ tuples = getTuples( new ProtectedItem.AllAttributeValues( attrTypes ) );
+
+ Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+ null, null, "attrA", null, null, null ).size() );
+
+ Assert.assertEquals( 0, filterB.filter( tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+ null, null, "attrB", null, null, null ).size() );
+ }
+
+
+ public void testAttributeType() throws Exception
+ {
+ Collection attrTypes = new ArrayList();
+ attrTypes.add( "attrA" );
+ Collection tuples = getTuples( new ProtectedItem.AttributeType( attrTypes ) );
+
+ // Test wrong scope
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+ "attrA", null, null, null ).size() );
+
+ tuples = getTuples( new ProtectedItem.AttributeType( attrTypes ) );
+
+ Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+ null, null, "attrA", null, null, null ).size() );
+
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+ null, null, "attrB", null, null, null ).size() );
+ }
+
+
+ public void testAttributeValue() throws Exception
+ {
+ Collection attributes = new ArrayList();
+ attributes.add( new BasicAttribute( "attrA", "valueA" ) );
+ Collection tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
+
+ // Test wrong scope
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+ "attrA", null, null, null ).size() );
+ tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+ null, null, "attrA", null, null, null ).size() );
+
+ tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
+
+ Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+ null, null, null, "attrA", "valueA", null, null ).size() );
+
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+ null, null, null, "attrA", "valueB", null, null ).size() );
+
+ tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
+
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+ null, null, null, "attrB", "valueA", null, null ).size() );
+ }
+
+
+ public void testClasses() throws Exception
+ {
+ // TODO I don't know how to test with Refinement yet.
+ }
+
+
+ public void testMaxImmSub() throws Exception
+ {
+ Collection tuples = getTuples( new ProtectedItem.MaxImmSub( 2 ) );
+
+ // Should always retain ruples.
+ Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+ "attrA", null, null, null ).size() );
+ }
+
+
+ public void testMaxValueCount() throws Exception
+ {
+ Collection mvcItems = new ArrayList();
+ mvcItems.add( new MaxValueCountItem( "attrA", 3 ) );
+ Collection tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
+
+ // Test wrong scope
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+ "attrA", null, null, null ).size() );
+ tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+ null, null, "attrA", null, null, null ).size() );
+
+ tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
+
+ Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+ null, null, null, "attrA", null, null, null ).size() );
+
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+ null, null, null, "attrB", null, null, null ).size() );
+ }
+
+
+ public void testRangeOfValues() throws Exception
+ {
+ Attributes entry = new BasicAttributes();
+ entry.put( "attrA", "valueA" );
+ Collection tuples = getTuples( new ProtectedItem.RangeOfValues( new PresenceNode( "attrA" ) ) );
+
+ Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null,
+ new LdapName( "ou=testEntry" ), null, null, entry, null ).size() );
+
+ entry.remove( "attrA" );
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+ null, null, new LdapName( "ou=testEntry" ), null, null, entry, null ).size() );
+ }
+
+
+ public void testRestrictedBy() throws Exception
+ {
+ Collection rbItems = new ArrayList();
+ rbItems.add( new RestrictedByItem( "attrA", "attrB" ) );
+ Collection tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
+
+ // Test wrong scope
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+ "attrA", null, null, null ).size() );
+ tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+ null, null, "attrA", null, null, null ).size() );
+
+ tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
+
+ Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+ null, null, null, "attrA", null, null, null ).size() );
+
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+ null, null, null, "attrB", null, null, null ).size() );
+ }
+
+
+ public void testSelfValue() throws Exception
+ {
+ Collection attrTypes = new ArrayList();
+ attrTypes.add( "attrA" );
+ Collection tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
+
+ Attributes entry = new BasicAttributes();
+ entry.put( "attrA", USER_NAME );
+
+ // Test wrong scope
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+ "attrA", null, entry, null ).size() );
+
+ tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
+
+ Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+ null, null, null, "attrA", null, entry, null ).size() );
+
+ entry.remove( "attrA" );
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+ null, null, null, "attrA", null, entry, null ).size() );
+
+ tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
+ Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+ null, null, null, "attrB", null, entry, null ).size() );
+ }
+
+
+ private static Collection getTuples( ProtectedItem protectedItem )
+ {
+ Collection protectedItems = new ArrayList();
+ protectedItems.add( protectedItem );
+
+ Collection tuples = new ArrayList();
+ tuples.add( new ACITuple( EMPTY_COLLECTION, AuthenticationLevel.NONE, protectedItems, EMPTY_SET, true, 0 ) );
+
+ return tuples;
+ }
+}
Propchange: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java (original)
+++ directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java Sun Feb 19 19:57:02 2006
@@ -1,231 +1,203 @@
-/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.directory.server.core.authz.support;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.naming.Name;
-import javax.naming.NamingException;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.directory.server.core.authz.support.OperationScope;
-import org.apache.directory.server.core.authz.support.RelatedUserClassFilter;
-import org.apache.directory.server.core.subtree.SubtreeEvaluator;
-import org.apache.directory.shared.ldap.aci.ACITuple;
-import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
-import org.apache.directory.shared.ldap.aci.UserClass;
-import org.apache.directory.shared.ldap.name.LdapName;
-
-/**
- * Tests {@link RelatedUserClassFilter}.
- *
- * @author The Apache Directory Project
- * @version $Rev$, $Date$
- */
-public class RelatedUserClassFilterTest extends TestCase
-{
- private static final Collection EMPTY_COLLECTION =
- Collections.unmodifiableCollection( new ArrayList() );
- private static final Set EMPTY_SET =
- Collections.unmodifiableSet( new HashSet() );
-
- private static final Name GROUP_NAME;
- private static final Name USER_NAME;
- private static final Set USER_NAMES = new HashSet();
- private static final Set GROUP_NAMES = new HashSet();
-
- private static final SubtreeEvaluator SUBTREE_EVALUATOR = new SubtreeEvaluator( new DummyOidRegistry() );
-
- private static final RelatedUserClassFilter filter = new RelatedUserClassFilter( SUBTREE_EVALUATOR );
-
- static
- {
- try
- {
- GROUP_NAME = new LdapName( "ou=test,ou=groups,ou=system" );
- USER_NAME = new LdapName( "ou=test, ou=users, ou=system" );
- }
- catch( NamingException e )
- {
- throw new Error();
- }
-
- USER_NAMES.add( USER_NAME );
- GROUP_NAMES.add( GROUP_NAME );
- }
-
- public void testZeroTuple() throws Exception
- {
- Assert.assertEquals(
- 0, filter.filter(
- EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE,
- null, null, null, null, null, null, null, null, null, null ).size() );
- }
-
- public void testAllUsers() throws Exception
- {
- Collection tuples = getTuples( UserClass.ALL_USERS );
-
- Assert.assertEquals(
- 1, filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, AuthenticationLevel.NONE, null, null, null, null, null ).size() );
- }
-
- public void testThisEntry() throws Exception
- {
- Collection tuples = getTuples( UserClass.THIS_ENTRY );
-
- Assert.assertEquals(
- 1, filter.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, AuthenticationLevel.NONE, USER_NAME,
- null, null, null, null ).size() );
- Assert.assertEquals(
- 0, filter.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, AuthenticationLevel.NONE, new LdapName( "ou=unrelated" ),
- null, null, null, null ).size() );
- }
-
- public void testName() throws Exception
- {
- Collection tuples = getTuples( new UserClass.Name( USER_NAMES ) );
- Assert.assertEquals(
- 1, filter.filter(
- tuples, OperationScope.ENTRY, null, null, USER_NAME,
- null, AuthenticationLevel.NONE, null,
- null, null, null, null ).size() );
- Assert.assertEquals(
- 0, filter.filter(
- tuples, OperationScope.ENTRY, null, null, new LdapName( "ou=unrelateduser, ou=users" ),
- null, AuthenticationLevel.NONE, USER_NAME,
- null, null, null, null ).size() );
- }
-
- public void testUserGroup() throws Exception
- {
- Collection tuples = getTuples( new UserClass.UserGroup( GROUP_NAMES ) );
- Assert.assertEquals(
- 1, filter.filter(
- tuples, OperationScope.ENTRY, null, GROUP_NAMES, USER_NAME,
- null, AuthenticationLevel.NONE, null,
- null, null, null, null ).size() );
-
- Set wrongGroupNames = new HashSet();
- wrongGroupNames.add( new LdapName( "ou=unrelatedgroup" ) );
-
- Assert.assertEquals(
- 0, filter.filter(
- tuples, OperationScope.ENTRY, null, wrongGroupNames, USER_NAME,
- null, AuthenticationLevel.NONE, USER_NAME,
- null, null, null, null ).size() );
- }
-
- public void testSubtree() throws Exception
- {
- // TODO Don't know how to test yet.
- }
-
- public void testAuthenticationLevel() throws Exception
- {
- Collection tuples = getTuples( AuthenticationLevel.SIMPLE, true );
-
- Assert.assertEquals(
- 1, filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, AuthenticationLevel.STRONG, null, null, null, null, null ).size() );
- Assert.assertEquals(
- 1, filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, AuthenticationLevel.SIMPLE, null, null, null, null, null ).size() );
- Assert.assertEquals(
- 0, filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, AuthenticationLevel.NONE, null, null, null, null, null ).size() );
-
- tuples = getTuples( AuthenticationLevel.SIMPLE, false );
-
- Assert.assertEquals(
- 1, filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, AuthenticationLevel.NONE, null, null, null, null, null ).size() );
-
- Assert.assertEquals(
- 0, filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, AuthenticationLevel.STRONG, null, null, null, null, null ).size() );
-
- tuples = getTuples( AuthenticationLevel.SIMPLE, false );
-
- Assert.assertEquals(
- 0, filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, AuthenticationLevel.SIMPLE, null, null, null, null, null ).size() );
- }
-
- private static Collection getTuples( UserClass userClass )
- {
- Collection classes = new ArrayList();
- classes.add( userClass );
-
- Collection tuples = new ArrayList();
- tuples.add( new ACITuple(
- classes, AuthenticationLevel.NONE, EMPTY_COLLECTION,
- EMPTY_SET, true, 0 ) );
-
- return tuples;
- }
-
- private static Collection getTuples( AuthenticationLevel level, boolean grant )
- {
- Collection classes = new ArrayList();
- if( grant )
- {
- classes.add( UserClass.ALL_USERS );
- }
- else
- {
- Set names = new HashSet();
- try
- {
- names.add( new LdapName( "dummy=dummy" ) );
- }
- catch( NamingException e )
- {
- throw new Error();
- }
-
- classes.add( new UserClass.Name( names ) );
- }
-
- Collection tuples = new ArrayList();
- tuples.add( new ACITuple(
- classes, level, EMPTY_COLLECTION,
- EMPTY_SET, grant, 0 ) );
-
- return tuples;
- }
-}
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.directory.server.core.authz.support;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.directory.server.core.authz.support.OperationScope;
+import org.apache.directory.server.core.authz.support.RelatedUserClassFilter;
+import org.apache.directory.server.core.subtree.SubtreeEvaluator;
+import org.apache.directory.shared.ldap.aci.ACITuple;
+import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
+import org.apache.directory.shared.ldap.aci.UserClass;
+import org.apache.directory.shared.ldap.name.LdapName;
+
+
+/**
+ * Tests {@link RelatedUserClassFilter}.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
+public class RelatedUserClassFilterTest extends TestCase
+{
+ private static final Collection EMPTY_COLLECTION = Collections.unmodifiableCollection( new ArrayList() );
+ private static final Set EMPTY_SET = Collections.unmodifiableSet( new HashSet() );
+
+ private static final Name GROUP_NAME;
+ private static final Name USER_NAME;
+ private static final Set USER_NAMES = new HashSet();
+ private static final Set GROUP_NAMES = new HashSet();
+
+ private static final SubtreeEvaluator SUBTREE_EVALUATOR = new SubtreeEvaluator( new DummyOidRegistry() );
+
+ private static final RelatedUserClassFilter filter = new RelatedUserClassFilter( SUBTREE_EVALUATOR );
+
+ static
+ {
+ try
+ {
+ GROUP_NAME = new LdapName( "ou=test,ou=groups,ou=system" );
+ USER_NAME = new LdapName( "ou=test, ou=users, ou=system" );
+ }
+ catch ( NamingException e )
+ {
+ throw new Error();
+ }
+
+ USER_NAMES.add( USER_NAME );
+ GROUP_NAMES.add( GROUP_NAME );
+ }
+
+
+ public void testZeroTuple() throws Exception
+ {
+ Assert.assertEquals( 0, filter.filter( EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
+ null, null, null, null, null, null, null, null ).size() );
+ }
+
+
+ public void testAllUsers() throws Exception
+ {
+ Collection tuples = getTuples( UserClass.ALL_USERS );
+
+ Assert.assertEquals( 1, filter.filter( tuples, OperationScope.ENTRY, null, null, null, null,
+ AuthenticationLevel.NONE, null, null, null, null, null ).size() );
+ }
+
+
+ public void testThisEntry() throws Exception
+ {
+ Collection tuples = getTuples( UserClass.THIS_ENTRY );
+
+ Assert.assertEquals( 1, filter.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
+ AuthenticationLevel.NONE, USER_NAME, null, null, null, null ).size() );
+ Assert.assertEquals( 0, filter.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
+ AuthenticationLevel.NONE, new LdapName( "ou=unrelated" ), null, null, null, null ).size() );
+ }
+
+
+ public void testName() throws Exception
+ {
+ Collection tuples = getTuples( new UserClass.Name( USER_NAMES ) );
+ Assert.assertEquals( 1, filter.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null,
+ AuthenticationLevel.NONE, null, null, null, null, null ).size() );
+ Assert.assertEquals( 0, filter.filter( tuples, OperationScope.ENTRY, null, null,
+ new LdapName( "ou=unrelateduser, ou=users" ), null, AuthenticationLevel.NONE, USER_NAME, null, null, null,
+ null ).size() );
+ }
+
+
+ public void testUserGroup() throws Exception
+ {
+ Collection tuples = getTuples( new UserClass.UserGroup( GROUP_NAMES ) );
+ Assert.assertEquals( 1, filter.filter( tuples, OperationScope.ENTRY, null, GROUP_NAMES, USER_NAME, null,
+ AuthenticationLevel.NONE, null, null, null, null, null ).size() );
+
+ Set wrongGroupNames = new HashSet();
+ wrongGroupNames.add( new LdapName( "ou=unrelatedgroup" ) );
+
+ Assert.assertEquals( 0, filter.filter( tuples, OperationScope.ENTRY, null, wrongGroupNames, USER_NAME, null,
+ AuthenticationLevel.NONE, USER_NAME, null, null, null, null ).size() );
+ }
+
+
+ public void testSubtree() throws Exception
+ {
+ // TODO Don't know how to test yet.
+ }
+
+
+ public void testAuthenticationLevel() throws Exception
+ {
+ Collection tuples = getTuples( AuthenticationLevel.SIMPLE, true );
+
+ Assert.assertEquals( 1, filter.filter( tuples, OperationScope.ENTRY, null, null, null, null,
+ AuthenticationLevel.STRONG, null, null, null, null, null ).size() );
+ Assert.assertEquals( 1, filter.filter( tuples, OperationScope.ENTRY, null, null, null, null,
+ AuthenticationLevel.SIMPLE, null, null, null, null, null ).size() );
+ Assert.assertEquals( 0, filter.filter( tuples, OperationScope.ENTRY, null, null, null, null,
+ AuthenticationLevel.NONE, null, null, null, null, null ).size() );
+
+ tuples = getTuples( AuthenticationLevel.SIMPLE, false );
+
+ Assert.assertEquals( 1, filter.filter( tuples, OperationScope.ENTRY, null, null, null, null,
+ AuthenticationLevel.NONE, null, null, null, null, null ).size() );
+
+ Assert.assertEquals( 0, filter.filter( tuples, OperationScope.ENTRY, null, null, null, null,
+ AuthenticationLevel.STRONG, null, null, null, null, null ).size() );
+
+ tuples = getTuples( AuthenticationLevel.SIMPLE, false );
+
+ Assert.assertEquals( 0, filter.filter( tuples, OperationScope.ENTRY, null, null, null, null,
+ AuthenticationLevel.SIMPLE, null, null, null, null, null ).size() );
+ }
+
+
+ private static Collection getTuples( UserClass userClass )
+ {
+ Collection classes = new ArrayList();
+ classes.add( userClass );
+
+ Collection tuples = new ArrayList();
+ tuples.add( new ACITuple( classes, AuthenticationLevel.NONE, EMPTY_COLLECTION, EMPTY_SET, true, 0 ) );
+
+ return tuples;
+ }
+
+
+ private static Collection getTuples( AuthenticationLevel level, boolean grant )
+ {
+ Collection classes = new ArrayList();
+ if ( grant )
+ {
+ classes.add( UserClass.ALL_USERS );
+ }
+ else
+ {
+ Set names = new HashSet();
+ try
+ {
+ names.add( new LdapName( "dummy=dummy" ) );
+ }
+ catch ( NamingException e )
+ {
+ throw new Error();
+ }
+
+ classes.add( new UserClass.Name( names ) );
+ }
+
+ Collection tuples = new ArrayList();
+ tuples.add( new ACITuple( classes, level, EMPTY_COLLECTION, EMPTY_SET, grant, 0 ) );
+
+ return tuples;
+ }
+}
Propchange: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java (original)
+++ directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java Sun Feb 19 19:57:02 2006
@@ -1,142 +1,125 @@
-/*
- * @(#) $Id$
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.directory.server.core.authz.support;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.directory.server.core.authz.support.OperationScope;
-import org.apache.directory.server.core.authz.support.RestrictedByFilter;
-import org.apache.directory.shared.ldap.aci.ACITuple;
-import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
-import org.apache.directory.shared.ldap.aci.ProtectedItem;
-import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedByItem;
-
-/**
- * Tests {@link RestrictedByFilter}.
- *
- * @author The Apache Directory Project
- * @version $Rev$, $Date$
- */
-public class RestrictedByFilterTest extends TestCase
-{
- private static final Collection EMPTY_COLLECTION =
- Collections.unmodifiableCollection( new ArrayList() );
- private static final Set EMPTY_SET =
- Collections.unmodifiableSet( new HashSet() );
-
- private static final Collection PROTECTED_ITEMS = new ArrayList();
- private static final Attributes ENTRY = new BasicAttributes();
-
- static
- {
- Collection mvcItems = new ArrayList();
- mvcItems.add( new RestrictedByItem( "choice", "option" ) );
- PROTECTED_ITEMS.add( new ProtectedItem.RestrictedBy( mvcItems ) );
-
- Attribute attr = new BasicAttribute( "option" );
- attr.add( "1" );
- attr.add( "2" );
-
- ENTRY.put( attr );
- }
-
- public void testWrongScope() throws Exception
- {
- RestrictedByFilter filter = new RestrictedByFilter();
- Collection tuples = new ArrayList();
- tuples.add( new ACITuple(
- EMPTY_COLLECTION, AuthenticationLevel.NONE, EMPTY_COLLECTION,
- EMPTY_SET, true, 0 ) );
-
- tuples = Collections.unmodifiableCollection( tuples );
-
- Assert.assertEquals(
- tuples, filter.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null,
- null, null, null, null, null, null, null ) );
-
- Assert.assertEquals(
- tuples, filter.filter(
- tuples, OperationScope.ENTRY, null, null, null,
- null, null, null, null, null, null, null ) );
- }
-
- public void testZeroTuple() throws Exception
- {
- RestrictedByFilter filter = new RestrictedByFilter();
-
- Assert.assertEquals(
- 0, filter.filter(
- EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE,
- null, null, null, null, null, null, null, null, null, null ).size() );
- }
-
- public void testDenialTuple() throws Exception
- {
- RestrictedByFilter filter = new RestrictedByFilter();
- Collection tuples = new ArrayList();
- tuples.add( new ACITuple(
- EMPTY_COLLECTION, AuthenticationLevel.NONE, PROTECTED_ITEMS,
- EMPTY_SET, false, 0 ) );
-
- tuples = Collections.unmodifiableCollection( tuples );
-
- Assert.assertEquals(
- tuples, filter.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
- null, null, null, "testAttr", null, ENTRY, null ) );
- }
-
-
- public void testGrantTuple() throws Exception
- {
- RestrictedByFilter filter = new RestrictedByFilter();
- Collection tuples = new ArrayList();
- tuples.add( new ACITuple(
- EMPTY_COLLECTION, AuthenticationLevel.NONE, PROTECTED_ITEMS,
- EMPTY_SET, true, 0 ) );
-
- Assert.assertEquals(
- 1, filter.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
- null, null, null, "choice", "1", ENTRY, null ).size() );
-
- Assert.assertEquals(
- 1, filter.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
- null, null, null, "choice", "2", ENTRY, null ).size() );
-
- Assert.assertEquals(
- 0, filter.filter(
- tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
- null, null, null, "choice", "3", ENTRY, null ).size() );
- }
-}
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.directory.server.core.authz.support;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.directory.server.core.authz.support.OperationScope;
+import org.apache.directory.server.core.authz.support.RestrictedByFilter;
+import org.apache.directory.shared.ldap.aci.ACITuple;
+import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
+import org.apache.directory.shared.ldap.aci.ProtectedItem;
+import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedByItem;
+
+
+/**
+ * Tests {@link RestrictedByFilter}.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
+public class RestrictedByFilterTest extends TestCase
+{
+ private static final Collection EMPTY_COLLECTION = Collections.unmodifiableCollection( new ArrayList() );
+ private static final Set EMPTY_SET = Collections.unmodifiableSet( new HashSet() );
+
+ private static final Collection PROTECTED_ITEMS = new ArrayList();
+ private static final Attributes ENTRY = new BasicAttributes();
+
+ static
+ {
+ Collection mvcItems = new ArrayList();
+ mvcItems.add( new RestrictedByItem( "choice", "option" ) );
+ PROTECTED_ITEMS.add( new ProtectedItem.RestrictedBy( mvcItems ) );
+
+ Attribute attr = new BasicAttribute( "option" );
+ attr.add( "1" );
+ attr.add( "2" );
+
+ ENTRY.put( attr );
+ }
+
+
+ public void testWrongScope() throws Exception
+ {
+ RestrictedByFilter filter = new RestrictedByFilter();
+ Collection tuples = new ArrayList();
+ tuples.add( new ACITuple( EMPTY_COLLECTION, AuthenticationLevel.NONE, EMPTY_COLLECTION, EMPTY_SET, true, 0 ) );
+
+ tuples = Collections.unmodifiableCollection( tuples );
+
+ Assert.assertEquals( tuples, filter.filter( tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
+ null, null, null, null, null, null ) );
+
+ Assert.assertEquals( tuples, filter.filter( tuples, OperationScope.ENTRY, null, null, null, null, null, null,
+ null, null, null, null ) );
+ }
+
+
+ public void testZeroTuple() throws Exception
+ {
+ RestrictedByFilter filter = new RestrictedByFilter();
+
+ Assert.assertEquals( 0, filter.filter( EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
+ null, null, null, null, null, null, null, null ).size() );
+ }
+
+
+ public void testDenialTuple() throws Exception
+ {
+ RestrictedByFilter filter = new RestrictedByFilter();
+ Collection tuples = new ArrayList();
+ tuples.add( new ACITuple( EMPTY_COLLECTION, AuthenticationLevel.NONE, PROTECTED_ITEMS, EMPTY_SET, false, 0 ) );
+
+ tuples = Collections.unmodifiableCollection( tuples );
+
+ Assert.assertEquals( tuples, filter.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
+ null, null, null, "testAttr", null, ENTRY, null ) );
+ }
+
+
+ public void testGrantTuple() throws Exception
+ {
+ RestrictedByFilter filter = new RestrictedByFilter();
+ Collection tuples = new ArrayList();
+ tuples.add( new ACITuple( EMPTY_COLLECTION, AuthenticationLevel.NONE, PROTECTED_ITEMS, EMPTY_SET, true, 0 ) );
+
+ Assert.assertEquals( 1, filter.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+ null, null, "choice", "1", ENTRY, null ).size() );
+
+ Assert.assertEquals( 1, filter.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+ null, null, "choice", "2", ENTRY, null ).size() );
+
+ Assert.assertEquals( 0, filter.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+ null, null, "choice", "3", ENTRY, null ).size() );
+ }
+}
Propchange: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id