[#12] Setup basic Travis CI build

This commit is contained in:
apldev3 2018-09-25 09:36:50 -04:00
parent eced951933
commit 00b1c913e4
4 changed files with 68 additions and 16 deletions

26
.travis.yml Normal file
View File

@ -0,0 +1,26 @@
os:
- linux
sudo: true
language: java
services:
- docker
before_install:
- docker build -t hirs-centos7 .
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
install: true
script:
- docker run --rm hirs-centos7 /bin/bash -c "cd /root/HIRS; git checkout ${TRAVIS_BRANCH}; make -C tpm_module/"
- docker run --rm hirs-centos7 /bin/bash -c "cd /root/HIRS; git checkout ${TRAVIS_BRANCH}; ./gradlew build"

14
Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM centos:7.5.1804
MAINTAINER apl.dev3@jhuapl.edu
# Install packages for building HIRS
RUN yum -y update && yum clean all
RUN yum install -y java-1.8.0-openjdk-devel epel-release cmake make git gcc-c++ doxygen graphviz python libssh2-devel openssl protobuf-compiler protobuf-devel tpm2-tss-devel trousers-devel
RUN yum install -y cppcheck log4cplus-devel re2-devel
# Set Environment Variables
ENV JAVA_HOME /usr/lib/jvm/java
# Download HIRS Project
RUN git clone https://github.com/nsacyber/HIRS.git /root/HIRS

View File

@ -16,6 +16,8 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.TimeZone;
import org.bouncycastle.util.encoders.Base64; import org.bouncycastle.util.encoders.Base64;
import static org.testng.Assert.fail; import static org.testng.Assert.fail;
@ -187,11 +189,12 @@ public class PlatformCredentialTest {
PlatformCredential credential = new PlatformCredential(certPath); PlatformCredential credential = new PlatformCredential(certPath);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.set(2017, 2, 23, 18, 34, 33); calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
calendar.set(2017, 2, 23, 22, 34, 33);
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
Assert.assertEquals(credential.getBeginValidity(), calendar.getTime()); Assert.assertEquals(credential.getBeginValidity().getTime(), calendar.getTime().getTime());
calendar.set(2030, 11, 31, 18, 59, 59); calendar.set(2030, 11, 31, 23, 59, 59);
Assert.assertEquals(credential.getEndValidity(), calendar.getTime()); Assert.assertEquals(credential.getEndValidity().getTime(), calendar.getTime().getTime());
Assert.assertNotNull(credential.getAttributeCertificate()); Assert.assertNotNull(credential.getAttributeCertificate());
byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes(); byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes();
@ -235,11 +238,12 @@ public class PlatformCredentialTest {
PlatformCredential credential = new PlatformCredential(certPath); PlatformCredential credential = new PlatformCredential(certPath);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.set(2017, 2, 23, 18, 34, 33); calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
calendar.set(2017, 2, 23, 22, 34, 33);
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
Assert.assertEquals(credential.getBeginValidity(), calendar.getTime()); Assert.assertEquals(credential.getBeginValidity().getTime(), calendar.getTime().getTime());
calendar.set(2030, 11, 31, 18, 59, 59); calendar.set(2030, 11, 31, 23, 59, 59);
Assert.assertEquals(credential.getEndValidity(), calendar.getTime()); Assert.assertEquals(credential.getEndValidity().getTime(), calendar.getTime().getTime());
Assert.assertNotNull(credential.getAttributeCertificate()); Assert.assertNotNull(credential.getAttributeCertificate());
byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes(); byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes();
@ -283,11 +287,12 @@ public class PlatformCredentialTest {
PlatformCredential credential = new PlatformCredential(certPath); PlatformCredential credential = new PlatformCredential(certPath);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.set(2017, 3, 21, 13, 5, 29); calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
calendar.set(2017, 3, 21, 17, 5, 29);
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
Assert.assertEquals(credential.getBeginValidity(), calendar.getTime()); Assert.assertEquals(credential.getBeginValidity().getTime(), calendar.getTime().getTime());
calendar.set(2030, 11, 31, 18, 59, 59); calendar.set(2030, 11, 31, 23, 59, 59);
Assert.assertEquals(credential.getEndValidity(), calendar.getTime()); Assert.assertEquals(credential.getEndValidity().getTime(), calendar.getTime().getTime());
Assert.assertNotNull(credential.getAttributeCertificate()); Assert.assertNotNull(credential.getAttributeCertificate());
byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes(); byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes();
@ -327,11 +332,12 @@ public class PlatformCredentialTest {
PlatformCredential credential = new PlatformCredential(certPath); PlatformCredential credential = new PlatformCredential(certPath);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.set(2017, 3, 21, 13, 5, 30); calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
calendar.set(2017, 3, 21, 17, 5, 30);
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
Assert.assertEquals(credential.getBeginValidity(), calendar.getTime()); Assert.assertEquals(credential.getBeginValidity().getTime(), calendar.getTime().getTime());
calendar.set(2030, 11, 31, 18, 59, 59); calendar.set(2030, 11, 31, 23, 59, 59);
Assert.assertEquals(credential.getEndValidity(), calendar.getTime()); Assert.assertEquals(credential.getEndValidity().getTime(), calendar.getTime().getTime());
Assert.assertNotNull(credential.getAttributeCertificate()); Assert.assertNotNull(credential.getAttributeCertificate());
byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes(); byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes();

View File

@ -44,6 +44,12 @@ subprojects {
mavenCentral() mavenCentral()
} }
test {
testLogging {
exceptionFormat = 'full'
}
}
tasks.withType(Test) { tasks.withType(Test) {
useTestNG() { useTestNG() {
includeGroups = project.ext.includeGroups.split() includeGroups = project.ext.includeGroups.split()