Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT MERGE #416

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ comment:
require_changes: no

ignore:
- "build"
- "deployment"
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
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
FROM kbase/sdkbase2 as build

COPY . /tmp/auth2
RUN cd /tmp \
&& git clone https://github.com/kbase/jars \
&& cd auth2 \
&& ant buildwar
RUN cd /tmp/auth2 && ./gradlew war

FROM kbase/kb_jre:latest

Expand All @@ -15,6 +12,8 @@ ARG BRANCH=develop

COPY --from=build /tmp/auth2/deployment/ /kb/deployment/
COPY --from=build /tmp/auth2/jettybase/ /kb/deployment/jettybase/
COPY --from=build /tmp/auth2/build/libs/auth2.war /kb/deployment/jettybase/webapps/ROOT.war
COPY --from=build /tmp/auth2/templates /kb/deployment/jettybase/templates

# The BUILD_DATE value seem to bust the docker cache when the timestamp changes, move to
# the end
Expand Down
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,24 +235,33 @@ Removes all test mode data from the system.
## Requirements

Java 8 (OpenJDK OK)
Apache Ant (http://ant.apache.org/)
MongoDB 2.6+ (https://www.mongodb.com/)
Jetty 9.3+ (http://www.eclipse.org/jetty/download.html)
(see jetty-config.md for version used for testing)
This repo (git clone https://github.com/kbase/auth2)
The jars repo (git clone https://github.com/kbase/jars)
The two repos above need to be in the same parent folder.

## To start server

start mongodb
if using mongo auth, create a mongo user
cd into the auth2 repo
`ant build`
copy `deploy.cfg.example` to `deploy.cfg` and fill in appropriately
`export KB_DEPLOYMENT_CONFIG=<path to deploy.cfg>`
`cd jettybase`
`./jettybase$ java -jar -Djetty.port=<port> <path to jetty install>/start.jar`
cd into the auth2 repo

```
./gradlew war
mkdir -p jettybase/webapps
cp build/libs/auth2.war jettybase/webapps/ROOT.war
cp templates jettybase/templates
```

copy `deploy.cfg.example` to `deploy.cfg` and fill in appropriately

```
export KB_DEPLOYMENT_CONFIG=<path to deploy.cfg>
cd jettybase
./jettybase$ java -jar -Djetty.port=<port> <path to jetty install>/start.jar
```

Or just use the Docker build, which is probably a lot easier.

## Administer the server

Expand Down
176 changes: 176 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
/*
* 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'
id 'org.ajoberstar.grgit' version '4.1.1'
}

repositories {
mavenCentral()
}

task getGitCommitId {
doLast {
def commitId = grgit.head().id
file('src/us/kbase/auth2/gitcommit').text = commitId
}
}

compileJava {
dependsOn getGitCommitId
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
}
}

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
*/
forkEvery = 1
/*
* 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
*/
systemProperty "AUTH2_TEST_CONFIG", "./test.cfg"
testLogging {
exceptionFormat = 'full'
showStandardStreams = true
}
finalizedBy jacocoTestReport
}

jacocoTestReport {
reports {
xml.required = true
csv.required = true
}
}

// TODO NOW javadocs
// TODO NOW run tests from Eclipse w/o specifying classpath manually
// TODO NOW make auth, test, and template jars
// TODO NOW make script
// TODO NOW test server starts in docker container, including templates when gradle done

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

war {
webXml = file('war/web.xml')
// For some reason the test directories are included in the war file
// although the files are gone. Not sure why
}

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
Loading