Skip to content

Commit

Permalink
[#12] Setup basic Travis CI build
Browse files Browse the repository at this point in the history
  • Loading branch information
apldev3 committed Sep 26, 2018
1 parent 9731a78 commit f7c2275
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 16 deletions.
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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 --name=hirs hirs-centos7 /bin/bash -c "cd /root/HIRS; git checkout ${TRAVIS_BRANCH}; ./gradlew build; make -C tpm_module/"
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM centos:7.5.1804

MAINTAINER [email protected]

# 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import java.nio.file.Paths;
import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;

import org.bouncycastle.util.encoders.Base64;

import static org.testng.Assert.fail;
Expand Down Expand Up @@ -187,11 +189,12 @@ public final void parseValidPlatformCertificate3() throws IOException, URISyntax

PlatformCredential credential = new PlatformCredential(certPath);
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);
Assert.assertEquals(credential.getBeginValidity(), calendar.getTime());
calendar.set(2030, 11, 31, 18, 59, 59);
Assert.assertEquals(credential.getEndValidity(), calendar.getTime());
Assert.assertEquals(credential.getBeginValidity().getTime(), calendar.getTime().getTime());
calendar.set(2030, 11, 31, 23, 59, 59);
Assert.assertEquals(credential.getEndValidity().getTime(), calendar.getTime().getTime());

Assert.assertNotNull(credential.getAttributeCertificate());
byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes();
Expand Down Expand Up @@ -235,11 +238,12 @@ public final void parseValidPlatformCertificate4() throws IOException, URISyntax

PlatformCredential credential = new PlatformCredential(certPath);
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);
Assert.assertEquals(credential.getBeginValidity(), calendar.getTime());
calendar.set(2030, 11, 31, 18, 59, 59);
Assert.assertEquals(credential.getEndValidity(), calendar.getTime());
Assert.assertEquals(credential.getBeginValidity().getTime(), calendar.getTime().getTime());
calendar.set(2030, 11, 31, 23, 59, 59);
Assert.assertEquals(credential.getEndValidity().getTime(), calendar.getTime().getTime());

Assert.assertNotNull(credential.getAttributeCertificate());
byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes();
Expand Down Expand Up @@ -283,11 +287,12 @@ public final void parseValidPlatformCertificate5() throws IOException, URISyntax
PlatformCredential credential = new PlatformCredential(certPath);

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);
Assert.assertEquals(credential.getBeginValidity(), calendar.getTime());
calendar.set(2030, 11, 31, 18, 59, 59);
Assert.assertEquals(credential.getEndValidity(), calendar.getTime());
Assert.assertEquals(credential.getBeginValidity().getTime(), calendar.getTime().getTime());
calendar.set(2030, 11, 31, 23, 59, 59);
Assert.assertEquals(credential.getEndValidity().getTime(), calendar.getTime().getTime());

Assert.assertNotNull(credential.getAttributeCertificate());
byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes();
Expand Down Expand Up @@ -327,11 +332,12 @@ public final void parseValidPlatformCertificate6() throws IOException, URISyntax
PlatformCredential credential = new PlatformCredential(certPath);

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);
Assert.assertEquals(credential.getBeginValidity(), calendar.getTime());
calendar.set(2030, 11, 31, 18, 59, 59);
Assert.assertEquals(credential.getEndValidity(), calendar.getTime());
Assert.assertEquals(credential.getBeginValidity().getTime(), calendar.getTime().getTime());
calendar.set(2030, 11, 31, 23, 59, 59);
Assert.assertEquals(credential.getEndValidity().getTime(), calendar.getTime().getTime());

Assert.assertNotNull(credential.getAttributeCertificate());
byte[] sig = credential.getAttributeCertificate().getSignatureValue().getBytes();
Expand Down
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ subprojects {
mavenCentral()
}

test {
testLogging {
exceptionFormat = 'full'
}
}

tasks.withType(Test) {
useTestNG() {
includeGroups = project.ext.includeGroups.split()
Expand Down

0 comments on commit f7c2275

Please sign in to comment.