You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by co...@apache.org on 2015/01/05 17:30:10 UTC

svn commit: r1649577 - in /directory/apacheds/trunk: kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosKRBProtocolTest.java server-annotations/src/test/java/org/apache/directory/server/factory/CreateKdcServerAnnotationTest.java

Author: coheigea
Date: Mon Jan  5 16:30:10 2015
New Revision: 1649577

URL: http://svn.apache.org/r1649577
Log:
[DIRSERVER-2031] - Adding some tests

Added:
    directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosKRBProtocolTest.java
Modified:
    directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/CreateKdcServerAnnotationTest.java

Added: directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosKRBProtocolTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosKRBProtocolTest.java?rev=1649577&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosKRBProtocolTest.java (added)
+++ directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosKRBProtocolTest.java Mon Jan  5 16:30:10 2015
@@ -0,0 +1,88 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.kerberos.kdc;
+
+
+import org.apache.directory.server.annotations.CreateKdcServer;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.annotations.ApplyLdifFiles;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.annotations.CreatePartition;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.kerberos.KeyDerivationInterceptor;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.server.protocol.shared.transport.UdpTransport;
+import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
+import org.apache.directory.shared.kerberos.crypto.checksum.ChecksumType;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Some tests for the new "KRB" protocol introduced as part of DIRSERVER-2031:
+ * 
+ * https://issues.apache.org/jira/browse/DIRSERVER-2031
+ */
+@RunWith(FrameworkRunner.class)
+@CreateDS(name = "KerberosKRBProtocolTest-class",
+    partitions =
+        {
+            @CreatePartition(
+                name = "example",
+                suffix = "dc=example,dc=com")
+    },
+    additionalInterceptors =
+        {
+            KeyDerivationInterceptor.class
+    })
+@CreateLdapServer(
+    transports =
+        {
+            @CreateTransport(protocol = "LDAP")
+    })
+@CreateKdcServer(
+    transports =
+        {
+            @CreateTransport(protocol = "KRB", address = "127.0.0.1")
+    })
+@ApplyLdifFiles("org/apache/directory/server/kerberos/kdc/KerberosIT.ldif")
+public class KerberosKRBProtocolTest extends AbstractKerberosITest
+{
+
+    @Test
+    public void testObtainTickets_AES128_TCP() throws Exception
+    {
+        // RFC3962, Section 7: aes128-cts-hmac-sha1-96 + hmac-sha1-96-aes128
+        ObtainTicketParameters parameters = new ObtainTicketParameters( TcpTransport.class,
+            EncryptionType.AES128_CTS_HMAC_SHA1_96, ChecksumType.HMAC_SHA1_96_AES128 );
+        testObtainTickets( parameters );
+    }
+    
+    @Test
+    public void testObtainTickets_AES128_UDP() throws Exception
+    {
+        // RFC3962, Section 7: aes128-cts-hmac-sha1-96 + hmac-sha1-96-aes128
+        ObtainTicketParameters parameters = new ObtainTicketParameters( UdpTransport.class,
+            EncryptionType.AES128_CTS_HMAC_SHA1_96, ChecksumType.HMAC_SHA1_96_AES128 );
+        testObtainTickets( parameters );
+    }
+
+}

Modified: directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/CreateKdcServerAnnotationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/CreateKdcServerAnnotationTest.java?rev=1649577&r1=1649576&r2=1649577&view=diff
==============================================================================
--- directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/CreateKdcServerAnnotationTest.java (original)
+++ directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/CreateKdcServerAnnotationTest.java Mon Jan  5 16:30:10 2015
@@ -41,17 +41,17 @@ import org.junit.Test;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @CreateDS(name = "CreateKdcServerAnnotationTest-class")
-@CreateKdcServer(primaryRealm = "apache.org",
-    kdcPrincipal = "krbtgt/apache.org@apache.org",
-    maxTicketLifetime = 1000,
-    maxRenewableLifetime = 2000,
-    transports =
-        {
-            @CreateTransport(protocol = "TCP"),
-            @CreateTransport(protocol = "UDP")
-    })
 public class CreateKdcServerAnnotationTest
 {
+    @CreateKdcServer(primaryRealm = "apache.org",
+        kdcPrincipal = "krbtgt/apache.org@apache.org",
+        maxTicketLifetime = 1000,
+        maxRenewableLifetime = 2000,
+        transports =
+            {
+                @CreateTransport(protocol = "TCP"),
+                @CreateTransport(protocol = "UDP")
+        })
     @Test
     public void testCreateKdcServer() throws Exception
     {
@@ -75,4 +75,37 @@ public class CreateKdcServerAnnotationTe
 
         FileUtils.deleteDirectory( directoryService.getInstanceLayout().getInstanceDirectory() );
     }
+    
+    @CreateKdcServer(primaryRealm = "apache.org",
+        kdcPrincipal = "krbtgt/apache.org@apache.org",
+        maxTicketLifetime = 1000,
+        maxRenewableLifetime = 2000,
+        transports =
+            {
+                @CreateTransport(protocol = "KRB")
+        })
+    @Test
+    public void testKRBProtocol() throws Exception
+    {
+        DirectoryService directoryService = DSAnnotationProcessor.getDirectoryService();
+        
+        assertEquals( "CreateKdcServerAnnotationTest-class", directoryService.getInstanceId() );
+        
+        KdcServer server = ServerAnnotationProcessor.getKdcServer( directoryService, AvailablePortFinder.getNextAvailable( 1024 ) );
+
+        assertEquals( 2, server.getTransports().length );
+        
+        KerberosConfig config = server.getConfig();
+        assertEquals( directoryService, server.getDirectoryService() );
+        assertEquals( "apache.org", config.getPrimaryRealm() );
+        assertEquals( "krbtgt/apache.org@apache.org", config.getServicePrincipal().getName() );
+        assertEquals( 1000, config.getMaximumTicketLifetime() );
+        assertEquals( 2000, config.getMaximumRenewableLifetime() );
+        
+        server.stop();
+        directoryService.shutdown();
+
+        FileUtils.deleteDirectory( directoryService.getInstanceLayout().getInstanceDirectory() );
+    }
+    
 }