diff --git a/.classpath b/.classpath deleted file mode 100644 index 1d5fa234..00000000 --- a/.classpath +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.codecov.yml b/.codecov.yml index 42c0d62b..b75b4f7a 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -26,5 +26,4 @@ comment: require_changes: no ignore: - - "build" - "deployment" diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..00a51aff --- /dev/null +++ b/.gitattributes @@ -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 + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1aee87ec..ce84ce6e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,13 +19,11 @@ 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-3.6.23' + mongo: 'mongodb-linux-x86_64-ubuntu2204-7.0.4' wired_tiger: 'false' - java: '11' mongo: 'mongodb-linux-x86_64-3.6.23' @@ -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: | @@ -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 diff --git a/Dockerfile b/Dockerfile index 82676aa7..90e65fea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,23 @@ FROM kbase/sdkbase2 as build -COPY . /tmp/auth2 -RUN cd /tmp \ - && git clone https://github.com/kbase/jars \ - && cd auth2 \ - && ant buildwar +WORKDIR /tmp/auth2 + +# dependencies take a while to D/L, so D/L & cache before the build so code changes don't cause +# a new D/L +# can't glob *gradle because of the .gradle dir +COPY build.gradle gradlew settings.gradle /tmp/auth2/ +COPY gradle/ /tmp/auth2/gradle/ +RUN ./gradlew dependencies + +# Now build the code +COPY deployment/ /tmp/auth2/deployment/ +COPY jettybase/ /tmp/auth2/jettybase/ +COPY src /tmp/auth2/src/ +COPY templates /tmp/auth2/templates/ +COPY war /tmp/auth2/war/ +# for the git commit +COPY .git /tmp/auth2/.git/ +RUN ./gradlew war FROM kbase/kb_jre:latest @@ -15,6 +28,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 @@ -28,6 +43,10 @@ LABEL org.label-schema.build-date=$BUILD_DATE \ WORKDIR /kb/deployment/jettybase ENV KB_DEPLOYMENT_CONFIG=/kb/deployment/conf/deployment.cfg +# TODO BUILD update to no longer use dockerize and take env vars (e.g. like Collections). +# TODO BUILD figure out how to add multiple environments as env vars (multiline env vars in rancher?) +# TODO BUILD Use subsections in the ini file / switch to TOML + ENTRYPOINT [ "/kb/deployment/bin/dockerize" ] # Here are some default params passed to dockerize. They would typically diff --git a/README.md b/README.md index b1f266cb..ec606e80 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,9 @@ the user. `DELETE /testmode/api/V2/testmodeonly/clear` Removes all test mode data from the system. -## Admin notes +## Administration + +### Notes * It is expected that this server always runs behind a reverse proxy (such as nginx) that enforces https / TLS and as such the auth server is configured to @@ -215,6 +217,9 @@ Removes all test mode data from the system. proxy_pass http://localhost:20002/; proxy_cookie_path /login /auth/login; proxy_cookie_path /link /auth/link; + + # If using alternate environments (see below) + add_header X-AUTH-ENV "environment_name"; } * Get Globus creds [here](https://developers.globus.org) @@ -224,47 +229,100 @@ Removes all test mode data from the system. * Get Google OAuth2 creds [here](https://console.developers.google.com/apis) * Get OrcID creds [here](https://orcid.org/content/register-client-application-0) * Note that only the public API has been tested with the auth server. + +#### Migration notes + +##### 0.6.0 + * In version 0.6.0, the canonicalization algorithm for user display names changed and the database needs to be updated. - * See the `--recanonicalize-display-names` option for the `manage_auth` script. This can + * See the `--recanonicalize-display-names` option for the `manage_auth` script + (See the administration section below). This can be run while the server is live **after** updating to version 0.6.0. * Once the names have been recanonicalized, the `--remove-recanonicalization-flag` can be used to remove flags set on database objects to avoid reprocessing if the recanonicalize process does not complete. -## Requirements +### Requirements + +* Java 8 (OpenJDK OK) +* MongoDB 2.6+ (https://www.mongodb.com/) +* Jetty 9.3+ (http://www.eclipse.org/jetty/download.html) +* This repo (git clone https://github.com/kbase/auth2) + +### Starting the server + +#### Docker -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. +The provided `Dockerfile` can be used to build and run an image. See the deployment template +in `deployment/conf/.templates` for the environment variables available to configure the +service - the `deploy.cfg.example` file provides documentation for these variables. -## To start server +`docker-compose --build -d` can be used to start a MongoDB instance and the auth server in +test mode (which can be configured via environment variables in the compose file). -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=` -`cd jettybase` -`./jettybase$ java -jar -Djetty.port= /start.jar` +#### Manually + +* Start mongodb +* If using mongo auth, create a mongo user +* `cd` into the auth2 repo + +```shell +./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 + +```shell +export KB_DEPLOYMENT_CONFIG= +cd jettybase +./jettybase$ java -jar -Djetty.port= /start.jar +``` -## Administer the server +### Perform initial setup + +Create the administration script: + +`./gradlew generateManageAuthScript` Set a root password: -`./manage_auth -d -r` +`build/manage_auth -d -r` + +* Note that the `deploy.cfg` file only needs accurate MongoDB connection information for use + with the auth CLI. Login to a local account as `***ROOT***` with the password you set. Create a local account and assign it the create administrator role. That account can then be used to create further administrators (including itself) without needing to login as root. The root account can then be disabled. -## Start & stop server w/o a pid +To set up alternate login / link environments, see [Environments](documentation/Environments.md). + +### Revoking tokens in an emergency + +The simple HTML only test UI included with the server supports most administration functions, +but revoking all tokens in the service is not included as it has a major impact on systems the +auth server supports, essentially shutting them down. If all tokens are revoked, the tokens for +every single token type (agent, service, etc.) for every single user in the auth system are +removed - the equivalent of clearing the tokens collection in MongoDB. + +This feature is intended to be used in an emergency such as many tokens becoming compromised or +the system needs to come to a near immediate halt (near immediate since services outside the auth +server may cache and accept tokens for some period of time after they're invalidated in auth). + +To revoke all tokens, issue the following request to the server (curl used as an example): + +``` +curl -X POST --cookie "kbase_session=" http:///admin/revokeall +``` + +If the `token-cookie-name` deployment configuration value is not `kbase_session` change +the request to match. + +### Start & stop server w/o a pid `./jettybase$ java -DSTOP.PORT=8079 -DSTOP.KEY=foo -jar ~/jetty/jetty-distribution-9.3.11.v20160721/start.jar` `./jettybase$ java -DSTOP.PORT=8079 -DSTOP.KEY=foo -jar ~/jetty/jetty-distribution-9.3.11.v20160721/start.jar --stop` @@ -286,14 +344,14 @@ Omit the stop key to have jetty generate one for you. * The master branch is the stable branch. Releases are made from the develop branch to the master branch. * Update the version as per the semantic version rules in - `src/us/kbase/auth2/service/common/ServiceCommon.java`. + `src/main/java/us/kbase/auth2/Version.java`. * Tag the version in git and github. ### Running tests * Copy `test.cfg.example` to `test.cfg` and fill in the values appropriately. * If it works as is start buying lottery tickets immediately. -* `ant test` +* `./gradlew test` ### UI diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index c27b795e..f1048bdc 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,15 @@ # Authentication Service MKII release notes +## 0.6.1 + +* Gradle has replaced Ant as the build tool. As a consequence, all the built artifacts + are now located in the `build` directory, including the `manage_auth` script. +* The MongoDB clients have been updated to the most recent version and the service tested + against Mongo 7. +* Added the ``mongo-retrywrites`` configuration setting in ``deploy.cfg``, defaulting to + ``false``. +* The docker-compose file has been updated to start an auth server in test mode. + ## 0.6.0 * ADMIN ACTION REQUIRED - after the server is upgraded, use the `manage_auth` script to diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..4fff21ec --- /dev/null +++ b/build.gradle @@ -0,0 +1,246 @@ +/* + * This file was generated by the Gradle 'init' task. + */ + +plugins { + id 'java' + id 'war' + id 'jacoco' + id 'org.ajoberstar.grgit' version '4.1.1' +} + +repositories { + mavenCentral() +} +// Warning - these values are hard coded in AuthController.java +def JAR_TEMPLATE_DIR = 'kbase_auth2_templates' +def TEMPLATE_LIST_FILE_NAME = "templates.manifest" + +task buildGitCommitFile { + doLast { + def commitId = grgit.head().id + // is there a variable for builddir/classes/java/main? + file("$buildDir/classes/java/main/us/kbase/auth2/gitcommit").text = commitId + } +} + +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 + } + finalizedBy buildGitCommitFile +} + +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 + * mongo tests with matrixed mongo versions. Combine coverage at the end somehow + */ + systemProperty "AUTH2_TEST_CONFIG", "./test.cfg" + testLogging { + exceptionFormat = 'full' + showStandardStreams = true + } + finalizedBy jacocoTestReport +} + +// TODO TEST add a test that starts the server in a docker container and checks some simple cmds + +jacocoTestReport { + reports { + xml.required = true + csv.required = true + } +} + +javadoc { + options { + links "https://mongodb.github.io/mongo-java-driver/4.11/apidocs/mongodb-driver-sync/" + // I don't know why this isn't working, but it's not worth spending time on right now + links "https://docs.oracle.com/javase/8/docs/api/" + } +} + +war { + webXml = file('war/web.xml') +} + +configurations { + // can't directly access testImplementation, so extend and access + testimpl.extendsFrom testImplementation +} + +task generateTemplateFileList { + doLast { + File directory = file('templates') + + // List files in the directory + def files = fileTree(dir: directory).files.collect { it.name } + + File outputFile = file("$buildDir/" + TEMPLATE_LIST_FILE_NAME) + outputFile.text = files.join('\n') + } +} + + +task fatTestJar(type: Jar) { + // Be careful when updating jars - you may want to set the duplicates strategy to WARN + // to see if any of the jars are shadowing the others when building the fat jar, which + // has been the case in the past + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + dependsOn generateTemplateFileList + archiveAppendix = 'test-fat' + + // include source files + from sourceSets.test.output + + // include all jars + from { + configurations.testimpl.collect { it.isDirectory() ? it : zipTree(it) } + } + + // Include text files from the "templates" directory + from('templates') { into JAR_TEMPLATE_DIR } + from("$buildDir/" + TEMPLATE_LIST_FILE_NAME) { into JAR_TEMPLATE_DIR } + + with jar +} + +task generateManageAuthScript { + dependsOn compileJava + doLast { + def dependencies = configurations.runtimeClasspath.collect { File file -> + file.absolutePath + } + + def classpath = dependencies.join(':') + + def scriptContent = """#!/bin/sh + +CLASSPATH=$classpath + +java -cp build/classes/java/main:\$CLASSPATH us.kbase.auth2.cli.AuthCLI \$@ +""" + + file("$buildDir/manage_auth").text = scriptContent + file("$buildDir/manage_auth").setExecutable(true) + } +} + +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 ### + + /* Notes on exclusions: + * Bizarrely, the glassfish verison of inject has a dependency on v1 inject, which + * causes problems when trying to build the fat jar + * There are other spots in the dependency tree where v1 inject exists as well, and + * collides with the newer version. + * Inject v1 has the exact same directories and classes as the 2.5.0-b05 and so is + * shadowed in any case, so removal is presumably safe since the tests pass. + */ + + 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') { + exclude group: 'javax.inject', module: 'javax.inject' + } + implementation('org.glassfish.jersey.media:jersey-media-json-jackson:2.23.2') { + exclude group: 'javax.inject', module: 'javax.inject' + } + implementation('org.glassfish.jersey.ext:jersey-mvc-mustache:2.23.2') { + exclude group: 'javax.inject', module: 'javax.inject' + // The servlet namespace changed between 2.4 and 3.X, and so we need to exclude the + // 2.4 namespace to avoid collisions. 3.X is backwards compatible: + // https://docs.oracle.com/cd/E19798-01/821-1752/beagj/index.html + exclude group: 'javax.servlet', module: 'servlet-api' + } + implementation 'javax.persistence:persistence-api:1.0' + implementation 'javax.servlet:javax.servlet-api:3.1.0' + 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.2.0.jar', + 'kbase-common-0.2.0' + ) + 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 syslog4j + implementation 'net.java.dev.jna:jna:3.4.0' + implementation 'joda-time:joda-time:2.3' + + // ### 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') { + exclude group: 'javax.inject', module: 'javax.inject' + // uses an old version of the activation api in a different namespace, so exclude it + // in favor of the new one which is a transitive dependency elsewhere + exclude group: 'javax.activation', module: 'activation' + } + 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' +} + +task showTestClassPath { + doLast { + configurations.testimpl.each { println it } + } +} diff --git a/build.xml b/build.xml deleted file mode 100644 index 659d03d2..00000000 --- a/build.xml +++ /dev/null @@ -1,436 +0,0 @@ - - - - Build file for the second KBase Authentication Service - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Classpath is ${classpathInName} - - - - - Classpath is ${classpathInName} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #!/bin/sh -java -cp ${dist}/${jar.file}:${lib.classpath} us.kbase.auth2.cli.AuthCLI $@ - - - - - - - - - - - - diff --git a/deploy.cfg.example b/deploy.cfg.example index 2657d40c..c41f6350 100644 --- a/deploy.cfg.example +++ b/deploy.cfg.example @@ -9,6 +9,9 @@ mongo-host = # The name of the mongo database to be used as auth storage. mongo-db = +# Whether to enable ('true') the MongoDB retryWrites parameter or not (anything other than 'true'). +# See https://www.mongodb.com/docs/manual/core/retryable-writes/ +mongo-retrywrites = false # If the mongo database is authenticated, the user name of a read/write account. mongo-user = # If the mongo data base is authenticated, the password for the given username. diff --git a/deployment/conf/.templates/deployment.cfg.templ b/deployment/conf/.templates/deployment.cfg.templ index fe2f4b90..6a90b1d9 100644 --- a/deployment/conf/.templates/deployment.cfg.templ +++ b/deployment/conf/.templates/deployment.cfg.templ @@ -1,6 +1,7 @@ [authserv2] mongo-host={{ default .Env.mongo_host "ci-mongo" }} mongo-db={{ default .Env.mongo_db "auth2" }} +mongo-retrywrites={{ default .Env.mongo_retrywrites "false" }} mongo-user={{ default .Env.mongo_user "" }} mongo-pwd={{ default .Env.mongo_pwd "" }} # The name of the cookie in which tokens should be stored in the browser. diff --git a/docker-compose.yml b/docker-compose.yml index e090887c..1e3187a1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,16 +5,18 @@ version: "3.1" # that is started up and polled services: auth2: - image: kbase/kb_auth2:latest + build: + context: . + dockerfile: Dockerfile ports: - "8080:8080" environment: - - KB_DEPLOYMENT_CONFIG=/kb/deployment/conf/deployment.cfg + mongo_host: "mongo:27017" + test_mode_enabled: "true" + identity_providers: "" command: - "-wait" - - "tcp://ci-mongo:27017" - - "-wait" - - "tcp://mongoinit:8080" + - "tcp://mongo:27017" - "-timeout" - "120s" - "-template" @@ -35,28 +37,10 @@ services: # you can add the following flag: # - "-validateCert=false" - "/kb/deployment/bin/start_auth2.sh" - depends_on: ["ci-mongo", "mongoinit"] + depends_on: ["mongo"] - mongoinit: - image: kbase/db_initialize:latest - volumes: - - ./auth2.mongodump:/mnt/auth2.mongodump - entrypoint: - - "/kb/deployment/bin/dockerize.sh" - - "-wait" - - "tcp://ci-mongo:27017" - - "-timeout" - - "120s" - - "mongorestore" - - "--host" - - "ci-mongo" - - "/mnt/auth2.mongodump" - depends_on: [ "ci-mongo" ] - - ci-mongo: - image: mongo:2 - command: - - "--smallfiles" + mongo: + image: mongo:7 ports: - "27017:27017" diff --git a/documentation/Environments.md b/documentation/Environments.md new file mode 100644 index 00000000..62ad9326 --- /dev/null +++ b/documentation/Environments.md @@ -0,0 +1,70 @@ +# Authentication service environments + +The auth service can support multiple environments, allowing it to service multiple domains - +for a KBase example, `narrative.kbase.us`, `appdev.kbase.us`, and `narrative-dev.kbase.us` +are all served by the same auth service. This allows sharing user accounts and tokens between +environments and deploying alternate versions of UIs running on the same backend. + +Alternate environments only affect the account login and linking flows and are otherwise +not relevant to the auth system once a login or account link is complete. For example, +a service contacting the auth service to validate a login token does not need to concern +itself about which environment was used to create the token, and the auth service itself +does not record any information about which environment was used to create a login +token or link an account. + +## Recommendations + +* When using multiple environments, it may be wise to clear the default environment and use + alternate environments for all the environments. This makes it less likely that a + misconfiguration could cause an alternate environment to use settings from the default + environment mistakenly. + +## Setup + +There are several steps to setting up an environment. The following steps assume the the default +or standard environment is `host1.org` and is properly configured in the auth service and +3rd party identity providers (IDPs). The new environment is assumed to be served at `host2.org`. +The environment names, respectively, will be `host1` and `host2`. + +* The login and link redirect URLs for `host2` must be registered with each IDP. + * They are usually going to be the same as the redirect URLs for `host1` with the replacement + of `host1.org` with `host2.org`. However, if URLs are rewritten by the reverse proxy in + a different manner between `host1` and `host2` that must be taken into account. +* The login and link redirect URLs must be added to the `deploy.cfg` file as described in + `deploy.cfg.example`. If using the Docker image, they need to be added to the environment + in the `env1` and `auth_base_url_env1` keys or the `additional_config` key. + * For example: + +``` +identity-provider-Google-env-host2-login-redirect-url=https://host2.org/auth/login/complete/google +identity-provider-Google-env-host2-link-redirect-url=https://host2.org/auth/link/complete/google +``` + +* The new environment must be activated in the `deploy.cfg` file, either directly or via + environment variable if using Docker: + +``` +identity-provider-envs=, host2 +``` + +* On login or linking requests, the auth server must know which environment to use. There are two + options for providing this information: + * Send a header to the auth server defining the environment. The name of the header is + defined in the `deploy.cfg` `environment-header` key. For example, if the environment + header was set to `X-AUTH-ENV` the auth service would receive requests with the header + `X-AUTH-ENV: host2` in order to set the environment to `host2`. This is the simplest + and preferred approach, as it generally only needs a one line addition to the reverse + proxy configuration for the host, at which point all requests to the auth service get the + environment header. + * The UI code can specify the environment when contacting the auth2 service to start a login or + link flow via the `environment` form parameter. This requires the UI code to be + environment aware which is generally held to be undesired. +* Once the previous steps have been completed the service can be restarted with the updated + configuration. +* The final step requires an admin to go to the `/admin/config` endpoint of the auth server. + The new environment should now be visible in the configuration. While the IDP relevant + configuration is all specified in the `deploy.cfg` file to avoid passing secrets over the API + and to locate cohesive configuration elements together, the host side configuration is + updateable on the fly via the API. The redirect URLs for login and linking must be updated + appropriately for the host. In many cases, this will be simply replacing `host1.org` with + `host2.org` but see the previously mentioned caveats regarding updating the URLs. diff --git a/documentation/recovering_lost_account_due_to_email_provider_change.md b/documentation/recovering_lost_account_due_to_email_provider_change.md index 54325eb2..e63dff47 100644 --- a/documentation/recovering_lost_account_due_to_email_provider_change.md +++ b/documentation/recovering_lost_account_due_to_email_provider_change.md @@ -101,7 +101,7 @@ should be impossible. 1. Add an option to the Auth command line tool to add identities to users to avoid incorrect DB updates. The CLI could, when possible, query the identity provider to ensure the information - provided command line is correct or pull additional information from the provider. + provided on the command line is correct or pull additional information from the provider. 2. Develop procedures for verifying a user's possession of an account and transferring trusted information needed to restore access to an account. 3. Develop and deploy user documentation recommending that users always have at least one diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..41d9927a Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..a5952066 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew new file mode 100755 index 00000000..1b6c7873 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/jetty-config.md b/jetty-config.md deleted file mode 100644 index e0c5a5bf..00000000 --- a/jetty-config.md +++ /dev/null @@ -1,67 +0,0 @@ - -Java Environment: ------------------ - java.home = /usr/lib/jvm/java-8-openjdk-amd64/jre - java.vm.vendor = Oracle Corporation - java.vm.version = 25.91-b14 - java.vm.name = OpenJDK 64-Bit Server VM - java.vm.info = mixed mode - java.runtime.name = OpenJDK Runtime Environment - java.runtime.version = 1.8.0_91-8u91-b14-0ubuntu4~14.04-b14 - java.io.tmpdir = /tmp - user.dir = *snip*/jettybase - user.language = en - user.country = US - -Jetty Environment: ------------------ - jetty.version = 9.3.11.v20160721 - jetty.tag.version = master - jetty.home = *snip*/jetty/jetty-distribution-9.3.11.v20160721 - jetty.base = *snip*/jettybase - -Config Search Order: --------------------- - - ${jetty.base} -> *snip*/jettybase - ${jetty.home} -> *snip*/jetty/jetty-distribution-9.3.11.v20160721 - - -JVM Arguments: --------------- - (no jvm args specified) - -System Properties: ------------------- - (no system properties specified) - -Properties: ------------ - java.version = 1.8.0_91 - java.version.major = 1 - java.version.minor = 8 - java.version.revision = 0 - java.version.update = 91 - -Jetty Server Classpath: ------------------------ -Version Information on 11 entries in the classpath. -Note: order presented here is how they would appear on the classpath. - changes to the --module=name command line options will be reflected here. - 0: 3.1.0 | ${jetty.home}/lib/servlet-api-3.1.jar - 1: 3.1.0.M0 | ${jetty.home}/lib/jetty-schemas-3.1.jar - 2: 9.3.11.v20160721 | ${jetty.home}/lib/jetty-http-9.3.11.v20160721.jar - 3: 9.3.11.v20160721 | ${jetty.home}/lib/jetty-server-9.3.11.v20160721.jar - 4: 9.3.11.v20160721 | ${jetty.home}/lib/jetty-xml-9.3.11.v20160721.jar - 5: 9.3.11.v20160721 | ${jetty.home}/lib/jetty-util-9.3.11.v20160721.jar - 6: 9.3.11.v20160721 | ${jetty.home}/lib/jetty-io-9.3.11.v20160721.jar - 7: 9.3.11.v20160721 | ${jetty.home}/lib/jetty-security-9.3.11.v20160721.jar - 8: 9.3.11.v20160721 | ${jetty.home}/lib/jetty-servlet-9.3.11.v20160721.jar - 9: 9.3.11.v20160721 | ${jetty.home}/lib/jetty-webapp-9.3.11.v20160721.jar -10: 9.3.11.v20160721 | ${jetty.home}/lib/jetty-deploy-9.3.11.v20160721.jar - -Jetty Active XMLs: ------------------- - ${jetty.home}/etc/jetty.xml - ${jetty.home}/etc/jetty-http.xml - ${jetty.home}/etc/jetty-deploy.xml diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..8a19017a --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/7.4.2/userguide/multi_project_builds.html + */ + +rootProject.name = 'auth2' diff --git a/src/us/kbase/auth2/GitCommit.java b/src/main/java/us/kbase/auth2/GitCommit.java similarity index 100% rename from src/us/kbase/auth2/GitCommit.java rename to src/main/java/us/kbase/auth2/GitCommit.java diff --git a/src/us/kbase/auth2/Version.java b/src/main/java/us/kbase/auth2/Version.java similarity index 76% rename from src/us/kbase/auth2/Version.java rename to src/main/java/us/kbase/auth2/Version.java index 67d4f7bb..ef29049f 100644 --- a/src/us/kbase/auth2/Version.java +++ b/src/main/java/us/kbase/auth2/Version.java @@ -5,6 +5,6 @@ public class Version { /** The version of the KBase Auth2 service. */ - public static final String VERSION = "0.6.0"; + public static final String VERSION = "0.6.1"; } diff --git a/src/us/kbase/auth2/cli/AuthCLI.java b/src/main/java/us/kbase/auth2/cli/AuthCLI.java similarity index 100% rename from src/us/kbase/auth2/cli/AuthCLI.java rename to src/main/java/us/kbase/auth2/cli/AuthCLI.java diff --git a/src/us/kbase/auth2/cli/package-info.java b/src/main/java/us/kbase/auth2/cli/package-info.java similarity index 100% rename from src/us/kbase/auth2/cli/package-info.java rename to src/main/java/us/kbase/auth2/cli/package-info.java diff --git a/src/us/kbase/auth2/cryptutils/PasswordCrypt.java b/src/main/java/us/kbase/auth2/cryptutils/PasswordCrypt.java similarity index 100% rename from src/us/kbase/auth2/cryptutils/PasswordCrypt.java rename to src/main/java/us/kbase/auth2/cryptutils/PasswordCrypt.java diff --git a/src/us/kbase/auth2/cryptutils/RandomDataGenerator.java b/src/main/java/us/kbase/auth2/cryptutils/RandomDataGenerator.java similarity index 100% rename from src/us/kbase/auth2/cryptutils/RandomDataGenerator.java rename to src/main/java/us/kbase/auth2/cryptutils/RandomDataGenerator.java diff --git a/src/us/kbase/auth2/cryptutils/SHA1RandomDataGenerator.java b/src/main/java/us/kbase/auth2/cryptutils/SHA1RandomDataGenerator.java similarity index 100% rename from src/us/kbase/auth2/cryptutils/SHA1RandomDataGenerator.java rename to src/main/java/us/kbase/auth2/cryptutils/SHA1RandomDataGenerator.java diff --git a/src/us/kbase/auth2/kbase/KBaseAuthConfig.java b/src/main/java/us/kbase/auth2/kbase/KBaseAuthConfig.java similarity index 97% rename from src/us/kbase/auth2/kbase/KBaseAuthConfig.java rename to src/main/java/us/kbase/auth2/kbase/KBaseAuthConfig.java index 218c9020..81e709c8 100644 --- a/src/us/kbase/auth2/kbase/KBaseAuthConfig.java +++ b/src/main/java/us/kbase/auth2/kbase/KBaseAuthConfig.java @@ -41,6 +41,7 @@ public class KBaseAuthConfig implements AuthStartupConfig { private static final String KEY_LOG_NAME = "log-name"; private static final String KEY_MONGO_HOST = "mongo-host"; private static final String KEY_MONGO_DB = "mongo-db"; + private static final String KEY_MONGO_RETRY_WRITES = "mongo-retrywrites"; private static final String KEY_MONGO_USER = "mongo-user"; private static final String KEY_MONGO_PWD = "mongo-pwd"; private static final String KEY_COOKIE_NAME = "token-cookie-name"; @@ -68,6 +69,7 @@ public class KBaseAuthConfig implements AuthStartupConfig { private final SLF4JAutoLogger logger; private final String mongoHost; private final String mongoDB; + private final boolean mongoRetryWrites; private final Optional mongoUser; private final Optional mongoPwd; private final String cookieName; @@ -98,6 +100,7 @@ public KBaseAuthConfig(final Path filepath, final boolean nullLogger) templateDir = Paths.get(getString(KEY_TEMPLATE_DIR, cfg, true)); mongoHost = getString(KEY_MONGO_HOST, cfg, true); mongoDB = getString(KEY_MONGO_DB, cfg, true); + mongoRetryWrites = TRUE.equals(getString(KEY_MONGO_RETRY_WRITES, cfg)); mongoUser = Optional.ofNullable(getString(KEY_MONGO_USER, cfg)); Optional mongop = Optional.ofNullable(getString(KEY_MONGO_PWD, cfg)); if (mongoUser.isPresent() ^ mongop.isPresent()) { @@ -342,6 +345,11 @@ public String getMongoDatabase() { return mongoDB; } + @Override + public boolean getMongoRetryWrites() { + return mongoRetryWrites; + } + @Override public Optional getMongoUser() { return mongoUser; diff --git a/src/us/kbase/auth2/lib/Authentication.java b/src/main/java/us/kbase/auth2/lib/Authentication.java similarity index 99% rename from src/us/kbase/auth2/lib/Authentication.java rename to src/main/java/us/kbase/auth2/lib/Authentication.java index 59b5104b..93ba621d 100644 --- a/src/us/kbase/auth2/lib/Authentication.java +++ b/src/main/java/us/kbase/auth2/lib/Authentication.java @@ -1659,7 +1659,7 @@ private IdentityProvider getIdentityProvider(final String provider) /** Start the OAuth2 login process. * @param lifetimeSec the lifetime of the temporary token to be returned. * @param provider the name of the 3rd party identity provider to login with. - * @param string the auth environment in which the login is taking place, or null for the + * @param environment the auth environment in which the login is taking place, or null for the * default environment. * @return data to start the login process. * @throws AuthStorageException if an error occurs accessing the storage system. @@ -1718,7 +1718,7 @@ private String generatePKCECodeChallenge(final String codeVerifier) { * @return A login token. In this case the token will always be a temporary token so the * control flow can be returned to the UI before returning an error. * @throws AuthStorageException if an error occurred accessing the storage system. - * @see #login(String, String, String, TokenCreationContext) + * @see #login(IncomingToken, String, String, String, TokenCreationContext, String) */ public LoginToken loginProviderError(final String providerError) throws AuthStorageException { checkStringNoCheckedException(providerError, "providerError"); @@ -1845,7 +1845,7 @@ private TemporaryToken storeTemporarySessionData(final TemporarySessionData data /** Get the current state of a login process associated with a temporary token. * This method is expected to be called after - * {@link #login(String, String, String, TokenCreationContext)}. + * {@link #login(IncomingToken, String, String, String, TokenCreationContext, String)}. * After user interaction is completed, a new user can be created via * {@link #createUser(IncomingToken, String, UserName, DisplayName, EmailAddress, Set, TokenCreationContext, boolean)} * or the login can complete via @@ -2433,7 +2433,7 @@ public OAuth2StartData linkStart( * @param providerError the error returned by the provider. * @return A temporary token. * @throws AuthStorageException if an error occurred accessing the storage system. - * @see #linkStart(IncomingToken, int) + * @see #link(IncomingToken, String, String, String, String) */ public TemporaryToken linkProviderError(final String providerError) throws AuthStorageException { @@ -2476,7 +2476,7 @@ private TemporaryToken storeErrorTemporarily( * to a new URL that does not contain said authcode as soon as possible. * * @param token the user's temporary token acquired from - * {@link #linkStart(IncomingToken, int)}. + * {@link #linkStart(IncomingToken, int, String, String)} * @param provider the name of the identity provider that is servicing the link request. * @param authcode the authcode provided by the provider. * @param environment the environment in which the link request is proceeding. Null for the @@ -2604,7 +2604,7 @@ private void filterLinkCandidates(final Set rids) /** Get the current state of a linking process associated with a temporary token. * This method is expected to be called after - * {@link #link(IncomingToken, String, String, String)}. + * {@link #link(IncomingToken, String, String, String, String)}. * After user interaction is completed, the link can be completed by calling * {@link #link(IncomingToken, IncomingToken, String)} or * {@link #linkAll(IncomingToken, IncomingToken)}. diff --git a/src/us/kbase/auth2/lib/CustomRole.java b/src/main/java/us/kbase/auth2/lib/CustomRole.java similarity index 100% rename from src/us/kbase/auth2/lib/CustomRole.java rename to src/main/java/us/kbase/auth2/lib/CustomRole.java diff --git a/src/us/kbase/auth2/lib/DisplayName.java b/src/main/java/us/kbase/auth2/lib/DisplayName.java similarity index 98% rename from src/us/kbase/auth2/lib/DisplayName.java rename to src/main/java/us/kbase/auth2/lib/DisplayName.java index 69b8f4fe..a6e3e4eb 100644 --- a/src/us/kbase/auth2/lib/DisplayName.java +++ b/src/main/java/us/kbase/auth2/lib/DisplayName.java @@ -34,6 +34,7 @@ public DisplayName(final String name) /** Get the canonical display name for a string. Returns a list of the whitespace and hyphen * separated tokens in the name. The tokens are lowercased, punctuation in the token is * removed, and non-unique elements are removed. + * @param name the string to analyze. * @return the canonical display name. */ public static List getCanonicalDisplayName(final String name) { diff --git a/src/us/kbase/auth2/lib/EmailAddress.java b/src/main/java/us/kbase/auth2/lib/EmailAddress.java similarity index 100% rename from src/us/kbase/auth2/lib/EmailAddress.java rename to src/main/java/us/kbase/auth2/lib/EmailAddress.java diff --git a/src/us/kbase/auth2/lib/LinkIdentities.java b/src/main/java/us/kbase/auth2/lib/LinkIdentities.java similarity index 100% rename from src/us/kbase/auth2/lib/LinkIdentities.java rename to src/main/java/us/kbase/auth2/lib/LinkIdentities.java diff --git a/src/us/kbase/auth2/lib/LinkToken.java b/src/main/java/us/kbase/auth2/lib/LinkToken.java similarity index 100% rename from src/us/kbase/auth2/lib/LinkToken.java rename to src/main/java/us/kbase/auth2/lib/LinkToken.java diff --git a/src/us/kbase/auth2/lib/LocalLoginResult.java b/src/main/java/us/kbase/auth2/lib/LocalLoginResult.java similarity index 100% rename from src/us/kbase/auth2/lib/LocalLoginResult.java rename to src/main/java/us/kbase/auth2/lib/LocalLoginResult.java diff --git a/src/us/kbase/auth2/lib/LoginState.java b/src/main/java/us/kbase/auth2/lib/LoginState.java similarity index 100% rename from src/us/kbase/auth2/lib/LoginState.java rename to src/main/java/us/kbase/auth2/lib/LoginState.java diff --git a/src/us/kbase/auth2/lib/LoginToken.java b/src/main/java/us/kbase/auth2/lib/LoginToken.java similarity index 100% rename from src/us/kbase/auth2/lib/LoginToken.java rename to src/main/java/us/kbase/auth2/lib/LoginToken.java diff --git a/src/us/kbase/auth2/lib/Name.java b/src/main/java/us/kbase/auth2/lib/Name.java similarity index 100% rename from src/us/kbase/auth2/lib/Name.java rename to src/main/java/us/kbase/auth2/lib/Name.java diff --git a/src/us/kbase/auth2/lib/OAuth2StartData.java b/src/main/java/us/kbase/auth2/lib/OAuth2StartData.java similarity index 98% rename from src/us/kbase/auth2/lib/OAuth2StartData.java rename to src/main/java/us/kbase/auth2/lib/OAuth2StartData.java index 43f30389..8973a285 100644 --- a/src/us/kbase/auth2/lib/OAuth2StartData.java +++ b/src/main/java/us/kbase/auth2/lib/OAuth2StartData.java @@ -24,6 +24,7 @@ private OAuth2StartData(final URI redirectURI, final TemporaryToken temporaryTok /** Create the OAuth data. * @param redirectURI the 3rd party redirect URI. * @param tempToken the temporary token to provide to the user to track them through the flow. + * @return the OAuth2 data. */ public static OAuth2StartData build(final URI redirectURI, final TemporaryToken tempToken) { return new OAuth2StartData(redirectURI, tempToken); diff --git a/src/us/kbase/auth2/lib/Password.java b/src/main/java/us/kbase/auth2/lib/Password.java similarity index 100% rename from src/us/kbase/auth2/lib/Password.java rename to src/main/java/us/kbase/auth2/lib/Password.java diff --git a/src/us/kbase/auth2/lib/PasswordHashAndSalt.java b/src/main/java/us/kbase/auth2/lib/PasswordHashAndSalt.java similarity index 100% rename from src/us/kbase/auth2/lib/PasswordHashAndSalt.java rename to src/main/java/us/kbase/auth2/lib/PasswordHashAndSalt.java diff --git a/src/us/kbase/auth2/lib/PolicyID.java b/src/main/java/us/kbase/auth2/lib/PolicyID.java similarity index 100% rename from src/us/kbase/auth2/lib/PolicyID.java rename to src/main/java/us/kbase/auth2/lib/PolicyID.java diff --git a/src/us/kbase/auth2/lib/Role.java b/src/main/java/us/kbase/auth2/lib/Role.java similarity index 100% rename from src/us/kbase/auth2/lib/Role.java rename to src/main/java/us/kbase/auth2/lib/Role.java diff --git a/src/us/kbase/auth2/lib/TemporarySessionData.java b/src/main/java/us/kbase/auth2/lib/TemporarySessionData.java similarity index 100% rename from src/us/kbase/auth2/lib/TemporarySessionData.java rename to src/main/java/us/kbase/auth2/lib/TemporarySessionData.java diff --git a/src/us/kbase/auth2/lib/TokenCreationContext.java b/src/main/java/us/kbase/auth2/lib/TokenCreationContext.java similarity index 100% rename from src/us/kbase/auth2/lib/TokenCreationContext.java rename to src/main/java/us/kbase/auth2/lib/TokenCreationContext.java diff --git a/src/us/kbase/auth2/lib/UserDisabledState.java b/src/main/java/us/kbase/auth2/lib/UserDisabledState.java similarity index 100% rename from src/us/kbase/auth2/lib/UserDisabledState.java rename to src/main/java/us/kbase/auth2/lib/UserDisabledState.java diff --git a/src/us/kbase/auth2/lib/UserName.java b/src/main/java/us/kbase/auth2/lib/UserName.java similarity index 100% rename from src/us/kbase/auth2/lib/UserName.java rename to src/main/java/us/kbase/auth2/lib/UserName.java diff --git a/src/us/kbase/auth2/lib/UserSearchSpec.java b/src/main/java/us/kbase/auth2/lib/UserSearchSpec.java similarity index 99% rename from src/us/kbase/auth2/lib/UserSearchSpec.java rename to src/main/java/us/kbase/auth2/lib/UserSearchSpec.java index deaa5ca3..613fe483 100644 --- a/src/us/kbase/auth2/lib/UserSearchSpec.java +++ b/src/main/java/us/kbase/auth2/lib/UserSearchSpec.java @@ -77,7 +77,7 @@ public boolean hasSearchRegex() { } /** Returns true if the search prefixes are set. This means the search regex is not set. - * @ return true if the search prefixes are set. + * @return true if the search prefixes are set. */ public boolean hasSearchPrefixes() { return prefixes != null; diff --git a/src/us/kbase/auth2/lib/UserUpdate.java b/src/main/java/us/kbase/auth2/lib/UserUpdate.java similarity index 100% rename from src/us/kbase/auth2/lib/UserUpdate.java rename to src/main/java/us/kbase/auth2/lib/UserUpdate.java diff --git a/src/us/kbase/auth2/lib/Utils.java b/src/main/java/us/kbase/auth2/lib/Utils.java similarity index 100% rename from src/us/kbase/auth2/lib/Utils.java rename to src/main/java/us/kbase/auth2/lib/Utils.java diff --git a/src/us/kbase/auth2/lib/ViewableUser.java b/src/main/java/us/kbase/auth2/lib/ViewableUser.java similarity index 100% rename from src/us/kbase/auth2/lib/ViewableUser.java rename to src/main/java/us/kbase/auth2/lib/ViewableUser.java diff --git a/src/us/kbase/auth2/lib/config/AuthConfig.java b/src/main/java/us/kbase/auth2/lib/config/AuthConfig.java similarity index 100% rename from src/us/kbase/auth2/lib/config/AuthConfig.java rename to src/main/java/us/kbase/auth2/lib/config/AuthConfig.java diff --git a/src/us/kbase/auth2/lib/config/AuthConfigSet.java b/src/main/java/us/kbase/auth2/lib/config/AuthConfigSet.java similarity index 100% rename from src/us/kbase/auth2/lib/config/AuthConfigSet.java rename to src/main/java/us/kbase/auth2/lib/config/AuthConfigSet.java diff --git a/src/us/kbase/auth2/lib/config/AuthConfigSetWithUpdateTime.java b/src/main/java/us/kbase/auth2/lib/config/AuthConfigSetWithUpdateTime.java similarity index 100% rename from src/us/kbase/auth2/lib/config/AuthConfigSetWithUpdateTime.java rename to src/main/java/us/kbase/auth2/lib/config/AuthConfigSetWithUpdateTime.java diff --git a/src/us/kbase/auth2/lib/config/AuthConfigUpdate.java b/src/main/java/us/kbase/auth2/lib/config/AuthConfigUpdate.java similarity index 100% rename from src/us/kbase/auth2/lib/config/AuthConfigUpdate.java rename to src/main/java/us/kbase/auth2/lib/config/AuthConfigUpdate.java diff --git a/src/us/kbase/auth2/lib/config/CollectingExternalConfig.java b/src/main/java/us/kbase/auth2/lib/config/CollectingExternalConfig.java similarity index 100% rename from src/us/kbase/auth2/lib/config/CollectingExternalConfig.java rename to src/main/java/us/kbase/auth2/lib/config/CollectingExternalConfig.java diff --git a/src/us/kbase/auth2/lib/config/ConfigAction.java b/src/main/java/us/kbase/auth2/lib/config/ConfigAction.java similarity index 100% rename from src/us/kbase/auth2/lib/config/ConfigAction.java rename to src/main/java/us/kbase/auth2/lib/config/ConfigAction.java diff --git a/src/us/kbase/auth2/lib/config/ConfigItem.java b/src/main/java/us/kbase/auth2/lib/config/ConfigItem.java similarity index 100% rename from src/us/kbase/auth2/lib/config/ConfigItem.java rename to src/main/java/us/kbase/auth2/lib/config/ConfigItem.java diff --git a/src/us/kbase/auth2/lib/config/ExternalConfig.java b/src/main/java/us/kbase/auth2/lib/config/ExternalConfig.java similarity index 100% rename from src/us/kbase/auth2/lib/config/ExternalConfig.java rename to src/main/java/us/kbase/auth2/lib/config/ExternalConfig.java diff --git a/src/us/kbase/auth2/lib/config/ExternalConfigMapper.java b/src/main/java/us/kbase/auth2/lib/config/ExternalConfigMapper.java similarity index 100% rename from src/us/kbase/auth2/lib/config/ExternalConfigMapper.java rename to src/main/java/us/kbase/auth2/lib/config/ExternalConfigMapper.java diff --git a/src/us/kbase/auth2/lib/config/package-info.java b/src/main/java/us/kbase/auth2/lib/config/package-info.java similarity index 100% rename from src/us/kbase/auth2/lib/config/package-info.java rename to src/main/java/us/kbase/auth2/lib/config/package-info.java diff --git a/src/us/kbase/auth2/lib/exceptions/AuthException.java b/src/main/java/us/kbase/auth2/lib/exceptions/AuthException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/AuthException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/AuthException.java diff --git a/src/us/kbase/auth2/lib/exceptions/AuthenticationException.java b/src/main/java/us/kbase/auth2/lib/exceptions/AuthenticationException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/AuthenticationException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/AuthenticationException.java diff --git a/src/us/kbase/auth2/lib/exceptions/DisabledUserException.java b/src/main/java/us/kbase/auth2/lib/exceptions/DisabledUserException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/DisabledUserException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/DisabledUserException.java diff --git a/src/us/kbase/auth2/lib/exceptions/ErrorType.java b/src/main/java/us/kbase/auth2/lib/exceptions/ErrorType.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/ErrorType.java rename to src/main/java/us/kbase/auth2/lib/exceptions/ErrorType.java diff --git a/src/us/kbase/auth2/lib/exceptions/ExternalConfigMappingException.java b/src/main/java/us/kbase/auth2/lib/exceptions/ExternalConfigMappingException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/ExternalConfigMappingException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/ExternalConfigMappingException.java diff --git a/src/us/kbase/auth2/lib/exceptions/IdentityLinkedException.java b/src/main/java/us/kbase/auth2/lib/exceptions/IdentityLinkedException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/IdentityLinkedException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/IdentityLinkedException.java diff --git a/src/us/kbase/auth2/lib/exceptions/IdentityProviderErrorException.java b/src/main/java/us/kbase/auth2/lib/exceptions/IdentityProviderErrorException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/IdentityProviderErrorException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/IdentityProviderErrorException.java diff --git a/src/us/kbase/auth2/lib/exceptions/IdentityRetrievalException.java b/src/main/java/us/kbase/auth2/lib/exceptions/IdentityRetrievalException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/IdentityRetrievalException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/IdentityRetrievalException.java diff --git a/src/us/kbase/auth2/lib/exceptions/IllegalParameterException.java b/src/main/java/us/kbase/auth2/lib/exceptions/IllegalParameterException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/IllegalParameterException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/IllegalParameterException.java diff --git a/src/us/kbase/auth2/lib/exceptions/IllegalPasswordException.java b/src/main/java/us/kbase/auth2/lib/exceptions/IllegalPasswordException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/IllegalPasswordException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/IllegalPasswordException.java diff --git a/src/us/kbase/auth2/lib/exceptions/InvalidTokenException.java b/src/main/java/us/kbase/auth2/lib/exceptions/InvalidTokenException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/InvalidTokenException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/InvalidTokenException.java diff --git a/src/us/kbase/auth2/lib/exceptions/LinkFailedException.java b/src/main/java/us/kbase/auth2/lib/exceptions/LinkFailedException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/LinkFailedException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/LinkFailedException.java diff --git a/src/us/kbase/auth2/lib/exceptions/MissingParameterException.java b/src/main/java/us/kbase/auth2/lib/exceptions/MissingParameterException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/MissingParameterException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/MissingParameterException.java diff --git a/src/us/kbase/auth2/lib/exceptions/NoDataException.java b/src/main/java/us/kbase/auth2/lib/exceptions/NoDataException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/NoDataException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/NoDataException.java diff --git a/src/us/kbase/auth2/lib/exceptions/NoSuchEnvironmentException.java b/src/main/java/us/kbase/auth2/lib/exceptions/NoSuchEnvironmentException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/NoSuchEnvironmentException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/NoSuchEnvironmentException.java diff --git a/src/us/kbase/auth2/lib/exceptions/NoSuchIdentityException.java b/src/main/java/us/kbase/auth2/lib/exceptions/NoSuchIdentityException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/NoSuchIdentityException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/NoSuchIdentityException.java diff --git a/src/us/kbase/auth2/lib/exceptions/NoSuchIdentityProviderException.java b/src/main/java/us/kbase/auth2/lib/exceptions/NoSuchIdentityProviderException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/NoSuchIdentityProviderException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/NoSuchIdentityProviderException.java diff --git a/src/us/kbase/auth2/lib/exceptions/NoSuchLocalUserException.java b/src/main/java/us/kbase/auth2/lib/exceptions/NoSuchLocalUserException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/NoSuchLocalUserException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/NoSuchLocalUserException.java diff --git a/src/us/kbase/auth2/lib/exceptions/NoSuchRoleException.java b/src/main/java/us/kbase/auth2/lib/exceptions/NoSuchRoleException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/NoSuchRoleException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/NoSuchRoleException.java diff --git a/src/us/kbase/auth2/lib/exceptions/NoSuchTokenException.java b/src/main/java/us/kbase/auth2/lib/exceptions/NoSuchTokenException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/NoSuchTokenException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/NoSuchTokenException.java diff --git a/src/us/kbase/auth2/lib/exceptions/NoSuchUserException.java b/src/main/java/us/kbase/auth2/lib/exceptions/NoSuchUserException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/NoSuchUserException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/NoSuchUserException.java diff --git a/src/us/kbase/auth2/lib/exceptions/NoTokenProvidedException.java b/src/main/java/us/kbase/auth2/lib/exceptions/NoTokenProvidedException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/NoTokenProvidedException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/NoTokenProvidedException.java diff --git a/src/us/kbase/auth2/lib/exceptions/PasswordMismatchException.java b/src/main/java/us/kbase/auth2/lib/exceptions/PasswordMismatchException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/PasswordMismatchException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/PasswordMismatchException.java diff --git a/src/us/kbase/auth2/lib/exceptions/TestModeException.java b/src/main/java/us/kbase/auth2/lib/exceptions/TestModeException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/TestModeException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/TestModeException.java diff --git a/src/us/kbase/auth2/lib/exceptions/UnLinkFailedException.java b/src/main/java/us/kbase/auth2/lib/exceptions/UnLinkFailedException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/UnLinkFailedException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/UnLinkFailedException.java diff --git a/src/us/kbase/auth2/lib/exceptions/UnauthorizedException.java b/src/main/java/us/kbase/auth2/lib/exceptions/UnauthorizedException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/UnauthorizedException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/UnauthorizedException.java diff --git a/src/us/kbase/auth2/lib/exceptions/UserExistsException.java b/src/main/java/us/kbase/auth2/lib/exceptions/UserExistsException.java similarity index 100% rename from src/us/kbase/auth2/lib/exceptions/UserExistsException.java rename to src/main/java/us/kbase/auth2/lib/exceptions/UserExistsException.java diff --git a/src/us/kbase/auth2/lib/identity/IdentityProvider.java b/src/main/java/us/kbase/auth2/lib/identity/IdentityProvider.java similarity index 97% rename from src/us/kbase/auth2/lib/identity/IdentityProvider.java rename to src/main/java/us/kbase/auth2/lib/identity/IdentityProvider.java index 7085b975..59d34eec 100644 --- a/src/us/kbase/auth2/lib/identity/IdentityProvider.java +++ b/src/main/java/us/kbase/auth2/lib/identity/IdentityProvider.java @@ -54,7 +54,7 @@ Set getIdentities( throws IdentityRetrievalException, NoSuchEnvironmentException; /** Get the names of the additional environments beyond the default environment that are - * configured. See {@link #getLoginURI(String, boolean, String)}. + * configured. See {@link #getLoginURI(String, String, boolean, String)}. * @return the environments. */ Set getEnvironments(); diff --git a/src/us/kbase/auth2/lib/identity/IdentityProviderConfig.java b/src/main/java/us/kbase/auth2/lib/identity/IdentityProviderConfig.java similarity index 100% rename from src/us/kbase/auth2/lib/identity/IdentityProviderConfig.java rename to src/main/java/us/kbase/auth2/lib/identity/IdentityProviderConfig.java diff --git a/src/us/kbase/auth2/lib/identity/IdentityProviderFactory.java b/src/main/java/us/kbase/auth2/lib/identity/IdentityProviderFactory.java similarity index 100% rename from src/us/kbase/auth2/lib/identity/IdentityProviderFactory.java rename to src/main/java/us/kbase/auth2/lib/identity/IdentityProviderFactory.java diff --git a/src/us/kbase/auth2/lib/identity/RemoteIdentity.java b/src/main/java/us/kbase/auth2/lib/identity/RemoteIdentity.java similarity index 100% rename from src/us/kbase/auth2/lib/identity/RemoteIdentity.java rename to src/main/java/us/kbase/auth2/lib/identity/RemoteIdentity.java diff --git a/src/us/kbase/auth2/lib/identity/RemoteIdentityDetails.java b/src/main/java/us/kbase/auth2/lib/identity/RemoteIdentityDetails.java similarity index 100% rename from src/us/kbase/auth2/lib/identity/RemoteIdentityDetails.java rename to src/main/java/us/kbase/auth2/lib/identity/RemoteIdentityDetails.java diff --git a/src/us/kbase/auth2/lib/identity/RemoteIdentityID.java b/src/main/java/us/kbase/auth2/lib/identity/RemoteIdentityID.java similarity index 100% rename from src/us/kbase/auth2/lib/identity/RemoteIdentityID.java rename to src/main/java/us/kbase/auth2/lib/identity/RemoteIdentityID.java diff --git a/src/us/kbase/auth2/lib/storage/AuthStorage.java b/src/main/java/us/kbase/auth2/lib/storage/AuthStorage.java similarity index 100% rename from src/us/kbase/auth2/lib/storage/AuthStorage.java rename to src/main/java/us/kbase/auth2/lib/storage/AuthStorage.java diff --git a/src/us/kbase/auth2/lib/storage/exceptions/AuthStorageException.java b/src/main/java/us/kbase/auth2/lib/storage/exceptions/AuthStorageException.java similarity index 100% rename from src/us/kbase/auth2/lib/storage/exceptions/AuthStorageException.java rename to src/main/java/us/kbase/auth2/lib/storage/exceptions/AuthStorageException.java diff --git a/src/us/kbase/auth2/lib/storage/exceptions/StorageInitException.java b/src/main/java/us/kbase/auth2/lib/storage/exceptions/StorageInitException.java similarity index 100% rename from src/us/kbase/auth2/lib/storage/exceptions/StorageInitException.java rename to src/main/java/us/kbase/auth2/lib/storage/exceptions/StorageInitException.java diff --git a/src/us/kbase/auth2/lib/storage/mongo/Fields.java b/src/main/java/us/kbase/auth2/lib/storage/mongo/Fields.java similarity index 100% rename from src/us/kbase/auth2/lib/storage/mongo/Fields.java rename to src/main/java/us/kbase/auth2/lib/storage/mongo/Fields.java diff --git a/src/us/kbase/auth2/lib/storage/mongo/MongoStorage.java b/src/main/java/us/kbase/auth2/lib/storage/mongo/MongoStorage.java similarity index 100% rename from src/us/kbase/auth2/lib/storage/mongo/MongoStorage.java rename to src/main/java/us/kbase/auth2/lib/storage/mongo/MongoStorage.java diff --git a/src/us/kbase/auth2/lib/token/IncomingHashedToken.java b/src/main/java/us/kbase/auth2/lib/token/IncomingHashedToken.java similarity index 100% rename from src/us/kbase/auth2/lib/token/IncomingHashedToken.java rename to src/main/java/us/kbase/auth2/lib/token/IncomingHashedToken.java diff --git a/src/us/kbase/auth2/lib/token/IncomingToken.java b/src/main/java/us/kbase/auth2/lib/token/IncomingToken.java similarity index 100% rename from src/us/kbase/auth2/lib/token/IncomingToken.java rename to src/main/java/us/kbase/auth2/lib/token/IncomingToken.java diff --git a/src/us/kbase/auth2/lib/token/NewToken.java b/src/main/java/us/kbase/auth2/lib/token/NewToken.java similarity index 100% rename from src/us/kbase/auth2/lib/token/NewToken.java rename to src/main/java/us/kbase/auth2/lib/token/NewToken.java diff --git a/src/us/kbase/auth2/lib/token/StoredToken.java b/src/main/java/us/kbase/auth2/lib/token/StoredToken.java similarity index 100% rename from src/us/kbase/auth2/lib/token/StoredToken.java rename to src/main/java/us/kbase/auth2/lib/token/StoredToken.java diff --git a/src/us/kbase/auth2/lib/token/TemporaryToken.java b/src/main/java/us/kbase/auth2/lib/token/TemporaryToken.java similarity index 100% rename from src/us/kbase/auth2/lib/token/TemporaryToken.java rename to src/main/java/us/kbase/auth2/lib/token/TemporaryToken.java diff --git a/src/us/kbase/auth2/lib/token/TokenName.java b/src/main/java/us/kbase/auth2/lib/token/TokenName.java similarity index 100% rename from src/us/kbase/auth2/lib/token/TokenName.java rename to src/main/java/us/kbase/auth2/lib/token/TokenName.java diff --git a/src/us/kbase/auth2/lib/token/TokenSet.java b/src/main/java/us/kbase/auth2/lib/token/TokenSet.java similarity index 100% rename from src/us/kbase/auth2/lib/token/TokenSet.java rename to src/main/java/us/kbase/auth2/lib/token/TokenSet.java diff --git a/src/us/kbase/auth2/lib/token/TokenType.java b/src/main/java/us/kbase/auth2/lib/token/TokenType.java similarity index 100% rename from src/us/kbase/auth2/lib/token/TokenType.java rename to src/main/java/us/kbase/auth2/lib/token/TokenType.java diff --git a/src/us/kbase/auth2/lib/user/AuthUser.java b/src/main/java/us/kbase/auth2/lib/user/AuthUser.java similarity index 100% rename from src/us/kbase/auth2/lib/user/AuthUser.java rename to src/main/java/us/kbase/auth2/lib/user/AuthUser.java diff --git a/src/us/kbase/auth2/lib/user/LocalUser.java b/src/main/java/us/kbase/auth2/lib/user/LocalUser.java similarity index 100% rename from src/us/kbase/auth2/lib/user/LocalUser.java rename to src/main/java/us/kbase/auth2/lib/user/LocalUser.java diff --git a/src/us/kbase/auth2/lib/user/NewUser.java b/src/main/java/us/kbase/auth2/lib/user/NewUser.java similarity index 100% rename from src/us/kbase/auth2/lib/user/NewUser.java rename to src/main/java/us/kbase/auth2/lib/user/NewUser.java diff --git a/src/us/kbase/auth2/providers/GlobusIdentityProviderFactory.java b/src/main/java/us/kbase/auth2/providers/GlobusIdentityProviderFactory.java similarity index 100% rename from src/us/kbase/auth2/providers/GlobusIdentityProviderFactory.java rename to src/main/java/us/kbase/auth2/providers/GlobusIdentityProviderFactory.java diff --git a/src/us/kbase/auth2/providers/GoogleIdentityProviderFactory.java b/src/main/java/us/kbase/auth2/providers/GoogleIdentityProviderFactory.java similarity index 100% rename from src/us/kbase/auth2/providers/GoogleIdentityProviderFactory.java rename to src/main/java/us/kbase/auth2/providers/GoogleIdentityProviderFactory.java diff --git a/src/us/kbase/auth2/providers/OrcIDIdentityProviderFactory.java b/src/main/java/us/kbase/auth2/providers/OrcIDIdentityProviderFactory.java similarity index 100% rename from src/us/kbase/auth2/providers/OrcIDIdentityProviderFactory.java rename to src/main/java/us/kbase/auth2/providers/OrcIDIdentityProviderFactory.java diff --git a/src/us/kbase/auth2/providers/package-info.java b/src/main/java/us/kbase/auth2/providers/package-info.java similarity index 100% rename from src/us/kbase/auth2/providers/package-info.java rename to src/main/java/us/kbase/auth2/providers/package-info.java diff --git a/src/us/kbase/auth2/service/AppEventListener.java b/src/main/java/us/kbase/auth2/service/AppEventListener.java similarity index 100% rename from src/us/kbase/auth2/service/AppEventListener.java rename to src/main/java/us/kbase/auth2/service/AppEventListener.java diff --git a/src/us/kbase/auth2/service/AuthAPIStaticConfig.java b/src/main/java/us/kbase/auth2/service/AuthAPIStaticConfig.java similarity index 100% rename from src/us/kbase/auth2/service/AuthAPIStaticConfig.java rename to src/main/java/us/kbase/auth2/service/AuthAPIStaticConfig.java diff --git a/src/us/kbase/auth2/service/AuthBuilder.java b/src/main/java/us/kbase/auth2/service/AuthBuilder.java similarity index 89% rename from src/us/kbase/auth2/service/AuthBuilder.java rename to src/main/java/us/kbase/auth2/service/AuthBuilder.java index 5fda63be..27be79c4 100644 --- a/src/us/kbase/auth2/service/AuthBuilder.java +++ b/src/main/java/us/kbase/auth2/service/AuthBuilder.java @@ -2,13 +2,15 @@ import static java.util.Objects.requireNonNull; +import java.util.Arrays; import java.util.HashSet; import java.util.Set; import org.slf4j.LoggerFactory; -import com.mongodb.MongoClient; -import com.mongodb.MongoClientOptions; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; +import com.mongodb.MongoClientSettings; import com.mongodb.MongoCredential; import com.mongodb.MongoException; import com.mongodb.ServerAddress; @@ -62,15 +64,18 @@ public AuthBuilder( private MongoClient buildMongo(final AuthStartupConfig c) throws StorageInitException { //TODO ZLATER MONGO handle shards & replica sets + final MongoClientSettings.Builder mongoBuilder = MongoClientSettings.builder() + .retryWrites(c.getMongoRetryWrites()) + .applyToClusterSettings(builder -> builder.hosts( + Arrays.asList(new ServerAddress(c.getMongoHost())))); try { if (c.getMongoUser().isPresent()) { final MongoCredential creds = MongoCredential.createCredential( c.getMongoUser().get(), c.getMongoDatabase(), c.getMongoPwd().get()); // unclear if and when it's safe to clear the password - return new MongoClient(new ServerAddress(c.getMongoHost()), creds, - MongoClientOptions.builder().build()); + return MongoClients.create(mongoBuilder.credential(creds).build()); } else { - return new MongoClient(new ServerAddress(c.getMongoHost())); + return MongoClients.create(mongoBuilder.build()); } } catch (MongoException e) { LoggerFactory.getLogger(getClass()).error( diff --git a/src/us/kbase/auth2/service/AuthExternalConfig.java b/src/main/java/us/kbase/auth2/service/AuthExternalConfig.java similarity index 100% rename from src/us/kbase/auth2/service/AuthExternalConfig.java rename to src/main/java/us/kbase/auth2/service/AuthExternalConfig.java diff --git a/src/us/kbase/auth2/service/AuthStartupConfig.java b/src/main/java/us/kbase/auth2/service/AuthStartupConfig.java similarity index 95% rename from src/us/kbase/auth2/service/AuthStartupConfig.java rename to src/main/java/us/kbase/auth2/service/AuthStartupConfig.java index 82a7a733..72f5b302 100644 --- a/src/us/kbase/auth2/service/AuthStartupConfig.java +++ b/src/main/java/us/kbase/auth2/service/AuthStartupConfig.java @@ -14,6 +14,7 @@ public interface AuthStartupConfig { Set getIdentityProviderConfigs(); String getMongoHost(); String getMongoDatabase(); + boolean getMongoRetryWrites(); // note both or neither for user & pwd Optional getMongoUser(); Optional getMongoPwd(); diff --git a/src/us/kbase/auth2/service/AuthenticationService.java b/src/main/java/us/kbase/auth2/service/AuthenticationService.java similarity index 98% rename from src/us/kbase/auth2/service/AuthenticationService.java rename to src/main/java/us/kbase/auth2/service/AuthenticationService.java index b51db4a2..a69f8706 100644 --- a/src/us/kbase/auth2/service/AuthenticationService.java +++ b/src/main/java/us/kbase/auth2/service/AuthenticationService.java @@ -8,7 +8,7 @@ import org.slf4j.LoggerFactory; import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; -import com.mongodb.MongoClient; +import com.mongodb.client.MongoClient; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; diff --git a/src/us/kbase/auth2/service/ContextFields.java b/src/main/java/us/kbase/auth2/service/ContextFields.java similarity index 100% rename from src/us/kbase/auth2/service/ContextFields.java rename to src/main/java/us/kbase/auth2/service/ContextFields.java diff --git a/src/us/kbase/auth2/service/LoggingFilter.java b/src/main/java/us/kbase/auth2/service/LoggingFilter.java similarity index 100% rename from src/us/kbase/auth2/service/LoggingFilter.java rename to src/main/java/us/kbase/auth2/service/LoggingFilter.java diff --git a/src/us/kbase/auth2/service/SLF4JAutoLogger.java b/src/main/java/us/kbase/auth2/service/SLF4JAutoLogger.java similarity index 100% rename from src/us/kbase/auth2/service/SLF4JAutoLogger.java rename to src/main/java/us/kbase/auth2/service/SLF4JAutoLogger.java diff --git a/src/us/kbase/auth2/service/UserAgentParser.java b/src/main/java/us/kbase/auth2/service/UserAgentParser.java similarity index 100% rename from src/us/kbase/auth2/service/UserAgentParser.java rename to src/main/java/us/kbase/auth2/service/UserAgentParser.java diff --git a/src/us/kbase/auth2/service/api/APIConstants.java b/src/main/java/us/kbase/auth2/service/api/APIConstants.java similarity index 100% rename from src/us/kbase/auth2/service/api/APIConstants.java rename to src/main/java/us/kbase/auth2/service/api/APIConstants.java diff --git a/src/us/kbase/auth2/service/api/APIPaths.java b/src/main/java/us/kbase/auth2/service/api/APIPaths.java similarity index 100% rename from src/us/kbase/auth2/service/api/APIPaths.java rename to src/main/java/us/kbase/auth2/service/api/APIPaths.java diff --git a/src/us/kbase/auth2/service/api/APIToken.java b/src/main/java/us/kbase/auth2/service/api/APIToken.java similarity index 100% rename from src/us/kbase/auth2/service/api/APIToken.java rename to src/main/java/us/kbase/auth2/service/api/APIToken.java diff --git a/src/us/kbase/auth2/service/api/Admin.java b/src/main/java/us/kbase/auth2/service/api/Admin.java similarity index 100% rename from src/us/kbase/auth2/service/api/Admin.java rename to src/main/java/us/kbase/auth2/service/api/Admin.java diff --git a/src/us/kbase/auth2/service/api/LegacyGlobus.java b/src/main/java/us/kbase/auth2/service/api/LegacyGlobus.java similarity index 100% rename from src/us/kbase/auth2/service/api/LegacyGlobus.java rename to src/main/java/us/kbase/auth2/service/api/LegacyGlobus.java diff --git a/src/us/kbase/auth2/service/api/LegacyKBase.java b/src/main/java/us/kbase/auth2/service/api/LegacyKBase.java similarity index 100% rename from src/us/kbase/auth2/service/api/LegacyKBase.java rename to src/main/java/us/kbase/auth2/service/api/LegacyKBase.java diff --git a/src/us/kbase/auth2/service/api/Me.java b/src/main/java/us/kbase/auth2/service/api/Me.java similarity index 100% rename from src/us/kbase/auth2/service/api/Me.java rename to src/main/java/us/kbase/auth2/service/api/Me.java diff --git a/src/us/kbase/auth2/service/api/NewAPIToken.java b/src/main/java/us/kbase/auth2/service/api/NewAPIToken.java similarity index 100% rename from src/us/kbase/auth2/service/api/NewAPIToken.java rename to src/main/java/us/kbase/auth2/service/api/NewAPIToken.java diff --git a/src/us/kbase/auth2/service/api/TestMode.java b/src/main/java/us/kbase/auth2/service/api/TestMode.java similarity index 100% rename from src/us/kbase/auth2/service/api/TestMode.java rename to src/main/java/us/kbase/auth2/service/api/TestMode.java diff --git a/src/us/kbase/auth2/service/api/Token.java b/src/main/java/us/kbase/auth2/service/api/Token.java similarity index 100% rename from src/us/kbase/auth2/service/api/Token.java rename to src/main/java/us/kbase/auth2/service/api/Token.java diff --git a/src/us/kbase/auth2/service/api/Users.java b/src/main/java/us/kbase/auth2/service/api/Users.java similarity index 100% rename from src/us/kbase/auth2/service/api/Users.java rename to src/main/java/us/kbase/auth2/service/api/Users.java diff --git a/src/us/kbase/auth2/service/common/ExternalToken.java b/src/main/java/us/kbase/auth2/service/common/ExternalToken.java similarity index 100% rename from src/us/kbase/auth2/service/common/ExternalToken.java rename to src/main/java/us/kbase/auth2/service/common/ExternalToken.java diff --git a/src/us/kbase/auth2/service/common/Fields.java b/src/main/java/us/kbase/auth2/service/common/Fields.java similarity index 100% rename from src/us/kbase/auth2/service/common/Fields.java rename to src/main/java/us/kbase/auth2/service/common/Fields.java diff --git a/src/us/kbase/auth2/service/common/IncomingJSON.java b/src/main/java/us/kbase/auth2/service/common/IncomingJSON.java similarity index 100% rename from src/us/kbase/auth2/service/common/IncomingJSON.java rename to src/main/java/us/kbase/auth2/service/common/IncomingJSON.java diff --git a/src/us/kbase/auth2/service/common/ServiceCommon.java b/src/main/java/us/kbase/auth2/service/common/ServiceCommon.java similarity index 100% rename from src/us/kbase/auth2/service/common/ServiceCommon.java rename to src/main/java/us/kbase/auth2/service/common/ServiceCommon.java diff --git a/src/us/kbase/auth2/service/exceptions/AuthConfigurationException.java b/src/main/java/us/kbase/auth2/service/exceptions/AuthConfigurationException.java similarity index 100% rename from src/us/kbase/auth2/service/exceptions/AuthConfigurationException.java rename to src/main/java/us/kbase/auth2/service/exceptions/AuthConfigurationException.java diff --git a/src/us/kbase/auth2/service/exceptions/ErrorMessage.java b/src/main/java/us/kbase/auth2/service/exceptions/ErrorMessage.java similarity index 100% rename from src/us/kbase/auth2/service/exceptions/ErrorMessage.java rename to src/main/java/us/kbase/auth2/service/exceptions/ErrorMessage.java diff --git a/src/us/kbase/auth2/service/exceptions/ExceptionHandler.java b/src/main/java/us/kbase/auth2/service/exceptions/ExceptionHandler.java similarity index 100% rename from src/us/kbase/auth2/service/exceptions/ExceptionHandler.java rename to src/main/java/us/kbase/auth2/service/exceptions/ExceptionHandler.java diff --git a/src/us/kbase/auth2/service/template/TemplateProcessor.java b/src/main/java/us/kbase/auth2/service/template/TemplateProcessor.java similarity index 100% rename from src/us/kbase/auth2/service/template/TemplateProcessor.java rename to src/main/java/us/kbase/auth2/service/template/TemplateProcessor.java diff --git a/src/us/kbase/auth2/service/template/mustache/MustacheProcessor.java b/src/main/java/us/kbase/auth2/service/template/mustache/MustacheProcessor.java similarity index 100% rename from src/us/kbase/auth2/service/template/mustache/MustacheProcessor.java rename to src/main/java/us/kbase/auth2/service/template/mustache/MustacheProcessor.java diff --git a/src/us/kbase/auth2/service/ui/Admin.java b/src/main/java/us/kbase/auth2/service/ui/Admin.java similarity index 100% rename from src/us/kbase/auth2/service/ui/Admin.java rename to src/main/java/us/kbase/auth2/service/ui/Admin.java diff --git a/src/us/kbase/auth2/service/ui/CustomRoles.java b/src/main/java/us/kbase/auth2/service/ui/CustomRoles.java similarity index 100% rename from src/us/kbase/auth2/service/ui/CustomRoles.java rename to src/main/java/us/kbase/auth2/service/ui/CustomRoles.java diff --git a/src/us/kbase/auth2/service/ui/Link.java b/src/main/java/us/kbase/auth2/service/ui/Link.java similarity index 100% rename from src/us/kbase/auth2/service/ui/Link.java rename to src/main/java/us/kbase/auth2/service/ui/Link.java diff --git a/src/us/kbase/auth2/service/ui/LocalAccounts.java b/src/main/java/us/kbase/auth2/service/ui/LocalAccounts.java similarity index 100% rename from src/us/kbase/auth2/service/ui/LocalAccounts.java rename to src/main/java/us/kbase/auth2/service/ui/LocalAccounts.java diff --git a/src/us/kbase/auth2/service/ui/Login.java b/src/main/java/us/kbase/auth2/service/ui/Login.java similarity index 100% rename from src/us/kbase/auth2/service/ui/Login.java rename to src/main/java/us/kbase/auth2/service/ui/Login.java diff --git a/src/us/kbase/auth2/service/ui/Logout.java b/src/main/java/us/kbase/auth2/service/ui/Logout.java similarity index 100% rename from src/us/kbase/auth2/service/ui/Logout.java rename to src/main/java/us/kbase/auth2/service/ui/Logout.java diff --git a/src/us/kbase/auth2/service/ui/Me.java b/src/main/java/us/kbase/auth2/service/ui/Me.java similarity index 100% rename from src/us/kbase/auth2/service/ui/Me.java rename to src/main/java/us/kbase/auth2/service/ui/Me.java diff --git a/src/us/kbase/auth2/service/ui/NewUIToken.java b/src/main/java/us/kbase/auth2/service/ui/NewUIToken.java similarity index 100% rename from src/us/kbase/auth2/service/ui/NewUIToken.java rename to src/main/java/us/kbase/auth2/service/ui/NewUIToken.java diff --git a/src/us/kbase/auth2/service/ui/Root.java b/src/main/java/us/kbase/auth2/service/ui/Root.java similarity index 100% rename from src/us/kbase/auth2/service/ui/Root.java rename to src/main/java/us/kbase/auth2/service/ui/Root.java diff --git a/src/us/kbase/auth2/service/ui/Tokens.java b/src/main/java/us/kbase/auth2/service/ui/Tokens.java similarity index 100% rename from src/us/kbase/auth2/service/ui/Tokens.java rename to src/main/java/us/kbase/auth2/service/ui/Tokens.java diff --git a/src/us/kbase/auth2/service/ui/UIConstants.java b/src/main/java/us/kbase/auth2/service/ui/UIConstants.java similarity index 100% rename from src/us/kbase/auth2/service/ui/UIConstants.java rename to src/main/java/us/kbase/auth2/service/ui/UIConstants.java diff --git a/src/us/kbase/auth2/service/ui/UIPaths.java b/src/main/java/us/kbase/auth2/service/ui/UIPaths.java similarity index 100% rename from src/us/kbase/auth2/service/ui/UIPaths.java rename to src/main/java/us/kbase/auth2/service/ui/UIPaths.java diff --git a/src/us/kbase/auth2/service/ui/UIToken.java b/src/main/java/us/kbase/auth2/service/ui/UIToken.java similarity index 100% rename from src/us/kbase/auth2/service/ui/UIToken.java rename to src/main/java/us/kbase/auth2/service/ui/UIToken.java diff --git a/src/us/kbase/auth2/service/ui/UIUtils.java b/src/main/java/us/kbase/auth2/service/ui/UIUtils.java similarity index 100% rename from src/us/kbase/auth2/service/ui/UIUtils.java rename to src/main/java/us/kbase/auth2/service/ui/UIUtils.java diff --git a/src/us/kbase/test/auth2/MapBuilder.java b/src/test/java/us/kbase/test/auth2/MapBuilder.java similarity index 100% rename from src/us/kbase/test/auth2/MapBuilder.java rename to src/test/java/us/kbase/test/auth2/MapBuilder.java diff --git a/src/us/kbase/test/auth2/MockIdentityProviderFactory.java b/src/test/java/us/kbase/test/auth2/MockIdentityProviderFactory.java similarity index 100% rename from src/us/kbase/test/auth2/MockIdentityProviderFactory.java rename to src/test/java/us/kbase/test/auth2/MockIdentityProviderFactory.java diff --git a/src/us/kbase/test/auth2/MongoStorageTestManager.java b/src/test/java/us/kbase/test/auth2/MongoStorageTestManager.java similarity index 94% rename from src/us/kbase/test/auth2/MongoStorageTestManager.java rename to src/test/java/us/kbase/test/auth2/MongoStorageTestManager.java index 45d79ab9..58776004 100644 --- a/src/us/kbase/test/auth2/MongoStorageTestManager.java +++ b/src/test/java/us/kbase/test/auth2/MongoStorageTestManager.java @@ -15,7 +15,8 @@ import org.bson.Document; import com.github.zafarkhaja.semver.Version; -import com.mongodb.MongoClient; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; import com.mongodb.client.MongoDatabase; import us.kbase.auth2.cryptutils.RandomDataGenerator; @@ -42,16 +43,16 @@ public MongoStorageTestManager(final String dbName) throws Exception { wiredTiger = useWiredTigerEngine(); System.out.println(String.format("Testing against mongo executable %s on port %s", getMongoExe(), mongo.getServerPort())); - mc = new MongoClient("localhost:" + mongo.getServerPort()); + mc = MongoClients.create("mongodb://localhost:" + mongo.getServerPort()); db = mc.getDatabase(dbName); - + final Document bi = db.runCommand(new Document("buildinfo", 1)); final String version = bi.getString("version"); mongoDBVer = Version.valueOf(version); indexVer = mongoDBVer.greaterThanOrEqualTo(Version.forIntegers(3, 4)) ? 2 : 1; reset(); } - + public void destroy() throws Exception { if (mc != null) { mc.close(); diff --git a/src/us/kbase/test/auth2/StandaloneAuthServer.java b/src/test/java/us/kbase/test/auth2/StandaloneAuthServer.java similarity index 100% rename from src/us/kbase/test/auth2/StandaloneAuthServer.java rename to src/test/java/us/kbase/test/auth2/StandaloneAuthServer.java diff --git a/src/us/kbase/test/auth2/TestCommon.java b/src/test/java/us/kbase/test/auth2/TestCommon.java similarity index 100% rename from src/us/kbase/test/auth2/TestCommon.java rename to src/test/java/us/kbase/test/auth2/TestCommon.java diff --git a/src/us/kbase/test/auth2/TestConfigurator.java b/src/test/java/us/kbase/test/auth2/TestConfigurator.java similarity index 98% rename from src/us/kbase/test/auth2/TestConfigurator.java rename to src/test/java/us/kbase/test/auth2/TestConfigurator.java index 3b0e3362..437ef331 100644 --- a/src/us/kbase/test/auth2/TestConfigurator.java +++ b/src/test/java/us/kbase/test/auth2/TestConfigurator.java @@ -133,6 +133,11 @@ public String getMongoHost() { public String getMongoDatabase() { return mongoDatabase == null ? System.getProperty(MONGO_DB_KEY) : mongoDatabase; } + + @Override + public boolean getMongoRetryWrites() { + return false; + } @Override public Optional getMongoUser() { diff --git a/src/us/kbase/test/auth2/authcontroller/AuthController.java b/src/test/java/us/kbase/test/auth2/authcontroller/AuthController.java similarity index 53% rename from src/us/kbase/test/auth2/authcontroller/AuthController.java rename to src/test/java/us/kbase/test/auth2/authcontroller/AuthController.java index 556ffeee..8588c6e7 100644 --- a/src/us/kbase/test/auth2/authcontroller/AuthController.java +++ b/src/test/java/us/kbase/test/auth2/authcontroller/AuthController.java @@ -17,17 +17,10 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; -import java.util.Enumeration; -import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Scanner; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipFile; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -37,10 +30,18 @@ import us.kbase.common.test.TestException; import us.kbase.test.auth2.StandaloneAuthServer; +/** Q&D utility to run the auth server in test mode for use in testing rigs. Expected to + * be packaged in a test jar with all dependencies and the templates in a /templates/ directory. + */ public class AuthController { - private final static String AUTH_CLASS = StandaloneAuthServer.class.getName(); - private static final String JARS_FILE = "authjars"; + // hardcoded in build.gradle + private static final String TEMPLATES_JAR_DIR = "kbase_auth2_templates"; + private static final String TEMPLATES_LIST_FILE = "templates.manifest"; + + private static final String AUTH_CLASS = StandaloneAuthServer.class.getName(); + private static final String JAR_PATH = StandaloneAuthServer.class.getProtectionDomain() + .getCodeSource().getLocation().getPath(); private final Process auth; private final int port; @@ -48,16 +49,14 @@ public class AuthController { private final String version; public AuthController( - final Path jarsDir, final String mongoHost, final String mongoDatabase, final Path rootTempDir) throws Exception { - this(jarsDir, mongoHost, mongoDatabase, rootTempDir, null, null); + this(mongoHost, mongoDatabase, rootTempDir, null, null); } public AuthController( - final Path jarsDir, final String mongoHost, final String mongoDatabase, final Path rootTempDir, @@ -67,16 +66,16 @@ public AuthController( if (mongoUser == null ^ mongoPwd == null) { throw new TestException("Both or neither of the mongo user / pwd must be provided"); } - final String classPath = getClassPath(jarsDir); tempDir = makeTempDirs(rootTempDir, "AuthController-", Arrays.asList("templates")); port = findFreePort(); + System.out.println("Using classpath " + JAR_PATH); final Path templateDir = tempDir.resolve("templates"); - installTemplates(jarsDir, templateDir); + installTemplates(templateDir); final List command = new ArrayList<>(Arrays.asList( "java", - "-classpath", classPath, + "-classpath", JAR_PATH, "-D" + MONGO_HOST_KEY + "=" + mongoHost, "-D" + MONGO_DB_KEY + "=" + mongoDatabase, "-D" + MONGO_TEMPLATES_KEY + "=" + templateDir.toString())); @@ -149,83 +148,37 @@ public void destroy(boolean deleteTempFiles) throws IOException { } } - private void installTemplates(final Path jarsDir, final Path templatesDir) throws IOException { - final Path templateZipFile; - try (final InputStream is = getJarsFileInputStream()) { - final BufferedReader br = new BufferedReader(new InputStreamReader(is)); - //first line is zip file with templates - templateZipFile = jarsDir.resolve(br.readLine().trim()); - } - try (final ZipFile zf = new ZipFile(templateZipFile.toFile())) { - for (Enumeration e = zf.entries(); e.hasMoreElements();) { - final ZipEntry ze = e.nextElement(); - if (ze.isDirectory()) { - continue; - } - final Path zippath = Paths.get(ze.getName()).normalize(); - if (zippath.isAbsolute() || zippath.startsWith("..")) { - throw new TestException("Zip file " + templateZipFile + - " contains files outside the zip " + - "directory - this is a sign of a malicious zip file."); - } - final Path file = templatesDir.resolve(zippath).toAbsolutePath(); - Files.createDirectories(file.getParent()); - Files.createFile(file); - try (final OutputStream os = Files.newOutputStream(file); - final InputStream zipinput = zf.getInputStream(ze)) { - IOUtils.copy(zipinput, os); - } + private void installTemplates(final Path templatesDir) throws IOException { + final String templatesJarFileList = "/" + TEMPLATES_JAR_DIR + "/" + TEMPLATES_LIST_FILE; + final List templateFiles = new ArrayList<>(); + try (final InputStream templateFilesStream = getClass() + .getResourceAsStream(templatesJarFileList) + ) { + if (templateFilesStream == null) { + throw new TestException(String.format( + "Could not find template file list file %s in jar", templatesJarFileList)); } - } catch (ZipException e) { - throw new TestException("Unable to open the zip file " + templateZipFile, e); + final BufferedReader br = new BufferedReader( + new InputStreamReader(templateFilesStream)); + br.lines().forEach(templateFile -> templateFiles.add(templateFile)); } - - } - - private String getClassPath(final Path jarsDir) throws IOException { - final List classpath = new LinkedList<>(); - try (final InputStream is = getJarsFileInputStream();) { - final BufferedReader br = new BufferedReader(new InputStreamReader(is)); - br.readLine(); // discard first line, which has the templates zip file - String line; - while ((line = br.readLine()) != null) { - if (!line.trim().isEmpty() && !line.trim().startsWith("#")) { - final Path jarPath = jarsDir.resolve(line); - if (Files.notExists(jarPath)) { - throw new TestException("Required jar does not exist: " + jarPath); - - } - classpath.add(jarPath.toString()); + for (final String templateFileName: templateFiles) { + final String templateJarPath = "/" + TEMPLATES_JAR_DIR + "/" + templateFileName; + final Path templateTargetPath = templatesDir.resolve(templateFileName) + .toAbsolutePath(); + try ( + final InputStream template = getClass() + .getResourceAsStream(templateJarPath); + final OutputStream target = Files.newOutputStream(templateTargetPath); + + ) { + if (template == null) { + throw new TestException(String.format( + "Could not find template file %s in jar", templateJarPath)); } + IOUtils.copy(template, target); } } - return String.join(":", classpath); - } - - private InputStream getJarsFileInputStream() { - final InputStream is = getClass().getResourceAsStream(JARS_FILE); - if (is == null) { - throw new TestException("No auth versions file " + JARS_FILE); - } - return is; - } - - public static void main(final String[] args) throws Exception { - final AuthController ac = new AuthController( - Paths.get("/home/crushingismybusiness/github/mrcreosote/jars/lib/jars"), - "localhost:27017", - "AuthController", - Paths.get("authtesttemp"), - "auth", - "auth"); - System.out.println(ac.getServerPort()); - System.out.println(ac.getTempDir()); - System.out.println(ac.getVersion()); - Scanner reader = new Scanner(System.in); - System.out.println("any char to shut down"); - reader.next(); - ac.destroy(false); - reader.close(); } } diff --git a/src/us/kbase/test/auth2/cli/AuthCLITest.java b/src/test/java/us/kbase/test/auth2/cli/AuthCLITest.java similarity index 100% rename from src/us/kbase/test/auth2/cli/AuthCLITest.java rename to src/test/java/us/kbase/test/auth2/cli/AuthCLITest.java diff --git a/src/us/kbase/test/auth2/cryptutils/CryptUtilsTest.java b/src/test/java/us/kbase/test/auth2/cryptutils/CryptUtilsTest.java similarity index 100% rename from src/us/kbase/test/auth2/cryptutils/CryptUtilsTest.java rename to src/test/java/us/kbase/test/auth2/cryptutils/CryptUtilsTest.java diff --git a/src/us/kbase/test/auth2/cryptutils/SHA1RandomDataGeneratorTest.java b/src/test/java/us/kbase/test/auth2/cryptutils/SHA1RandomDataGeneratorTest.java similarity index 100% rename from src/us/kbase/test/auth2/cryptutils/SHA1RandomDataGeneratorTest.java rename to src/test/java/us/kbase/test/auth2/cryptutils/SHA1RandomDataGeneratorTest.java diff --git a/src/us/kbase/test/auth2/kbase/KBaseAuthConfigTest.java b/src/test/java/us/kbase/test/auth2/kbase/KBaseAuthConfigTest.java similarity index 98% rename from src/us/kbase/test/auth2/kbase/KBaseAuthConfigTest.java rename to src/test/java/us/kbase/test/auth2/kbase/KBaseAuthConfigTest.java index e485d442..5662459e 100644 --- a/src/us/kbase/test/auth2/kbase/KBaseAuthConfigTest.java +++ b/src/test/java/us/kbase/test/auth2/kbase/KBaseAuthConfigTest.java @@ -78,6 +78,7 @@ public void minimalConfigFromProp() throws Exception { assertThat("incorrect mongo host", cfg.getMongoHost(), is("localhost:50000")); assertThat("incorrect mongo db", cfg.getMongoDatabase(), is("mydb")); + assertThat("incorrect retry writes", cfg.getMongoRetryWrites(), is(false)); assertThat("incorrect mongo user", cfg.getMongoUser(), is(Optional.empty())); assertThat("incorrect mongo pwd", cfg.getMongoPwd(), is(Optional.empty())); assertThat("incorrect test mode", cfg.isTestModeEnabled(), is(false)); @@ -96,6 +97,7 @@ public void maximalConfigFromEnv() throws Exception { "[authserv2]", "mongo-host= localhost:50000 ", "mongo-db = mydb ", + "mongo-retrywrites = \t true \t ", "mongo-user= muser", "mongo-pwd = mpwd", "test-mode-enabled= true", @@ -141,6 +143,7 @@ public void maximalConfigFromEnv() throws Exception { assertThat("incorrect mongo host", cfg.getMongoHost(), is("localhost:50000")); assertThat("incorrect mongo db", cfg.getMongoDatabase(), is("mydb")); + assertThat("incorrect retry writes", cfg.getMongoRetryWrites(), is(true)); assertThat("incorrect mongo user", cfg.getMongoUser(), is(Optional.of("muser"))); assertThat("incorrect mongo pwd", Arrays.equals(cfg.getMongoPwd().get(), "mpwd".toCharArray()), is(true)); @@ -224,6 +227,7 @@ public void minimalConfigFromFileNullLogger() throws Exception { assertThat("incorrect mongo host", cfg.getMongoHost(), is("localhost:50000")); assertThat("incorrect mongo db", cfg.getMongoDatabase(), is("mydb")); + assertThat("incorrect retry writes", cfg.getMongoRetryWrites(), is(false)); assertThat("incorrect mongo user", cfg.getMongoUser(), is(Optional.empty())); assertThat("incorrect mongo pwd", cfg.getMongoPwd(), is(Optional.empty())); assertThat("incorrect test mode", cfg.isTestModeEnabled(), is(false)); @@ -242,6 +246,7 @@ public void maximalConfigFromFileStdLogger() throws Exception { "[authserv2]", "mongo-host= localhost:50000 ", "mongo-db = mydb ", + "mongo-retrywrites=true", "mongo-user= muser", "mongo-pwd = mpwd", "test-mode-enabled= true", @@ -273,6 +278,7 @@ public void maximalConfigFromFileStdLogger() throws Exception { assertThat("incorrect mongo host", cfg.getMongoHost(), is("localhost:50000")); assertThat("incorrect mongo db", cfg.getMongoDatabase(), is("mydb")); + assertThat("incorrect retry writes", cfg.getMongoRetryWrites(), is(true)); assertThat("incorrect mongo user", cfg.getMongoUser(), is(Optional.of("muser"))); assertThat("incorrect mongo pwd", Arrays.equals(cfg.getMongoPwd().get(), "mpwd".toCharArray()), is(true)); diff --git a/src/us/kbase/test/auth2/lib/AuthenticationAnonymousIDsTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationAnonymousIDsTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationAnonymousIDsTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationAnonymousIDsTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationConfigTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationConfigTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationConfigTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationConfigTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationConstructorTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationConstructorTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationConstructorTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationConstructorTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationCreateLocalUserTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationCreateLocalUserTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationCreateLocalUserTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationCreateLocalUserTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationCreateRootTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationCreateRootTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationCreateRootTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationCreateRootTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationCustomRoleTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationCustomRoleTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationCustomRoleTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationCustomRoleTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationDisableUserTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationDisableUserTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationDisableUserTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationDisableUserTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationGetAvailableUserNameTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationGetAvailableUserNameTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationGetAvailableUserNameTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationGetAvailableUserNameTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationGetUserDisplayNamesTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationGetUserDisplayNamesTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationGetUserDisplayNamesTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationGetUserDisplayNamesTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationGetUserTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationGetUserTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationGetUserTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationGetUserTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationIdentityProviderTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationIdentityProviderTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationIdentityProviderTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationIdentityProviderTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationImportUserTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationImportUserTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationImportUserTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationImportUserTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationLinkTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationLinkTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationLinkTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationLinkTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationLoginTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationLoginTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationLoginTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationLoginTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationPasswordLoginTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationPasswordLoginTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationPasswordLoginTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationPasswordLoginTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationPolicyIDTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationPolicyIDTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationPolicyIDTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationPolicyIDTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationRoleTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationRoleTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationRoleTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationRoleTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationTestModeGetUserDisplayNamesTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationTestModeGetUserDisplayNamesTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationTestModeGetUserDisplayNamesTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationTestModeGetUserDisplayNamesTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationTestModeRoleTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationTestModeRoleTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationTestModeRoleTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationTestModeRoleTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationTestModeTokenTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationTestModeTokenTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationTestModeTokenTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationTestModeTokenTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationTestModeUserTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationTestModeUserTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationTestModeUserTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationTestModeUserTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationTester.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationTester.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationTester.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationTester.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationTokenTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationTokenTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationTokenTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationTokenTest.java diff --git a/src/us/kbase/test/auth2/lib/AuthenticationUserUpdateTest.java b/src/test/java/us/kbase/test/auth2/lib/AuthenticationUserUpdateTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/AuthenticationUserUpdateTest.java rename to src/test/java/us/kbase/test/auth2/lib/AuthenticationUserUpdateTest.java diff --git a/src/us/kbase/test/auth2/lib/CustomRoleTest.java b/src/test/java/us/kbase/test/auth2/lib/CustomRoleTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/CustomRoleTest.java rename to src/test/java/us/kbase/test/auth2/lib/CustomRoleTest.java diff --git a/src/us/kbase/test/auth2/lib/DisplayNameTest.java b/src/test/java/us/kbase/test/auth2/lib/DisplayNameTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/DisplayNameTest.java rename to src/test/java/us/kbase/test/auth2/lib/DisplayNameTest.java diff --git a/src/us/kbase/test/auth2/lib/EmailAddressTest.java b/src/test/java/us/kbase/test/auth2/lib/EmailAddressTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/EmailAddressTest.java rename to src/test/java/us/kbase/test/auth2/lib/EmailAddressTest.java diff --git a/src/us/kbase/test/auth2/lib/LinkIdentitiesTest.java b/src/test/java/us/kbase/test/auth2/lib/LinkIdentitiesTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/LinkIdentitiesTest.java rename to src/test/java/us/kbase/test/auth2/lib/LinkIdentitiesTest.java diff --git a/src/us/kbase/test/auth2/lib/LinkTokenTest.java b/src/test/java/us/kbase/test/auth2/lib/LinkTokenTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/LinkTokenTest.java rename to src/test/java/us/kbase/test/auth2/lib/LinkTokenTest.java diff --git a/src/us/kbase/test/auth2/lib/LocalLoginResultTest.java b/src/test/java/us/kbase/test/auth2/lib/LocalLoginResultTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/LocalLoginResultTest.java rename to src/test/java/us/kbase/test/auth2/lib/LocalLoginResultTest.java diff --git a/src/us/kbase/test/auth2/lib/LoginStateTest.java b/src/test/java/us/kbase/test/auth2/lib/LoginStateTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/LoginStateTest.java rename to src/test/java/us/kbase/test/auth2/lib/LoginStateTest.java diff --git a/src/us/kbase/test/auth2/lib/LoginTokenTest.java b/src/test/java/us/kbase/test/auth2/lib/LoginTokenTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/LoginTokenTest.java rename to src/test/java/us/kbase/test/auth2/lib/LoginTokenTest.java diff --git a/src/us/kbase/test/auth2/lib/NameTest.java b/src/test/java/us/kbase/test/auth2/lib/NameTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/NameTest.java rename to src/test/java/us/kbase/test/auth2/lib/NameTest.java diff --git a/src/us/kbase/test/auth2/lib/OAuth2StartDataTest.java b/src/test/java/us/kbase/test/auth2/lib/OAuth2StartDataTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/OAuth2StartDataTest.java rename to src/test/java/us/kbase/test/auth2/lib/OAuth2StartDataTest.java diff --git a/src/us/kbase/test/auth2/lib/PasswordHashAndSaltTest.java b/src/test/java/us/kbase/test/auth2/lib/PasswordHashAndSaltTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/PasswordHashAndSaltTest.java rename to src/test/java/us/kbase/test/auth2/lib/PasswordHashAndSaltTest.java diff --git a/src/us/kbase/test/auth2/lib/PasswordTest.java b/src/test/java/us/kbase/test/auth2/lib/PasswordTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/PasswordTest.java rename to src/test/java/us/kbase/test/auth2/lib/PasswordTest.java diff --git a/src/us/kbase/test/auth2/lib/PolicyIDTest.java b/src/test/java/us/kbase/test/auth2/lib/PolicyIDTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/PolicyIDTest.java rename to src/test/java/us/kbase/test/auth2/lib/PolicyIDTest.java diff --git a/src/us/kbase/test/auth2/lib/RoleTest.java b/src/test/java/us/kbase/test/auth2/lib/RoleTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/RoleTest.java rename to src/test/java/us/kbase/test/auth2/lib/RoleTest.java diff --git a/src/us/kbase/test/auth2/lib/TemporarySessionDataTest.java b/src/test/java/us/kbase/test/auth2/lib/TemporarySessionDataTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/TemporarySessionDataTest.java rename to src/test/java/us/kbase/test/auth2/lib/TemporarySessionDataTest.java diff --git a/src/us/kbase/test/auth2/lib/TokenCreationContextTest.java b/src/test/java/us/kbase/test/auth2/lib/TokenCreationContextTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/TokenCreationContextTest.java rename to src/test/java/us/kbase/test/auth2/lib/TokenCreationContextTest.java diff --git a/src/us/kbase/test/auth2/lib/UserDisabledStateTest.java b/src/test/java/us/kbase/test/auth2/lib/UserDisabledStateTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/UserDisabledStateTest.java rename to src/test/java/us/kbase/test/auth2/lib/UserDisabledStateTest.java diff --git a/src/us/kbase/test/auth2/lib/UserNameTest.java b/src/test/java/us/kbase/test/auth2/lib/UserNameTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/UserNameTest.java rename to src/test/java/us/kbase/test/auth2/lib/UserNameTest.java diff --git a/src/us/kbase/test/auth2/lib/UserSearchSpecTest.java b/src/test/java/us/kbase/test/auth2/lib/UserSearchSpecTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/UserSearchSpecTest.java rename to src/test/java/us/kbase/test/auth2/lib/UserSearchSpecTest.java diff --git a/src/us/kbase/test/auth2/lib/UserUpdateTest.java b/src/test/java/us/kbase/test/auth2/lib/UserUpdateTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/UserUpdateTest.java rename to src/test/java/us/kbase/test/auth2/lib/UserUpdateTest.java diff --git a/src/us/kbase/test/auth2/lib/UtilsTest.java b/src/test/java/us/kbase/test/auth2/lib/UtilsTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/UtilsTest.java rename to src/test/java/us/kbase/test/auth2/lib/UtilsTest.java diff --git a/src/us/kbase/test/auth2/lib/ViewableUserTest.java b/src/test/java/us/kbase/test/auth2/lib/ViewableUserTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/ViewableUserTest.java rename to src/test/java/us/kbase/test/auth2/lib/ViewableUserTest.java diff --git a/src/us/kbase/test/auth2/lib/config/AuthConfigTest.java b/src/test/java/us/kbase/test/auth2/lib/config/AuthConfigTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/config/AuthConfigTest.java rename to src/test/java/us/kbase/test/auth2/lib/config/AuthConfigTest.java diff --git a/src/us/kbase/test/auth2/lib/config/CollectingExternalConfigTest.java b/src/test/java/us/kbase/test/auth2/lib/config/CollectingExternalConfigTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/config/CollectingExternalConfigTest.java rename to src/test/java/us/kbase/test/auth2/lib/config/CollectingExternalConfigTest.java diff --git a/src/us/kbase/test/auth2/lib/config/FailConfig.java b/src/test/java/us/kbase/test/auth2/lib/config/FailConfig.java similarity index 100% rename from src/us/kbase/test/auth2/lib/config/FailConfig.java rename to src/test/java/us/kbase/test/auth2/lib/config/FailConfig.java diff --git a/src/us/kbase/test/auth2/lib/config/TestExternalConfig.java b/src/test/java/us/kbase/test/auth2/lib/config/TestExternalConfig.java similarity index 100% rename from src/us/kbase/test/auth2/lib/config/TestExternalConfig.java rename to src/test/java/us/kbase/test/auth2/lib/config/TestExternalConfig.java diff --git a/src/us/kbase/test/auth2/lib/exceptions/ExceptionTest.java b/src/test/java/us/kbase/test/auth2/lib/exceptions/ExceptionTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/exceptions/ExceptionTest.java rename to src/test/java/us/kbase/test/auth2/lib/exceptions/ExceptionTest.java diff --git a/src/us/kbase/test/auth2/lib/identity/IdentityProviderConfigTest.java b/src/test/java/us/kbase/test/auth2/lib/identity/IdentityProviderConfigTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/identity/IdentityProviderConfigTest.java rename to src/test/java/us/kbase/test/auth2/lib/identity/IdentityProviderConfigTest.java diff --git a/src/us/kbase/test/auth2/lib/identity/RemoteIdentityTest.java b/src/test/java/us/kbase/test/auth2/lib/identity/RemoteIdentityTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/identity/RemoteIdentityTest.java rename to src/test/java/us/kbase/test/auth2/lib/identity/RemoteIdentityTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageAnonymousIDTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageAnonymousIDTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageAnonymousIDTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageAnonymousIDTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageConfigTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageConfigTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageConfigTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageConfigTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageCustomRoleTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageCustomRoleTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageCustomRoleTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageCustomRoleTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageDisableAccountTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageDisableAccountTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageDisableAccountTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageDisableAccountTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageDuplicateKeyCheckerTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageDuplicateKeyCheckerTest.java similarity index 98% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageDuplicateKeyCheckerTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageDuplicateKeyCheckerTest.java index 19fe314c..cf19b290 100644 --- a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageDuplicateKeyCheckerTest.java +++ b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageDuplicateKeyCheckerTest.java @@ -131,8 +131,9 @@ public void unparseable() throws Exception { fail("expected exception"); } catch (InvocationTargetException ex) { TestCommon.assertExceptionCorrect((Exception) ex.getTargetException(), - new AuthStorageException("Unable to parse duplicate key error: some ")); - + new AuthStorageException("Unable to parse duplicate key error: " + + "Write operation error on server 127.0.0.1:27017. " + + "Write error: WriteError{code=11000, message='some ")); } } diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageGetDisplayNamesTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageGetDisplayNamesTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageGetDisplayNamesTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageGetDisplayNamesTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageInvalidDBDataTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageInvalidDBDataTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageInvalidDBDataTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageInvalidDBDataTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageLinkTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageLinkTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageLinkTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageLinkTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStoragePasswordTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStoragePasswordTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStoragePasswordTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStoragePasswordTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageRecanonicalizationTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageRecanonicalizationTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageRecanonicalizationTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageRecanonicalizationTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageRolesTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageRolesTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageRolesTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageRolesTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java similarity index 70% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java index 14e12c3a..f6642907 100644 --- a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java +++ b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java @@ -1,9 +1,9 @@ package us.kbase.test.auth2.lib.storage.mongo; import static org.hamcrest.CoreMatchers.is; + import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; - import static us.kbase.test.auth2.TestCommon.set; import java.util.Arrays; @@ -36,7 +36,7 @@ public void nullConstructor() throws Exception { assertThat("incorrect exception message", e.getMessage(), is("db")); } } - + @Test public void startUpAndCheckConfigDoc() throws Exception { final MongoDatabase db = mc.getDatabase("startUpAndCheckConfigDoc"); @@ -45,35 +45,35 @@ public void startUpAndCheckConfigDoc() throws Exception { assertThat("Only one config doc", col.countDocuments(), is(1L)); final FindIterable c = col.find(); final Document d = c.first(); - + assertThat("correct config key & value", (String)d.get("schema"), is("schema")); assertThat("not in update", (Boolean)d.get("inupdate"), is(false)); assertThat("schema v1", (Integer)d.get("schemaver"), is(1)); - + //check startup works with the config object in place final MongoStorage ms = new MongoStorage(db); ms.setCustomRole(new CustomRole("foo", "bar")); assertThat("failed basic storage operation", ms.getCustomRoles(), is(set(new CustomRole("foo", "bar")))); } - + @Test public void startUpWith2ConfigDocs() throws Exception { final MongoDatabase db = mc.getDatabase("startUpWith2ConfigDocs"); - + final Document m = new Document("schema", "schema") .append("inupdate", false) .append("schemaver", 1); - + db.getCollection("config").insertMany(Arrays.asList(m, // need to create a new document to create a new mongo _id new Document(m))); - + final Pattern errorPattern = Pattern.compile( "Failed to create index: Write failed with error code 11000 and error message " + - "'(exception: )?E11000 duplicate key error (index|collection): " + + "'(exception: )?(.*)E11000 duplicate key error (index|collection): " + "startUpWith2ConfigDocs.config( index: |\\.\\$)schema_1\\s+dup key: " + - "\\{ : \"schema\" \\}'"); + "(\\{ schema: \"schema\" \\}'|\\{ : \"schema\" \\}')"); try { new MongoStorage(db); fail("started mongo with bad config"); @@ -82,36 +82,36 @@ public void startUpWith2ConfigDocs() throws Exception { assertThat("exception did not match: \n" + e.getMessage(), match.matches(), is(true)); } } - + @Test public void startUpWithBadSchemaVersion() throws Exception { final MongoDatabase db = mc.getDatabase("startUpWithBadSchemaVersion"); - + final Document m = new Document("schema", "schema") .append("inupdate", false) .append("schemaver", 4); - + db.getCollection("config").insertOne(m); - + failMongoStart(db, new StorageInitException( "Incompatible database schema. Server is v1, DB is v4")); } - + @Test public void startUpWithUpdateInProgress() throws Exception { final MongoDatabase db = mc.getDatabase("startUpWithUpdateInProgress"); - + final Document m = new Document("schema", "schema") .append("inupdate", true) .append("schemaver", 1); - + db.getCollection("config").insertOne(m); - + failMongoStart(db, new StorageInitException( "The database is in the middle of an update from v1 of the " + "schema. Aborting startup.")); } - + private void failMongoStart(final MongoDatabase db, final Exception exp) throws Exception { try { @@ -121,13 +121,13 @@ private void failMongoStart(final MongoDatabase db, final Exception exp) TestCommon.assertExceptionCorrect(e, exp); } } - + /* The following tests ensure that all indexes are created correctly. The collection names - * are tested so that if a new collection is added the test will fail without altering + * are tested so that if a new collection is added the test will fail without altering * said test, at which time the coder will hopefully read this notice and add index tests * for the new collection. */ - + @Test public void checkCollectionNames() throws Exception { final Set names = new HashSet<>(); @@ -151,284 +151,246 @@ public void checkCollectionNames() throws Exception { db.listCollectionNames().forEach((Consumer) names::add); assertThat("incorrect collection names", names, is(expected)); } - + @Test public void indexesConfig() { - final Set indexes = new HashSet<>(); - db.getCollection("config").listIndexes().forEach((Consumer) indexes::add); + final Set indexes = getAndNormalizeIndexes("config"); assertThat("incorrect indexes", indexes, is(set( new Document("v", indexVer) .append("unique", true) .append("key", new Document("schema", 1)) - .append("name", "schema_1") - .append("ns", "test_mongostorage.config"), + .append("name", "schema_1"), new Document("v", indexVer) .append("key", new Document("_id", 1)) .append("name", "_id_") - .append("ns", "test_mongostorage.config") ))); } - + @Test public void indexesConfigApp() { - final Set indexes = new HashSet<>(); - db.getCollection("config_app").listIndexes().forEach((Consumer) indexes::add); + final Set indexes = getAndNormalizeIndexes("config_app"); assertThat("incorrect indexes", indexes, is(set( new Document("v", indexVer) .append("unique", true) .append("key", new Document("key", 1)) - .append("name", "key_1") - .append("ns", "test_mongostorage.config_app"), + .append("name", "key_1"), new Document("v", indexVer) .append("key", new Document("_id", 1)) .append("name", "_id_") - .append("ns", "test_mongostorage.config_app") ))); } - + @Test public void indexesConfigExt() { - final Set indexes = new HashSet<>(); - db.getCollection("config_ext").listIndexes().forEach((Consumer) indexes::add); + final Set indexes = getAndNormalizeIndexes("config_ext"); assertThat("incorrect indexes", indexes, is(set( new Document("v", indexVer) .append("unique", true) .append("key", new Document("key", 1)) - .append("name", "key_1") - .append("ns", "test_mongostorage.config_ext"), + .append("name", "key_1"), new Document("v", indexVer) .append("key", new Document("_id", 1)) .append("name", "_id_") - .append("ns", "test_mongostorage.config_ext") ))); } - + @Test public void indexesConfigProv() { - final Set indexes = new HashSet<>(); - db.getCollection("config_prov").listIndexes().forEach((Consumer) indexes::add); + final Set indexes = getAndNormalizeIndexes("config_prov"); assertThat("incorrect indexes", indexes, is(set( new Document("v", indexVer) .append("unique", true) .append("key", new Document("prov", 1).append("key", 1)) - .append("name", "prov_1_key_1") - .append("ns", "test_mongostorage.config_prov"), + .append("name", "prov_1_key_1"), new Document("v", indexVer) .append("key", new Document("_id", 1)) .append("name", "_id_") - .append("ns", "test_mongostorage.config_prov") ))); } - + @Test public void indexesCustRoles() { - final Set indexes = new HashSet<>(); - db.getCollection("cust_roles").listIndexes().forEach((Consumer) indexes::add); + final Set indexes = getAndNormalizeIndexes("cust_roles"); assertThat("incorrect indexes", indexes, is(set( new Document("v", indexVer) .append("unique", true) .append("key", new Document("id", 1)) - .append("name", "id_1") - .append("ns", "test_mongostorage.cust_roles"), + .append("name", "id_1"), new Document("v", indexVer) .append("key", new Document("_id", 1)) .append("name", "_id_") - .append("ns", "test_mongostorage.cust_roles") ))); } - + @Test public void indexesTestCustRoles() { - final Set indexes = new HashSet<>(); - db.getCollection("test_cust_roles").listIndexes() - .forEach((Consumer) indexes::add); + final Set indexes = getAndNormalizeIndexes("test_cust_roles"); assertThat("incorrect indexes", indexes, is(set( new Document("v", indexVer) .append("unique", true) .append("key", new Document("id", 1)) - .append("name", "id_1") - .append("ns", "test_mongostorage.test_cust_roles"), + .append("name", "id_1"), new Document("v", indexVer) .append("key", new Document("_id", 1)) - .append("name", "_id_") - .append("ns", "test_mongostorage.test_cust_roles"), + .append("name", "_id_"), new Document("v", indexVer) .append("key", new Document("expires", 1)) .append("name", "expires_1") - .append("ns", "test_mongostorage.test_cust_roles") .append("expireAfterSeconds", 0L) ))); } - + @Test public void indexesTempData() { - final Set indexes = new HashSet<>(); - db.getCollection("tempdata").listIndexes().forEach((Consumer) indexes::add); + final Set indexes = getAndNormalizeIndexes("tempdata"); assertThat("incorrect indexes", indexes, is(set( new Document("v", indexVer) .append("unique", true) .append("key", new Document("token", 1)) - .append("name", "token_1") - .append("ns", "test_mongostorage.tempdata"), + .append("name", "token_1"), new Document("v", indexVer) .append("key", new Document("expires", 1)) .append("name", "expires_1") - .append("ns", "test_mongostorage.tempdata") .append("expireAfterSeconds", 0L), new Document("v", indexVer) .append("sparse", true) .append("key", new Document("user", 1)) - .append("name", "user_1") - .append("ns", "test_mongostorage.tempdata"), + .append("name", "user_1"), new Document("v", indexVer) .append("key", new Document("_id", 1)) - .append("name", "_id_") - .append("ns", "test_mongostorage.tempdata"), + .append("name", "_id_"), new Document("v", indexVer) .append("unique", true) .append("key", new Document("id", 1)) .append("name", "id_1") - .append("ns", "test_mongostorage.tempdata") ))); } - + @Test public void indexesTokens() { - final Set indexes = new HashSet<>(); - db.getCollection("tokens").listIndexes().forEach((Consumer) indexes::add); + final Set indexes = getAndNormalizeIndexes("tokens"); assertThat("incorrect indexes", indexes, is(set( new Document("v", indexVer) .append("unique", true) .append("key", new Document("token", 1)) - .append("name", "token_1") - .append("ns", "test_mongostorage.tokens"), + .append("name", "token_1"), new Document("v", indexVer) .append("key", new Document("expires", 1)) .append("name", "expires_1") - .append("ns", "test_mongostorage.tokens") .append("expireAfterSeconds", 0L), new Document("v", indexVer) .append("key", new Document("_id", 1)) - .append("name", "_id_") - .append("ns", "test_mongostorage.tokens"), + .append("name", "_id_"), new Document("v", indexVer) .append("key", new Document("user", 1)) - .append("name", "user_1") - .append("ns", "test_mongostorage.tokens"), + .append("name", "user_1"), new Document("v", indexVer) .append("unique", true) .append("key", new Document("id", 1)) .append("name", "id_1") - .append("ns", "test_mongostorage.tokens") ))); } - + @Test public void indexesTestTokens() { - final Set indexes = new HashSet<>(); - db.getCollection("test_tokens").listIndexes().forEach((Consumer) indexes::add); + final Set indexes = getAndNormalizeIndexes("test_tokens"); assertThat("incorrect indexes", indexes, is(set( new Document("v", indexVer) .append("unique", true) .append("key", new Document("token", 1)) - .append("name", "token_1") - .append("ns", "test_mongostorage.test_tokens"), + .append("name", "token_1"), new Document("v", indexVer) .append("key", new Document("expires", 1)) .append("name", "expires_1") - .append("ns", "test_mongostorage.test_tokens") .append("expireAfterSeconds", 0L), new Document("v", indexVer) .append("key", new Document("_id", 1)) - .append("name", "_id_") - .append("ns", "test_mongostorage.test_tokens"), + .append("name", "_id_"), new Document("v", indexVer) .append("key", new Document("user", 1)) - .append("name", "user_1") - .append("ns", "test_mongostorage.test_tokens"), + .append("name", "user_1"), new Document("v", indexVer) .append("unique", true) .append("key", new Document("id", 1)) .append("name", "id_1") - .append("ns", "test_mongostorage.test_tokens") ))); } - + @Test public void indexesUsers() { - final Set indexes = new HashSet<>(); - db.getCollection("users").listIndexes().forEach((Consumer) indexes::add); + final Set indexes = getAndNormalizeIndexes("users"); assertThat("incorrect indexes", indexes, is(set( new Document("v", indexVer) .append("key", new Document("custrls", 1)) .append("name", "custrls_1") - .append("ns", "test_mongostorage.users") .append("sparse", true), new Document("v", indexVer) .append("key", new Document("dispcan", 1)) - .append("name", "dispcan_1") - .append("ns", "test_mongostorage.users"), + .append("name", "dispcan_1"), new Document("v", indexVer) .append("key", new Document("_id", 1)) - .append("name", "_id_") - .append("ns", "test_mongostorage.users"), + .append("name", "_id_"), new Document("v", indexVer) - .append("unique", true) + .append("unique", true) .append("key", new Document("idents.id", 1)) .append("name", "idents.id_1") - .append("ns", "test_mongostorage.users") .append("sparse", true), new Document("v", indexVer) .append("key", new Document("roles", 1)) .append("name", "roles_1") - .append("ns", "test_mongostorage.users") .append("sparse", true), new Document("v", indexVer) .append("unique", true) .append("key", new Document("user", 1)) - .append("name", "user_1") - .append("ns", "test_mongostorage.users"), + .append("name", "user_1"), new Document("v", indexVer) .append("key", new Document("anonid", 1)) .append("name", "anonid_1") - .append("ns", "test_mongostorage.users") .append("sparse", true) ))); } - + @Test public void indexesTestUsers() { - final Set indexes = new HashSet<>(); - db.getCollection("test_users").listIndexes().forEach((Consumer) indexes::add); + final Set indexes = getAndNormalizeIndexes("test_users"); assertThat("incorrect indexes", indexes, is(set( new Document("v", indexVer) .append("key", new Document("custrls", 1)) .append("name", "custrls_1") - .append("ns", "test_mongostorage.test_users") .append("sparse", true), new Document("v", indexVer) .append("key", new Document("dispcan", 1)) - .append("name", "dispcan_1") - .append("ns", "test_mongostorage.test_users"), + .append("name", "dispcan_1"), new Document("v", indexVer) .append("key", new Document("_id", 1)) - .append("name", "_id_") - .append("ns", "test_mongostorage.test_users"), + .append("name", "_id_"), new Document("v", indexVer) .append("key", new Document("roles", 1)) .append("name", "roles_1") - .append("ns", "test_mongostorage.test_users") .append("sparse", true), new Document("v", indexVer) .append("unique", true) .append("key", new Document("user", 1)) - .append("name", "user_1") - .append("ns", "test_mongostorage.test_users"), + .append("name", "user_1"), new Document("v", indexVer) .append("key", new Document("expires", 1)) .append("name", "expires_1") - .append("ns", "test_mongostorage.test_users") .append("expireAfterSeconds", 0L) ))); } + + private Set getAndNormalizeIndexes(final String collectionName) { + final Set indexes = new HashSet<>(); + for (Document index: db.getCollection(collectionName).listIndexes()) { + // In MongoDB 4.4, the listIndexes and the mongo shell helper method db.collection.getIndexes() + // no longer returns the namespace ns field in the index specification documents. + index.remove("ns"); + // some versions of Mongo return ints, some longs. Convert all to longs. + if (index.containsKey("expireAfterSeconds")) { + index.put("expireAfterSeconds", ((Number) index.get("expireAfterSeconds")).longValue()); + } + indexes.add(index); + } + return indexes; + } } diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTempSessionDataTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTempSessionDataTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTempSessionDataTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTempSessionDataTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestCommon.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestCommon.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestCommon.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestCommon.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestGetDisplayNamesTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestGetDisplayNamesTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestGetDisplayNamesTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestGetDisplayNamesTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestRoleTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestRoleTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestRoleTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestRoleTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestTokensTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestTokensTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestTokensTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestTokensTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestUserCreateGetTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestUserCreateGetTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestUserCreateGetTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTestUserCreateGetTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTester.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTester.java similarity index 97% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTester.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTester.java index 0e53ca84..94f6c902 100644 --- a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTester.java +++ b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTester.java @@ -7,7 +7,7 @@ import org.junit.BeforeClass; import com.github.zafarkhaja.semver.Version; -import com.mongodb.MongoClient; +import com.mongodb.client.MongoClient; import com.mongodb.client.MongoDatabase; import us.kbase.auth2.cryptutils.RandomDataGenerator; diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTokensTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTokensTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTokensTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageTokensTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageUpdateUserFieldsTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageUpdateUserFieldsTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageUpdateUserFieldsTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageUpdateUserFieldsTest.java diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageUserCreateGetTest.java b/src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageUserCreateGetTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageUserCreateGetTest.java rename to src/test/java/us/kbase/test/auth2/lib/storage/mongo/MongoStorageUserCreateGetTest.java diff --git a/src/us/kbase/test/auth2/lib/token/TokenNameTest.java b/src/test/java/us/kbase/test/auth2/lib/token/TokenNameTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/token/TokenNameTest.java rename to src/test/java/us/kbase/test/auth2/lib/token/TokenNameTest.java diff --git a/src/us/kbase/test/auth2/lib/token/TokenTest.java b/src/test/java/us/kbase/test/auth2/lib/token/TokenTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/token/TokenTest.java rename to src/test/java/us/kbase/test/auth2/lib/token/TokenTest.java diff --git a/src/us/kbase/test/auth2/lib/user/AuthUserTest.java b/src/test/java/us/kbase/test/auth2/lib/user/AuthUserTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/user/AuthUserTest.java rename to src/test/java/us/kbase/test/auth2/lib/user/AuthUserTest.java diff --git a/src/us/kbase/test/auth2/lib/user/LocalUserTest.java b/src/test/java/us/kbase/test/auth2/lib/user/LocalUserTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/user/LocalUserTest.java rename to src/test/java/us/kbase/test/auth2/lib/user/LocalUserTest.java diff --git a/src/us/kbase/test/auth2/lib/user/NewUserTest.java b/src/test/java/us/kbase/test/auth2/lib/user/NewUserTest.java similarity index 100% rename from src/us/kbase/test/auth2/lib/user/NewUserTest.java rename to src/test/java/us/kbase/test/auth2/lib/user/NewUserTest.java diff --git a/src/us/kbase/test/auth2/providers/GlobusIdentityProviderTest.java b/src/test/java/us/kbase/test/auth2/providers/GlobusIdentityProviderTest.java similarity index 100% rename from src/us/kbase/test/auth2/providers/GlobusIdentityProviderTest.java rename to src/test/java/us/kbase/test/auth2/providers/GlobusIdentityProviderTest.java diff --git a/src/us/kbase/test/auth2/providers/GoogleIdentityProviderTest.java b/src/test/java/us/kbase/test/auth2/providers/GoogleIdentityProviderTest.java similarity index 100% rename from src/us/kbase/test/auth2/providers/GoogleIdentityProviderTest.java rename to src/test/java/us/kbase/test/auth2/providers/GoogleIdentityProviderTest.java diff --git a/src/us/kbase/test/auth2/providers/OrcIDIdentityProviderTest.java b/src/test/java/us/kbase/test/auth2/providers/OrcIDIdentityProviderTest.java similarity index 100% rename from src/us/kbase/test/auth2/providers/OrcIDIdentityProviderTest.java rename to src/test/java/us/kbase/test/auth2/providers/OrcIDIdentityProviderTest.java diff --git a/src/us/kbase/test/auth2/service/AuthExternalConfigTest.java b/src/test/java/us/kbase/test/auth2/service/AuthExternalConfigTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/AuthExternalConfigTest.java rename to src/test/java/us/kbase/test/auth2/service/AuthExternalConfigTest.java diff --git a/src/us/kbase/test/auth2/service/LoggingFilterTest.java b/src/test/java/us/kbase/test/auth2/service/LoggingFilterTest.java similarity index 99% rename from src/us/kbase/test/auth2/service/LoggingFilterTest.java rename to src/test/java/us/kbase/test/auth2/service/LoggingFilterTest.java index 4e9ce017..2c79f2ce 100644 --- a/src/us/kbase/test/auth2/service/LoggingFilterTest.java +++ b/src/test/java/us/kbase/test/auth2/service/LoggingFilterTest.java @@ -87,6 +87,11 @@ public String getMongoHost() { public String getMongoDatabase() { return DB_NAME; } + + @Override + public boolean getMongoRetryWrites() { + return false; + } @Override public Optional getMongoUser() { diff --git a/src/us/kbase/test/auth2/service/ServiceTestUtils.java b/src/test/java/us/kbase/test/auth2/service/ServiceTestUtils.java similarity index 100% rename from src/us/kbase/test/auth2/service/ServiceTestUtils.java rename to src/test/java/us/kbase/test/auth2/service/ServiceTestUtils.java diff --git a/src/us/kbase/test/auth2/service/api/APITokenTest.java b/src/test/java/us/kbase/test/auth2/service/api/APITokenTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/api/APITokenTest.java rename to src/test/java/us/kbase/test/auth2/service/api/APITokenTest.java diff --git a/src/us/kbase/test/auth2/service/api/AdminIntegrationTest.java b/src/test/java/us/kbase/test/auth2/service/api/AdminIntegrationTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/api/AdminIntegrationTest.java rename to src/test/java/us/kbase/test/auth2/service/api/AdminIntegrationTest.java diff --git a/src/us/kbase/test/auth2/service/api/AdminTest.java b/src/test/java/us/kbase/test/auth2/service/api/AdminTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/api/AdminTest.java rename to src/test/java/us/kbase/test/auth2/service/api/AdminTest.java diff --git a/src/us/kbase/test/auth2/service/api/TestModeIntegrationTest.java b/src/test/java/us/kbase/test/auth2/service/api/TestModeIntegrationTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/api/TestModeIntegrationTest.java rename to src/test/java/us/kbase/test/auth2/service/api/TestModeIntegrationTest.java diff --git a/src/us/kbase/test/auth2/service/api/TestModeTest.java b/src/test/java/us/kbase/test/auth2/service/api/TestModeTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/api/TestModeTest.java rename to src/test/java/us/kbase/test/auth2/service/api/TestModeTest.java diff --git a/src/us/kbase/test/auth2/service/api/TokenEndpointTest.java b/src/test/java/us/kbase/test/auth2/service/api/TokenEndpointTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/api/TokenEndpointTest.java rename to src/test/java/us/kbase/test/auth2/service/api/TokenEndpointTest.java diff --git a/src/us/kbase/test/auth2/service/api/UserEndpointTest.java b/src/test/java/us/kbase/test/auth2/service/api/UserEndpointTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/api/UserEndpointTest.java rename to src/test/java/us/kbase/test/auth2/service/api/UserEndpointTest.java diff --git a/src/us/kbase/test/auth2/service/api/package-info.java b/src/test/java/us/kbase/test/auth2/service/api/package-info.java similarity index 100% rename from src/us/kbase/test/auth2/service/api/package-info.java rename to src/test/java/us/kbase/test/auth2/service/api/package-info.java diff --git a/src/us/kbase/test/auth2/service/common/ExternalTokenTest.java b/src/test/java/us/kbase/test/auth2/service/common/ExternalTokenTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/common/ExternalTokenTest.java rename to src/test/java/us/kbase/test/auth2/service/common/ExternalTokenTest.java diff --git a/src/us/kbase/test/auth2/service/common/FailOnInstantiation.java b/src/test/java/us/kbase/test/auth2/service/common/FailOnInstantiation.java similarity index 100% rename from src/us/kbase/test/auth2/service/common/FailOnInstantiation.java rename to src/test/java/us/kbase/test/auth2/service/common/FailOnInstantiation.java diff --git a/src/us/kbase/test/auth2/service/common/FailOnInstantiationNoNullaryConstructor.java b/src/test/java/us/kbase/test/auth2/service/common/FailOnInstantiationNoNullaryConstructor.java similarity index 100% rename from src/us/kbase/test/auth2/service/common/FailOnInstantiationNoNullaryConstructor.java rename to src/test/java/us/kbase/test/auth2/service/common/FailOnInstantiationNoNullaryConstructor.java diff --git a/src/us/kbase/test/auth2/service/common/FailOnInstantiationPrivateConstructor.java b/src/test/java/us/kbase/test/auth2/service/common/FailOnInstantiationPrivateConstructor.java similarity index 100% rename from src/us/kbase/test/auth2/service/common/FailOnInstantiationPrivateConstructor.java rename to src/test/java/us/kbase/test/auth2/service/common/FailOnInstantiationPrivateConstructor.java diff --git a/src/us/kbase/test/auth2/service/common/IncomingJSONTest.java b/src/test/java/us/kbase/test/auth2/service/common/IncomingJSONTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/common/IncomingJSONTest.java rename to src/test/java/us/kbase/test/auth2/service/common/IncomingJSONTest.java diff --git a/src/us/kbase/test/auth2/service/common/ServiceCommonTest.java b/src/test/java/us/kbase/test/auth2/service/common/ServiceCommonTest.java similarity index 99% rename from src/us/kbase/test/auth2/service/common/ServiceCommonTest.java rename to src/test/java/us/kbase/test/auth2/service/common/ServiceCommonTest.java index 5edda50b..9d8b9eb0 100644 --- a/src/us/kbase/test/auth2/service/common/ServiceCommonTest.java +++ b/src/test/java/us/kbase/test/auth2/service/common/ServiceCommonTest.java @@ -47,7 +47,7 @@ public class ServiceCommonTest { public static final String SERVICE_NAME = "Authentication Service"; - public static final String SERVER_VER = "0.6.0"; + public static final String SERVER_VER = "0.6.1"; public static final String GIT_ERR = "Missing git commit file gitcommit, should be in us.kbase.auth2"; diff --git a/src/us/kbase/test/auth2/service/common/package-info.java b/src/test/java/us/kbase/test/auth2/service/common/package-info.java similarity index 100% rename from src/us/kbase/test/auth2/service/common/package-info.java rename to src/test/java/us/kbase/test/auth2/service/common/package-info.java diff --git a/src/us/kbase/test/auth2/service/ui/AdminIntegrationTest.java b/src/test/java/us/kbase/test/auth2/service/ui/AdminIntegrationTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/AdminIntegrationTest.java rename to src/test/java/us/kbase/test/auth2/service/ui/AdminIntegrationTest.java diff --git a/src/us/kbase/test/auth2/service/ui/AdminTest.java b/src/test/java/us/kbase/test/auth2/service/ui/AdminTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/AdminTest.java rename to src/test/java/us/kbase/test/auth2/service/ui/AdminTest.java diff --git a/src/us/kbase/test/auth2/service/ui/LinkTest.java b/src/test/java/us/kbase/test/auth2/service/ui/LinkTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LinkTest.java rename to src/test/java/us/kbase/test/auth2/service/ui/LinkTest.java diff --git a/src/us/kbase/test/auth2/service/ui/LoginTest.java b/src/test/java/us/kbase/test/auth2/service/ui/LoginTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LoginTest.java rename to src/test/java/us/kbase/test/auth2/service/ui/LoginTest.java diff --git a/src/us/kbase/test/auth2/service/ui/MeTest.java b/src/test/java/us/kbase/test/auth2/service/ui/MeTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/MeTest.java rename to src/test/java/us/kbase/test/auth2/service/ui/MeTest.java diff --git a/src/us/kbase/test/auth2/service/ui/PKCEChallengeMatcher.java b/src/test/java/us/kbase/test/auth2/service/ui/PKCEChallengeMatcher.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/PKCEChallengeMatcher.java rename to src/test/java/us/kbase/test/auth2/service/ui/PKCEChallengeMatcher.java diff --git a/src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest.java b/src/test/java/us/kbase/test/auth2/service/ui/SimpleEndpointsTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest.java rename to src/test/java/us/kbase/test/auth2/service/ui/SimpleEndpointsTest.java diff --git a/src/us/kbase/test/auth2/service/ui/StateMatcher.java b/src/test/java/us/kbase/test/auth2/service/ui/StateMatcher.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/StateMatcher.java rename to src/test/java/us/kbase/test/auth2/service/ui/StateMatcher.java diff --git a/src/us/kbase/test/auth2/service/ui/TokensTest.java b/src/test/java/us/kbase/test/auth2/service/ui/TokensTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/TokensTest.java rename to src/test/java/us/kbase/test/auth2/service/ui/TokensTest.java diff --git a/src/us/kbase/test/auth2/service/ui/UITokensTest.java b/src/test/java/us/kbase/test/auth2/service/ui/UITokensTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/UITokensTest.java rename to src/test/java/us/kbase/test/auth2/service/ui/UITokensTest.java diff --git a/src/us/kbase/test/auth2/service/ui/UIUtilsTest.java b/src/test/java/us/kbase/test/auth2/service/ui/UIUtilsTest.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/UIUtilsTest.java rename to src/test/java/us/kbase/test/auth2/service/ui/UIUtilsTest.java diff --git a/src/us/kbase/test/auth2/service/ui/package-info.java b/src/test/java/us/kbase/test/auth2/service/ui/package-info.java similarity index 100% rename from src/us/kbase/test/auth2/service/ui/package-info.java rename to src/test/java/us/kbase/test/auth2/service/ui/package-info.java diff --git a/src/us/kbase/test/auth2/service/ui/AdminIntegrationTest_userDisplay.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/AdminIntegrationTest_userDisplay.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/AdminIntegrationTest_userDisplay.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/AdminIntegrationTest_userDisplay.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTML.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTML.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTML.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTML.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLNoLinks.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLNoLinks.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLNoLinks.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLNoLinks.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLOnlyLinks.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLOnlyLinks.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLOnlyLinks.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLOnlyLinks.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLTrailingSlash.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLTrailingSlash.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLTrailingSlash.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkChoiceHTMLTrailingSlash.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayNoProviders.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayNoProviders.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayNoProviders.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayNoProviders.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithLocalUser.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithLocalUser.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithLocalUser.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithLocalUser.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithOneProvider.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithOneProvider.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithOneProvider.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithOneProvider.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithTwoProviders.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithTwoProviders.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithTwoProviders.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LinkTest_linkDisplayWithTwoProviders.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2CreateAndLoginDisabled.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2CreateAndLoginDisabled.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2CreateAndLoginDisabled.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2CreateAndLoginDisabled.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2CreateWithRedirectURL.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2CreateWithRedirectURL.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2CreateWithRedirectURL.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2CreateWithRedirectURL.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2LoginWithRedirectAndLoginDisabled.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2LoginWithRedirectAndLoginDisabled.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2LoginWithRedirectAndLoginDisabled.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_loginChoice2LoginWithRedirectAndLoginDisabled.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LoginTest_loginChoice3Create2Login.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_loginChoice3Create2Login.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LoginTest_loginChoice3Create2Login.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_loginChoice3Create2Login.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LoginTest_startDisplayLoginDisabled.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_startDisplayLoginDisabled.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LoginTest_startDisplayLoginDisabled.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_startDisplayLoginDisabled.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LoginTest_startDisplayWithOneProvider.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_startDisplayWithOneProvider.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LoginTest_startDisplayWithOneProvider.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_startDisplayWithOneProvider.testdata diff --git a/src/us/kbase/test/auth2/service/ui/LoginTest_startDisplayWithTwoProviders.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_startDisplayWithTwoProviders.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/LoginTest_startDisplayWithTwoProviders.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/LoginTest_startDisplayWithTwoProviders.testdata diff --git a/src/us/kbase/test/auth2/service/ui/MeTest_getMeMaximalInput.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/MeTest_getMeMaximalInput.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/MeTest_getMeMaximalInput.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/MeTest_getMeMaximalInput.testdata diff --git a/src/us/kbase/test/auth2/service/ui/MeTest_getMeMinimalInput.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/MeTest_getMeMinimalInput.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/MeTest_getMeMinimalInput.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/MeTest_getMeMinimalInput.testdata diff --git a/src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_customRolesEmpty.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_customRolesEmpty.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_customRolesEmpty.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_customRolesEmpty.testdata diff --git a/src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_customRolesFull.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_customRolesFull.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_customRolesFull.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_customRolesFull.testdata diff --git a/src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginDisplay.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginDisplay.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginDisplay.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginDisplay.testdata diff --git a/src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginResetDisplayNoUser.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginResetDisplayNoUser.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginResetDisplayNoUser.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginResetDisplayNoUser.testdata diff --git a/src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginResetDisplayWithUser.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginResetDisplayWithUser.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginResetDisplayWithUser.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_localLoginResetDisplayWithUser.testdata diff --git a/src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutDisplay.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutDisplay.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutDisplay.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutDisplay.testdata diff --git a/src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutWithBadTokenHTML.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutWithBadTokenHTML.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutWithBadTokenHTML.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutWithBadTokenHTML.testdata diff --git a/src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutWithGoodTokenHTML.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutWithGoodTokenHTML.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutWithGoodTokenHTML.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_logoutWithGoodTokenHTML.testdata diff --git a/src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_rootHTML.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_rootHTML.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_rootHTML.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/SimpleEndpointsTest_rootHTML.testdata diff --git a/src/us/kbase/test/auth2/service/ui/TokensTest_createTokenMaximalInput.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/TokensTest_createTokenMaximalInput.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/TokensTest_createTokenMaximalInput.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/TokensTest_createTokenMaximalInput.testdata diff --git a/src/us/kbase/test/auth2/service/ui/TokensTest_createTokenMinimalInput.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/TokensTest_createTokenMinimalInput.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/TokensTest_createTokenMinimalInput.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/TokensTest_createTokenMinimalInput.testdata diff --git a/src/us/kbase/test/auth2/service/ui/TokensTest_getTokensMaximalInput.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/TokensTest_getTokensMaximalInput.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/TokensTest_getTokensMaximalInput.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/TokensTest_getTokensMaximalInput.testdata diff --git a/src/us/kbase/test/auth2/service/ui/TokensTest_getTokensMinimalInput.testdata b/src/test/resources/us/kbase/test/auth2/service/ui/TokensTest_getTokensMinimalInput.testdata similarity index 100% rename from src/us/kbase/test/auth2/service/ui/TokensTest_getTokensMinimalInput.testdata rename to src/test/resources/us/kbase/test/auth2/service/ui/TokensTest_getTokensMinimalInput.testdata diff --git a/src/us/kbase/test/auth2/authcontroller/authjars b/src/us/kbase/test/auth2/authcontroller/authjars deleted file mode 100644 index c79b8d68..00000000 --- a/src/us/kbase/test/auth2/authcontroller/authjars +++ /dev/null @@ -1,74 +0,0 @@ -kbase/auth2/kbase-auth2templates-0.4.3.zip - -kbase/auth2/kbase-auth2-0.4.3.jar -kbase/auth2/kbase-auth2test-0.4.3.jar - -#lib -apache_commons/commons-codec-1.8.jar -apache_commons/commons-validator-1.5.1.jar -google/guava-18.0.jar -ini4j/ini4j-0.5.2.jar -jcommander/jcommander-1.48.jar -mongo/mongo-java-driver-3.8.2.jar -mustache/compiler-0.9.3.jar -nulab-inc/zxcvbn-1.2.2.jar - -#logging -kbase/common/kbase-common-0.0.22.jar -jna/jna-3.4.0.jar -logback/logback-core-1.1.2.jar -logback/logback-classic-1.1.2.jar -slf4j/slf4j-api-1.7.25.jar -syslog4j/syslog4j-0.9.46.jar - -#yauaa -yauaa/yauaa-1.3.jar -apache_commons/commons-lang3-3.5.jar -apache_commons/commons-collections4-4.1.jar -apache_commons/commons-logging-1.2.jar -apache_commons/commons-io-2.4.jar -kohsuke/args4j-2.33.jar -snakeyaml/snakeyaml-1.18.jar - -#jackson -jackson/jackson-annotations-2.5.4.jar -jackson/jackson-core-2.5.4.jar -jackson/jackson-databind-2.5.4.jar -jackson/jackson-jaxrs-base-2.5.4.jar -jackson/jackson-jaxrs-json-provider-2.5.4.jar -jackson/jackson-module-jaxb-annotations-2.5.4.jar - -#jersey -jersey/entity-filtering/jersey-entity-filtering-2.23.2.jar -jersey/entity-filtering/jersey-media-json-jackson-2.23.2.jar -jersey/mvc/jersey-mvc-2.23.2.jar -jersey/mvc/jersey-mvc-mustache-2.23.2.jar -jersey/jersey-client-2.23.2.jar -jersey/jersey-common-2.23.2.jar -jersey/jersey-container-servlet-2.23.2.jar -jersey/jersey-container-servlet-core-2.23.2.jar -jersey/jersey-guava-2.23.2.jar -jersey/jersey-media-jaxb-2.23.2.jar -jersey/jersey-server-2.23.2.jar - -#jerseydeps -annotation/javax.annotation-api-1.2.jar -asm/asm-debug-all-5.0.4.jar -inject/javax.inject-2.5.0-b05.jar -javassist/javassist-3.20.0-GA.jar -jaxb/jaxb-api-2.2.7.jar -jaxrs/javax.ws.rs-api-2.0.1.jar -osgi/org.osgi.core-4.2.0.jar -persistence/persistence-api-1.0.jar -servlet/javax.servlet-api-3.0.1.jar -validationapi/validation-api-1.1.0.Final.jar - -#jerseydep_hk2 -hk2/aopalliance-repackaged-2.5.0-b05.jar -hk2/hk2-api-2.5.0-b05.jar -hk2/hk2-locator-2.5.0-b05.jar -hk2/hk2-utils-2.5.0-b05.jar -hk2/osgi-resource-locator-1.0.1.jar - -#test -jetty/jetty-all-9.3.11.v20160721-uber.jar diff --git a/templates/adminconfig.mustache b/templates/adminconfig.mustache index 800b5358..6e967912 100644 --- a/templates/adminconfig.mustache +++ b/templates/adminconfig.mustache @@ -28,24 +28,24 @@ The stack trace is always logged.

Allowed post-login redirect URL prefix: -

Redirect URL when a user cannot be logged in immediately after return from 3rd party provider, e.g. a choice of accounts is required or an account must be created. -

Redirect URL after an account link (usually to a user page showing their identities). -

Redirect URL when a user account cannot be linked immediately after return from 3rd party provider, e.g. a choice of accounts is required. -

@@ -87,24 +87,24 @@ provider, e.g. a choice of accounts is required.

Allowed post-login redirect URL prefix: -

Redirect URL when a user cannot be logged in immediately after return from 3rd party provider, e.g. a choice of accounts is required or an account must be created. -

Redirect URL after an account link (usually to a user page showing their identities). -

Redirect URL when a user account cannot be linked immediately after return from 3rd party provider, e.g. a choice of accounts is required. -

diff --git a/templates/admingeneral.mustache b/templates/admingeneral.mustache index c98f2306..986a7fcc 100644 --- a/templates/admingeneral.mustache +++ b/templates/admingeneral.mustache @@ -3,9 +3,6 @@
-
- -
View token:
@@ -34,5 +31,7 @@ {{id}}
{{/customroles}} +
+ \ No newline at end of file