Skip to content

Commit

Permalink
Tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCreosote committed Jan 19, 2024
1 parent 7ac5999 commit aa25cfd
Show file tree
Hide file tree
Showing 7 changed files with 411 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

13 changes: 2 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ jobs:
auth2_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Note that there's a mongo-only ant test directive. Use that for all mongo versions
# except for one if there's > 1 mongo version to test. No need for testing code that
# doesn't touch mongo against multiple mongo versions
include:
- java: '8'
mongo: 'mongodb-linux-x86_64-ubuntu2204-7.0.4'
Expand All @@ -40,13 +38,6 @@ jobs:
distribution: 'temurin'
java-version: ${{matrix.java}}

- name: Clone jars as sister repo
shell: bash
run: |
cd ..
git clone https://github.com/kbase/jars
cd -
- name: Install mongo and set up test config
shell: bash
run: |
Expand All @@ -62,7 +53,7 @@ jobs:
cat test.cfg
- name: Run tests
run: ant test
run: ./gradlew test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
154 changes: 154 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/7.4.2/userguide/building_java_projects.html
*/

plugins {
id 'java'
id 'war'
id 'jacoco'
}

repositories {
mavenCentral()
}

compileJava {
if (JavaVersion.current() <= JavaVersion.VERSION_1_8) {
// TODO BUILD remove when we no longer support java 8
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8
} else {
options.release = 8
}
// TODO NOW build in git commit
// TODO NOW javadocs
}

test {
/*
* TODO TEST Figure out why tests fail without this and remove. Might have something to do
* with the stfuLoggers() call in many of the tests, might kill logging for tests that
* require it
* Although it seems to make Mongo start up correctly as well which is odd
*/
/*
* TODO TEST split tests into mongo wrapper tests & all other tests (incl. integration).
* Set up GHA to run the non-mongo tests with a single version of mongo and run the
* mong tests with matrixed mongo versions. Combine coverage at the end somehow
*/
forkEvery = 1
systemProperty "AUTH2_TEST_CONFIG", "./test.cfg"
testLogging {
exceptionFormat = 'full'
showStandardStreams = true
}
// TODO NOW coverage working?
}

// TODO NOW make auth, test, and template jars
// TODO NOW make script

// Custom java project layout
sourceSets {
main {
java {
srcDirs = ["src"]
exclude '**/test/**'
}
}
test {
java {
srcDirs = ["src"]
include '**/test/**'
}
resources {
srcDirs = ["src"]
include "**/*.testdata"
include "**/authjars"
}
}
}

war {
webXml = file('war/web.xml')
// TODO NOW GRADLE probably needs updates
}

def fromURL = { url, name ->
File file = new File("$buildDir/download/${name}.jar")
file.parentFile.mkdirs()
if (!file.exists()) {
new URL(url).withInputStream { downloadStream ->
file.withOutputStream { fileOut ->
fileOut << downloadStream
}
}
}
files(file.absolutePath)
}

dependencies {

// ### General application dependencies ###

implementation 'commons-codec:commons-codec:1.8'
implementation 'commons-validator:commons-validator:1.5.1'
implementation 'com.google.guava:guava:18.0'
implementation 'org.ini4j:ini4j:0.5.2'
implementation 'com.beust:jcommander:1.48'
implementation 'org.mongodb:mongodb-driver-core:4.11.1'
implementation 'org.mongodb:mongodb-driver-sync:4.11.1'
implementation 'org.mongodb:bson-record-codec:4.11.1'
implementation 'org.mongodb:bson:4.11.1'
implementation 'com.github.spullara.mustache.java:compiler:0.9.3'
implementation 'com.nulab-inc:zxcvbn:1.2.2'
implementation 'nl.basjes.parse.useragent:yauaa:1.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.5.4'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.5.4'
implementation 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.5.4'
implementation 'com.github.zafarkhaja:java-semver:0.9.0'
implementation 'org.glassfish.jersey.containers:jersey-container-servlet:2.23.2'
implementation 'org.glassfish.jersey.media:jersey-media-json-jackson:2.23.2'
implementation 'org.glassfish.jersey.ext:jersey-mvc-mustache:2.23.2'
implementation 'javax.persistence:persistence-api:1.0'
implementation 'javax.servlet:javax.servlet-api:3.0.1'
implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'


// ### Logging dependencies ###
implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/common/kbase-common-0.0.22.jar',
'kbase-common-0.0.22'
)
implementation 'ch.qos.logback:logback-classic:1.1.2'
implementation 'org.slf4j:slf4j-api:1.7.25'
// Syslog4j 0.9.46 doesn't appear to be available on Maven. It apparently lives in
// a JetBrains artifact server, but that's too much trouble and there's only one version there
// anyway.
// https://mvnrepository.com/artifact/org.jetbrains/syslog4j/0.9.46
// Need to rework the java common logger to not use syslog4j at all since it's abandonware
// and has a ton of CVEs, even in the newer versions.
implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/syslog4j/syslog4j-0.9.46.jar',
'syslog4j-0.9.46'
)
// needed for syslog
implementation 'net.java.dev.jna:jna:3.4.0'

// ### Test ###

testImplementation 'commons-io:commons-io:2.4'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.1.10'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mock-server:mockserver-netty:3.10.4'
testImplementation 'org.eclipse.jetty:jetty-server:9.3.11.v20160721'
testImplementation 'org.eclipse.jetty:jetty-servlet:9.3.11.v20160721'
testImplementation 'io.github.java-diff-utils:java-diff-utils:2.2.0'
testImplementation 'de.danielbechler:java-object-diff:0.94'
testImplementation 'org.jsoup:jsoup:1.10.2'
testImplementation 'org.mockito:mockito-core:3.0.0'
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit aa25cfd

Please sign in to comment.