You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/12/03 21:09:55 UTC

svn commit: r723053 - in /directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server: operations/add/ operations/bind/ operations/modify/ ssl/

Author: elecharny
Date: Wed Dec  3 12:09:54 2008
New Revision: 723053

URL: http://svn.apache.org/viewvc?rev=723053&view=rev
Log:
Replaced tabs by 4 spaces.

Modified:
    directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
    directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java
    directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
    directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java
    directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java

Modified: directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java?rev=723053&r1=723052&r2=723053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java (original)
+++ directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java Wed Dec  3 12:09:54 2008
@@ -763,14 +763,14 @@
     public void testDIRSERVER_1183() throws Exception
     {
         LdapContext ctx = ( LdapContext ) getWiredContext( ldapService ).lookup( BASE );
-    	Attributes attrs = new BasicAttributes( "objectClass", "inetOrgPerson", true );
-    	attrs.get( "objectClass" ).add( "organizationalPerson" );
-    	attrs.get( "objectClass" ).add( "person" );
-    	attrs.put( "givenName", "Jim" );
-    	attrs.put( "sn", "Bean" );
-    	attrs.put( "cn", "\"Jim, Bean\"" );
-    	
-    	ctx.createSubcontext( "cn=\"Jim, Bean\"", attrs );
+        Attributes attrs = new BasicAttributes( "objectClass", "inetOrgPerson", true );
+        attrs.get( "objectClass" ).add( "organizationalPerson" );
+        attrs.get( "objectClass" ).add( "person" );
+        attrs.put( "givenName", "Jim" );
+        attrs.put( "sn", "Bean" );
+        attrs.put( "cn", "\"Jim, Bean\"" );
+        
+        ctx.createSubcontext( "cn=\"Jim, Bean\"", attrs );
     }
 
 

Modified: directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java?rev=723053&r1=723052&r2=723053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java (original)
+++ directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java Wed Dec  3 12:09:54 2008
@@ -202,8 +202,8 @@
             }
             catch ( Exception e )
             {
-            	// We should not get here
-            	fail();
+                // We should not get here
+                fail();
             }
         }
 

Modified: directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java?rev=723053&r1=723052&r2=723053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java (original)
+++ directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java Wed Dec  3 12:09:54 2008
@@ -170,7 +170,7 @@
         }
         catch ( AuthenticationException ae )
         {
-    		// Error code 49 : LDAP_INVALID_CREDENTIALS
+            // Error code 49 : LDAP_INVALID_CREDENTIALS
             assertTrue( ae.getMessage().contains( "error code 49" ) );
         }
         catch ( NamingException e )
@@ -200,8 +200,8 @@
         }
         catch ( InvalidNameException ine )
         {
-    		// Error code 34 : LDAP_INVALID_DN_SYNTAX
-        	assertTrue( ine.getMessage().startsWith( "[LDAP: error code 34 - Incorrect DN given" ) );
+            // Error code 34 : LDAP_INVALID_DN_SYNTAX
+            assertTrue( ine.getMessage().startsWith( "[LDAP: error code 34 - Incorrect DN given" ) );
         }
         catch ( NamingException e )
         {
@@ -256,47 +256,47 @@
         env.put( Context.SECURITY_CREDENTIALS, "" );
 
         String[] attrIDs = { "*", "+" };
-    	DirContext ctx = null;
-    	
-    	// Create the initial context
-    	try
-    	{
-    		ctx = new InitialDirContext(env);
-    	}
-    	catch ( NamingException ne )
-    	{
-    		fail();
-    	}
-    	
-    	// We should be anonymous here. 
-    	// Check that we can read the rootDSE
-    	try
-    	{
+        DirContext ctx = null;
+        
+        // Create the initial context
+        try
+        {
+            ctx = new InitialDirContext(env);
+        }
+        catch ( NamingException ne )
+        {
+            fail();
+        }
+        
+        // We should be anonymous here. 
+        // Check that we can read the rootDSE
+        try
+        {
             Attributes attrs = ctx.getAttributes( "", attrIDs );
-    		
-    		assertNotNull( attrs );
-    		assertEquals( "Apache Software Foundation", attrs.get( "vendorName" ).get() );
-    	}
-    	catch ( NamingException ne )
-    	{
-    		fail();
-    	}
-
-    	// Check that we cannot read another entry being anonymous
-    	try
-    	{
+            
+            assertNotNull( attrs );
+            assertEquals( "Apache Software Foundation", attrs.get( "vendorName" ).get() );
+        }
+        catch ( NamingException ne )
+        {
+            fail();
+        }
+
+        // Check that we cannot read another entry being anonymous
+        try
+        {
             Attributes attrs = ctx.getAttributes( "uid=admin,ou=system", attrIDs );
-    		
-    		assertNotNull( attrs );
-    		assertEquals( 0, attrs.size() );
+            
+            assertNotNull( attrs );
+            assertEquals( 0, attrs.size() );
             fail( "Should not be able to read the root DSE" );
-    	}
-    	catch ( NamingException ne )
-    	{
-    	}
-    	
-    	ldapService.getDirectoryService().setAllowAnonymousAccess( oldValue );
-    	ldapService.setAllowAnonymousAccess( oldValue );
+        }
+        catch ( NamingException ne )
+        {
+        }
+        
+        ldapService.getDirectoryService().setAllowAnonymousAccess( oldValue );
+        ldapService.setAllowAnonymousAccess( oldValue );
     }
     
     
@@ -314,19 +314,19 @@
         env.put( Context.SECURITY_CREDENTIALS, "" );
 
         // Create the initial context
-    	try
-    	{
-    		new InitialDirContext(env);
-    	}
-    	catch ( OperationNotSupportedException onse )
-    	{
-    		// Error code 53 : LDAP_UNWILLING_TO_PERFORM
-    		assertTrue( onse.getMessage().contains( "error code 53" ) );
-    	}
-    	catch ( NamingException ne )
-    	{
-    		fail();
-    	}
+        try
+        {
+            new InitialDirContext(env);
+        }
+        catch ( OperationNotSupportedException onse )
+        {
+            // Error code 53 : LDAP_UNWILLING_TO_PERFORM
+            assertTrue( onse.getMessage().contains( "error code 53" ) );
+        }
+        catch ( NamingException ne )
+        {
+            fail();
+        }
     }    
     
     
@@ -345,17 +345,17 @@
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
 
         // Create the initial context
-    	try
-    	{
-    		new InitialDirContext(env);
-    	}
-    	catch ( AuthenticationException ae )
-    	{
-    	}
-    	catch ( NamingException ne )
-    	{
-    		fail( "Expected AuthenticationException but instead got: " + ne.getMessage() );
-    	}
+        try
+        {
+            new InitialDirContext(env);
+        }
+        catch ( AuthenticationException ae )
+        {
+        }
+        catch ( NamingException ne )
+        {
+            fail( "Expected AuthenticationException but instead got: " + ne.getMessage() );
+        }
     }    
 
 

Modified: directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java?rev=723053&r1=723052&r2=723053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java (original)
+++ directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java Wed Dec  3 12:09:54 2008
@@ -326,7 +326,7 @@
         }
         catch ( NoSuchAttributeException e )
         {
-        	assertTrue( true );
+            assertTrue( true );
             // expected behaviour
         }
     }
@@ -354,7 +354,7 @@
         Attribute attr2 = new BasicAttribute( "telephoneNumber", "7890" );
         Attributes attrs2 = new BasicAttributes( true );
         attrs2.put( attr2 );
-    	
+    
         ctx.modifyAttributes( RDN, DirContext.REMOVE_ATTRIBUTE, attrs2 );
         
         // We shopuld not get an exception

Modified: directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java?rev=723053&r1=723052&r2=723053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java (original)
+++ directory/apacheds/branches/apacheds-mina2/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java Wed Dec  3 12:09:54 2008
@@ -111,27 +111,27 @@
     @Before
     public void installKeyStoreWithCertificate() throws Exception
     {
-    	if ( ksFile != null && ksFile.exists() )
-    	{
-    		ksFile.delete();
-    	}
-    	
-    	ksFile = File.createTempFile( "testStore", "ks" );
-    	
-    	CoreSession session = ldapService.getDirectoryService().getAdminSession();
-    	ClonedServerEntry entry = session.lookup( new LdapDN( "uid=admin,ou=system" ), CERT_IDS );
-    	byte[] userCertificate = entry.get( CERT_IDS[0] ).getBytes();
-    	assertNotNull( userCertificate );
-
-    	ByteArrayInputStream in = new ByteArrayInputStream( userCertificate );
-    	CertificateFactory factory = CertificateFactory.getInstance( "X.509" );
-    	Certificate cert = factory.generateCertificate( in );
-    	KeyStore ks = KeyStore.getInstance( KeyStore.getDefaultType() );
-    	ks.load( null, null );
-    	ks.setCertificateEntry( "apacheds", cert );
-    	ks.store( new FileOutputStream( ksFile ), "changeit".toCharArray() );
-    	LOG.debug( "Keystore file installed: {}", ksFile.getAbsolutePath() );
-    	
+        if ( ksFile != null && ksFile.exists() )
+        {
+            ksFile.delete();
+        }
+        
+        ksFile = File.createTempFile( "testStore", "ks" );
+        
+        CoreSession session = ldapService.getDirectoryService().getAdminSession();
+        ClonedServerEntry entry = session.lookup( new LdapDN( "uid=admin,ou=system" ), CERT_IDS );
+        byte[] userCertificate = entry.get( CERT_IDS[0] ).getBytes();
+        assertNotNull( userCertificate );
+
+        ByteArrayInputStream in = new ByteArrayInputStream( userCertificate );
+        CertificateFactory factory = CertificateFactory.getInstance( "X.509" );
+        Certificate cert = factory.generateCertificate( in );
+        KeyStore ks = KeyStore.getInstance( KeyStore.getDefaultType() );
+        ks.load( null, null );
+        ks.setCertificateEntry( "apacheds", cert );
+        ks.store( new FileOutputStream( ksFile ), "changeit".toCharArray() );
+        LOG.debug( "Keystore file installed: {}", ksFile.getAbsolutePath() );
+        
         oldConfidentialityRequiredValue = ldapService.isConfidentialityRequired();
     }
     
@@ -142,25 +142,25 @@
     @After
     public void deleteKeyStore() throws Exception
     {
-    	if ( ksFile != null && ksFile.exists() )
-    	{
-    		ksFile.delete();
-    	}
-    	
-    	LOG.debug( "Keystore file deleted: {}", ksFile.getAbsolutePath() );
-    	ldapService.setConfidentialityRequired( oldConfidentialityRequiredValue );
+        if ( ksFile != null && ksFile.exists() )
+        {
+            ksFile.delete();
+        }
+        
+        LOG.debug( "Keystore file deleted: {}", ksFile.getAbsolutePath() );
+        ldapService.setConfidentialityRequired( oldConfidentialityRequiredValue );
     }
     
 
     private LdapContext getSecuredContext() throws Exception
     {
-    	System.setProperty ( "javax.net.ssl.trustStore", ksFile.getAbsolutePath() );
-    	System.setProperty ( "javax.net.ssl.keyStore", ksFile.getAbsolutePath() );
-    	System.setProperty ( "javax.net.ssl.keyStorePassword", "changeit" );
-    	LOG.debug( "testStartTls() test starting ... " );
-    	
-    	// Set up environment for creating initial context
-    	Hashtable<String, Object> env = new Hashtable<String,Object>();
+        System.setProperty ( "javax.net.ssl.trustStore", ksFile.getAbsolutePath() );
+        System.setProperty ( "javax.net.ssl.keyStore", ksFile.getAbsolutePath() );
+        System.setProperty ( "javax.net.ssl.keyStorePassword", "changeit" );
+        LOG.debug( "testStartTls() test starting ... " );
+        
+        // Set up environment for creating initial context
+        Hashtable<String, Object> env = new Hashtable<String,Object>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
         
         // Must use the name of the server that is found in its certificate?
@@ -195,103 +195,103 @@
         ldapService.setConfidentialityRequired( true );
 
         // -------------------------------------------------------------------
-    	// Unsecured bind should fail
-    	// -------------------------------------------------------------------
+        // Unsecured bind should fail
+        // -------------------------------------------------------------------
 
-    	try
-    	{
-    		ServerIntegrationUtils.getWiredContext( ldapService );
-    		fail( "Should not get here due to violation of confidentiality requirements" );
-    	}
-    	catch( AuthenticationNotSupportedException e )
-    	{
-    	}
-    	
-    	// -------------------------------------------------------------------
-    	// get anonymous connection with StartTLS (no bind request sent)
-    	// -------------------------------------------------------------------
-
-    	LdapContext ctx = getSecuredContext();
-    	assertNotNull( ctx );
-    	
-    	// -------------------------------------------------------------------
-    	// upgrade connection via bind request (same physical connection - TLS)
-    	// -------------------------------------------------------------------
-
-    	ctx.addToEnvironment( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
-    	ctx.addToEnvironment( Context.SECURITY_CREDENTIALS, "secret" );
-    	ctx.addToEnvironment( Context.SECURITY_AUTHENTICATION, "simple" );
-    	ctx.reconnect( null );
-    	
-    	// -------------------------------------------------------------------
-    	// do a search and confirm
-    	// -------------------------------------------------------------------
-
-    	NamingEnumeration<SearchResult> results = ctx.search( "ou=system", "(objectClass=*)", new SearchControls() );
-    	Set<String> names = new HashSet<String>();
-    	while( results.hasMore() )
-    	{
-    		names.add( results.next().getName() );
-    	}
-    	results.close();
-    	assertTrue( names.contains( "prefNodeName=sysPrefRoot" ) );
-    	assertTrue( names.contains( "ou=users" ) );
-    	assertTrue( names.contains( "ou=configuration" ) );
-    	assertTrue( names.contains( "uid=admin" ) );
-    	assertTrue( names.contains( "ou=groups" ) );
-    	
-    	// -------------------------------------------------------------------
-    	// do add and confirm
-    	// -------------------------------------------------------------------
-
-    	Attributes attrs = new BasicAttributes( "objectClass", "person", true );
-    	attrs.put( "sn", "foo" );
-    	attrs.put( "cn", "foo bar" );
-    	ctx.createSubcontext( "cn=foo bar,ou=system", attrs );
-    	assertNotNull( ctx.lookup( "cn=foo bar,ou=system" ) );
-    	
-    	// -------------------------------------------------------------------
-    	// do modify and confirm
-    	// -------------------------------------------------------------------
-
-    	ModificationItem[] mods = new ModificationItem[] {
-    			new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute( "cn", "fbar" ) )
-    	};
-    	ctx.modifyAttributes( "cn=foo bar,ou=system", mods );
-    	Attributes reread = ( Attributes ) ctx.getAttributes( "cn=foo bar,ou=system" );
-    	assertTrue( reread.get( "cn" ).contains( "fbar" ) );
-    	
-    	// -------------------------------------------------------------------
-    	// do rename and confirm 
-    	// -------------------------------------------------------------------
-
-    	ctx.rename( "cn=foo bar,ou=system", "cn=fbar,ou=system" );
-    	try
-    	{
-    		ctx.getAttributes( "cn=foo bar,ou=system" );
-    		fail( "old name of renamed entry should not be found" );
-    	}
-    	catch ( NameNotFoundException e )
-    	{
-    	}
-    	reread = ( Attributes ) ctx.getAttributes( "cn=fbar,ou=system" );
-    	assertTrue( reread.get( "cn" ).contains( "fbar" ) );
-    	
-    	// -------------------------------------------------------------------
-    	// do delete and confirm
-    	// -------------------------------------------------------------------
-
-    	ctx.destroySubcontext( "cn=fbar,ou=system" );
-    	try
-    	{
-    		ctx.getAttributes( "cn=fbar,ou=system" );
-    		fail( "deleted entry should not be found" );
-    	}
-    	catch ( NameNotFoundException e )
-    	{
-    	}
-    	
-    	ctx.close();
+        try
+        {
+            ServerIntegrationUtils.getWiredContext( ldapService );
+            fail( "Should not get here due to violation of confidentiality requirements" );
+        }
+        catch( AuthenticationNotSupportedException e )
+        {
+        }
+        
+        // -------------------------------------------------------------------
+        // get anonymous connection with StartTLS (no bind request sent)
+        // -------------------------------------------------------------------
+
+        LdapContext ctx = getSecuredContext();
+        assertNotNull( ctx );
+        
+        // -------------------------------------------------------------------
+        // upgrade connection via bind request (same physical connection - TLS)
+        // -------------------------------------------------------------------
+
+        ctx.addToEnvironment( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
+        ctx.addToEnvironment( Context.SECURITY_CREDENTIALS, "secret" );
+        ctx.addToEnvironment( Context.SECURITY_AUTHENTICATION, "simple" );
+        ctx.reconnect( null );
+        
+        // -------------------------------------------------------------------
+        // do a search and confirm
+        // -------------------------------------------------------------------
+
+        NamingEnumeration<SearchResult> results = ctx.search( "ou=system", "(objectClass=*)", new SearchControls() );
+        Set<String> names = new HashSet<String>();
+        while( results.hasMore() )
+        {
+            names.add( results.next().getName() );
+        }
+        results.close();
+        assertTrue( names.contains( "prefNodeName=sysPrefRoot" ) );
+        assertTrue( names.contains( "ou=users" ) );
+        assertTrue( names.contains( "ou=configuration" ) );
+        assertTrue( names.contains( "uid=admin" ) );
+        assertTrue( names.contains( "ou=groups" ) );
+        
+        // -------------------------------------------------------------------
+        // do add and confirm
+        // -------------------------------------------------------------------
+
+        Attributes attrs = new BasicAttributes( "objectClass", "person", true );
+        attrs.put( "sn", "foo" );
+        attrs.put( "cn", "foo bar" );
+        ctx.createSubcontext( "cn=foo bar,ou=system", attrs );
+        assertNotNull( ctx.lookup( "cn=foo bar,ou=system" ) );
+        
+        // -------------------------------------------------------------------
+        // do modify and confirm
+        // -------------------------------------------------------------------
+
+        ModificationItem[] mods = new ModificationItem[] {
+                new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute( "cn", "fbar" ) )
+        };
+        ctx.modifyAttributes( "cn=foo bar,ou=system", mods );
+        Attributes reread = ( Attributes ) ctx.getAttributes( "cn=foo bar,ou=system" );
+        assertTrue( reread.get( "cn" ).contains( "fbar" ) );
+        
+        // -------------------------------------------------------------------
+        // do rename and confirm 
+        // -------------------------------------------------------------------
+
+        ctx.rename( "cn=foo bar,ou=system", "cn=fbar,ou=system" );
+        try
+        {
+            ctx.getAttributes( "cn=foo bar,ou=system" );
+            fail( "old name of renamed entry should not be found" );
+        }
+        catch ( NameNotFoundException e )
+        {
+        }
+        reread = ( Attributes ) ctx.getAttributes( "cn=fbar,ou=system" );
+        assertTrue( reread.get( "cn" ).contains( "fbar" ) );
+        
+        // -------------------------------------------------------------------
+        // do delete and confirm
+        // -------------------------------------------------------------------
+
+        ctx.destroySubcontext( "cn=fbar,ou=system" );
+        try
+        {
+            ctx.getAttributes( "cn=fbar,ou=system" );
+            fail( "deleted entry should not be found" );
+        }
+        catch ( NameNotFoundException e )
+        {
+        }
+        
+        ctx.close();
     }