directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject [25/27] directory-kerby git commit: Adding @Ignore'd test case for certificate encoding
Date Thu, 07 Jul 2016 06:42:10 GMT
Adding @Ignore'd test case for certificate encoding


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/88a7c956
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/88a7c956
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/88a7c956

Branch: refs/heads/kpasswd
Commit: 88a7c9566f3dd68cfd74f495808b29067052281b
Parents: 9af4754
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Jul 6 11:44:55 2016 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Jul 6 11:44:55 2016 +0100

----------------------------------------------------------------------
 .../apache/kerby/kerberos/kerb/CryptoTest.java  | 52 ++++++++++++++++++++
 .../src/test/resources/kdccerttest.pem          | 25 ++++++++++
 2 files changed, 77 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/88a7c956/kerby-kerb/kerb-common/src/test/java/org/apache/kerby/kerberos/kerb/CryptoTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-common/src/test/java/org/apache/kerby/kerberos/kerb/CryptoTest.java
b/kerby-kerb/kerb-common/src/test/java/org/apache/kerby/kerberos/kerb/CryptoTest.java
new file mode 100644
index 0000000..715e67d
--- /dev/null
+++ b/kerby-kerb/kerb-common/src/test/java/org/apache/kerby/kerberos/kerb/CryptoTest.java
@@ -0,0 +1,52 @@
+/**
+ *  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;
+
+import java.io.IOException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.util.List;
+
+import org.apache.kerby.kerberos.kerb.preauth.pkinit.CertificateHelper;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CryptoTest {
+
+    @Test
+    @org.junit.Ignore
+    public void testCertificateLoading() throws IOException, KrbException, CertificateEncodingException
{
+        // Load cert
+        List<Certificate> certs = CertificateHelper.loadCerts("kdccerttest.pem");
+        Assert.assertEquals(1, certs.size());
+        
+        // Now convert to a Kerby Certificate type
+        org.apache.kerby.x509.type.Certificate certificate = new org.apache.kerby.x509.type.Certificate();
+        byte[] encodedBytes = certs.get(0).getEncoded();
+        certificate.decode(encodedBytes);
+        Assert.assertNotNull(certificate);
+        
+        // Now convert back to an X.509 Certificate
+        byte[] certBytes = certificate.encode();
+        
+        // Test for equality
+        Assert.assertArrayEquals(certBytes, encodedBytes);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/88a7c956/kerby-kerb/kerb-common/src/test/resources/kdccerttest.pem
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-common/src/test/resources/kdccerttest.pem b/kerby-kerb/kerb-common/src/test/resources/kdccerttest.pem
new file mode 100644
index 0000000..f1d6bb2
--- /dev/null
+++ b/kerby-kerb/kerb-common/src/test/resources/kdccerttest.pem
@@ -0,0 +1,25 @@
+-----BEGIN CERTIFICATE-----
+MIIEQDCCAyigAwIBAgIJAJV7O31Zn93hMA0GCSqGSIb3DQEBBQUAMHwxCzAJBgNV
+BAYTAkNOMQswCQYDVQQIDAJTSDELMAkGA1UEB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