directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject directory-kerby git commit: KERB. Consolidated tests in kerb-core-test module into kerb-core module
Date Mon, 07 Dec 2015 12:45:01 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 7907cd056 -> f37896d76


KERB. Consolidated tests in kerb-core-test module into kerb-core module


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

Branch: refs/heads/master
Commit: f37896d76591288fbc940576c145bfd5705d2d99
Parents: 7907cd0
Author: Kai Zheng <kai.zheng@intel.com>
Authored: Mon Dec 7 20:44:42 2015 +0800
Committer: Kai Zheng <kai.zheng@intel.com>
Committed: Mon Dec 7 20:44:42 2015 +0800

----------------------------------------------------------------------
 kerby-kerb/kerb-core-test/pom.xml               |  46 --------
 .../kerby/kerberos/kerb/codec/CodecTest.java    |  46 --------
 .../kerberos/kerb/codec/CodecTestUtil.java      |  33 ------
 .../kerberos/kerb/codec/TestAsRepCodec.java     |  72 ------------
 .../kerberos/kerb/codec/TestAsReqCodec.java     | 109 -------------------
 .../kerberos/kerb/codec/TestTgsRepCodec.java    |  68 ------------
 .../kerberos/kerb/codec/TestTgsReqCodec.java    |  92 ----------------
 .../src/test/resources/asrep.token              | Bin 1241 -> 0 bytes
 .../src/test/resources/asreq.token              | Bin 291 -> 0 bytes
 .../src/test/resources/server.keytab            | Bin 387 -> 0 bytes
 .../src/test/resources/tgsrep.token             | Bin 1189 -> 0 bytes
 .../src/test/resources/tgsreq.token             | Bin 1211 -> 0 bytes
 .../kerby/kerberos/kerb/codec/CodecTest.java    |  46 ++++++++
 .../kerberos/kerb/codec/CodecTestUtil.java      |  33 ++++++
 .../kerberos/kerb/codec/TestAsRepCodec.java     |  72 ++++++++++++
 .../kerberos/kerb/codec/TestAsReqCodec.java     | 109 +++++++++++++++++++
 .../kerberos/kerb/codec/TestTgsRepCodec.java    |  68 ++++++++++++
 .../kerberos/kerb/codec/TestTgsReqCodec.java    |  92 ++++++++++++++++
 .../src/main/test/resources/asrep.token         | Bin 0 -> 1241 bytes
 .../src/main/test/resources/asreq.token         | Bin 0 -> 291 bytes
 .../src/main/test/resources/server.keytab       | Bin 0 -> 387 bytes
 .../src/main/test/resources/tgsrep.token        | Bin 0 -> 1189 bytes
 .../src/main/test/resources/tgsreq.token        | Bin 0 -> 1211 bytes
 kerby-kerb/pom.xml                              |   1 -
 .../apache/kerby/cms/TestCompressedData.java    |   4 -
 .../org/apache/kerby/cms/TestSignedData.java    |   5 -
 26 files changed, 420 insertions(+), 476 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/pom.xml b/kerby-kerb/kerb-core-test/pom.xml
deleted file mode 100644
index d796f98..0000000
--- a/kerby-kerb/kerb-core-test/pom.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed 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. See accompanying LICENSE file.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.apache.kerby</groupId>
-    <artifactId>kerby-kerb</artifactId>
-    <version>1.0.0-RC2-SNAPSHOT</version>
-  </parent>
-
-  <artifactId>kerb-core-test</artifactId>
-
-  <name>kerby-kerb-coreTest</name>
-  <description>Kerb core tests</description>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.kerby</groupId>
-      <artifactId>kerby-asn1</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.kerby</groupId>
-      <artifactId>kerb-core</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.kerby</groupId>
-      <artifactId>kerb-util</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-  </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTest.java b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTest.java
deleted file mode 100644
index 3507bf0..0000000
--- a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTest.java
+++ /dev/null
@@ -1,46 +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.codec;
-
-import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.KrbCodec;
-import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
-import org.apache.kerby.kerberos.kerb.type.base.CheckSumType;
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CodecTest {
-
-    @Test
-    public void testCodec() throws KrbException {
-        CheckSum mcs = new CheckSum();
-        mcs.setCksumtype(CheckSumType.CRC32);
-        mcs.setChecksum(new byte[] {0x10});
-        byte[] bytes = KrbCodec.encode(mcs);
-        assertThat(bytes).isNotNull();
-
-        CheckSum restored = KrbCodec.decode(bytes, CheckSum.class);
-        assertThat(restored).isNotNull();
-        assertThat(restored.getCksumtype()).isEqualTo(mcs.getCksumtype());
-        assertThat(mcs.getChecksum()).isEqualTo(restored.getChecksum());
-        assertThat(restored.tag()).isEqualTo(mcs.tag());
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTestUtil.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTestUtil.java b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTestUtil.java
deleted file mode 100644
index e2fb3cf..0000000
--- a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTestUtil.java
+++ /dev/null
@@ -1,33 +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.codec;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-public class CodecTestUtil {
-    /*package*/ 
-    static byte[] readBinaryFile(String path) throws IOException {
-        InputStream is = CodecTestUtil.class.getResourceAsStream(path);
-        byte[] bytes = new byte[is.available()];
-        is.read(bytes);
-        return bytes;
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsRepCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsRepCodec.java b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsRepCodec.java
deleted file mode 100644
index 24f0ab0..0000000
--- a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsRepCodec.java
+++ /dev/null
@@ -1,72 +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.codec;
-
-import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
-import org.apache.kerby.kerberos.kerb.type.base.NameType;
-import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
-import org.apache.kerby.kerberos.kerb.type.kdc.AsRep;
-import org.apache.kerby.kerberos.kerb.type.ticket.Ticket;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * Test AsRep message using a real 'correct' network packet captured from MS-AD to detective programming errors
- * and compatibility issues particularly regarding Kerberos crypto.
- */
-public class TestAsRepCodec {
-
-    @Test
-    public void test() throws IOException {
-        byte[] bytes = CodecTestUtil.readBinaryFile("/asrep.token");
-        ByteBuffer asRepToken = ByteBuffer.wrap(bytes);
-
-        AsRep asRep = new AsRep();
-        asRep.decode(asRepToken);
-
-        assertThat(asRep.getPvno()).isEqualTo(5);
-        assertThat(asRep.getMsgType()).isEqualTo(KrbMessageType.AS_REP);
-        assertThat(asRep.getCrealm()).isEqualTo("DENYDC.COM");
-
-        PrincipalName cName = asRep.getCname();
-        assertThat(cName.getNameType()).isEqualTo(NameType.NT_PRINCIPAL);
-        assertThat(cName.getNameStrings()).hasSize(1).contains("u5");
-
-        Ticket ticket = asRep.getTicket();
-        assertThat(ticket.getTktvno()).isEqualTo(5);
-        assertThat(ticket.getRealm()).isEqualTo("DENYDC.COM");
-        PrincipalName sName = ticket.getSname();
-        assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_INST);
-        assertThat(sName.getNameStrings()).hasSize(2)
-                .contains("krbtgt", "DENYDC.COM");
-        //FIXME
-        //EncTicketPart encTicketPart = ticket.getEncPart();
-        //assertThat(encTicketPart.getKey().getKvno()).isEqualTo(2);
-        //assertThat(encTicketPart.getKey().getKeyType().getValue()).isEqualTo(0x0017);
-
-        //EncKdcRepPart encKdcRepPart = asRep.getEncPart();
-        //assertThat(encKdcRepPart.getKey().getKeyType().getValue()).isEqualTo(0x0017);
-        //assertThat(encKdcRepPart.getKey().getKvno()).isEqualTo(7);
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java
deleted file mode 100644
index b8599a7..0000000
--- a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java
+++ /dev/null
@@ -1,109 +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.codec;
-
-import org.apache.kerby.asn1.Asn1;
-import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
-import org.apache.kerby.kerberos.kerb.type.base.HostAddrType;
-import org.apache.kerby.kerberos.kerb.type.base.HostAddress;
-import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
-import org.apache.kerby.kerberos.kerb.type.base.NameType;
-import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
-import org.apache.kerby.kerberos.kerb.type.kdc.AsReq;
-import org.apache.kerby.kerberos.kerb.type.kdc.KdcReqBody;
-import org.apache.kerby.kerberos.kerb.type.pa.PaData;
-import org.apache.kerby.kerberos.kerb.type.pa.PaDataEntry;
-import org.apache.kerby.kerberos.kerb.type.pa.PaDataType;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.SimpleTimeZone;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * Test AsReq message using a real 'correct' network packet captured from MS-AD
- * to detective programming errors and compatibility issues particularly
- * regarding Kerberos crypto.
- */
-public class TestAsReqCodec {
-
-    @Test
-    public void test() throws IOException, ParseException {
-        byte[] bytes = CodecTestUtil.readBinaryFile("/asreq.token");
-        Asn1.dump(bytes);
-        ByteBuffer asReqToken = ByteBuffer.wrap(bytes);
-
-        AsReq asReq = new AsReq();
-        asReq.decode(asReqToken);
-        Asn1.dump(asReq, false);
-
-        assertThat(asReq.getPvno()).isEqualTo(5);
-        assertThat(asReq.getMsgType()).isEqualTo(KrbMessageType.AS_REQ);
-
-        PaData paData = asReq.getPaData();
-        PaDataEntry encTimestampEntry = paData.findEntry(PaDataType.ENC_TIMESTAMP);
-        assertThat(encTimestampEntry.getPaDataType()).isEqualTo(PaDataType.ENC_TIMESTAMP);
-        assertThat(encTimestampEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 33, 96));
-        PaDataEntry pacRequestEntry = paData.findEntry(PaDataType.PAC_REQUEST);
-        assertThat(pacRequestEntry.getPaDataType()).isEqualTo(PaDataType.PAC_REQUEST);
-        assertThat(pacRequestEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 108, 115));
-
-        KdcReqBody body = asReq.getReqBody();
-        assertThat(body.getKdcOptions().getPadding()).isEqualTo(0);
-        assertThat(body.getKdcOptions().getValue()).isEqualTo(Arrays.copyOfRange(bytes, 126, 130));
-        PrincipalName cName = body.getCname();
-        assertThat(cName.getNameType()).isEqualTo(NameType.NT_PRINCIPAL);
-        assertThat(cName.getName()).isEqualTo("des");
-        assertThat(body.getRealm()).isEqualTo("DENYDC");
-        PrincipalName sName = body.getSname();
-        assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_INST);
-        assertThat(sName.getNameStrings()).hasSize(2)
-                .contains("krbtgt", "DENYDC");
-
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
-        sdf.setTimeZone(new SimpleTimeZone(0, "Z"));
-        Date date = sdf.parse("20370913024805");
-        assertThat(body.getTill().getTime()).isEqualTo(date.getTime());
-        assertThat(body.getRtime().getTime()).isEqualTo(date.getTime());
-
-        assertThat(body.getNonce()).isEqualTo(197451134);
-
-        List<EncryptionType> types = body.getEtypes();
-        assertThat(types).hasSize(7);
-        assertThat(types.get(0).getValue()).isEqualTo(0x0017);
-        //assertThat(types.get(1).getValue()).isEqualTo(0xff7b);//FIXME
-        //assertThat(types.get(2).getValue()).isEqualTo(0x0080);//FIXME
-        assertThat(types.get(3).getValue()).isEqualTo(0x0003);
-        assertThat(types.get(4).getValue()).isEqualTo(0x0001);
-        assertThat(types.get(5).getValue()).isEqualTo(0x0018);
-        //assertThat(types.get(6).getValue()).isEqualTo(0xff79);//FIXME
-
-        List<HostAddress> hostAddress = body.getAddresses().getElements();
-        assertThat(hostAddress).hasSize(1);
-        assertThat(hostAddress.get(0).getAddrType()).isEqualTo(HostAddrType.ADDRTYPE_NETBIOS);
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsRepCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsRepCodec.java b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsRepCodec.java
deleted file mode 100644
index 48aa83f..0000000
--- a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsRepCodec.java
+++ /dev/null
@@ -1,68 +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.codec;
-
-import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
-import org.apache.kerby.kerberos.kerb.type.base.NameType;
-import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
-import org.apache.kerby.kerberos.kerb.type.kdc.TgsRep;
-import org.apache.kerby.kerberos.kerb.type.ticket.Ticket;
-import org.junit.Test;
-
-import java.io.IOException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * Test TgsRep message using a real 'correct' network packet captured from MS-AD to detective programming errors
- * and compatibility issues particularly regarding Kerberos crypto.
- */
-public class TestTgsRepCodec {
-
-    @Test
-    public void test() throws IOException {
-        byte[] bytes = CodecTestUtil.readBinaryFile("/tgsrep.token");
-        TgsRep tgsRep = new TgsRep();
-        tgsRep.decode(bytes);
-
-        assertThat(tgsRep.getPvno()).isEqualTo(5);
-        assertThat(tgsRep.getMsgType()).isEqualTo(KrbMessageType.TGS_REP);
-        assertThat(tgsRep.getCrealm()).isEqualTo("DENYDC.COM");
-
-        PrincipalName cName = tgsRep.getCname();
-        assertThat(cName.getNameType()).isEqualTo(NameType.NT_PRINCIPAL);
-        assertThat(cName.getNameStrings()).hasSize(1).contains("des");
-
-        Ticket ticket = tgsRep.getTicket();
-        assertThat(ticket.getTktvno()).isEqualTo(5);
-        assertThat(ticket.getRealm()).isEqualTo("DENYDC.COM");
-        PrincipalName sName = ticket.getSname();
-        assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_HST);
-        assertThat(sName.getNameStrings()).hasSize(2)
-                .contains("host", "xp1.denydc.com");
-        //FIXME
-        //EncTicketPart encTicketPart = ticket.getEncPart();
-        //assertThat(encTicketPart.getKey().getKeyType().getValue()).isEqualTo(23);
-        //assertThat(encTicketPart.getKey().getKvno()).isEqualTo(2);
-
-        //EncKdcRepPart encKdcRepPart = tgsRep.getEncPart();
-        //assertThat(encKdcRepPart.getKey().getKeyType().getValue()).isEqualTo(3);
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java
deleted file mode 100644
index 10dca95..0000000
--- a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java
+++ /dev/null
@@ -1,92 +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.codec;
-
-import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
-import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
-import org.apache.kerby.kerberos.kerb.type.base.NameType;
-import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
-import org.apache.kerby.kerberos.kerb.type.kdc.KdcReqBody;
-import org.apache.kerby.kerberos.kerb.type.kdc.TgsReq;
-import org.apache.kerby.kerberos.kerb.type.pa.PaData;
-import org.apache.kerby.kerberos.kerb.type.pa.PaDataEntry;
-import org.apache.kerby.kerberos.kerb.type.pa.PaDataType;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.SimpleTimeZone;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * Test TgsReq message using a real 'correct' network packet captured from MS-AD to detective programming errors
- * and compatibility issues particularly regarding Kerberos crypto.
- */
-public class TestTgsReqCodec {
-
-    @Test
-    public void test() throws IOException, ParseException {
-        byte[] bytes = CodecTestUtil.readBinaryFile("/tgsreq.token");
-        TgsReq tgsReq = new TgsReq();
-        tgsReq.decode(bytes);
-
-        assertThat(tgsReq.getPvno()).isEqualTo(5);
-        assertThat(tgsReq.getMsgType()).isEqualTo(KrbMessageType.TGS_REQ);
-
-        PaData paData = tgsReq.getPaData();
-        assertThat(paData.getElements()).hasSize(1);
-        PaDataEntry entry = paData.getElements().iterator().next();
-        assertThat(entry.getPaDataType()).isEqualTo(PaDataType.TGS_REQ);
-
-        //request body
-        KdcReqBody body = tgsReq.getReqBody();
-        assertThat(body.getKdcOptions().getPadding()).isEqualTo(0);
-        byte[] kdcOptionsValue = {64, (byte) 128, 0, 0};
-        assertThat(body.getKdcOptions().getValue()).isEqualTo(kdcOptionsValue);
-
-        assertThat(body.getRealm()).isEqualTo("DENYDC.COM");
-
-        PrincipalName sName = body.getSname();
-        assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_HST);
-        assertThat(sName.getNameStrings()).hasSize(2)
-                .contains("host", "xp1.denydc.com");
-
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
-        sdf.setTimeZone(new SimpleTimeZone(0, "Z"));
-        Date date = sdf.parse("20370913024805");
-        assertThat(body.getTill().getTime()).isEqualTo(date.getTime());
-
-        assertThat(body.getNonce()).isEqualTo(197296424);
-
-        List<EncryptionType> eTypes = body.getEtypes();
-        assertThat(eTypes).hasSize(7);
-        assertThat(eTypes.get(0).getValue()).isEqualTo(0x0017);
-        //assertThat(eTypes.get(1).getValue()).isEqualTo(-133);//FIXME
-        //assertThat(eTypes.get(2).getValue()).isEqualTo(-128);//FIXME
-        assertThat(eTypes.get(3).getValue()).isEqualTo(0x0003);
-        assertThat(eTypes.get(4).getValue()).isEqualTo(0x0001);
-        assertThat(eTypes.get(5).getValue()).isEqualTo(0x0018);
-        //assertThat(eTypes.get(6).getValue()).isEqualTo(-135);//FIXME
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/src/test/resources/asrep.token
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/resources/asrep.token b/kerby-kerb/kerb-core-test/src/test/resources/asrep.token
deleted file mode 100644
index d77cff7..0000000
Binary files a/kerby-kerb/kerb-core-test/src/test/resources/asrep.token and /dev/null differ

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/src/test/resources/asreq.token
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/resources/asreq.token b/kerby-kerb/kerb-core-test/src/test/resources/asreq.token
deleted file mode 100644
index 6d503b3..0000000
Binary files a/kerby-kerb/kerb-core-test/src/test/resources/asreq.token and /dev/null differ

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/src/test/resources/server.keytab
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/resources/server.keytab b/kerby-kerb/kerb-core-test/src/test/resources/server.keytab
deleted file mode 100644
index b44347c..0000000
Binary files a/kerby-kerb/kerb-core-test/src/test/resources/server.keytab and /dev/null differ

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/src/test/resources/tgsrep.token
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/resources/tgsrep.token b/kerby-kerb/kerb-core-test/src/test/resources/tgsrep.token
deleted file mode 100644
index 25d6270..0000000
Binary files a/kerby-kerb/kerb-core-test/src/test/resources/tgsrep.token and /dev/null differ

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core-test/src/test/resources/tgsreq.token
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/resources/tgsreq.token b/kerby-kerb/kerb-core-test/src/test/resources/tgsreq.token
deleted file mode 100644
index 69f6b46..0000000
Binary files a/kerby-kerb/kerb-core-test/src/test/resources/tgsreq.token and /dev/null differ

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTest.java b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTest.java
new file mode 100644
index 0000000..3507bf0
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTest.java
@@ -0,0 +1,46 @@
+/**
+ *  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.codec;
+
+import org.apache.kerby.kerberos.kerb.KrbException;
+import org.apache.kerby.kerberos.kerb.KrbCodec;
+import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
+import org.apache.kerby.kerberos.kerb.type.base.CheckSumType;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class CodecTest {
+
+    @Test
+    public void testCodec() throws KrbException {
+        CheckSum mcs = new CheckSum();
+        mcs.setCksumtype(CheckSumType.CRC32);
+        mcs.setChecksum(new byte[] {0x10});
+        byte[] bytes = KrbCodec.encode(mcs);
+        assertThat(bytes).isNotNull();
+
+        CheckSum restored = KrbCodec.decode(bytes, CheckSum.class);
+        assertThat(restored).isNotNull();
+        assertThat(restored.getCksumtype()).isEqualTo(mcs.getCksumtype());
+        assertThat(mcs.getChecksum()).isEqualTo(restored.getChecksum());
+        assertThat(restored.tag()).isEqualTo(mcs.tag());
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTestUtil.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTestUtil.java b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTestUtil.java
new file mode 100644
index 0000000..e2fb3cf
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTestUtil.java
@@ -0,0 +1,33 @@
+/**
+ *  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.codec;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class CodecTestUtil {
+    /*package*/ 
+    static byte[] readBinaryFile(String path) throws IOException {
+        InputStream is = CodecTestUtil.class.getResourceAsStream(path);
+        byte[] bytes = new byte[is.available()];
+        is.read(bytes);
+        return bytes;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsRepCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsRepCodec.java b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsRepCodec.java
new file mode 100644
index 0000000..24f0ab0
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsRepCodec.java
@@ -0,0 +1,72 @@
+/**
+ *  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.codec;
+
+import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
+import org.apache.kerby.kerberos.kerb.type.base.NameType;
+import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
+import org.apache.kerby.kerberos.kerb.type.kdc.AsRep;
+import org.apache.kerby.kerberos.kerb.type.ticket.Ticket;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Test AsRep message using a real 'correct' network packet captured from MS-AD to detective programming errors
+ * and compatibility issues particularly regarding Kerberos crypto.
+ */
+public class TestAsRepCodec {
+
+    @Test
+    public void test() throws IOException {
+        byte[] bytes = CodecTestUtil.readBinaryFile("/asrep.token");
+        ByteBuffer asRepToken = ByteBuffer.wrap(bytes);
+
+        AsRep asRep = new AsRep();
+        asRep.decode(asRepToken);
+
+        assertThat(asRep.getPvno()).isEqualTo(5);
+        assertThat(asRep.getMsgType()).isEqualTo(KrbMessageType.AS_REP);
+        assertThat(asRep.getCrealm()).isEqualTo("DENYDC.COM");
+
+        PrincipalName cName = asRep.getCname();
+        assertThat(cName.getNameType()).isEqualTo(NameType.NT_PRINCIPAL);
+        assertThat(cName.getNameStrings()).hasSize(1).contains("u5");
+
+        Ticket ticket = asRep.getTicket();
+        assertThat(ticket.getTktvno()).isEqualTo(5);
+        assertThat(ticket.getRealm()).isEqualTo("DENYDC.COM");
+        PrincipalName sName = ticket.getSname();
+        assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_INST);
+        assertThat(sName.getNameStrings()).hasSize(2)
+                .contains("krbtgt", "DENYDC.COM");
+        //FIXME
+        //EncTicketPart encTicketPart = ticket.getEncPart();
+        //assertThat(encTicketPart.getKey().getKvno()).isEqualTo(2);
+        //assertThat(encTicketPart.getKey().getKeyType().getValue()).isEqualTo(0x0017);
+
+        //EncKdcRepPart encKdcRepPart = asRep.getEncPart();
+        //assertThat(encKdcRepPart.getKey().getKeyType().getValue()).isEqualTo(0x0017);
+        //assertThat(encKdcRepPart.getKey().getKvno()).isEqualTo(7);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java
new file mode 100644
index 0000000..b8599a7
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java
@@ -0,0 +1,109 @@
+/**
+ *  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.codec;
+
+import org.apache.kerby.asn1.Asn1;
+import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
+import org.apache.kerby.kerberos.kerb.type.base.HostAddrType;
+import org.apache.kerby.kerberos.kerb.type.base.HostAddress;
+import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
+import org.apache.kerby.kerberos.kerb.type.base.NameType;
+import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
+import org.apache.kerby.kerberos.kerb.type.kdc.AsReq;
+import org.apache.kerby.kerberos.kerb.type.kdc.KdcReqBody;
+import org.apache.kerby.kerberos.kerb.type.pa.PaData;
+import org.apache.kerby.kerberos.kerb.type.pa.PaDataEntry;
+import org.apache.kerby.kerberos.kerb.type.pa.PaDataType;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.SimpleTimeZone;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Test AsReq message using a real 'correct' network packet captured from MS-AD
+ * to detective programming errors and compatibility issues particularly
+ * regarding Kerberos crypto.
+ */
+public class TestAsReqCodec {
+
+    @Test
+    public void test() throws IOException, ParseException {
+        byte[] bytes = CodecTestUtil.readBinaryFile("/asreq.token");
+        Asn1.dump(bytes);
+        ByteBuffer asReqToken = ByteBuffer.wrap(bytes);
+
+        AsReq asReq = new AsReq();
+        asReq.decode(asReqToken);
+        Asn1.dump(asReq, false);
+
+        assertThat(asReq.getPvno()).isEqualTo(5);
+        assertThat(asReq.getMsgType()).isEqualTo(KrbMessageType.AS_REQ);
+
+        PaData paData = asReq.getPaData();
+        PaDataEntry encTimestampEntry = paData.findEntry(PaDataType.ENC_TIMESTAMP);
+        assertThat(encTimestampEntry.getPaDataType()).isEqualTo(PaDataType.ENC_TIMESTAMP);
+        assertThat(encTimestampEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 33, 96));
+        PaDataEntry pacRequestEntry = paData.findEntry(PaDataType.PAC_REQUEST);
+        assertThat(pacRequestEntry.getPaDataType()).isEqualTo(PaDataType.PAC_REQUEST);
+        assertThat(pacRequestEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 108, 115));
+
+        KdcReqBody body = asReq.getReqBody();
+        assertThat(body.getKdcOptions().getPadding()).isEqualTo(0);
+        assertThat(body.getKdcOptions().getValue()).isEqualTo(Arrays.copyOfRange(bytes, 126, 130));
+        PrincipalName cName = body.getCname();
+        assertThat(cName.getNameType()).isEqualTo(NameType.NT_PRINCIPAL);
+        assertThat(cName.getName()).isEqualTo("des");
+        assertThat(body.getRealm()).isEqualTo("DENYDC");
+        PrincipalName sName = body.getSname();
+        assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_INST);
+        assertThat(sName.getNameStrings()).hasSize(2)
+                .contains("krbtgt", "DENYDC");
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        sdf.setTimeZone(new SimpleTimeZone(0, "Z"));
+        Date date = sdf.parse("20370913024805");
+        assertThat(body.getTill().getTime()).isEqualTo(date.getTime());
+        assertThat(body.getRtime().getTime()).isEqualTo(date.getTime());
+
+        assertThat(body.getNonce()).isEqualTo(197451134);
+
+        List<EncryptionType> types = body.getEtypes();
+        assertThat(types).hasSize(7);
+        assertThat(types.get(0).getValue()).isEqualTo(0x0017);
+        //assertThat(types.get(1).getValue()).isEqualTo(0xff7b);//FIXME
+        //assertThat(types.get(2).getValue()).isEqualTo(0x0080);//FIXME
+        assertThat(types.get(3).getValue()).isEqualTo(0x0003);
+        assertThat(types.get(4).getValue()).isEqualTo(0x0001);
+        assertThat(types.get(5).getValue()).isEqualTo(0x0018);
+        //assertThat(types.get(6).getValue()).isEqualTo(0xff79);//FIXME
+
+        List<HostAddress> hostAddress = body.getAddresses().getElements();
+        assertThat(hostAddress).hasSize(1);
+        assertThat(hostAddress.get(0).getAddrType()).isEqualTo(HostAddrType.ADDRTYPE_NETBIOS);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsRepCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsRepCodec.java b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsRepCodec.java
new file mode 100644
index 0000000..48aa83f
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsRepCodec.java
@@ -0,0 +1,68 @@
+/**
+ *  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.codec;
+
+import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
+import org.apache.kerby.kerberos.kerb.type.base.NameType;
+import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
+import org.apache.kerby.kerberos.kerb.type.kdc.TgsRep;
+import org.apache.kerby.kerberos.kerb.type.ticket.Ticket;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Test TgsRep message using a real 'correct' network packet captured from MS-AD to detective programming errors
+ * and compatibility issues particularly regarding Kerberos crypto.
+ */
+public class TestTgsRepCodec {
+
+    @Test
+    public void test() throws IOException {
+        byte[] bytes = CodecTestUtil.readBinaryFile("/tgsrep.token");
+        TgsRep tgsRep = new TgsRep();
+        tgsRep.decode(bytes);
+
+        assertThat(tgsRep.getPvno()).isEqualTo(5);
+        assertThat(tgsRep.getMsgType()).isEqualTo(KrbMessageType.TGS_REP);
+        assertThat(tgsRep.getCrealm()).isEqualTo("DENYDC.COM");
+
+        PrincipalName cName = tgsRep.getCname();
+        assertThat(cName.getNameType()).isEqualTo(NameType.NT_PRINCIPAL);
+        assertThat(cName.getNameStrings()).hasSize(1).contains("des");
+
+        Ticket ticket = tgsRep.getTicket();
+        assertThat(ticket.getTktvno()).isEqualTo(5);
+        assertThat(ticket.getRealm()).isEqualTo("DENYDC.COM");
+        PrincipalName sName = ticket.getSname();
+        assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_HST);
+        assertThat(sName.getNameStrings()).hasSize(2)
+                .contains("host", "xp1.denydc.com");
+        //FIXME
+        //EncTicketPart encTicketPart = ticket.getEncPart();
+        //assertThat(encTicketPart.getKey().getKeyType().getValue()).isEqualTo(23);
+        //assertThat(encTicketPart.getKey().getKvno()).isEqualTo(2);
+
+        //EncKdcRepPart encKdcRepPart = tgsRep.getEncPart();
+        //assertThat(encKdcRepPart.getKey().getKeyType().getValue()).isEqualTo(3);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java
new file mode 100644
index 0000000..10dca95
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java
@@ -0,0 +1,92 @@
+/**
+ *  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.codec;
+
+import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
+import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
+import org.apache.kerby.kerberos.kerb.type.base.NameType;
+import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
+import org.apache.kerby.kerberos.kerb.type.kdc.KdcReqBody;
+import org.apache.kerby.kerberos.kerb.type.kdc.TgsReq;
+import org.apache.kerby.kerberos.kerb.type.pa.PaData;
+import org.apache.kerby.kerberos.kerb.type.pa.PaDataEntry;
+import org.apache.kerby.kerberos.kerb.type.pa.PaDataType;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.SimpleTimeZone;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Test TgsReq message using a real 'correct' network packet captured from MS-AD to detective programming errors
+ * and compatibility issues particularly regarding Kerberos crypto.
+ */
+public class TestTgsReqCodec {
+
+    @Test
+    public void test() throws IOException, ParseException {
+        byte[] bytes = CodecTestUtil.readBinaryFile("/tgsreq.token");
+        TgsReq tgsReq = new TgsReq();
+        tgsReq.decode(bytes);
+
+        assertThat(tgsReq.getPvno()).isEqualTo(5);
+        assertThat(tgsReq.getMsgType()).isEqualTo(KrbMessageType.TGS_REQ);
+
+        PaData paData = tgsReq.getPaData();
+        assertThat(paData.getElements()).hasSize(1);
+        PaDataEntry entry = paData.getElements().iterator().next();
+        assertThat(entry.getPaDataType()).isEqualTo(PaDataType.TGS_REQ);
+
+        //request body
+        KdcReqBody body = tgsReq.getReqBody();
+        assertThat(body.getKdcOptions().getPadding()).isEqualTo(0);
+        byte[] kdcOptionsValue = {64, (byte) 128, 0, 0};
+        assertThat(body.getKdcOptions().getValue()).isEqualTo(kdcOptionsValue);
+
+        assertThat(body.getRealm()).isEqualTo("DENYDC.COM");
+
+        PrincipalName sName = body.getSname();
+        assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_HST);
+        assertThat(sName.getNameStrings()).hasSize(2)
+                .contains("host", "xp1.denydc.com");
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        sdf.setTimeZone(new SimpleTimeZone(0, "Z"));
+        Date date = sdf.parse("20370913024805");
+        assertThat(body.getTill().getTime()).isEqualTo(date.getTime());
+
+        assertThat(body.getNonce()).isEqualTo(197296424);
+
+        List<EncryptionType> eTypes = body.getEtypes();
+        assertThat(eTypes).hasSize(7);
+        assertThat(eTypes.get(0).getValue()).isEqualTo(0x0017);
+        //assertThat(eTypes.get(1).getValue()).isEqualTo(-133);//FIXME
+        //assertThat(eTypes.get(2).getValue()).isEqualTo(-128);//FIXME
+        assertThat(eTypes.get(3).getValue()).isEqualTo(0x0003);
+        assertThat(eTypes.get(4).getValue()).isEqualTo(0x0001);
+        assertThat(eTypes.get(5).getValue()).isEqualTo(0x0018);
+        //assertThat(eTypes.get(6).getValue()).isEqualTo(-135);//FIXME
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core/src/main/test/resources/asrep.token
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/test/resources/asrep.token b/kerby-kerb/kerb-core/src/main/test/resources/asrep.token
new file mode 100644
index 0000000..d77cff7
Binary files /dev/null and b/kerby-kerb/kerb-core/src/main/test/resources/asrep.token differ

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core/src/main/test/resources/asreq.token
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/test/resources/asreq.token b/kerby-kerb/kerb-core/src/main/test/resources/asreq.token
new file mode 100644
index 0000000..6d503b3
Binary files /dev/null and b/kerby-kerb/kerb-core/src/main/test/resources/asreq.token differ

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core/src/main/test/resources/server.keytab
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/test/resources/server.keytab b/kerby-kerb/kerb-core/src/main/test/resources/server.keytab
new file mode 100644
index 0000000..b44347c
Binary files /dev/null and b/kerby-kerb/kerb-core/src/main/test/resources/server.keytab differ

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core/src/main/test/resources/tgsrep.token
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/test/resources/tgsrep.token b/kerby-kerb/kerb-core/src/main/test/resources/tgsrep.token
new file mode 100644
index 0000000..25d6270
Binary files /dev/null and b/kerby-kerb/kerb-core/src/main/test/resources/tgsrep.token differ

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/kerb-core/src/main/test/resources/tgsreq.token
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/test/resources/tgsreq.token b/kerby-kerb/kerb-core/src/main/test/resources/tgsreq.token
new file mode 100644
index 0000000..69f6b46
Binary files /dev/null and b/kerby-kerb/kerb-core/src/main/test/resources/tgsreq.token differ

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-kerb/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-kerb/pom.xml b/kerby-kerb/pom.xml
index 768d899..ae3d44a 100644
--- a/kerby-kerb/pom.xml
+++ b/kerby-kerb/pom.xml
@@ -27,7 +27,6 @@
 
   <modules>
     <module>kerb-core</module>
-    <module>kerb-core-test</module>
     <module>kerb-common</module>
     <module>kerb-util</module>
     <module>kerb-crypto</module>

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-pkix/src/test/java/org/apache/kerby/cms/TestCompressedData.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestCompressedData.java b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestCompressedData.java
index ecb1013..a662182 100644
--- a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestCompressedData.java
+++ b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestCompressedData.java
@@ -20,15 +20,11 @@
 package org.apache.kerby.cms;
 
 import org.apache.kerby.asn1.Asn1;
-import org.apache.kerby.asn1.util.HexUtil;
-import org.apache.kerby.asn1.util.IOUtil;
-import org.apache.kerby.cms.type.CompressedData;
 import org.apache.kerby.cms.type.ContentInfo;
 import org.junit.Assert;
 import org.junit.Test;
 
 import java.io.IOException;
-import java.io.InputStream;
 
 public class TestCompressedData extends CmsTestBase {
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f37896d7/kerby-pkix/src/test/java/org/apache/kerby/cms/TestSignedData.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestSignedData.java b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestSignedData.java
index cf6f283..92b7d13 100644
--- a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestSignedData.java
+++ b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestSignedData.java
@@ -20,16 +20,11 @@
 package org.apache.kerby.cms;
 
 import org.apache.kerby.asn1.Asn1;
-import org.apache.kerby.asn1.util.HexUtil;
-import org.apache.kerby.asn1.util.IOUtil;
-import org.apache.kerby.cms.type.CompressedData;
 import org.apache.kerby.cms.type.ContentInfo;
-import org.apache.kerby.cms.type.SignedData;
 import org.junit.Assert;
 import org.junit.Test;
 
 import java.io.IOException;
-import java.io.InputStream;
 
 public class TestSignedData extends CmsTestBase {
 


Mime
View raw message