Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A51BC10704 for ; Sat, 21 Mar 2015 12:11:44 +0000 (UTC) Received: (qmail 74288 invoked by uid 500); 21 Mar 2015 12:11:44 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 74237 invoked by uid 500); 21 Mar 2015 12:11:44 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 74220 invoked by uid 99); 21 Mar 2015 12:11:44 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Mar 2015 12:11:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2254FDF9F1; Sat, 21 Mar 2015 12:11:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: drankye@apache.org To: commits@directory.apache.org Date: Sat, 21 Mar 2015 12:11:44 -0000 Message-Id: <9a512e247b8543219e7c01a445756679@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [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 @@ kerby-kerb kerby-kdc kdc-tool + kerby-kdc-test kdc-backend kerby-dist benchmark