Skip to content

Commit

Permalink
Use published jars
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCreosote committed May 8, 2024
1 parent 45f065d commit 558aa15
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 276 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ jobs:
# move to parent dir of homedir to install binaries etc
cd ..
# set up jars
git clone https://github.com/kbase/jars
export JARSDIR=$(pwd)/jars/lib/jars/
# set up mongo
wget -q http://fastdl.mongodb.org/linux/${{matrix.mongo}}.tgz
tar xfz ${{matrix.mongo}}.tgz
Expand All @@ -61,7 +57,6 @@ jobs:
# set up test config
cd $HOMEDIR
cp -n test.cfg.example test.cfg
sed -i "s#^test.jars.dir.*#test.jars.dir=$JARSDIR#" test.cfg
sed -i "s#^test.temp.dir=.*#test.temp.dir=temp_test_dir#" test.cfg
sed -i "s#^test.mongo.exe.*#test.mongo.exe=$MONGOD#" test.cfg
sed -i "s#^test.mongo.useWiredTiger.*#test.mongo.useWiredTiger=${{matrix.wired_tiger}}#" test.cfg
Expand Down
54 changes: 31 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ plugins {

repositories {
mavenCentral()
maven {
name = "Jitpack"
url = 'https://jitpack.io'
}
maven {
name = "Clojars"
url = "https://repo.clojars.org/"
}
}

task buildGitCommitFile {
Expand Down Expand Up @@ -86,30 +94,29 @@ dependencies {

compileOnly 'javax.servlet:javax.servlet-api:3.0.1'

implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/auth/kbase-auth-0.4.4.jar',
'kbase-auth-0.4.4'
)
implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/workspace/WorkspaceClient-0.8.0.jar',
'WorkspaceClient-0.8.0'
)
implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/catalog/kbase-catalog-client-2.1.3.jar',
'kbase-catalog-client-2.1.3'
)
implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/common/kbase-common-0.0.25.jar',
'kbase-common-0.0.25'
)
// Pull from jars repo vs a maven repository to avoid the JNA dependency
// TODO DEPS 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'
)
// TODO DEPS 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 "org.syslog4j:syslog4j:0.9.46"
implementation 'ch.qos.logback:logback-classic:1.1.2'
implementation("com.github.kbase:auth2_client_java:0.5.0") {
exclude group: 'com.fasterxml.jackson.core' // breaks everything if we upgrade
}
implementation("com.github.kbase:java_common:0.3.0") {
exclude group: 'net.java.dev.jna' // breaks mac builds, not needed
exclude group: 'org.eclipse.jetty.aggregate' // ugh, java common pollutes everything
exclude group: 'com.fasterxml.jackson.core' // breaks everything if we upgrade
exclude group: 'javax.servlet', module: 'servlet-api' // 2.5 vs 3.0.1 above
}
implementation('com.github.kbase.workspace_deluxe:workspace-client:0.15.0') {
exclude group: 'net.java.dev.jna' // breaks mac builds, not needed
exclude group: 'org.eclipse.jetty.aggregate' // ugh, java common pollutes everything
exclude group: 'com.fasterxml.jackson.core' // breaks everything if we upgrade
exclude group: 'javax.servlet', module: 'servlet-api' // 2.5 vs 3.0.1 above
}
implementation 'org.ini4j:ini4j:0.5.2'
implementation 'org.mongodb:mongo-java-driver:3.8.2'
implementation 'org.apache.kafka:kafka-clients:2.1.0'
Expand All @@ -121,10 +128,11 @@ dependencies {
implementation 'org.glassfish.jersey.media:jersey-media-json-jackson:2.23.2'
implementation 'com.github.zafarkhaja:java-semver:0.9.0'

testImplementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/auth2/kbase-auth2-test-shadow-all-0.7.0.jar',
'kbase-auth2-test-shadow-all-0.7.0'
)
testImplementation "com.github.kbase:auth2:0.7.1"
testImplementation('com.github.kbase:java_test_utilities:0.1.0') {
exclude group: 'com.fasterxml.jackson.core' // breaks everything if we upgrade
}
testImplementation 'com.github.kbase.workspace_deluxe:workspace_deluxe-test-shadow-all:0.15.0'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.1.10'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:3.0.0'
Expand Down
30 changes: 11 additions & 19 deletions src/main/java/us/kbase/groups/userhandler/KBaseUserHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
import static com.google.common.base.Preconditions.checkNotNull;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;

import org.slf4j.LoggerFactory;

import us.kbase.auth.AuthConfig;
import us.kbase.auth.AuthException;
import us.kbase.auth.AuthToken;
import us.kbase.auth.ConfigurableAuthService;
import us.kbase.auth.client.AuthClient;
import us.kbase.groups.core.Token;
import us.kbase.groups.core.UserHandler;
import us.kbase.groups.core.UserName;
Expand All @@ -31,13 +29,9 @@ public class KBaseUserHandler implements UserHandler {

// TODO TEST

// note the configurable auth service handles its own caching.
// note the auth client handles its own caching.

private static final String GLOBUS_URL_SUFFIX = "api/legacy/globus";
private static final String KBASE_URL_SUFFIX = "api/legacy/KBase/Sessions/Login";

private final URI rootAuthURI;
private final ConfigurableAuthService auth;
private final AuthClient auth;
private final Token serviceToken;

/** Create the handler.
Expand All @@ -58,15 +52,14 @@ public KBaseUserHandler(
AuthenticationException {
checkNotNull(rootAuthURL, "rootAuthURL");
checkNotNull(serviceToken, "serviceToken");
if (rootAuthURL.toString().endsWith("/")) {
this.rootAuthURI = rootAuthURL.toURI();
} else {
this.rootAuthURI = new URL(rootAuthURL.toString() + "/").toURI();
try {
auth = AuthClient.from(rootAuthURL.toURI());
} catch (AuthException e) {
throw new AuthenticationException(

Check warning on line 58 in src/main/java/us/kbase/groups/userhandler/KBaseUserHandler.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/us/kbase/groups/userhandler/KBaseUserHandler.java#L57-L58

Added lines #L57 - L58 were not covered by tests
ErrorType.AUTHENTICATION_FAILED,
"Failed to contact the auth service: " + e.getMessage(),

Check warning on line 60 in src/main/java/us/kbase/groups/userhandler/KBaseUserHandler.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/us/kbase/groups/userhandler/KBaseUserHandler.java#L60

Added line #L60 was not covered by tests
e);
}
auth = new ConfigurableAuthService(new AuthConfig()
.withAllowInsecureURLs(allowInsecureURL)
.withKBaseAuthServerURL(this.rootAuthURI.resolve(KBASE_URL_SUFFIX).toURL())
.withGlobusAuthURL(this.rootAuthURI.resolve(GLOBUS_URL_SUFFIX).toURL()));
this.serviceToken = serviceToken;
getUser(this.serviceToken); // check token is valid
}
Expand Down Expand Up @@ -94,8 +87,7 @@ public boolean isValidUser(final UserName userName) throws AuthenticationExcepti
checkNotNull(userName, "userName");
try {
return auth.isValidUserName(
Arrays.asList(userName.getName()),
new AuthToken(serviceToken.getToken(), "fakeuser"))
Arrays.asList(userName.getName()), serviceToken.getToken())

Check warning on line 90 in src/main/java/us/kbase/groups/userhandler/KBaseUserHandler.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/us/kbase/groups/userhandler/KBaseUserHandler.java#L90

Added line #L90 was not covered by tests
.get(userName.getName());
} catch (IOException | AuthException e) {
LoggerFactory.getLogger(getClass()).error("Unexpected auth service response", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;

import us.kbase.common.test.controllers.mongo.MongoController;
import us.kbase.groups.core.resource.ResourceType;
import us.kbase.groups.storage.mongo.MongoGroupsStorage;
import us.kbase.testutils.controllers.mongo.MongoController;

public class MongoStorageTestManager {

Expand Down
8 changes: 1 addition & 7 deletions src/test/java/us/kbase/test/groups/TestCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.core.AppenderBase;
import us.kbase.common.test.TestException;
import us.kbase.testutils.TestException;

public class TestCommon {

public static final String MONGOEXE = "test.mongo.exe";
public static final String MONGO_USE_WIRED_TIGER = "test.mongo.wired_tiger";

public static final String JARS_PATH = "test.jars.dir";

public static final String TEST_TEMP_DIR = "test.temp.dir";
public static final String KEEP_TEMP_DIR = "test.temp.dir.keep";

Expand Down Expand Up @@ -171,10 +169,6 @@ public static Path getMongoExe() {
return Paths.get(getTestProperty(MONGOEXE)).toAbsolutePath().normalize();
}

public static Path getJarsDir() {
return Paths.get(getTestProperty(JARS_PATH)).toAbsolutePath().normalize();
}

public static Path getTempDir() {
return Paths.get(getTestProperty(TEST_TEMP_DIR)).toAbsolutePath().normalize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import us.kbase.catalog.ModuleVersionInfo;
import us.kbase.catalog.SelectOneModuleParams;
import us.kbase.common.service.JsonClientException;
import us.kbase.common.test.TestException;
import us.kbase.groups.cataloghandler.SDKClientCatalogHandler;
import us.kbase.groups.core.UserName;
import us.kbase.groups.core.exceptions.ResourceHandlerException;
Expand All @@ -43,6 +42,7 @@
import us.kbase.groups.core.resource.ResourceInformationSet;
import us.kbase.test.groups.MapBuilder;
import us.kbase.test.groups.TestCommon;
import us.kbase.testutils.TestException;

public class SDKClientCatalogHandlerTest {

Expand Down

This file was deleted.

Loading

0 comments on commit 558aa15

Please sign in to comment.