You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by dr...@apache.org on 2015/03/21 13:11:44 UTC

[2/3] directory-kerby git commit: Introduced kerby-kdc-test module for integration tests

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/c59056a8/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/WithCertKdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/WithCertKdcTest.java b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/WithCertKdcTest.java
deleted file mode 100644
index 01a6474..0000000
--- a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/WithCertKdcTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- *  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.kerby.kerberos.kerb.server;
-
-import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.KrbRuntime;
-import org.apache.kerby.kerberos.kerb.provider.PkiLoader;
-import org.apache.kerby.kerberos.kerb.spec.ticket.ServiceTicket;
-import org.apache.kerby.kerberos.kerb.spec.ticket.TgtTicket;
-import org.junit.Before;
-
-import java.io.InputStream;
-import java.security.PrivateKey;
-import java.security.cert.Certificate;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- openssl genrsa -out cakey.pem 2048
- openssl req -key cakey.pem -new -x509 -out cacert.pem -days 3650
- vi extensions.kdc
- openssl genrsa -out kdckey.pem 2048
- openssl req -new -out kdc.req -key kdckey.pem
- env REALM=SH.INTEL.COM openssl x509 -req -in kdc.req -CAkey cakey.pem \
- -CA cacert.pem -out kdc.pem -days 365 -extfile extensions.kdc -extensions kdc_cert -CAcreateserial
- */
-public class WithCertKdcTest extends KdcTestBase {
-    private PkiLoader pkiLoader;
-    private Certificate userCert;
-    private PrivateKey userKey;
-
-    @Before
-    public void setUp() throws Exception {
-        //KrbRuntime.setPkiProvider(new KerbyPkiProvider());
-        pkiLoader = KrbRuntime.getPkiProvider().createPkiLoader();
-
-        super.setUp();
-    }
-
-    @Override
-    protected void setUpClient() throws Exception {
-        super.setUpClient();
-
-        loadCredentials();
-    }
-
-    @Override
-    protected void setUpKdcServer() throws Exception {
-        super.setUpKdcServer();
-        kdcServer.createPrincipals(clientPrincipal);
-    }
-
-    //@Test
-    public void testKdc() throws Exception {
-        assertThat(userCert).isNotNull();
-
-        kdcServer.start();
-        assertThat(kdcServer.isStarted()).isTrue();
-        krbClnt.init();
-
-        TgtTicket tgt = null;
-        try {
-            tgt = krbClnt.requestTgtTicket(clientPrincipal, userCert, userKey, null);
-        } catch (KrbException te) {
-            assertThat(te.getMessage().contains("timeout")).isTrue();
-            return;
-        }
-        assertThat(tgt).isNull();
-
-        ServiceTicket tkt = krbClnt.requestServiceTicket(tgt, serverPrincipal, null);
-        assertThat(tkt).isNull();
-    }
-
-    private void loadCredentials() throws KrbException {
-        InputStream res = getClass().getResourceAsStream("/usercert.pem");
-        userCert = pkiLoader.loadCerts(res).iterator().next();
-
-        res = getClass().getResourceAsStream("/userkey.pem");
-        userKey = pkiLoader.loadPrivateKey(res, null);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/c59056a8/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/WithTokenKdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/WithTokenKdcTest.java b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/WithTokenKdcTest.java
deleted file mode 100644
index a0390f5..0000000
--- a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/WithTokenKdcTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *  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.kerby.kerberos.kerb.server;
-
-import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.spec.ticket.ServiceTicket;
-import org.apache.kerby.kerberos.kerb.spec.ticket.TgtTicket;
-import org.apache.kerby.kerberos.kerb.spec.base.AuthToken;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class WithTokenKdcTest extends KdcTestBase {
-
-    private AuthToken token;
-
-    @Override
-    protected void setUpKdcServer() throws Exception {
-        super.setUpKdcServer();
-        kdcServer.createPrincipals(clientPrincipal);
-    }
-
-    //@Test
-    public void testKdc() throws Exception {
-        kdcServer.start();
-        assertThat(kdcServer.isStarted()).isTrue();
-        krbClnt.init();
-
-        TgtTicket tgt = null;
-        try {
-            tgt = krbClnt.requestTgtTicket(clientPrincipal, token, null);
-        } catch (KrbException te) {
-            assertThat(te.getMessage().contains("timeout")).isTrue();
-            return;
-        }
-        assertThat(tgt).isNull();
-
-        ServiceTicket tkt = krbClnt.requestServiceTicket(tgt, serverPrincipal, null);
-        assertThat(tkt).isNull();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/c59056a8/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 625d7c3..8bf88da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,6 +42,7 @@
     <module>kerby-kerb</module>
     <module>kerby-kdc</module>
     <module>kdc-tool</module>
+    <module>kerby-kdc-test</module>
     <module>kdc-backend</module>
     <module>kerby-dist</module>
     <module>benchmark</module>