Author: akarasulu
Date: Sun Nov 7 18:38:04 2004
New Revision: 56892
Modified:
incubator/directory/kerberos/trunk/ (props changed)
incubator/directory/kerberos/trunk/eve-kerberos/ (props changed)
incubator/directory/kerberos/trunk/eve-kerberos/etc/kerberos.properties
incubator/directory/kerberos/trunk/eve-kerberos/src/test/org/apache/kerberos/kdc/EmbeddedEveStoreTest.java
Log:
Changes ...
o added correct schemas to the properties file
o added code to delete databases to test => this should be made into abstract
class
o added ignores
Modified:
incubator/directory/kerberos/trunk/eve-kerberos/etc/kerberos.properties
==============================================================================
--- incubator/directory/kerberos/trunk/eve-kerberos/etc/kerberos.properties
(original)
+++ incubator/directory/kerberos/trunk/eve-kerberos/etc/kerberos.properties
Sun Nov 7 18:38:04 2004
@@ -46,14 +46,14 @@
# The working directory where Eve stores it's partition database files
eve.wkdir = ./target/eve
# The published LDAP schema's to initialize: all listed are required for
example.com
-# eve.schemas =
system,core,cosine,inetorgperson,krb5kdc
+eve.schemas =
org.apache.eve.schema.bootstrap.SystemSchema,
org.apache.eve.schema.bootstrap.EveSchema,
org.apache.eve.schema.bootstrap.CoreSchema,org.apache.eve.schema.bootstrap.CosineSchema,
org.apache.eve.schema.bootstrap.InetorgpersonSchema,
org.apache.eve.schema.bootstrap.Krb5kdcSchema
# Comma separated name of the partitions to attach/create
eve.db.partitions = example
# Suffix for the example partition
-eve.db.partition.suffix.example = dc=example,dc=com
+eve.db.partition.suffix.example = dc=example,dc=com
# User defined indices for the example partition
-eve.db.partition.indices.example = ou uid objectClass krb5PrincipalName
+eve.db.partition.indices.example = ou uid objectClass krb5PrincipalName
# ObjectClass attribute values for the partition root at dc=example,dc=com
eve.db.partition.attributes.example = dn: dc=example,dc=com*objectClass:
top*objectClass: domain*dc: example
Modified:
incubator/directory/kerberos/trunk/eve-kerberos/src/test/org/apache/kerberos/kdc/EmbeddedEveStoreTest.java
==============================================================================
---
incubator/directory/kerberos/trunk/eve-kerberos/src/test/org/apache/kerberos/kdc/EmbeddedEveStoreTest.java
(original)
+++
incubator/directory/kerberos/trunk/eve-kerberos/src/test/org/apache/kerberos/kdc/EmbeddedEveStoreTest.java
Sun Nov 7 18:38:04 2004
@@ -20,15 +20,17 @@
import java.util.Hashtable;
import java.util.Properties;
import java.io.File;
+import java.io.IOException;
import javax.naming.Context;
+import javax.naming.InitialContext;
import javax.naming.directory.*;
import javax.security.auth.kerberos.KerberosPrincipal;
import junit.framework.TestCase;
import org.apache.eve.jndi.EveContextFactory;
-import org.apache.kerberos.kdc.store.PrincipalStoreEntry;
import org.apache.ldap.common.util.PropertiesUtils;
+import org.apache.commons.io.FileUtils;
/**
@@ -39,11 +41,62 @@
*/
public class EmbeddedEveStoreTest extends TestCase
{
+ /** flag whether to delete database files for each test or not */
+ protected boolean doDelete = true;
+
+
+ /**
+ * Get's the initial context factory for the provider's ou=system context
+ * root.
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ doDelete( new File( "target" + File.separator + "eve" ) );
+ }
+
+
+ /**
+ * Deletes the Eve working directory.
+ *
+ * @throws java.io.IOException if there are failures while deleting.
+ */
+ protected void doDelete( File wkdir ) throws IOException
+ {
+ if ( doDelete )
+ {
+ if ( wkdir.exists() )
+ {
+ FileUtils.deleteDirectory( wkdir );
+ }
+ }
+ }
+
+
+ /**
+ * Sets the system context root to null.
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ Hashtable env = new Hashtable();
+ env.put( Context.PROVIDER_URL, "ou=system" );
+ env.put( Context.INITIAL_CONTEXT_FACTORY,
"org.apache.eve.jndi.EveContextFactory" );
+ env.put( EveContextFactory.SHUTDOWN_OP_ENV, "" );
+ env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
+ env.put( Context.SECURITY_CREDENTIALS, "testing" );
+ try { new InitialContext( env ); } catch( Exception e ) {}
+ }
+
+
public void testLoadFromEtc() throws Exception
{
Properties env = PropertiesUtils.getProperties( new File(
"./etc/kerberos.properties" ) );
-
EmbeddedEveStore store = new EmbeddedEveStore( env );
store.init();
@@ -60,7 +113,7 @@
}
- public void testEveStore() throws Exception
+ public void testEveStoreHardCodedProperties() throws Exception
{
Hashtable env = new Hashtable();
env.put( Context.PROVIDER_URL, "dc=example,dc=com" );
@@ -98,38 +151,5 @@
KerberosPrincipal nonexistent = new KerberosPrincipal( "[EMAIL
PROTECTED]" );
assertNull( store.getEntry( nonexistent ) );
- }
-
-
- public void testEveStoreGetEntry() throws Exception
- {
- Hashtable env = new Hashtable();
- env.put( Context.PROVIDER_URL, "dc=example,dc=com" );
- env.put( Context.INITIAL_CONTEXT_FACTORY,
"org.apache.eve.jndi.EveContextFactory" );
- env.put( EveContextFactory.WKDIR_ENV, "target" + File.separator +
"eve" );
-
- BasicAttributes attrs = new BasicAttributes( true );
- BasicAttribute attr = new BasicAttribute( "objectClass" );
- attr.add( "top" );
- attr.add( "organizationalUnit" );
- attr.add( "extensibleObject" );
- attrs.put( attr );
- attr = new BasicAttribute( "ou" );
- attr.add( "testing" );
- attrs.put( attr );
-
- env.put( EveContextFactory.PARTITIONS_ENV, "example" );
- env.put( EveContextFactory.SUFFIX_BASE_ENV + "example",
"dc=example,dc=com" );
- env.put( EveContextFactory.INDICES_BASE_ENV + "example", "ou
objectClass" );
- env.put( EveContextFactory.ATTRIBUTES_BASE_ENV + "example", attrs );
-
- env.put( EmbeddedEveStore.KDC_ENTRY_LDIF_FILE,
"./src/ldif/example.com" );
- env.put( EmbeddedEveStore.KDC_ENTRY_BASEDN_KEY,
"ou=Users,dc=example,dc=com" );
-
- EmbeddedEveStore store = new EmbeddedEveStore( env );
- store.init();
- KerberosPrincipal principal = new KerberosPrincipal( "krbtgt/[EMAIL
PROTECTED]" );
- PrincipalStoreEntry entry = store.getEntry( principal );
- assertNull( entry );
}
}