You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/06/13 07:01:34 UTC
svn commit: r190350 - in
/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server:
authn/ authz/ exception/ jndi/ operational/ prefs/
Author: trustin
Date: Sun Jun 12 22:01:33 2005
New Revision: 190350
URL: http://svn.apache.org/viewcvs?rev=190350&view=rev
Log:
Fixed: DIREVE-162 Support multiple 'new InitialContext()' calls with different principle and root DN
Added:
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsAdminTest.java (with props)
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsNonAdminTest.java (with props)
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsAdminTest.java (with props)
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsNonAdminTest.java (with props)
Removed:
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/AbstractMultiUserJndiTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListTest.java
Modified:
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/exception/ExceptionServiceTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ComparatorNPEBugTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/CreateContextTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/DestroyContextTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ModifyContextTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ObjStateFactoryTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/RFC2713Tests.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SearchContextTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ShutdownTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/operational/BinaryAttributeFilterTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/operational/OperationalAttributeServiceTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/prefs/ServerPreferencesFactoryTest.java
directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/prefs/ServerSystemPreferencesTest.java
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java Sun Jun 12 22:01:33 2005
@@ -34,7 +34,7 @@
import org.apache.ldap.common.exception.LdapConfigurationException;
import org.apache.ldap.common.exception.LdapNoPermissionException;
import org.apache.ldap.common.util.ArrayUtils;
-import org.apache.ldap.server.AbstractCoreTest;
+import org.apache.ldap.server.AbstractAdminTestCase;
/**
@@ -44,7 +44,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class SimpleAuthenticationTest extends AbstractCoreTest
+public class SimpleAuthenticationTest extends AbstractAdminTestCase
{
/**
* Cleans up old database files on creation.
Added: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsAdminTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsAdminTest.java?rev=190350&view=auto
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsAdminTest.java (added)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsAdminTest.java Sun Jun 12 22:01:33 2005
@@ -0,0 +1,128 @@
+/*
+ * 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.ldap.server.authz;
+
+
+import java.util.HashSet;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+
+import org.apache.ldap.common.exception.LdapNoPermissionException;
+import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.server.AbstractAdminTestCase;
+import org.apache.ldap.server.db.DbSearchResult;
+
+
+/**
+ * Tests the Authorization service to make sure it is enforcing policies
+ * correctly.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class AuthorizationServiceAsAdminTest extends AbstractAdminTestCase
+{
+ /**
+ * Makes sure the admin cannot delete the admin account.
+ *
+ * @throws NamingException if there are problems
+ */
+ public void testNoDeleteOnAdminByAdmin() throws NamingException
+ {
+ try
+ {
+ sysRoot.destroySubcontext( "uid=admin" );
+ fail( "admin should not be able to delete his account" );
+ }
+ catch ( LdapNoPermissionException e )
+ {
+ assertNotNull( e );
+ }
+ }
+
+
+ /**
+ * Makes sure the admin cannot rename the admin account.
+ *
+ * @throws NamingException if there are problems
+ */
+ public void testNoRdnChangesOnAdminByAdmin() throws NamingException
+ {
+ try
+ {
+ sysRoot.rename( "uid=admin", "uid=alex" );
+ fail( "admin should not be able to rename his account" );
+ }
+ catch ( LdapNoPermissionException e )
+ {
+ assertNotNull( e );
+ }
+ }
+
+
+ /**
+ * Makes sure the admin cannot rename the admin account.
+ *
+ * @throws NamingException if there are problems
+ */
+ public void testModifyOnAdminByAdmin() throws NamingException
+ {
+ Attributes attributes = new LockableAttributesImpl();
+ attributes.put( "userPassword", "replaced" );
+ sysRoot.modifyAttributes( "uid=admin", DirContext.REPLACE_ATTRIBUTE, attributes );
+ Attributes newAttrs = sysRoot.getAttributes( "uid=admin" );
+ assertEquals( "replaced", newAttrs.get( "userPassword" ).get() );
+ }
+
+
+ /**
+ * Makes sure the admin can see all entries we know of on a subtree search.
+ *
+ * @throws NamingException if there are problems
+ */
+ public void testSearchSubtreeByAdmin() throws NamingException
+ {
+ SearchControls controls = new SearchControls();
+
+ controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+ HashSet set = new HashSet();
+
+ NamingEnumeration list = sysRoot.search( "", "(objectClass=*)", controls );
+
+ while ( list.hasMore() )
+ {
+ DbSearchResult result = ( DbSearchResult ) list.next();
+
+ set.add( result.getName() );
+ }
+
+ assertTrue( set.contains( "ou=system" ) );
+
+ assertTrue( set.contains( "ou=groups,ou=system" ) );
+
+ assertTrue( set.contains( "ou=users,ou=system" ) );
+
+ assertTrue( set.contains( "uid=akarasulu,ou=users,ou=system" ) );
+
+ assertTrue( set.contains( "uid=admin,ou=system" ) );
+ }
+}
Propchange: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsAdminTest.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Added: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsNonAdminTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsNonAdminTest.java?rev=190350&view=auto
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsNonAdminTest.java (added)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsNonAdminTest.java Sun Jun 12 22:01:33 2005
@@ -0,0 +1,123 @@
+/*
+ * 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.ldap.server.authz;
+
+
+import org.apache.ldap.common.exception.LdapNoPermissionException;
+import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.server.AbstractNonAdminTestCase;
+import org.apache.ldap.server.db.DbSearchResult;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+import java.util.HashSet;
+
+
+/**
+ * Tests the Authorization service to make sure it is enforcing policies
+ * correctly.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class AuthorizationServiceAsNonAdminTest extends AbstractNonAdminTestCase
+{
+ /**
+ * Makes sure a non-admin user cannot delete the admin account.
+ *
+ * @throws NamingException if there are problems
+ */
+ public void testNoDeleteOnAdminByNonAdmin() throws NamingException
+ {
+ try
+ {
+ sysRoot.destroySubcontext( "uid=admin" );
+ fail( "User 'admin' should not be able to delete his account" );
+ }
+ catch ( LdapNoPermissionException e )
+ {
+ assertNotNull( e );
+ }
+ }
+
+
+ /**
+ * Makes sure a non-admin user cannot rename the admin account.
+ *
+ * @throws NamingException if there are problems
+ */
+ public void testNoRdnChangesOnAdminByNonAdmin() throws NamingException
+ {
+ try
+ {
+ sysRoot.rename( "uid=admin", "uid=alex" );
+ fail( "admin should not be able to rename his account" );
+ }
+ catch ( LdapNoPermissionException e )
+ {
+ assertNotNull( e );
+ }
+ }
+
+
+ /**
+ * Makes sure the a non-admin user cannot rename the admin account.
+ */
+ public void testModifyOnAdminByNonAdmin()
+ {
+ Attributes attributes = new LockableAttributesImpl();
+ attributes.put( "userPassword", "replaced" );
+
+ try
+ {
+ sysRoot.modifyAttributes( "uid=admin",
+ DirContext.REPLACE_ATTRIBUTE, attributes );
+ fail( "User 'uid=admin' should not be able to modify attributes on admin" );
+ } catch( Exception e ) { }
+ }
+
+
+ /**
+ * Makes sure the admin can see all entries we know of on a subtree search.
+ *
+ * @throws NamingException if there are problems
+ */
+ public void testSearchSubtreeByNonAdmin() throws NamingException
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+ HashSet set = new HashSet();
+ NamingEnumeration list = sysRoot.search( "",
+ "(objectClass=*)", controls );
+ while ( list.hasMore() )
+ {
+ DbSearchResult result = ( DbSearchResult ) list.next();
+ set.add( result.getName() );
+ }
+
+ assertTrue( set.contains( "ou=system" ) );
+ assertTrue( set.contains( "ou=groups,ou=system" ) );
+ assertFalse( set.contains( "cn=administrators,ou=groups,ou=system" ) );
+ assertTrue( set.contains( "ou=users,ou=system" ) );
+ assertFalse( set.contains( "uid=akarasulu,ou=users,ou=system" ) );
+ assertFalse( set.contains( "uid=admin,ou=system" ) );
+ }
+}
Propchange: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceAsNonAdminTest.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/exception/ExceptionServiceTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/exception/ExceptionServiceTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/exception/ExceptionServiceTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/exception/ExceptionServiceTest.java Sun Jun 12 22:01:33 2005
@@ -17,18 +17,25 @@
package org.apache.ldap.server.exception;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.LdapContext;
+
import org.apache.ldap.common.exception.LdapContextNotEmptyException;
import org.apache.ldap.common.exception.LdapNameAlreadyBoundException;
import org.apache.ldap.common.exception.LdapNameNotFoundException;
import org.apache.ldap.common.exception.LdapNamingException;
import org.apache.ldap.common.message.ResultCodeEnum;
-import org.apache.ldap.server.AbstractCoreTest;
-
-import javax.naming.Context;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.*;
-import javax.naming.ldap.LdapContext;
+import org.apache.ldap.server.AbstractAdminTestCase;
/**
@@ -37,7 +44,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ExceptionServiceTest extends AbstractCoreTest
+public class ExceptionServiceTest extends AbstractAdminTestCase
{
// ------------------------------------------------------------------------
// Search Operation Tests
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ComparatorNPEBugTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ComparatorNPEBugTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ComparatorNPEBugTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ComparatorNPEBugTest.java Sun Jun 12 22:01:33 2005
@@ -17,7 +17,7 @@
package org.apache.ldap.server.jndi;
-import org.apache.ldap.server.AbstractCoreTest;
+import org.apache.ldap.server.AbstractAdminTestCase;
/**
@@ -27,7 +27,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ComparatorNPEBugTest extends AbstractCoreTest
+public class ComparatorNPEBugTest extends AbstractAdminTestCase
{
public ComparatorNPEBugTest()
{
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/CreateContextTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/CreateContextTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/CreateContextTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/CreateContextTest.java Sun Jun 12 22:01:33 2005
@@ -17,10 +17,14 @@
package org.apache.ldap.server.jndi;
-import org.apache.ldap.server.AbstractCoreTest;
-
import javax.naming.NamingException;
-import javax.naming.directory.*;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+
+import org.apache.ldap.server.AbstractAdminTestCase;
/**
@@ -29,7 +33,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class CreateContextTest extends AbstractCoreTest
+public class CreateContextTest extends AbstractAdminTestCase
{
/**
* Tests the creation and subsequent read of a new JNDI context under the
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/DestroyContextTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/DestroyContextTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/DestroyContextTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/DestroyContextTest.java Sun Jun 12 22:01:33 2005
@@ -17,11 +17,15 @@
package org.apache.ldap.server.jndi;
-import org.apache.ldap.common.exception.LdapNameNotFoundException;
-import org.apache.ldap.server.AbstractCoreTest;
-
import javax.naming.NamingException;
-import javax.naming.directory.*;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+
+import org.apache.ldap.common.exception.LdapNameNotFoundException;
+import org.apache.ldap.server.AbstractAdminTestCase;
/**
@@ -30,7 +34,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class DestroyContextTest extends AbstractCoreTest
+public class DestroyContextTest extends AbstractAdminTestCase
{
protected void setUp() throws Exception
{
Added: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsAdminTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsAdminTest.java?rev=190350&view=auto
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsAdminTest.java (added)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsAdminTest.java Sun Jun 12 22:01:33 2005
@@ -0,0 +1,75 @@
+/*
+ * 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.ldap.server.jndi;
+
+
+import java.util.HashSet;
+
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+import org.apache.ldap.server.AbstractAdminTestCase;
+
+
+/**
+ * Tests our ability to list elements as the admin user and as a non admin user
+ * on security sensitive values. We do not return results or name class pairs
+ * for user accounts if the user is not the admin.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ListAsAdminTest extends AbstractAdminTestCase
+{
+ public void testListSystemAsAdmin() throws NamingException
+ {
+ HashSet set = new HashSet();
+
+ NamingEnumeration list = sysRoot.list( "" );
+
+ while ( list.hasMore() )
+ {
+ NameClassPair ncp = ( NameClassPair ) list.next();
+
+ set.add( ncp.getName() );
+ }
+
+ assertTrue( set.contains( "uid=admin,ou=system" ) );
+
+ assertTrue( set.contains( "ou=users,ou=system" ) );
+
+ assertTrue( set.contains( "ou=groups,ou=system" ) );
+ }
+
+
+ public void testListUsersAsAdmin() throws NamingException
+ {
+ HashSet set = new HashSet();
+
+ NamingEnumeration list = sysRoot.list( "ou=users" );
+
+ while ( list.hasMore() )
+ {
+ NameClassPair ncp = ( NameClassPair ) list.next();
+
+ set.add( ncp.getName() );
+ }
+
+ assertTrue( set.contains( "uid=akarasulu,ou=users,ou=system" ) );
+ }
+}
Propchange: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsAdminTest.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Added: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsNonAdminTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsNonAdminTest.java?rev=190350&view=auto
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsNonAdminTest.java (added)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsNonAdminTest.java Sun Jun 12 22:01:33 2005
@@ -0,0 +1,75 @@
+/*
+ * 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.ldap.server.jndi;
+
+
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+import org.apache.ldap.server.AbstractNonAdminTestCase;
+
+import java.util.HashSet;
+
+
+/**
+ * Tests our ability to list elements as the admin user and as a non admin user
+ * on security sensitive values. We do not return results or name class pairs
+ * for user accounts if the user is not the admin.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ListAsNonAdminTest extends AbstractNonAdminTestCase
+{
+ public void testListSystemAsNonAdmin() throws NamingException
+ {
+ HashSet set = new HashSet();
+
+ NamingEnumeration list = sysRoot.list( "" );
+
+ while ( list.hasMore() )
+ {
+ NameClassPair ncp = ( NameClassPair ) list.next();
+
+ set.add( ncp.getName() );
+ }
+
+ assertFalse( set.contains( "uid=admin,ou=system" ) );
+
+ assertTrue( set.contains( "ou=users,ou=system" ) );
+
+ assertTrue( set.contains( "ou=groups,ou=system" ) );
+ }
+
+
+ public void testListUsersAsNonAdmin() throws NamingException
+ {
+ HashSet set = new HashSet();
+
+ NamingEnumeration list = sysRoot.list( "ou=users" );
+
+ while ( list.hasMore() )
+ {
+ NameClassPair ncp = ( NameClassPair ) list.next();
+
+ set.add( ncp.getName() );
+ }
+
+ assertFalse( set.contains( "uid=akarasulu,ou=users,ou=system" ) );
+ }
+}
Propchange: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ListAsNonAdminTest.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ModifyContextTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ModifyContextTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ModifyContextTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ModifyContextTest.java Sun Jun 12 22:01:33 2005
@@ -17,10 +17,14 @@
package org.apache.ldap.server.jndi;
-import org.apache.ldap.server.AbstractCoreTest;
-
import javax.naming.NamingException;
-import javax.naming.directory.*;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+
+import org.apache.ldap.server.AbstractAdminTestCase;
/**
@@ -30,7 +34,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ModifyContextTest extends AbstractCoreTest
+public class ModifyContextTest extends AbstractAdminTestCase
{
protected void setUp() throws Exception
{
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ObjStateFactoryTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ObjStateFactoryTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ObjStateFactoryTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ObjStateFactoryTest.java Sun Jun 12 22:01:33 2005
@@ -17,15 +17,20 @@
package org.apache.ldap.server.jndi;
-import org.apache.ldap.server.AbstractCoreTest;
+import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NamingException;
-import javax.naming.directory.*;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.SchemaViolationException;
import javax.naming.spi.DirObjectFactory;
import javax.naming.spi.DirStateFactory;
-import java.util.Hashtable;
+
+import org.apache.ldap.server.AbstractAdminTestCase;
/**
@@ -34,7 +39,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ObjStateFactoryTest extends AbstractCoreTest
+public class ObjStateFactoryTest extends AbstractAdminTestCase
{
public void testObjectFactory() throws NamingException
{
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/RFC2713Tests.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/RFC2713Tests.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/RFC2713Tests.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/RFC2713Tests.java Sun Jun 12 22:01:33 2005
@@ -17,11 +17,12 @@
package org.apache.ldap.server.jndi;
-import org.apache.ldap.server.AbstractCoreTest;
+import java.util.ArrayList;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
-import java.util.ArrayList;
+
+import org.apache.ldap.server.AbstractAdminTestCase;
/**
@@ -31,7 +32,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class RFC2713Tests extends AbstractCoreTest
+public class RFC2713Tests extends AbstractAdminTestCase
{
public void testSerialization() throws Exception
{
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SearchContextTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SearchContextTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SearchContextTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SearchContextTest.java Sun Jun 12 22:01:33 2005
@@ -17,13 +17,20 @@
package org.apache.ldap.server.jndi;
-import org.apache.ldap.common.message.DerefAliasesEnum;
-import org.apache.ldap.server.AbstractCoreTest;
+import java.util.HashMap;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import javax.naming.directory.*;
-import java.util.HashMap;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+import org.apache.ldap.common.message.DerefAliasesEnum;
+import org.apache.ldap.server.AbstractAdminTestCase;
/**
@@ -32,7 +39,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class SearchContextTest extends AbstractCoreTest
+public class SearchContextTest extends AbstractAdminTestCase
{
protected void setUp() throws Exception
{
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ShutdownTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ShutdownTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ShutdownTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ShutdownTest.java Sun Jun 12 22:01:33 2005
@@ -17,7 +17,7 @@
package org.apache.ldap.server.jndi;
-import org.apache.ldap.server.AbstractCoreTest;
+import org.apache.ldap.server.AbstractAdminTestCase;
import org.apache.ldap.server.configuration.ShutdownConfiguration;
@@ -27,7 +27,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ShutdownTest extends AbstractCoreTest
+public class ShutdownTest extends AbstractAdminTestCase
{
protected void tearDown() throws Exception
{
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java Sun Jun 12 22:01:33 2005
@@ -19,7 +19,7 @@
import javax.naming.directory.Attributes;
-import org.apache.ldap.server.AbstractCoreTest;
+import org.apache.ldap.server.AbstractAdminTestCase;
import org.apache.ldap.server.configuration.SyncConfiguration;
@@ -29,7 +29,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class SyncTest extends AbstractCoreTest
+public class SyncTest extends AbstractAdminTestCase
{
/**
* Makes sure the changes to the JNDI provider take effect where a sync op
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/operational/BinaryAttributeFilterTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/operational/BinaryAttributeFilterTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/operational/BinaryAttributeFilterTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/operational/BinaryAttributeFilterTest.java Sun Jun 12 22:01:33 2005
@@ -17,14 +17,14 @@
package org.apache.ldap.server.operational;
-import org.apache.ldap.server.AbstractCoreTest;
-
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
+import org.apache.ldap.server.AbstractAdminTestCase;
+
/**
* Tests to see that the binary property filtering in the schema service's
@@ -34,7 +34,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class BinaryAttributeFilterTest extends AbstractCoreTest
+public class BinaryAttributeFilterTest extends AbstractAdminTestCase
{
private static final String BINARY_KEY = "java.naming.ldap.attributes.binary";
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/operational/OperationalAttributeServiceTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/operational/OperationalAttributeServiceTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/operational/OperationalAttributeServiceTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/operational/OperationalAttributeServiceTest.java Sun Jun 12 22:01:33 2005
@@ -17,12 +17,18 @@
package org.apache.ldap.server.operational;
-import org.apache.ldap.common.message.DerefAliasesEnum;
-import org.apache.ldap.server.AbstractCoreTest;
-
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import javax.naming.directory.*;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+import org.apache.ldap.common.message.DerefAliasesEnum;
+import org.apache.ldap.server.AbstractAdminTestCase;
/**
@@ -32,7 +38,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class OperationalAttributeServiceTest extends AbstractCoreTest
+public class OperationalAttributeServiceTest extends AbstractAdminTestCase
{
private static final String CREATORS_NAME = "creatorsName";
private static final String CREATE_TIMESTAMP = "createTimestamp";
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/prefs/ServerPreferencesFactoryTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/prefs/ServerPreferencesFactoryTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/prefs/ServerPreferencesFactoryTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/prefs/ServerPreferencesFactoryTest.java Sun Jun 12 22:01:33 2005
@@ -17,10 +17,10 @@
package org.apache.ldap.server.prefs;
-import org.apache.ldap.server.AbstractCoreTest;
-
import java.util.prefs.Preferences;
+import org.apache.ldap.server.AbstractAdminTestCase;
+
/**
* Test cases for the server PreferencessFactory.
@@ -28,16 +28,14 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ServerPreferencesFactoryTest extends AbstractCoreTest
+public class ServerPreferencesFactoryTest extends AbstractAdminTestCase
{
public void testSystemRoot()
{
ServerPreferencesFactory factory = new ServerPreferencesFactory();
-
Preferences prefs = factory.systemRoot();
assertNotNull( prefs );
-
- assertEquals( "sysPrefRoot", prefs.get( "prefNodeName", "sysPrefRoot" ) );
+ assertEquals( "sysPrefRoot", prefs.get( "prefNodeName", "default value" ) );
}
}
Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/prefs/ServerSystemPreferencesTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/prefs/ServerSystemPreferencesTest.java?rev=190350&r1=190349&r2=190350&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/prefs/ServerSystemPreferencesTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/prefs/ServerSystemPreferencesTest.java Sun Jun 12 22:01:33 2005
@@ -17,11 +17,11 @@
package org.apache.ldap.server.prefs;
-import org.apache.ldap.server.AbstractCoreTest;
-
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
+import org.apache.ldap.server.AbstractAdminTestCase;
+
/**
* Tests the ServerSystemPreferences class.
@@ -29,18 +29,24 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ServerSystemPreferencesTest extends AbstractCoreTest
+public class ServerSystemPreferencesTest extends AbstractAdminTestCase
{
+ private ServerSystemPreferences prefs;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ prefs = new ServerSystemPreferences();
+ }
+
/**
* Tests to make sure the system preferences root has entry (test, abc123).
*/
public void testRoot() throws Exception
{
- ServerSystemPreferences prefs = new ServerSystemPreferences();
assertEquals( "sysPrefRoot", prefs.get( "prefNodeName", "not the value" ) );
}
-
/**
* Tests the creation and use of a new preferences node.
*
@@ -48,7 +54,6 @@
*/
public void testCreate() throws BackingStoreException
{
- Preferences prefs = new ServerSystemPreferences();
Preferences testNode = prefs.node( "testNode" );
testNode.put( "testNodeKey", "testNodeValue" );
@@ -63,38 +68,25 @@
*/
public void testCreateAndSet() throws BackingStoreException
{
- Preferences prefs = new ServerSystemPreferences();
-
Preferences testNode = prefs.node( "testNode" );
testNode.put( "testNodeKey", "testNodeValue" );
-
testNode.sync();
testNode.putBoolean( "boolKey", true );
-
testNode.putByteArray( "arrayKey", new byte[10] );
-
testNode.putDouble( "doubleKey", 3.14 );
-
testNode.putFloat( "floatKey", ( float ) 3.14 );
-
testNode.putInt( "intKey", 345 );
-
testNode.putLong( "longKey", 75449559185447L );
-
testNode.sync();
testNode = prefs.node( "testNode" );
assertEquals( true, testNode.getBoolean( "boolKey", false ) );
-
assertTrue( 3.14 == testNode.getDouble( "doubleKey", 9.20 ) );
-
assertTrue( (float) 3.14 == testNode.getFloat( "floatKey", (float) 3.90 ) );
-
assertEquals( 345, testNode.getInt( "intKey", 87 ) );
-
assertEquals( 75449559185447L, testNode.getLong( "longKey", 75449547L ) );
}
@@ -106,52 +98,36 @@
*/
public void testCreateAndRemove() throws BackingStoreException
{
- Preferences prefs = new ServerSystemPreferences();
-
Preferences testNode = prefs.node( "testNode" );
testNode.put( "testNodeKey", "testNodeValue" );
-
testNode.sync();
testNode.putBoolean( "boolKey", true );
-
testNode.putByteArray( "arrayKey", new byte[10] );
-
testNode.putDouble( "doubleKey", 3.14 );
-
testNode.putFloat( "floatKey", ( float ) 3.14 );
-
testNode.putInt( "intKey", 345 );
-
testNode.putLong( "longKey", 75449559185447L );
-
testNode.sync();
testNode = prefs.node( "testNode" );
assertEquals( true, testNode.getBoolean( "boolKey", false ) );
-
assertTrue( 3.14 == testNode.getDouble( "doubleKey", 9.20 ) );
-
assertTrue( (float) 3.14 == testNode.getFloat( "floatKey", (float) 3.90 ) );
-
assertEquals( 345, testNode.getInt( "intKey", 87 ) );
-
assertEquals( 75449559185447L, testNode.getLong( "longKey", 75449547L ) );
testNode.remove( "doubleKey" );
-
testNode.remove( "arrayKey" );
assertEquals( "no value", testNode.get( "doubleKey", "no value" ) );
-
assertEquals( "no value", testNode.get( "arrayKey", "no value" ) );
testNode.sync();
assertEquals( "no value", testNode.get( "doubleKey", "no value" ) );
-
assertEquals( "no value", testNode.get( "arrayKey", "no value" ) );
}
}