directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject directory-kerby git commit: Refine some tests.
Date Tue, 22 Dec 2015 05:11:36 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 31b9dee4d -> d89eba715


Refine some tests.


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

Branch: refs/heads/master
Commit: d89eba7152df3fd7f8db43c559a782c0d0ab3ca4
Parents: 31b9dee
Author: plusplusjiajia <jiajia.li@intel.com>
Authored: Tue Dec 22 13:18:27 2015 +0800
Committer: plusplusjiajia <jiajia.li@intel.com>
Committed: Tue Dec 22 13:18:27 2015 +0800

----------------------------------------------------------------------
 .../kerberos/kerb/codec/TestPaPkAsRep.java      |  4 +-
 .../codec/TestPkinitAnonymousAsRepCodec.java    | 49 +++++++++++---------
 .../codec/TestPkinitAnonymousAsReqCodec.java    | 24 ++++++----
 3 files changed, 44 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d89eba71/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPaPkAsRep.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPaPkAsRep.java
b/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPaPkAsRep.java
index 135a093..53d7abf 100644
--- a/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPaPkAsRep.java
+++ b/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPaPkAsRep.java
@@ -22,6 +22,7 @@ package org.apache.kerby.kerberos.kerb.codec;
 import org.apache.kerby.asn1.Asn1;
 import org.apache.kerby.asn1.type.Asn1ObjectIdentifier;
 import org.apache.kerby.cms.type.ContentInfo;
+import org.apache.kerby.kerberos.kerb.KrbCodec;
 import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.type.pa.pkinit.DHRepInfo;
 import org.apache.kerby.kerberos.kerb.type.pa.pkinit.PaPkAsRep;
@@ -40,7 +41,6 @@ public class TestPaPkAsRep {
         dhRepInfo.setDHSignedData(contentInfo.encode());
         paPkAsRep.setDHRepInfo(dhRepInfo);
         Asn1.parseAndDump(paPkAsRep.encode());
-        //TO BE FIXED
-        //KrbCodec.decode(paPkAsRep.encode(), PaPkAsRep.class);
+        KrbCodec.decode(paPkAsRep.encode(), PaPkAsRep.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d89eba71/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPkinitAnonymousAsRepCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPkinitAnonymousAsRepCodec.java
b/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPkinitAnonymousAsRepCodec.java
index 7f37974..a67bb2c 100644
--- a/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPkinitAnonymousAsRepCodec.java
+++ b/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPkinitAnonymousAsRepCodec.java
@@ -20,8 +20,8 @@
 package org.apache.kerby.kerberos.kerb.codec;
 
 import org.apache.kerby.asn1.Asn1;
-import org.apache.kerby.cms.type.ContentInfo;
 import org.apache.kerby.cms.type.EncapsulatedContentInfo;
+import org.apache.kerby.cms.type.SignedContentInfo;
 import org.apache.kerby.cms.type.SignedData;
 import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
 import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
@@ -63,25 +63,7 @@ public class TestPkinitAnonymousAsRepCodec {
         //Asn1.parseAndDump(padataValue);
         paPkAsRep.decode(padataValue);
 
-        assertThat(paPkAsRep.getDHRepInfo()).isNotNull();
-
-        DHRepInfo dhRepInfo = paPkAsRep.getDHRepInfo();
-        byte[] dhSignedData = dhRepInfo.getDHSignedData();
-        ContentInfo contentInfo = new ContentInfo();
-        contentInfo.decode(dhSignedData);
-        assertThat(contentInfo.getContentType().getValue()).isEqualTo("1.2.840.113549.1.7.2");
-        SignedData signedData = contentInfo.getContentAs(SignedData.class);
-        assertThat(signedData.getCertificates()).isNotNull();
-
-        EncapsulatedContentInfo encapsulatedContentInfo = signedData.getEncapContentInfo();
-        assertThat(encapsulatedContentInfo.getContentType().getValue()).isEqualTo("1.3.6.1.5.2.3.2");
-
-        byte[] eContentInfo = encapsulatedContentInfo.getContent();
-        KdcDHKeyInfo kdcDhKeyInfo = new KdcDHKeyInfo();
-        kdcDhKeyInfo.decode(eContentInfo);
-        assertThat(kdcDhKeyInfo.getSubjectPublicKey()).isNotNull();
-        assertThat(kdcDhKeyInfo.getDHKeyExpiration()).isNotNull();
-        assertThat(kdcDhKeyInfo.getNonce()).isNotNull();
+        testPaPkAsRep(paPkAsRep);
 
         PaDataEntry etypeInfo2Entry = paData.findEntry(PaDataType.ETYPE_INFO2);
         assertThat(etypeInfo2Entry.getPaDataType()).isEqualTo(PaDataType.ETYPE_INFO2);
@@ -112,7 +94,30 @@ public class TestPkinitAnonymousAsRepCodec {
         // Test encode PaPkAsRep
         byte[] encodedPaPkAsRep = paPkAsRep.encode();
         Asn1.parseAndDump(encodedPaPkAsRep);
-        PaPkAsRep decodedPaPkAsReq = new PaPkAsRep();
-        decodedPaPkAsReq.decode(encodedPaPkAsRep);
+        PaPkAsRep decodedPaPkAsRep = new PaPkAsRep();
+        decodedPaPkAsRep.decode(encodedPaPkAsRep);
+        testPaPkAsRep(decodedPaPkAsRep);
+    }
+
+    private void testPaPkAsRep(PaPkAsRep paPkAsRep) throws IOException {
+        assertThat(paPkAsRep.getDHRepInfo()).isNotNull();
+
+        DHRepInfo dhRepInfo = paPkAsRep.getDHRepInfo();
+        byte[] dhSignedData = dhRepInfo.getDHSignedData();
+        SignedContentInfo contentInfo = new SignedContentInfo();
+        contentInfo.decode(dhSignedData);
+        assertThat(contentInfo.getContentType().getValue()).isEqualTo("1.2.840.113549.1.7.2");
+        SignedData signedData = contentInfo.getContentAs(SignedData.class);
+        assertThat(signedData.getCertificates()).isNotNull();
+
+        EncapsulatedContentInfo encapsulatedContentInfo = signedData.getEncapContentInfo();
+        assertThat(encapsulatedContentInfo.getContentType().getValue()).isEqualTo("1.3.6.1.5.2.3.2");
+
+        byte[] eContentInfo = encapsulatedContentInfo.getContent();
+        KdcDHKeyInfo kdcDhKeyInfo = new KdcDHKeyInfo();
+        kdcDhKeyInfo.decode(eContentInfo);
+        assertThat(kdcDhKeyInfo.getSubjectPublicKey()).isNotNull();
+        assertThat(kdcDhKeyInfo.getDHKeyExpiration()).isNotNull();
+        assertThat(kdcDhKeyInfo.getNonce()).isNotNull();
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d89eba71/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPkinitAnonymousAsReqCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPkinitAnonymousAsReqCodec.java
b/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPkinitAnonymousAsReqCodec.java
index 7f9c738..8a67c6e 100644
--- a/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPkinitAnonymousAsReqCodec.java
+++ b/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestPkinitAnonymousAsReqCodec.java
@@ -20,7 +20,7 @@
 package org.apache.kerby.kerberos.kerb.codec;
 
 import org.apache.kerby.asn1.Asn1;
-import org.apache.kerby.cms.type.ContentInfo;
+import org.apache.kerby.cms.type.SignedContentInfo;
 import org.apache.kerby.cms.type.SignedData;
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
 import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
@@ -68,15 +68,8 @@ public class TestPkinitAnonymousAsReqCodec {
 
         PaPkAsReq paPkAsReq = new PaPkAsReq();
         paPkAsReq.decode(pkAsReqEntry.getPaDataValue());
-        ContentInfo contentInfo = new ContentInfo();
-        Asn1.parseAndDump(paPkAsReq.getSignedAuthPack());
-        contentInfo.decode(paPkAsReq.getSignedAuthPack());
-        assertThat(contentInfo.getContentType().getValue()).isEqualTo("1.2.840.113549.1.7.2");
-        Asn1.dump(contentInfo);
 
-        SignedData signedData = contentInfo.getContentAs(SignedData.class);
-        assertThat(signedData.getCertificates().getElements().isEmpty()).isEqualTo(true);
-        assertThat(signedData.getEncapContentInfo().getContentType().getValue()).isEqualTo("1.3.6.1.5.2.3.1");
+        testPaPkAsReq(paPkAsReq);
 
         PaDataEntry encpaEntry = paData.findEntry(PaDataType.ENCPADATA_REQ_ENC_PA_REP);
         assertThat(encpaEntry.getPaDataType()).isEqualTo(PaDataType.ENCPADATA_REQ_ENC_PA_REP);
@@ -109,5 +102,18 @@ public class TestPkinitAnonymousAsReqCodec {
         byte[] encodedPaPkAsReq = paPkAsReq.encode();
         PaPkAsReq decodedPaPkAsReq = new PaPkAsReq();
         decodedPaPkAsReq.decode(encodedPaPkAsReq);
+        testPaPkAsReq(decodedPaPkAsReq);
+    }
+
+    private void testPaPkAsReq(PaPkAsReq paPkAsReq) throws IOException {
+        SignedContentInfo contentInfo = new SignedContentInfo();
+        Asn1.parseAndDump(paPkAsReq.getSignedAuthPack());
+        contentInfo.decode(paPkAsReq.getSignedAuthPack());
+        assertThat(contentInfo.getContentType().getValue()).isEqualTo("1.2.840.113549.1.7.2");
+        Asn1.dump(contentInfo);
+
+        SignedData signedData = contentInfo.getContentAs(SignedData.class);
+        assertThat(signedData.getCertificates().getElements().isEmpty()).isEqualTo(true);
+        assertThat(signedData.getEncapContentInfo().getContentType().getValue()).isEqualTo("1.3.6.1.5.2.3.1");
     }
 }


Mime
View raw message