diff --git a/build.gradle b/build.gradle index b6fc335..c7e321c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { id "java" - id "io.franzbecker.gradle-lombok" version "5.0.0" apply false - id "com.diffplug.spotless" version "6.25.0" apply false + id "io.freefair.lombok" version "8.6" + id "com.diffplug.spotless" version "6.25.0" id "com.avast.gradle.docker-compose" version "0.17.6" } @@ -25,6 +25,12 @@ tasks.withType(JavaCompile).configureEach { } tasks.withType(Test).configureEach { + useJUnitPlatform() + testLogging { + exceptionFormat = "full" + events = ["standardOut", "standardError", "skipped", "failed"] + } + testLogging { exceptionFormat = "full" events = ["standardOut", "standardError", "skipped", "failed"] @@ -38,54 +44,89 @@ spotless { } } -subprojects { +ext { + apacheHttpComponentsVersion = "4.5.14" + awaitilityVersion = "4.2.1" + bcryptVersion = "0.10.2" + caffeineVersion = "3.1.8" + checkstyleVersion = "8.45" + commonsCliVersion = "1.8.0" + commonsCodecVersion = "1.17.0" + commonsIoVersion = "2.16.1" + commonsMathVersion = "3.6.1" + commonsTextVersion = "1.12.0" + databaseRiderVersion = "1.42.0" + dropwizardVersion = "2.1.0" + dropwizardWebsocketsVersion = "1.3.14" + equalsVerifierVersion = "3.16.1" + feignCoreVersion = "13.2.1" + feignGsonVersion = "13.2.1" + javaWebSocketVersion = "1.5.3" + gsonVersion = "2.11.0" + guavaVersion = "33.2.1-jre" + hamcrestJsonVersion = "0.3" + hamcrestOptionalVersion = "2.0.0" + hamcrestVersion = "2.0.0.0" + jacksonDataTypeVersion = "2.17.1" + jakartaMailVersion = "2.0.1" + javaWebsocketVersion = "1.5.3" + javaxActivationVersion = "1.1.1" + jaxbApiVersion = "2.3.1" + jaxbCoreVersion = "4.0.5" + jaxbImplVersion = "4.0.5" + jdbiVersion = "3.45.1" + jetbrainsAnnotationsVersion = "24.1.0" + jlayerVersion = "1.0.1.4" + junitJupiterVersion = "5.10.2" + junitPlatformLauncherVersion = "1.10.2" + logbackClassicVersion = "1.2.11" + mockitoVersion = "5.11.0" + openFeignVersion = "13.2.1" + postgresqlVersion = "42.7.3" + snakeYamlVersion = "2.7" + sonatypeGoodiesPrefsVersion = "2.3.9" + substanceVersion = "4.5.0" + wireMockJunit5Version = "1.3.1" + wireMockVersion = "3.0.1" + xchartVersion = "3.8.8" + xmlUnitCore = "2.10.0" + xmlUnitMatchers = "2.10.0" +} - ext { - apacheHttpComponentsVersion = "4.5.14" - awaitilityVersion = "4.2.1" - bcryptVersion = "0.10.2" - caffeineVersion = "3.1.8" - checkstyleVersion = "8.45" - commonsCliVersion = "1.8.0" - commonsCodecVersion = "1.17.0" - commonsIoVersion = "2.16.1" - commonsMathVersion = "3.6.1" - commonsTextVersion = "1.12.0" - databaseRiderVersion = "1.42.0" - dropwizardVersion = "2.1.0" - dropwizardWebsocketsVersion = "1.3.14" - equalsVerifierVersion = "3.16.1" - feignCoreVersion = "13.2.1" - feignGsonVersion = "13.2.1" - javaWebSocketVersion = "1.5.3" - gsonVersion = "2.11.0" - guavaVersion = "33.2.1-jre" - hamcrestJsonVersion = "0.3" - hamcrestOptionalVersion = "2.0.0" - hamcrestVersion = "2.0.0.0" - jacksonDataTypeVersion = "2.17.1" - jakartaMailVersion = "2.0.1" - javaWebsocketVersion = "1.5.3" - javaxActivationVersion = "1.1.1" - jaxbApiVersion = "2.3.1" - jaxbCoreVersion = "4.0.5" - jaxbImplVersion = "4.0.5" - jdbiVersion = "3.45.1" - jetbrainsAnnotationsVersion = "24.1.0" - jlayerVersion = "1.0.1.4" - junitJupiterVersion = "5.10.2" - junitPlatformLauncherVersion = "1.10.2" - logbackClassicVersion = "1.2.11" - mockitoVersion = "5.11.0" - openFeignVersion = "13.2.1" - postgresqlVersion = "42.7.3" - snakeYamlVersion = "2.7" - sonatypeGoodiesPrefsVersion = "2.3.9" - substanceVersion = "4.5.0" - wireMockJunit5Version = "1.3.1" - wireMockVersion = "3.0.1" - xchartVersion = "3.8.8" - xmlUnitCore = "2.10.0" - xmlUnitMatchers = "2.10.0" - } +dependencies { + implementation "at.favre.lib:bcrypt:$bcryptVersion" + implementation "com.liveperson:dropwizard-websockets:$dropwizardWebsocketsVersion" + implementation "com.sun.mail:jakarta.mail:$jakartaMailVersion" + implementation "com.sun.xml.bind:jaxb-core:$jaxbCoreVersion" + implementation "com.sun.xml.bind:jaxb-impl:$jaxbImplVersion" + implementation "io.dropwizard:dropwizard-auth:$dropwizardVersion" + implementation "io.dropwizard:dropwizard-core:$dropwizardVersion" + implementation "io.dropwizard:dropwizard-jdbi3:$dropwizardVersion" + implementation "io.github.openfeign:feign-core:$openFeignVersion" + implementation "io.github.openfeign:feign-gson:$openFeignVersion" + implementation "javax.activation:activation:$javaxActivationVersion" + implementation "javax.xml.bind:jaxb-api:$jaxbApiVersion" + implementation "org.java-websocket:Java-WebSocket:$javaWebSocketVersion" + implementation "org.jdbi:jdbi3-core:$jdbiVersion" + implementation "org.jdbi:jdbi3-sqlobject:$jdbiVersion" + implementation "triplea:lobby-client:2.6.14759" + + testImplementation "com.github.database-rider:rider-junit5:$databaseRiderVersion" + testImplementation "com.github.npathai:hamcrest-optional:2.0.0" + testImplementation "com.sun.mail:jakarta.mail:$jakartaMailVersion" + testImplementation "io.dropwizard:dropwizard-testing:$dropwizardVersion" + testImplementation "org.awaitility:awaitility:$awaitilityVersion" + testImplementation "org.java-websocket:Java-WebSocket:$javaWebsocketVersion" + testImplementation "org.jdbi:jdbi3-core:$jdbiVersion" + testImplementation "org.jdbi:jdbi3-sqlobject:$jdbiVersion" + testImplementation "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion" + testImplementation "org.junit.jupiter:junit-jupiter-params:$junitJupiterVersion" + testImplementation "org.mockito:mockito-core:$mockitoVersion" + testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion" + testImplementation "org.wiremock:wiremock:3.7.0" + testImplementation "ru.lanwen.wiremock:wiremock-junit5:1.3.1" + testImplementation "uk.co.datumedge:hamcrest-json:$hamcrestJsonVersion" + + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junitPlatformLauncherVersion" } diff --git a/server/database/.dockerignore b/database/.dockerignore similarity index 100% rename from server/database/.dockerignore rename to database/.dockerignore diff --git a/server/database/README.md b/database/README.md similarity index 100% rename from server/database/README.md rename to database/README.md diff --git a/server/database/build.gradle b/database/build.gradle similarity index 100% rename from server/database/build.gradle rename to database/build.gradle diff --git a/server/database/connect_to_docker_db b/database/connect_to_docker_db similarity index 100% rename from server/database/connect_to_docker_db rename to database/connect_to_docker_db diff --git a/server/database/load_sample_data b/database/load_sample_data similarity index 100% rename from server/database/load_sample_data rename to database/load_sample_data diff --git a/server/database/reset_docker_db b/database/reset_docker_db similarity index 100% rename from server/database/reset_docker_db rename to database/reset_docker_db diff --git a/server/database/sql/init/01-create-users.sql b/database/sql/init/01-create-users.sql similarity index 100% rename from server/database/sql/init/01-create-users.sql rename to database/sql/init/01-create-users.sql diff --git a/server/database/sql/init/02-create-databases.sql b/database/sql/init/02-create-databases.sql similarity index 100% rename from server/database/sql/init/02-create-databases.sql rename to database/sql/init/02-create-databases.sql diff --git a/server/database/sql/sample_data/lobby_db_sample_data.sql b/database/sql/sample_data/lobby_db_sample_data.sql similarity index 100% rename from server/database/sql/sample_data/lobby_db_sample_data.sql rename to database/sql/sample_data/lobby_db_sample_data.sql diff --git a/server/database/src/main/resources/db/migration/error_report/V1.00.00__create_tables.sql b/database/src/main/resources/db/migration/error_report/V1.00.00__create_tables.sql similarity index 100% rename from server/database/src/main/resources/db/migration/error_report/V1.00.00__create_tables.sql rename to database/src/main/resources/db/migration/error_report/V1.00.00__create_tables.sql diff --git a/server/database/src/main/resources/db/migration/lobby_db/V2.00.00__lobby.sql b/database/src/main/resources/db/migration/lobby_db/V2.00.00__lobby.sql similarity index 100% rename from server/database/src/main/resources/db/migration/lobby_db/V2.00.00__lobby.sql rename to database/src/main/resources/db/migration/lobby_db/V2.00.00__lobby.sql diff --git a/server/database/src/main/resources/db/migration/lobby_db/V2.00.01__add_chat_history.sql b/database/src/main/resources/db/migration/lobby_db/V2.00.01__add_chat_history.sql similarity index 100% rename from server/database/src/main/resources/db/migration/lobby_db/V2.00.01__add_chat_history.sql rename to database/src/main/resources/db/migration/lobby_db/V2.00.01__add_chat_history.sql diff --git a/server/database/src/main/resources/db/migration/lobby_db/V2.00.02__game_and_player_history.sql b/database/src/main/resources/db/migration/lobby_db/V2.00.02__game_and_player_history.sql similarity index 100% rename from server/database/src/main/resources/db/migration/lobby_db/V2.00.02__game_and_player_history.sql rename to database/src/main/resources/db/migration/lobby_db/V2.00.02__game_and_player_history.sql diff --git a/server/database/src/main/resources/db/migration/lobby_db/V2.00.03__change_game_history_index.sql b/database/src/main/resources/db/migration/lobby_db/V2.00.03__change_game_history_index.sql similarity index 100% rename from server/database/src/main/resources/db/migration/lobby_db/V2.00.03__change_game_history_index.sql rename to database/src/main/resources/db/migration/lobby_db/V2.00.03__change_game_history_index.sql diff --git a/server/database/src/main/resources/db/migration/lobby_db/V2.00.04__add_lobby_user_fk_to_access_log.sql b/database/src/main/resources/db/migration/lobby_db/V2.00.04__add_lobby_user_fk_to_access_log.sql similarity index 100% rename from server/database/src/main/resources/db/migration/lobby_db/V2.00.04__add_lobby_user_fk_to_access_log.sql rename to database/src/main/resources/db/migration/lobby_db/V2.00.04__add_lobby_user_fk_to_access_log.sql diff --git a/server/database/src/main/resources/db/migration/lobby_db/V2.00.05__drop_legacy_password.sql b/database/src/main/resources/db/migration/lobby_db/V2.00.05__drop_legacy_password.sql similarity index 100% rename from server/database/src/main/resources/db/migration/lobby_db/V2.00.05__drop_legacy_password.sql rename to database/src/main/resources/db/migration/lobby_db/V2.00.05__drop_legacy_password.sql diff --git a/server/database/src/main/resources/db/migration/lobby_db/V2.00.06__error_report_issue_and_title_column.sql b/database/src/main/resources/db/migration/lobby_db/V2.00.06__error_report_issue_and_title_column.sql similarity index 100% rename from server/database/src/main/resources/db/migration/lobby_db/V2.00.06__error_report_issue_and_title_column.sql rename to database/src/main/resources/db/migration/lobby_db/V2.00.06__error_report_issue_and_title_column.sql diff --git a/server/database/src/main/resources/db/migration/lobby_db/V2.01.00__fix_username_ban_casing.sql b/database/src/main/resources/db/migration/lobby_db/V2.01.00__fix_username_ban_casing.sql similarity index 100% rename from server/database/src/main/resources/db/migration/lobby_db/V2.01.00__fix_username_ban_casing.sql rename to database/src/main/resources/db/migration/lobby_db/V2.01.00__fix_username_ban_casing.sql diff --git a/server/database/src/main/resources/db/migration/lobby_db/V2.01.01__maps_index_tables.sql b/database/src/main/resources/db/migration/lobby_db/V2.01.01__maps_index_tables.sql similarity index 100% rename from server/database/src/main/resources/db/migration/lobby_db/V2.01.01__maps_index_tables.sql rename to database/src/main/resources/db/migration/lobby_db/V2.01.01__maps_index_tables.sql diff --git a/server/database/src/main/resources/db/migration/lobby_db/V2.01.02__map_tags.sql b/database/src/main/resources/db/migration/lobby_db/V2.01.02__map_tags.sql similarity index 100% rename from server/database/src/main/resources/db/migration/lobby_db/V2.01.02__map_tags.sql rename to database/src/main/resources/db/migration/lobby_db/V2.01.02__map_tags.sql diff --git a/server/database/src/main/resources/db/migration/lobby_db/V2.02.00__lobby_message.sql b/database/src/main/resources/db/migration/lobby_db/V2.02.00__lobby_message.sql similarity index 100% rename from server/database/src/main/resources/db/migration/lobby_db/V2.02.00__lobby_message.sql rename to database/src/main/resources/db/migration/lobby_db/V2.02.00__lobby_message.sql diff --git a/server/database/start_docker_db b/database/start_docker_db similarity index 100% rename from server/database/start_docker_db rename to database/start_docker_db diff --git a/http-clients/github-client/build.gradle b/http-clients/github-client/build.gradle deleted file mode 100644 index 699c8e8..0000000 --- a/http-clients/github-client/build.gradle +++ /dev/null @@ -1,13 +0,0 @@ -plugins { - id "java" -} - -dependencies { - implementation "io.github.openfeign:feign-core:13.2.1" - implementation "io.github.openfeign:feign-gson:13.2.1" -// implementation project(":lib:feign-common") -// implementation project(":lib:java-extras") - testImplementation "ru.lanwen.wiremock:wiremock-junit5:1.3.1" - testImplementation "com.github.tomakehurst:wiremock:1.3.1" -// testImplementation project(":lib:test-common") -} diff --git a/server/database-test-support/build.gradle b/server/database-test-support/build.gradle deleted file mode 100644 index fce41d2..0000000 --- a/server/database-test-support/build.gradle +++ /dev/null @@ -1,10 +0,0 @@ -plugins { - id "java" -} - -dependencies { - implementation "com.github.database-rider:rider-junit5:$databaseRiderVersion" - implementation "org.jdbi:jdbi3-core:$jdbiVersion" - implementation "org.jdbi:jdbi3-sqlobject:$jdbiVersion" - implementation "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion" -} diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/latest/version/LatestVersionController.java b/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/latest/version/LatestVersionController.java deleted file mode 100644 index ee6c6d2..0000000 --- a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/latest/version/LatestVersionController.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.triplea.spitfire.server.controllers.latest.version; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.Response; -import lombok.Builder; -import org.triplea.http.client.latest.version.LatestVersionClient; -import org.triplea.http.client.latest.version.LatestVersionResponse; -import org.triplea.modules.latest.version.LatestVersionModule; -import org.triplea.spitfire.server.HttpController; - -@Builder -public class LatestVersionController extends HttpController { - private final LatestVersionModule latestVersionModule; - - public static LatestVersionController build(final LatestVersionModule latestVersionModule) { - return new LatestVersionController(latestVersionModule); - } - - @GET - @Path(LatestVersionClient.LATEST_VERSION_PATH) - public Response getLatestEngineVersion() { - return latestVersionModule - .getLatestVersion() - .map( - latest -> - Response.ok( - LatestVersionResponse.builder() // - .latestEngineVersion(latest) - .releaseNotesUrl("https://triplea-game.org/release_notes/") - .downloadUrl("https://triplea-game.org/download/") - .build()) - .build()) - .orElseGet(() -> Response.status(503, "Unable to fetch latest version").build()); - } -} diff --git a/server/dropwizard-server/src/test/java/org/triplea/spitfire/server/ControllerIntegrationTest.java b/server/dropwizard-server/src/test/java/org/triplea/spitfire/server/ControllerIntegrationTest.java index 8743fa3..5c86722 100644 --- a/server/dropwizard-server/src/test/java/org/triplea/spitfire/server/ControllerIntegrationTest.java +++ b/server/dropwizard-server/src/test/java/org/triplea/spitfire/server/ControllerIntegrationTest.java @@ -18,13 +18,11 @@ import org.triplea.domain.data.ApiKey; import org.triplea.domain.data.SystemIdLoader; import org.triplea.http.client.LobbyHttpClientConfig; -import org.triplea.test.common.RequiresDatabase; @ExtendWith(SpitfireServerTestExtension.class) @ExtendWith(SpitfireDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) @DataSet(value = ControllerIntegrationTest.DATA_SETS, useSequenceFiltering = false) -@RequiresDatabase public abstract class ControllerIntegrationTest { @BeforeAll diff --git a/server/latest-version-module/README.md b/server/latest-version-module/README.md deleted file mode 100644 index 99c8e01..0000000 --- a/server/latest-version-module/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Latest Version Module - -This module provides a latest engine version web-API. This would typically be -used by front-end clients to know if they are running an out of date engine version. - -The latest version data is obtained from Github's webservice API. More specifically -we query Github's API for the 'tag name' of the 'latest release'. We then keep this -data in an in-memory cache and then refresh the cache periodically. In particular -we use a cache for a faster server response, but also to limit interactions with -Github's API (it is rate limited). diff --git a/server/latest-version-module/build.gradle b/server/latest-version-module/build.gradle deleted file mode 100644 index 627a655..0000000 --- a/server/latest-version-module/build.gradle +++ /dev/null @@ -1,12 +0,0 @@ -plugins { - id "java" -} - -dependencies { - implementation project(":http-clients:github-client") -// implementation project(":lib:feign-common") -// implementation project(":lib:java-extras") - implementation project(":server:server-lib") - implementation "io.dropwizard:dropwizard-core:$dropwizardVersion" -// testImplementation project(":lib:test-common") -} diff --git a/server/latest-version-module/src/main/java/org/triplea/modules/latest/version/LatestVersionModule.java b/server/latest-version-module/src/main/java/org/triplea/modules/latest/version/LatestVersionModule.java deleted file mode 100644 index c9e76a7..0000000 --- a/server/latest-version-module/src/main/java/org/triplea/modules/latest/version/LatestVersionModule.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.triplea.modules.latest.version; - -import io.dropwizard.lifecycle.Managed; -import java.time.Duration; -import java.util.Optional; -import java.util.function.Supplier; -import lombok.Builder; -import lombok.Value; -import lombok.extern.slf4j.Slf4j; -import org.triplea.http.client.github.GithubApiClient; -import org.triplea.server.lib.scheduled.tasks.ScheduledTask; - -@Slf4j -public class LatestVersionModule { - - private String latestVersion; - - public Optional getLatestVersion() { - return Optional.ofNullable(latestVersion); - } - - public void notifyLatest(final String newLatestVersion) { - log.info("Latest engine version set to: {}", newLatestVersion); - this.latestVersion = newLatestVersion; - } - - @Builder - @Value - public static class RefreshConfiguration { - Duration delay; - Duration period; - } - - public Managed buildRefreshSchedule( - final LatestVersionModuleConfig configuration, - final RefreshConfiguration refreshConfiguration) { - - final GithubApiClient githubApiClient = configuration.createGamesRepoGithubApiClient(); - - final Supplier> githubLatestVersionFetcher = - githubApiClient::fetchLatestVersion; - - return ScheduledTask.builder() - .taskName("Latest-Engine-Version-Fetcher") - .delay(refreshConfiguration.getDelay()) - .period(refreshConfiguration.getPeriod()) - .task(() -> githubLatestVersionFetcher.get().ifPresent(this::notifyLatest)) - .build(); - } -} diff --git a/server/latest-version-module/src/main/java/org/triplea/modules/latest/version/LatestVersionModuleConfig.java b/server/latest-version-module/src/main/java/org/triplea/modules/latest/version/LatestVersionModuleConfig.java deleted file mode 100644 index 212a3c2..0000000 --- a/server/latest-version-module/src/main/java/org/triplea/modules/latest/version/LatestVersionModuleConfig.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.triplea.modules.latest.version; - -import org.triplea.http.client.github.GithubApiClient; - -public interface LatestVersionModuleConfig { - GithubApiClient createGamesRepoGithubApiClient(); -} diff --git a/server/lobby-module/build.gradle b/server/lobby-module/build.gradle deleted file mode 100644 index f6d019d..0000000 --- a/server/lobby-module/build.gradle +++ /dev/null @@ -1,33 +0,0 @@ -plugins { - id "java" -} - -dependencies { - implementation "at.favre.lib:bcrypt:$bcryptVersion" - implementation "com.liveperson:dropwizard-websockets:$dropwizardWebsocketsVersion" - implementation "com.sun.mail:jakarta.mail:$jakartaMailVersion" - implementation "com.sun.xml.bind:jaxb-core:$jaxbCoreVersion" - implementation "com.sun.xml.bind:jaxb-impl:$jaxbImplVersion" - implementation "io.github.openfeign:feign-gson:$openFeignVersion" - implementation "javax.activation:activation:$javaxActivationVersion" - implementation "javax.xml.bind:jaxb-api:$jaxbApiVersion" - implementation "org.java-websocket:Java-WebSocket:$javaWebSocketVersion" - implementation "org.jdbi:jdbi3-core:$jdbiVersion" - implementation "org.jdbi:jdbi3-sqlobject:$jdbiVersion" -// implementation project(':game-app:domain-data') -// implementation project(':http-clients:github-client') -// implementation project(':http-clients:lobby-client') -// implementation project(':lib:feign-common') -// implementation project(':lib:java-extras') -// implementation project(':lib:websocket-client') -// implementation project(':lib:websocket-server') - testImplementation "com.github.database-rider:rider-junit5:$databaseRiderVersion" - testImplementation "com.sun.mail:jakarta.mail:$jakartaMailVersion" - testImplementation "io.dropwizard:dropwizard-testing:$dropwizardVersion" - testImplementation "org.awaitility:awaitility:$awaitilityVersion" - testImplementation "org.java-websocket:Java-WebSocket:$javaWebsocketVersion" - testImplementation "uk.co.datumedge:hamcrest-json:$hamcrestJsonVersion" -// testImplementation project(":lib:java-extras") -// testImplementation project(":lib:test-common") - testImplementation project(":server:database-test-support") -} diff --git a/server/lobby-module/src/test/resources/logback-test.xml b/server/lobby-module/src/test/resources/logback-test.xml deleted file mode 100644 index 66d0fe6..0000000 --- a/server/lobby-module/src/test/resources/logback-test.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - %d [%thread] %logger{36} %-5level: %msg%n - - - - - - - - - - - - - - diff --git a/server/server-lib/build.gradle b/server/server-lib/build.gradle deleted file mode 100644 index 7ba6f7e..0000000 --- a/server/server-lib/build.gradle +++ /dev/null @@ -1,64 +0,0 @@ -plugins { - id "java" -} - -ext { - - apacheHttpComponentsVersion = "4.5.14" - awaitilityVersion = "4.2.1" - bcryptVersion = "0.10.2" - caffeineVersion = "3.1.8" - checkstyleVersion = "8.45" - commonsCliVersion = "1.8.0" - commonsCodecVersion = "1.17.0" - commonsIoVersion = "2.16.1" - commonsMathVersion = "3.6.1" - commonsTextVersion = "1.12.0" - databaseRiderVersion = "1.42.0" - dropwizardVersion = "2.1.0" - dropwizardWebsocketsVersion = "1.3.14" - equalsVerifierVersion = "3.16.1" - feignCoreVersion = "13.2.1" - feignGsonVersion = "13.2.1" - javaWebSocketVersion = "1.5.3" - gsonVersion = "2.11.0" - guavaVersion = "33.2.1-jre" - hamcrestJsonVersion = "0.3" - hamcrestOptionalVersion = "2.0.0" - hamcrestVersion = "2.0.0.0" - jacksonDataTypeVersion = "2.17.1" - jakartaMailVersion = "2.0.1" - javaWebsocketVersion = "1.5.3" - javaxActivationVersion = "1.1.1" - jaxbApiVersion = "2.3.1" - jaxbCoreVersion = "4.0.5" - jaxbImplVersion = "4.0.5" - jdbiVersion = "3.45.1" - jetbrainsAnnotationsVersion = "24.1.0" - jlayerVersion = "1.0.1.4" - junitJupiterVersion = "5.10.2" - junitPlatformLauncherVersion = "1.10.2" - logbackClassicVersion = "1.2.11" - mockitoVersion = "5.11.0" - openFeignVersion = "13.2.1" - postgresqlVersion = "42.7.3" - snakeYamlVersion = "2.7" - sonatypeGoodiesPrefsVersion = "2.3.9" - substanceVersion = "4.5.0" - wireMockJunit5Version = "1.3.1" - wireMockVersion = "3.0.1" - xchartVersion = "3.8.8" - xmlUnitCore = "2.10.0" - xmlUnitMatchers = "2.10.0" - -} - -dependencies { - implementation "com.liveperson:dropwizard-websockets:$dropwizardWebsocketsVersion" - implementation "io.dropwizard:dropwizard-auth:$dropwizardVersion" - implementation "io.dropwizard:dropwizard-core:$dropwizardVersion" - implementation "io.dropwizard:dropwizard-jdbi3:$dropwizardVersion" -// implementation project(":lib:java-extras") - - testImplementation "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion" -} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index d6584e1..0000000 --- a/settings.gradle +++ /dev/null @@ -1,17 +0,0 @@ -rootProject.name='lobby-server' -//include 'lib:feign-common' -//include 'lib:http-client-lib' -//include 'lib:java-extras' -//include 'lib:swing-lib' -//include 'lib:swing-lib-test-support' -//include 'lib:test-common' -//include 'lib:websocket-client' -//include 'lib:websocket-server' -//include 'lib:xml-reader' - -include 'http-clients:github-client' -include 'server:server-lib' -include 'server:database' -include 'server:database-test-support' -include 'server:dropwizard-server' -include 'server:lobby-module' diff --git a/server/lobby-module/src/main/java/org/triplea/db/LobbyModuleRowMappers.java b/src/main/java/org/triplea/db/LobbyModuleRowMappers.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/LobbyModuleRowMappers.java rename to src/main/java/org/triplea/db/LobbyModuleRowMappers.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/access/log/AccessLogDao.java b/src/main/java/org/triplea/db/dao/access/log/AccessLogDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/access/log/AccessLogDao.java rename to src/main/java/org/triplea/db/dao/access/log/AccessLogDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/access/log/AccessLogRecord.java b/src/main/java/org/triplea/db/dao/access/log/AccessLogRecord.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/access/log/AccessLogRecord.java rename to src/main/java/org/triplea/db/dao/access/log/AccessLogRecord.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/api/key/ApiKeyHasher.java b/src/main/java/org/triplea/db/dao/api/key/ApiKeyHasher.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/api/key/ApiKeyHasher.java rename to src/main/java/org/triplea/db/dao/api/key/ApiKeyHasher.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/api/key/GameHostingApiKeyDao.java b/src/main/java/org/triplea/db/dao/api/key/GameHostingApiKeyDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/api/key/GameHostingApiKeyDao.java rename to src/main/java/org/triplea/db/dao/api/key/GameHostingApiKeyDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoWrapper.java b/src/main/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoWrapper.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoWrapper.java rename to src/main/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoWrapper.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyDao.java b/src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyDao.java rename to src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoWrapper.java b/src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoWrapper.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoWrapper.java rename to src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoWrapper.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyLookupRecord.java b/src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyLookupRecord.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyLookupRecord.java rename to src/main/java/org/triplea/db/dao/api/key/PlayerApiKeyLookupRecord.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/api/key/PlayerIdentifiersByApiKeyLookup.java b/src/main/java/org/triplea/db/dao/api/key/PlayerIdentifiersByApiKeyLookup.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/api/key/PlayerIdentifiersByApiKeyLookup.java rename to src/main/java/org/triplea/db/dao/api/key/PlayerIdentifiersByApiKeyLookup.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/chat/history/LobbyChatHistoryDao.java b/src/main/java/org/triplea/db/dao/chat/history/LobbyChatHistoryDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/chat/history/LobbyChatHistoryDao.java rename to src/main/java/org/triplea/db/dao/chat/history/LobbyChatHistoryDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/lobby/games/LobbyGameDao.java b/src/main/java/org/triplea/db/dao/lobby/games/LobbyGameDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/lobby/games/LobbyGameDao.java rename to src/main/java/org/triplea/db/dao/lobby/games/LobbyGameDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/moderator/BadWordsDao.java b/src/main/java/org/triplea/db/dao/moderator/BadWordsDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/moderator/BadWordsDao.java rename to src/main/java/org/triplea/db/dao/moderator/BadWordsDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryDao.java b/src/main/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryDao.java rename to src/main/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryRecord.java b/src/main/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryRecord.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryRecord.java rename to src/main/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryRecord.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/moderator/ModeratorUserDaoData.java b/src/main/java/org/triplea/db/dao/moderator/ModeratorUserDaoData.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/moderator/ModeratorUserDaoData.java rename to src/main/java/org/triplea/db/dao/moderator/ModeratorUserDaoData.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/moderator/ModeratorsDao.java b/src/main/java/org/triplea/db/dao/moderator/ModeratorsDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/moderator/ModeratorsDao.java rename to src/main/java/org/triplea/db/dao/moderator/ModeratorsDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/moderator/chat/history/ChatHistoryRecord.java b/src/main/java/org/triplea/db/dao/moderator/chat/history/ChatHistoryRecord.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/moderator/chat/history/ChatHistoryRecord.java rename to src/main/java/org/triplea/db/dao/moderator/chat/history/ChatHistoryRecord.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/moderator/chat/history/GameChatHistoryDao.java b/src/main/java/org/triplea/db/dao/moderator/chat/history/GameChatHistoryDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/moderator/chat/history/GameChatHistoryDao.java rename to src/main/java/org/triplea/db/dao/moderator/chat/history/GameChatHistoryDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/moderator/player/info/PlayerAliasRecord.java b/src/main/java/org/triplea/db/dao/moderator/player/info/PlayerAliasRecord.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/moderator/player/info/PlayerAliasRecord.java rename to src/main/java/org/triplea/db/dao/moderator/player/info/PlayerAliasRecord.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/moderator/player/info/PlayerBanRecord.java b/src/main/java/org/triplea/db/dao/moderator/player/info/PlayerBanRecord.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/moderator/player/info/PlayerBanRecord.java rename to src/main/java/org/triplea/db/dao/moderator/player/info/PlayerBanRecord.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/moderator/player/info/PlayerInfoForModeratorDao.java b/src/main/java/org/triplea/db/dao/moderator/player/info/PlayerInfoForModeratorDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/moderator/player/info/PlayerInfoForModeratorDao.java rename to src/main/java/org/triplea/db/dao/moderator/player/info/PlayerInfoForModeratorDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/temp/password/TempPasswordDao.java b/src/main/java/org/triplea/db/dao/temp/password/TempPasswordDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/temp/password/TempPasswordDao.java rename to src/main/java/org/triplea/db/dao/temp/password/TempPasswordDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/temp/password/TempPasswordHistoryDao.java b/src/main/java/org/triplea/db/dao/temp/password/TempPasswordHistoryDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/temp/password/TempPasswordHistoryDao.java rename to src/main/java/org/triplea/db/dao/temp/password/TempPasswordHistoryDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/user/UserJdbiDao.java b/src/main/java/org/triplea/db/dao/user/UserJdbiDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/user/UserJdbiDao.java rename to src/main/java/org/triplea/db/dao/user/UserJdbiDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/user/ban/BanLookupRecord.java b/src/main/java/org/triplea/db/dao/user/ban/BanLookupRecord.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/user/ban/BanLookupRecord.java rename to src/main/java/org/triplea/db/dao/user/ban/BanLookupRecord.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/user/ban/UserBanDao.java b/src/main/java/org/triplea/db/dao/user/ban/UserBanDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/user/ban/UserBanDao.java rename to src/main/java/org/triplea/db/dao/user/ban/UserBanDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/user/ban/UserBanRecord.java b/src/main/java/org/triplea/db/dao/user/ban/UserBanRecord.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/user/ban/UserBanRecord.java rename to src/main/java/org/triplea/db/dao/user/ban/UserBanRecord.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/user/history/PlayerHistoryDao.java b/src/main/java/org/triplea/db/dao/user/history/PlayerHistoryDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/user/history/PlayerHistoryDao.java rename to src/main/java/org/triplea/db/dao/user/history/PlayerHistoryDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/user/history/PlayerHistoryRecord.java b/src/main/java/org/triplea/db/dao/user/history/PlayerHistoryRecord.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/user/history/PlayerHistoryRecord.java rename to src/main/java/org/triplea/db/dao/user/history/PlayerHistoryRecord.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/user/role/UserRole.java b/src/main/java/org/triplea/db/dao/user/role/UserRole.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/user/role/UserRole.java rename to src/main/java/org/triplea/db/dao/user/role/UserRole.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/user/role/UserRoleDao.java b/src/main/java/org/triplea/db/dao/user/role/UserRoleDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/user/role/UserRoleDao.java rename to src/main/java/org/triplea/db/dao/user/role/UserRoleDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/user/role/UserRoleLookup.java b/src/main/java/org/triplea/db/dao/user/role/UserRoleLookup.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/user/role/UserRoleLookup.java rename to src/main/java/org/triplea/db/dao/user/role/UserRoleLookup.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/username/ban/UsernameBanDao.java b/src/main/java/org/triplea/db/dao/username/ban/UsernameBanDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/username/ban/UsernameBanDao.java rename to src/main/java/org/triplea/db/dao/username/ban/UsernameBanDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/db/dao/username/ban/UsernameBanRecord.java b/src/main/java/org/triplea/db/dao/username/ban/UsernameBanRecord.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/db/dao/username/ban/UsernameBanRecord.java rename to src/main/java/org/triplea/db/dao/username/ban/UsernameBanRecord.java diff --git a/server/server-lib/src/main/java/org/triplea/dropwizard/common/AuthenticationConfiguration.java b/src/main/java/org/triplea/dropwizard/common/AuthenticationConfiguration.java similarity index 100% rename from server/server-lib/src/main/java/org/triplea/dropwizard/common/AuthenticationConfiguration.java rename to src/main/java/org/triplea/dropwizard/common/AuthenticationConfiguration.java diff --git a/server/server-lib/src/main/java/org/triplea/dropwizard/common/IllegalArgumentMapper.java b/src/main/java/org/triplea/dropwizard/common/IllegalArgumentMapper.java similarity index 100% rename from server/server-lib/src/main/java/org/triplea/dropwizard/common/IllegalArgumentMapper.java rename to src/main/java/org/triplea/dropwizard/common/IllegalArgumentMapper.java diff --git a/server/server-lib/src/main/java/org/triplea/dropwizard/common/IpAddressExtractor.java b/src/main/java/org/triplea/dropwizard/common/IpAddressExtractor.java similarity index 100% rename from server/server-lib/src/main/java/org/triplea/dropwizard/common/IpAddressExtractor.java rename to src/main/java/org/triplea/dropwizard/common/IpAddressExtractor.java diff --git a/server/server-lib/src/main/java/org/triplea/dropwizard/common/JdbiLogging.java b/src/main/java/org/triplea/dropwizard/common/JdbiLogging.java similarity index 100% rename from server/server-lib/src/main/java/org/triplea/dropwizard/common/JdbiLogging.java rename to src/main/java/org/triplea/dropwizard/common/JdbiLogging.java diff --git a/server/server-lib/src/main/java/org/triplea/dropwizard/common/ServerConfiguration.java b/src/main/java/org/triplea/dropwizard/common/ServerConfiguration.java similarity index 100% rename from server/server-lib/src/main/java/org/triplea/dropwizard/common/ServerConfiguration.java rename to src/main/java/org/triplea/dropwizard/common/ServerConfiguration.java diff --git a/http-clients/github-client/src/main/java/org/triplea/http/client/github/BranchInfoResponse.java b/src/main/java/org/triplea/http/client/github/BranchInfoResponse.java similarity index 100% rename from http-clients/github-client/src/main/java/org/triplea/http/client/github/BranchInfoResponse.java rename to src/main/java/org/triplea/http/client/github/BranchInfoResponse.java diff --git a/http-clients/github-client/src/main/java/org/triplea/http/client/github/CreateIssueRequest.java b/src/main/java/org/triplea/http/client/github/CreateIssueRequest.java similarity index 100% rename from http-clients/github-client/src/main/java/org/triplea/http/client/github/CreateIssueRequest.java rename to src/main/java/org/triplea/http/client/github/CreateIssueRequest.java diff --git a/http-clients/github-client/src/main/java/org/triplea/http/client/github/CreateIssueResponse.java b/src/main/java/org/triplea/http/client/github/CreateIssueResponse.java similarity index 100% rename from http-clients/github-client/src/main/java/org/triplea/http/client/github/CreateIssueResponse.java rename to src/main/java/org/triplea/http/client/github/CreateIssueResponse.java diff --git a/http-clients/github-client/src/main/java/org/triplea/http/client/github/GithubApiClient.java b/src/main/java/org/triplea/http/client/github/GithubApiClient.java similarity index 100% rename from http-clients/github-client/src/main/java/org/triplea/http/client/github/GithubApiClient.java rename to src/main/java/org/triplea/http/client/github/GithubApiClient.java diff --git a/http-clients/github-client/src/main/java/org/triplea/http/client/github/GithubApiFeignClient.java b/src/main/java/org/triplea/http/client/github/GithubApiFeignClient.java similarity index 100% rename from http-clients/github-client/src/main/java/org/triplea/http/client/github/GithubApiFeignClient.java rename to src/main/java/org/triplea/http/client/github/GithubApiFeignClient.java diff --git a/http-clients/github-client/src/main/java/org/triplea/http/client/github/LatestReleaseResponse.java b/src/main/java/org/triplea/http/client/github/LatestReleaseResponse.java similarity index 100% rename from http-clients/github-client/src/main/java/org/triplea/http/client/github/LatestReleaseResponse.java rename to src/main/java/org/triplea/http/client/github/LatestReleaseResponse.java diff --git a/http-clients/github-client/src/main/java/org/triplea/http/client/github/MapRepoListing.java b/src/main/java/org/triplea/http/client/github/MapRepoListing.java similarity index 100% rename from http-clients/github-client/src/main/java/org/triplea/http/client/github/MapRepoListing.java rename to src/main/java/org/triplea/http/client/github/MapRepoListing.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/LobbyModuleConfig.java b/src/main/java/org/triplea/modules/LobbyModuleConfig.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/LobbyModuleConfig.java rename to src/main/java/org/triplea/modules/LobbyModuleConfig.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/chat/ChatMessagingService.java b/src/main/java/org/triplea/modules/chat/ChatMessagingService.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/chat/ChatMessagingService.java rename to src/main/java/org/triplea/modules/chat/ChatMessagingService.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/chat/ChatterSession.java b/src/main/java/org/triplea/modules/chat/ChatterSession.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/chat/ChatterSession.java rename to src/main/java/org/triplea/modules/chat/ChatterSession.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/chat/Chatters.java b/src/main/java/org/triplea/modules/chat/Chatters.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/chat/Chatters.java rename to src/main/java/org/triplea/modules/chat/Chatters.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/ChatMessageListener.java b/src/main/java/org/triplea/modules/chat/event/processing/ChatMessageListener.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/ChatMessageListener.java rename to src/main/java/org/triplea/modules/chat/event/processing/ChatMessageListener.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/ChatParticipantAdapter.java b/src/main/java/org/triplea/modules/chat/event/processing/ChatParticipantAdapter.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/ChatParticipantAdapter.java rename to src/main/java/org/triplea/modules/chat/event/processing/ChatParticipantAdapter.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/PlayerConnectedListener.java b/src/main/java/org/triplea/modules/chat/event/processing/PlayerConnectedListener.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/PlayerConnectedListener.java rename to src/main/java/org/triplea/modules/chat/event/processing/PlayerConnectedListener.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/PlayerIsMutedMessage.java b/src/main/java/org/triplea/modules/chat/event/processing/PlayerIsMutedMessage.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/PlayerIsMutedMessage.java rename to src/main/java/org/triplea/modules/chat/event/processing/PlayerIsMutedMessage.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/PlayerLeftListener.java b/src/main/java/org/triplea/modules/chat/event/processing/PlayerLeftListener.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/PlayerLeftListener.java rename to src/main/java/org/triplea/modules/chat/event/processing/PlayerLeftListener.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/SlapListener.java b/src/main/java/org/triplea/modules/chat/event/processing/SlapListener.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/SlapListener.java rename to src/main/java/org/triplea/modules/chat/event/processing/SlapListener.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/StatusUpdateListener.java b/src/main/java/org/triplea/modules/chat/event/processing/StatusUpdateListener.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/chat/event/processing/StatusUpdateListener.java rename to src/main/java/org/triplea/modules/chat/event/processing/StatusUpdateListener.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/forgot/password/ForgotPasswordModule.java b/src/main/java/org/triplea/modules/forgot/password/ForgotPasswordModule.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/forgot/password/ForgotPasswordModule.java rename to src/main/java/org/triplea/modules/forgot/password/ForgotPasswordModule.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/forgot/password/PasswordEmailSender.java b/src/main/java/org/triplea/modules/forgot/password/PasswordEmailSender.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/forgot/password/PasswordEmailSender.java rename to src/main/java/org/triplea/modules/forgot/password/PasswordEmailSender.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/forgot/password/PasswordGenerator.java b/src/main/java/org/triplea/modules/forgot/password/PasswordGenerator.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/forgot/password/PasswordGenerator.java rename to src/main/java/org/triplea/modules/forgot/password/PasswordGenerator.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/forgot/password/TempPasswordHistory.java b/src/main/java/org/triplea/modules/forgot/password/TempPasswordHistory.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/forgot/password/TempPasswordHistory.java rename to src/main/java/org/triplea/modules/forgot/password/TempPasswordHistory.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/forgot/password/TempPasswordPersistence.java b/src/main/java/org/triplea/modules/forgot/password/TempPasswordPersistence.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/forgot/password/TempPasswordPersistence.java rename to src/main/java/org/triplea/modules/forgot/password/TempPasswordPersistence.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/game/listing/GameListing.java b/src/main/java/org/triplea/modules/game/listing/GameListing.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/game/listing/GameListing.java rename to src/main/java/org/triplea/modules/game/listing/GameListing.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/game/listing/GameTtlExpiredListener.java b/src/main/java/org/triplea/modules/game/listing/GameTtlExpiredListener.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/game/listing/GameTtlExpiredListener.java rename to src/main/java/org/triplea/modules/game/listing/GameTtlExpiredListener.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/game/lobby/watcher/ChatUploadModule.java b/src/main/java/org/triplea/modules/game/lobby/watcher/ChatUploadModule.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/game/lobby/watcher/ChatUploadModule.java rename to src/main/java/org/triplea/modules/game/lobby/watcher/ChatUploadModule.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/game/lobby/watcher/ConnectivityCheck.java b/src/main/java/org/triplea/modules/game/lobby/watcher/ConnectivityCheck.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/game/lobby/watcher/ConnectivityCheck.java rename to src/main/java/org/triplea/modules/game/lobby/watcher/ConnectivityCheck.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/game/lobby/watcher/GamePostingModule.java b/src/main/java/org/triplea/modules/game/lobby/watcher/GamePostingModule.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/game/lobby/watcher/GamePostingModule.java rename to src/main/java/org/triplea/modules/game/lobby/watcher/GamePostingModule.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/moderation/access/log/AccessLogService.java b/src/main/java/org/triplea/modules/moderation/access/log/AccessLogService.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/moderation/access/log/AccessLogService.java rename to src/main/java/org/triplea/modules/moderation/access/log/AccessLogService.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/moderation/audit/history/ModeratorAuditHistoryService.java b/src/main/java/org/triplea/modules/moderation/audit/history/ModeratorAuditHistoryService.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/moderation/audit/history/ModeratorAuditHistoryService.java rename to src/main/java/org/triplea/modules/moderation/audit/history/ModeratorAuditHistoryService.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/moderation/bad/words/BadWordsService.java b/src/main/java/org/triplea/modules/moderation/bad/words/BadWordsService.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/moderation/bad/words/BadWordsService.java rename to src/main/java/org/triplea/modules/moderation/bad/words/BadWordsService.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/moderation/ban/name/UsernameBanService.java b/src/main/java/org/triplea/modules/moderation/ban/name/UsernameBanService.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/moderation/ban/name/UsernameBanService.java rename to src/main/java/org/triplea/modules/moderation/ban/name/UsernameBanService.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/moderation/ban/user/BannedPlayerEventHandler.java b/src/main/java/org/triplea/modules/moderation/ban/user/BannedPlayerEventHandler.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/moderation/ban/user/BannedPlayerEventHandler.java rename to src/main/java/org/triplea/modules/moderation/ban/user/BannedPlayerEventHandler.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/moderation/ban/user/UserBanService.java b/src/main/java/org/triplea/modules/moderation/ban/user/UserBanService.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/moderation/ban/user/UserBanService.java rename to src/main/java/org/triplea/modules/moderation/ban/user/UserBanService.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/moderation/chat/history/FetchGameChatHistoryModule.java b/src/main/java/org/triplea/modules/moderation/chat/history/FetchGameChatHistoryModule.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/moderation/chat/history/FetchGameChatHistoryModule.java rename to src/main/java/org/triplea/modules/moderation/chat/history/FetchGameChatHistoryModule.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/moderation/disconnect/user/DisconnectUserAction.java b/src/main/java/org/triplea/modules/moderation/disconnect/user/DisconnectUserAction.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/moderation/disconnect/user/DisconnectUserAction.java rename to src/main/java/org/triplea/modules/moderation/disconnect/user/DisconnectUserAction.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/moderation/moderators/ModeratorsService.java b/src/main/java/org/triplea/modules/moderation/moderators/ModeratorsService.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/moderation/moderators/ModeratorsService.java rename to src/main/java/org/triplea/modules/moderation/moderators/ModeratorsService.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/moderation/remote/actions/RemoteActionsModule.java b/src/main/java/org/triplea/modules/moderation/remote/actions/RemoteActionsModule.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/moderation/remote/actions/RemoteActionsModule.java rename to src/main/java/org/triplea/modules/moderation/remote/actions/RemoteActionsModule.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/player/info/FetchPlayerInfoModule.java b/src/main/java/org/triplea/modules/player/info/FetchPlayerInfoModule.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/player/info/FetchPlayerInfoModule.java rename to src/main/java/org/triplea/modules/player/info/FetchPlayerInfoModule.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/NameIsAvailableValidation.java b/src/main/java/org/triplea/modules/user/account/NameIsAvailableValidation.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/NameIsAvailableValidation.java rename to src/main/java/org/triplea/modules/user/account/NameIsAvailableValidation.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/NameValidation.java b/src/main/java/org/triplea/modules/user/account/NameValidation.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/NameValidation.java rename to src/main/java/org/triplea/modules/user/account/NameValidation.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/PasswordBCrypter.java b/src/main/java/org/triplea/modules/user/account/PasswordBCrypter.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/PasswordBCrypter.java rename to src/main/java/org/triplea/modules/user/account/PasswordBCrypter.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/create/AccountCreator.java b/src/main/java/org/triplea/modules/user/account/create/AccountCreator.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/create/AccountCreator.java rename to src/main/java/org/triplea/modules/user/account/create/AccountCreator.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/create/CreateAccountModule.java b/src/main/java/org/triplea/modules/user/account/create/CreateAccountModule.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/create/CreateAccountModule.java rename to src/main/java/org/triplea/modules/user/account/create/CreateAccountModule.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/create/CreateAccountValidation.java b/src/main/java/org/triplea/modules/user/account/create/CreateAccountValidation.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/create/CreateAccountValidation.java rename to src/main/java/org/triplea/modules/user/account/create/CreateAccountValidation.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/create/EmailValidation.java b/src/main/java/org/triplea/modules/user/account/create/EmailValidation.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/create/EmailValidation.java rename to src/main/java/org/triplea/modules/user/account/create/EmailValidation.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/create/PasswordValidation.java b/src/main/java/org/triplea/modules/user/account/create/PasswordValidation.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/create/PasswordValidation.java rename to src/main/java/org/triplea/modules/user/account/create/PasswordValidation.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/login/AccessLogUpdater.java b/src/main/java/org/triplea/modules/user/account/login/AccessLogUpdater.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/login/AccessLogUpdater.java rename to src/main/java/org/triplea/modules/user/account/login/AccessLogUpdater.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/login/ApiKeyGenerator.java b/src/main/java/org/triplea/modules/user/account/login/ApiKeyGenerator.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/login/ApiKeyGenerator.java rename to src/main/java/org/triplea/modules/user/account/login/ApiKeyGenerator.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/login/LobbyLoginMessageDao.java b/src/main/java/org/triplea/modules/user/account/login/LobbyLoginMessageDao.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/login/LobbyLoginMessageDao.java rename to src/main/java/org/triplea/modules/user/account/login/LobbyLoginMessageDao.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/login/LoginModule.java b/src/main/java/org/triplea/modules/user/account/login/LoginModule.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/login/LoginModule.java rename to src/main/java/org/triplea/modules/user/account/login/LoginModule.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/login/LoginRecord.java b/src/main/java/org/triplea/modules/user/account/login/LoginRecord.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/login/LoginRecord.java rename to src/main/java/org/triplea/modules/user/account/login/LoginRecord.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/login/authorizer/anonymous/AnonymousLogin.java b/src/main/java/org/triplea/modules/user/account/login/authorizer/anonymous/AnonymousLogin.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/login/authorizer/anonymous/AnonymousLogin.java rename to src/main/java/org/triplea/modules/user/account/login/authorizer/anonymous/AnonymousLogin.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/login/authorizer/registered/PasswordCheck.java b/src/main/java/org/triplea/modules/user/account/login/authorizer/registered/PasswordCheck.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/login/authorizer/registered/PasswordCheck.java rename to src/main/java/org/triplea/modules/user/account/login/authorizer/registered/PasswordCheck.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/login/authorizer/temp/password/TempPasswordLogin.java b/src/main/java/org/triplea/modules/user/account/login/authorizer/temp/password/TempPasswordLogin.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/login/authorizer/temp/password/TempPasswordLogin.java rename to src/main/java/org/triplea/modules/user/account/login/authorizer/temp/password/TempPasswordLogin.java diff --git a/server/lobby-module/src/main/java/org/triplea/modules/user/account/update/UpdateAccountService.java b/src/main/java/org/triplea/modules/user/account/update/UpdateAccountService.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/modules/user/account/update/UpdateAccountService.java rename to src/main/java/org/triplea/modules/user/account/update/UpdateAccountService.java diff --git a/server/server-lib/src/main/java/org/triplea/server/lib/scheduled/tasks/ScheduledTask.java b/src/main/java/org/triplea/server/lib/scheduled/tasks/ScheduledTask.java similarity index 100% rename from server/server-lib/src/main/java/org/triplea/server/lib/scheduled/tasks/ScheduledTask.java rename to src/main/java/org/triplea/server/lib/scheduled/tasks/ScheduledTask.java diff --git a/server/server-lib/src/main/java/org/triplea/spitfire/server/HttpController.java b/src/main/java/org/triplea/spitfire/server/HttpController.java similarity index 100% rename from server/server-lib/src/main/java/org/triplea/spitfire/server/HttpController.java rename to src/main/java/org/triplea/spitfire/server/HttpController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/ResponseStatus.java b/src/main/java/org/triplea/spitfire/server/ResponseStatus.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/ResponseStatus.java rename to src/main/java/org/triplea/spitfire/server/ResponseStatus.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/SpitfireServerApplication.java b/src/main/java/org/triplea/spitfire/server/SpitfireServerApplication.java similarity index 88% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/SpitfireServerApplication.java rename to src/main/java/org/triplea/spitfire/server/SpitfireServerApplication.java index 309dbed..e5146b1 100644 --- a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/SpitfireServerApplication.java +++ b/src/main/java/org/triplea/spitfire/server/SpitfireServerApplication.java @@ -5,7 +5,6 @@ import io.dropwizard.jdbi3.JdbiFactory; import io.dropwizard.setup.Bootstrap; import io.dropwizard.setup.Environment; -import java.time.Duration; import java.util.List; import lombok.extern.slf4j.Slf4j; import org.jdbi.v3.core.Jdbi; @@ -19,12 +18,10 @@ import org.triplea.modules.chat.ChatMessagingService; import org.triplea.modules.chat.Chatters; import org.triplea.modules.game.listing.GameListing; -import org.triplea.modules.latest.version.LatestVersionModule; import org.triplea.spitfire.server.access.authentication.ApiKeyAuthenticator; import org.triplea.spitfire.server.access.authentication.AuthenticatedUser; import org.triplea.spitfire.server.access.authorization.BannedPlayerFilter; import org.triplea.spitfire.server.access.authorization.RoleAuthorizer; -import org.triplea.spitfire.server.controllers.latest.version.LatestVersionController; import org.triplea.spitfire.server.controllers.lobby.GameHostingController; import org.triplea.spitfire.server.controllers.lobby.GameListingController; import org.triplea.spitfire.server.controllers.lobby.LobbyWatcherController; @@ -96,22 +93,6 @@ public void run(final SpitfireServerConfig configuration, final Environment envi JdbiLogging.registerSqlLogger(jdbi); } - final LatestVersionModule latestVersionModule = new LatestVersionModule(); - if (configuration.isLatestVersionFetcherEnabled()) { - log.info("Latest Engine Version Fetching running every 30 minutes"); - environment - .lifecycle() - .manage( - latestVersionModule.buildRefreshSchedule( - configuration, - LatestVersionModule.RefreshConfiguration.builder() - .delay(Duration.ofSeconds(10L)) - .period(Duration.ofMinutes(30L)) - .build())); - } else { - log.info("Latest Engine Version Fetching is disabled"); - } - serverConfiguration.registerRequestFilter( environment, BannedPlayerFilter.newBannedPlayerFilter(jdbi)); @@ -160,8 +141,7 @@ public void run(final SpitfireServerConfig configuration, final Environment envi PlayerInfoController.build(jdbi, chatters, gameListing), PlayersInGameController.build(gameListing), RemoteActionsController.build(jdbi, gameConnectionMessagingBus), - UpdateAccountController.build(jdbi), - LatestVersionController.build(latestVersionModule)) + UpdateAccountController.build(jdbi)) .forEach(controller -> environment.jersey().register(controller)); } } diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/SpitfireServerConfig.java b/src/main/java/org/triplea/spitfire/server/SpitfireServerConfig.java similarity index 93% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/SpitfireServerConfig.java rename to src/main/java/org/triplea/spitfire/server/SpitfireServerConfig.java index 492dc83..be25102 100644 --- a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/SpitfireServerConfig.java +++ b/src/main/java/org/triplea/spitfire/server/SpitfireServerConfig.java @@ -10,7 +10,6 @@ import lombok.Setter; import org.triplea.http.client.github.GithubApiClient; import org.triplea.modules.LobbyModuleConfig; -import org.triplea.modules.latest.version.LatestVersionModuleConfig; /** * This configuration class represents the configuration values in the server YML configuration. An @@ -18,8 +17,7 @@ * class. Values can be injected into the application by using environment variables in the server * YML configuration file. */ -public class SpitfireServerConfig extends Configuration - implements LobbyModuleConfig, LatestVersionModuleConfig { +public class SpitfireServerConfig extends Configuration implements LobbyModuleConfig { /** * Flag that indicates if we are running in production. This can be used to verify we do not have diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/access/authentication/ApiKeyAuthenticator.java b/src/main/java/org/triplea/spitfire/server/access/authentication/ApiKeyAuthenticator.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/access/authentication/ApiKeyAuthenticator.java rename to src/main/java/org/triplea/spitfire/server/access/authentication/ApiKeyAuthenticator.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/access/authentication/AuthenticatedUser.java b/src/main/java/org/triplea/spitfire/server/access/authentication/AuthenticatedUser.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/access/authentication/AuthenticatedUser.java rename to src/main/java/org/triplea/spitfire/server/access/authentication/AuthenticatedUser.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/access/authorization/BannedPlayerFilter.java b/src/main/java/org/triplea/spitfire/server/access/authorization/BannedPlayerFilter.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/access/authorization/BannedPlayerFilter.java rename to src/main/java/org/triplea/spitfire/server/access/authorization/BannedPlayerFilter.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/access/authorization/RoleAuthorizer.java b/src/main/java/org/triplea/spitfire/server/access/authorization/RoleAuthorizer.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/access/authorization/RoleAuthorizer.java rename to src/main/java/org/triplea/spitfire/server/access/authorization/RoleAuthorizer.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/GameHostingController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/GameHostingController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/GameHostingController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/GameHostingController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/GameListingController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/GameListingController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/GameListingController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/GameListingController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/LobbyWatcherController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/LobbyWatcherController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/LobbyWatcherController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/LobbyWatcherController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/PlayersInGameController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/PlayersInGameController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/PlayersInGameController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/PlayersInGameController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/AccessLogController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/AccessLogController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/AccessLogController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/AccessLogController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/BadWordsController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/BadWordsController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/BadWordsController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/BadWordsController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/DisconnectUserController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/DisconnectUserController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/DisconnectUserController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/DisconnectUserController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/GameChatHistoryController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/GameChatHistoryController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/GameChatHistoryController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/GameChatHistoryController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/ModeratorAuditHistoryController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/ModeratorAuditHistoryController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/ModeratorAuditHistoryController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/ModeratorAuditHistoryController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/ModeratorsController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/ModeratorsController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/ModeratorsController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/ModeratorsController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/MuteUserController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/MuteUserController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/MuteUserController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/MuteUserController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/RemoteActionsController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/RemoteActionsController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/RemoteActionsController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/RemoteActionsController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/UserBanController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/UserBanController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/UserBanController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/UserBanController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/UsernameBanController.java b/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/UsernameBanController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/UsernameBanController.java rename to src/main/java/org/triplea/spitfire/server/controllers/lobby/moderation/UsernameBanController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/user/account/CreateAccountController.java b/src/main/java/org/triplea/spitfire/server/controllers/user/account/CreateAccountController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/user/account/CreateAccountController.java rename to src/main/java/org/triplea/spitfire/server/controllers/user/account/CreateAccountController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/user/account/ForgotPasswordController.java b/src/main/java/org/triplea/spitfire/server/controllers/user/account/ForgotPasswordController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/user/account/ForgotPasswordController.java rename to src/main/java/org/triplea/spitfire/server/controllers/user/account/ForgotPasswordController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/user/account/LoginController.java b/src/main/java/org/triplea/spitfire/server/controllers/user/account/LoginController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/user/account/LoginController.java rename to src/main/java/org/triplea/spitfire/server/controllers/user/account/LoginController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/user/account/PlayerInfoController.java b/src/main/java/org/triplea/spitfire/server/controllers/user/account/PlayerInfoController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/user/account/PlayerInfoController.java rename to src/main/java/org/triplea/spitfire/server/controllers/user/account/PlayerInfoController.java diff --git a/server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/user/account/UpdateAccountController.java b/src/main/java/org/triplea/spitfire/server/controllers/user/account/UpdateAccountController.java similarity index 100% rename from server/dropwizard-server/src/main/java/org/triplea/spitfire/server/controllers/user/account/UpdateAccountController.java rename to src/main/java/org/triplea/spitfire/server/controllers/user/account/UpdateAccountController.java diff --git a/server/lobby-module/src/main/java/org/triplea/web/socket/GameConnectionWebSocket.java b/src/main/java/org/triplea/web/socket/GameConnectionWebSocket.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/web/socket/GameConnectionWebSocket.java rename to src/main/java/org/triplea/web/socket/GameConnectionWebSocket.java diff --git a/src/main/java/org/triplea/web/socket/GenericWebSocket.java b/src/main/java/org/triplea/web/socket/GenericWebSocket.java new file mode 100644 index 0000000..ca48533 --- /dev/null +++ b/src/main/java/org/triplea/web/socket/GenericWebSocket.java @@ -0,0 +1,211 @@ +package org.triplea.web.socket; + +import com.github.benmanes.caffeine.cache.Cache; +import com.github.benmanes.caffeine.cache.Caffeine; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; +import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; +import java.net.InetAddress; +import java.time.Duration; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Predicate; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.websocket.CloseReason; +import javax.websocket.Session; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.java_websocket.WebSocket; +import org.triplea.http.client.web.socket.MessageEnvelope; +import org.triplea.http.client.web.socket.messages.envelopes.ServerErrorMessage; +import org.triplea.java.StringUtils; + +/** + * Extracts common code between websocket server methods. Each websocket endpoint is essentially + * identical and they delegate their behavior to a 'messagingBus' which has listeners that will act + * on messages received. In general there should not be many websocket endpoints and they are + * grouped by the "types" of connections that are created to them (eg: players or games) + */ +@Slf4j +@AllArgsConstructor(access = AccessLevel.PACKAGE) +public class GenericWebSocket { + @VisibleForTesting static final int MAX_BAD_MESSAGES = 2; + + private static final Gson GSON = new Gson(); + private static final Cache badMessageCache = + Caffeine.newBuilder().expireAfterWrite(Duration.ofSeconds(30)).build(); + private static final Map, GenericWebSocket> websockets = new HashMap<>(); + + @Nonnull private final WebSocketMessagingBus webSocketMessagingBus; + @Nullable private final Predicate banCheck; + @Nonnull private final MessageSender messageSender; + + public GenericWebSocket(@Nonnull final WebSocketMessagingBus webSocketMessagingBus) { + this(webSocketMessagingBus, ip -> false, new MessageSender()); + } + + public GenericWebSocket( + @Nonnull final WebSocketMessagingBus webSocketMessagingBus, + @Nullable final Predicate banCheck) { + this(webSocketMessagingBus, banCheck, new MessageSender()); + } + + public static void init( + final Class websocketClass, + final WebSocketMessagingBus webSocketMessagingBus, + @Nullable final Predicate banCheck) { + + final var genericWebsocket = + new GenericWebSocket(webSocketMessagingBus, banCheck, new MessageSender()); + websockets.put(websocketClass, genericWebsocket); + } + + public static GenericWebSocket getInstance(final Class websocketClass) { + return Preconditions.checkNotNull( + websockets.get(websocketClass), + "Error, unable to find generic websocket for: " + + websocketClass + + ", did you run GenericWebSocket.init(" + + websocketClass + + ", ...) ?"); + } + + void onOpen(final WebSocket webSocket) { + onOpen(WebSocketSessionAdapter.fromWebSocket(webSocket)); + } + + void onOpen(final Session session) { + onOpen(WebSocketSessionAdapter.fromSession(session)); + } + + void onOpen(final WebSocketSession session) { + if (isSessionBanned(session)) { + disconnectBannedSession(session); + } else { + webSocketMessagingBus.onOpen(session); + } + } + + private boolean isSessionBanned(final WebSocketSession session) { + return Optional.ofNullable(banCheck) + .map(check -> check.test(session.getRemoteAddress())) + .orElse(false); + } + + private static void disconnectBannedSession(final WebSocketSession session) { + session.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, "You have been banned")); + } + + public void onMessage(final WebSocket webSocket, final String message) { + onMessage(WebSocketSessionAdapter.fromWebSocket(webSocket), message, badMessageCache); + } + + public void onMessage(final Session session, final String message) { + onMessage(WebSocketSessionAdapter.fromSession(session), message, badMessageCache); + } + + public void onMessage(final WebSocketSession session, final String message) { + onMessage(session, message, badMessageCache); + } + + @VisibleForTesting + void onMessage( + final WebSocketSession session, + final String message, + final Cache badMessageCache) { + readJsonMessage(session, message, badMessageCache) + .ifPresent(envelope -> webSocketMessagingBus.onMessage(session, envelope)); + } + + /** + * Checks if session has sent too many bad messages, if so we ignore messages from that session + * and return an empty. Otherwise we will convert the message JSON string to a {@code + * MessageEnvelope} and return that. If the message is badly formatted, we'll send back an error + * message response to the session, increment the bad message count and return an empty. + */ + private Optional readJsonMessage( + final WebSocketSession session, + final String message, + final Cache badMessageCache) { + + if (burnMessagesFromThisSession(session, badMessageCache)) { + // Burn the message -> no-op + // To conserve server resources, we do not even log the message. + return Optional.empty(); + } + + try { + return Optional.of(GSON.fromJson(message, MessageEnvelope.class)); + } catch (final JsonSyntaxException e) { + final InetAddress inetAddress = session.getRemoteAddress(); + incrementBadMessageCount(session, badMessageCache); + logBadMessage(inetAddress, message); + respondWithServerError(messageSender, session); + return Optional.empty(); + } + } + + private static boolean burnMessagesFromThisSession( + final WebSocketSession session, final Cache badMessageCache) { + final InetAddress inetAddress = session.getRemoteAddress(); + + final int badMessageCount = + Optional.ofNullable(badMessageCache.getIfPresent(inetAddress)) + .map(AtomicInteger::get) + .orElse(0); + + return badMessageCount > MAX_BAD_MESSAGES; + } + + private static void incrementBadMessageCount( + final WebSocketSession session, final Cache badMessageCache) { + badMessageCache + .asMap() + .computeIfAbsent(session.getRemoteAddress(), inet -> new AtomicInteger(0)) + .incrementAndGet(); + } + + private static void logBadMessage(final InetAddress inetAddress, final String message) { + log.warn( + "Failed to decode JSON string from IP {}, into a MessageEnvelope: {}", + inetAddress, + StringUtils.truncate(message, 500)); + } + + private static void respondWithServerError( + final MessageSender messageSender, final WebSocketSession session) { + messageSender.accept( + session, + new ServerErrorMessage("Server is unable to process request, error reading message") + .toEnvelope()); + } + + void onClose(final WebSocket webSocket, final CloseReason closeReason) { + onClose(WebSocketSessionAdapter.fromWebSocket(webSocket), closeReason); + } + + void onClose(final Session session, final CloseReason closeReason) { + onClose(WebSocketSessionAdapter.fromSession(session), closeReason); + } + + void onClose(final WebSocketSession session, final CloseReason closeReason) { + webSocketMessagingBus.onClose(session); + } + + public void onError(final WebSocket webSocket, final Throwable throwable) { + onError(WebSocketSessionAdapter.fromWebSocket(webSocket), throwable); + } + + public void onError(final Session session, final Throwable throwable) { + onError(WebSocketSessionAdapter.fromSession(session), throwable); + } + + void onError(final WebSocketSession session, final Throwable throwable) { + webSocketMessagingBus.onError(session, throwable); + } +} diff --git a/src/main/java/org/triplea/web/socket/InetExtractor.java b/src/main/java/org/triplea/web/socket/InetExtractor.java new file mode 100644 index 0000000..72d49cc --- /dev/null +++ b/src/main/java/org/triplea/web/socket/InetExtractor.java @@ -0,0 +1,37 @@ +package org.triplea.web.socket; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Splitter; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Map; +import lombok.experimental.UtilityClass; + +@UtilityClass +public class InetExtractor { + + @VisibleForTesting + public static final String IP_ADDRESS_KEY = "javax.websocket.endpoint.remoteAddress"; + + /** + * Returns the IP address of the session from the provided 'userSession' map. It is expected that + * for the websocket library that we use that we will always find an IP address. + */ + public static InetAddress extract(final Map userSession) { + // expected format '/127.0.0.1:42840' or (for test-cases) '127.0.0.1' + final String rawIpString = String.valueOf(userSession.get(IP_ADDRESS_KEY)); + + final String ipString = + rawIpString.startsWith("/") // + ? rawIpString.substring(1) + : rawIpString; + + try { + final String ip = Splitter.on(':').splitToList(ipString).get(0); + return InetAddress.getByName(ip); + } catch (final UnknownHostException e) { + // not expected + throw new AssertionError("Unexpected bad hostname: " + userSession.get(IP_ADDRESS_KEY), e); + } + } +} diff --git a/src/main/java/org/triplea/web/socket/MessageBroadcaster.java b/src/main/java/org/triplea/web/socket/MessageBroadcaster.java new file mode 100644 index 0000000..aa973cb --- /dev/null +++ b/src/main/java/org/triplea/web/socket/MessageBroadcaster.java @@ -0,0 +1,38 @@ +package org.triplea.web.socket; + +import java.util.Collection; +import java.util.function.BiConsumer; +import lombok.AllArgsConstructor; +import org.triplea.http.client.web.socket.MessageEnvelope; + +/** + * Sends a server message (encoded as a JSON string) to all open and connected websocket sessions. + */ +@AllArgsConstructor +public class MessageBroadcaster + implements BiConsumer, MessageEnvelope> { + + private final BiConsumer messageSender; + + public static MessageBroadcaster build() { + return new MessageBroadcaster(new MessageSender()); + } + + /** + * Sends a message to sessions. + * + *

Warning: use a concurrent collection for {@param sessions}, the broadcast could take a + * significant amount of time, any modifications during that time could trigger a + * ConcurrentModificationException. + * + * @param sessions Sessions to receive message. + * @param messageEnvelope The message to send. + */ + @Override + public void accept( + final Collection sessions, final MessageEnvelope messageEnvelope) { + sessions.parallelStream() + .filter(WebSocketSession::isOpen) + .forEach(s -> messageSender.accept(s, messageEnvelope)); + } +} diff --git a/src/main/java/org/triplea/web/socket/MessageSender.java b/src/main/java/org/triplea/web/socket/MessageSender.java new file mode 100644 index 0000000..c4ec4e3 --- /dev/null +++ b/src/main/java/org/triplea/web/socket/MessageSender.java @@ -0,0 +1,24 @@ +package org.triplea.web.socket; + +import com.google.gson.Gson; +import java.util.function.BiConsumer; +import org.triplea.http.client.web.socket.MessageEnvelope; +import org.triplea.java.Interruptibles; + +/** Sends a server message (encoded as a JSON string) to a specific connected websocket sessions. */ +public class MessageSender implements BiConsumer { + private static final Gson GSON = new Gson(); + + @Override + public void accept(final WebSocketSession session, final MessageEnvelope message) { + if (session.isOpen()) { + new Thread(() -> Interruptibles.await(() -> sendMessage(session, message))).start(); + } + } + + private void sendMessage(final WebSocketSession session, final MessageEnvelope message) { + if (session.isOpen()) { + session.sendText(GSON.toJson(message)); + } + } +} diff --git a/server/lobby-module/src/main/java/org/triplea/web/socket/PlayerConnectionWebSocket.java b/src/main/java/org/triplea/web/socket/PlayerConnectionWebSocket.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/web/socket/PlayerConnectionWebSocket.java rename to src/main/java/org/triplea/web/socket/PlayerConnectionWebSocket.java diff --git a/server/lobby-module/src/main/java/org/triplea/web/socket/SessionBannedCheck.java b/src/main/java/org/triplea/web/socket/SessionBannedCheck.java similarity index 100% rename from server/lobby-module/src/main/java/org/triplea/web/socket/SessionBannedCheck.java rename to src/main/java/org/triplea/web/socket/SessionBannedCheck.java diff --git a/src/main/java/org/triplea/web/socket/SessionSet.java b/src/main/java/org/triplea/web/socket/SessionSet.java new file mode 100644 index 0000000..089ab3f --- /dev/null +++ b/src/main/java/org/triplea/web/socket/SessionSet.java @@ -0,0 +1,59 @@ +package org.triplea.web.socket; + +import com.google.common.annotations.VisibleForTesting; +import java.net.InetAddress; +import java.util.Collection; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; +import lombok.AccessLevel; +import lombok.Getter; + +/** + * Tracks sessions, can be used to listen to IP session ban events and close any matching sessions. + * + *

Closed sessions are removed when sessions are retrieved, so there is no need to 'remove' or + * 'unregister' sessions. + * + *

    + * This class has two main purposes: + *
  1. Unify common session tracking code + *
  2. Provide a mechanism to close already established connections that have been banned. We will + * rely on request filtering to prevent banned sessions from creating a new websocket + * connection, this part is needed to remove existing connections of a banned user. + *
+ */ +public class SessionSet { + + @Getter(value = AccessLevel.PACKAGE, onMethod_ = @VisibleForTesting) + private final Collection sessions = ConcurrentHashMap.newKeySet(); + + // private final MessageSender messageSender = new MessageSender(); + // private final MessageBroadcaster messageBroadcaster = new MessageBroadcaster(messageSender); + + public void put(final WebSocketSession session) { + sessions.add(session); + } + + public void remove(final WebSocketSession session) { + sessions.remove(session); + } + + public Collection values() { + return sessions.stream().filter(WebSocketSession::isOpen).collect(Collectors.toSet()); + } + + public Collection getSessionsByIp(final InetAddress serverIp) { + return sessions.stream() + .filter(WebSocketSession::isOpen) + .filter(s -> s.getRemoteAddress().equals(serverIp)) + .collect(Collectors.toSet()); + } + + /** All sessions matching a given IP are closed. */ + public void closeSessionsByIp(final InetAddress ip) { + sessions.stream() + .filter(WebSocketSession::isOpen) + .filter(s -> s.getRemoteAddress().equals(ip)) + .forEach(WebSocketSession::close); + } +} diff --git a/src/main/java/org/triplea/web/socket/StandaloneWebsocketServer.java b/src/main/java/org/triplea/web/socket/StandaloneWebsocketServer.java new file mode 100644 index 0000000..d54592d --- /dev/null +++ b/src/main/java/org/triplea/web/socket/StandaloneWebsocketServer.java @@ -0,0 +1,59 @@ +package org.triplea.web.socket; + +import java.net.InetSocketAddress; +import javax.websocket.CloseReason; +import lombok.extern.slf4j.Slf4j; +import org.java_websocket.WebSocket; +import org.java_websocket.handshake.ClientHandshake; +import org.java_websocket.server.WebSocketServer; + +@Slf4j +public class StandaloneWebsocketServer extends WebSocketServer { + private final GenericWebSocket genericWebSocket; + + public StandaloneWebsocketServer( + final WebSocketMessagingBus webSocketMessagingBus, final int portToOpen) { + this(new GenericWebSocket(webSocketMessagingBus), portToOpen); + } + + public StandaloneWebsocketServer(final GenericWebSocket genericWebSocket, final int portToOpen) { + super(new InetSocketAddress(portToOpen)); + this.genericWebSocket = genericWebSocket; + } + + @Override + public void onOpen(final WebSocket webSocket, final ClientHandshake handshake) { + genericWebSocket.onOpen(webSocket); + } + + @Override + public void onClose( + final WebSocket webSocket, final int code, final String reason, final boolean remote) { + genericWebSocket.onClose(webSocket, new CloseReason(() -> code, reason)); + } + + @Override + public void onMessage(final WebSocket webSocket, final String message) { + genericWebSocket.onMessage(webSocket, message); + } + + @Override + public void onError(final WebSocket webSocket, final Exception exception) { + genericWebSocket.onError(webSocket, exception); + } + + @Override + public void onStart() {} + + public void shutdown() { + try { + super.stop(); + } catch (final InterruptedException e) { + Thread.currentThread().interrupt(); + log.warn( + "Shutdown terminated early, game server may not be fully stopped. " + + "Terminate any remaining java processes to ensure it is stopped.", + e); + } + } +} diff --git a/src/main/java/org/triplea/web/socket/WebSocketMessageContext.java b/src/main/java/org/triplea/web/socket/WebSocketMessageContext.java new file mode 100644 index 0000000..baaa65f --- /dev/null +++ b/src/main/java/org/triplea/web/socket/WebSocketMessageContext.java @@ -0,0 +1,22 @@ +package org.triplea.web.socket; + +import javax.annotation.Nonnull; +import lombok.Builder; +import lombok.Getter; +import org.triplea.http.client.web.socket.messages.WebSocketMessage; + +@Builder +@Getter +public class WebSocketMessageContext { + @Nonnull WebSocketMessagingBus messagingBus; + @Nonnull WebSocketSession senderSession; + @Nonnull T message; + + public void sendResponse(final X responseMessage) { + messagingBus.sendResponse(senderSession, responseMessage); + } + + public void broadcastMessage(final X broadcastMessage) { + messagingBus.broadcastMessage(broadcastMessage); + } +} diff --git a/src/main/java/org/triplea/web/socket/WebSocketMessagingBus.java b/src/main/java/org/triplea/web/socket/WebSocketMessagingBus.java new file mode 100644 index 0000000..82252db --- /dev/null +++ b/src/main/java/org/triplea/web/socket/WebSocketMessagingBus.java @@ -0,0 +1,157 @@ +package org.triplea.web.socket; + +import com.google.common.annotations.VisibleForTesting; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.stream.Stream; +import javax.annotation.Nonnull; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Value; +import lombok.extern.slf4j.Slf4j; +import org.triplea.http.client.web.socket.MessageEnvelope; +import org.triplea.http.client.web.socket.messages.MessageType; +import org.triplea.http.client.web.socket.messages.WebSocketMessage; +import org.triplea.http.client.web.socket.messages.envelopes.ServerErrorMessage; + +@AllArgsConstructor(access = AccessLevel.PACKAGE, onConstructor_ = @VisibleForTesting) +@Slf4j +public class WebSocketMessagingBus { + public static final String MESSAGING_BUS_KEY = "messaging.bus"; + + @Nonnull private final MessageBroadcaster messageBroadcaster; + @Nonnull private final MessageSender messageSender; + @Nonnull private final SessionSet sessionSet; + + private final List> sessionClosedListeners = + new ArrayList<>(); + + @Value + private static class MessageListener { + MessageType messageType; + Consumer> listener; + } + + /** These listeners are for specific message types. */ + private final List> messageListeners = new ArrayList<>(); + + /** These listeners are invoked when we receive any type of message. */ + private final List> anyMessageListeners = new ArrayList<>(); + + public WebSocketMessagingBus() { + messageSender = new MessageSender(); + messageBroadcaster = new MessageBroadcaster(messageSender); + sessionSet = new SessionSet(); + } + + public void sendResponse( + final WebSocketSession session, final X responseMessage) { + messageSender.accept(session, responseMessage.toEnvelope()); + } + + public void broadcastMessage(final X broadcastMessage) { + broadcastMessage(broadcastMessage.toEnvelope()); + } + + public void broadcastMessage(final MessageEnvelope messageEnvelope) { + messageBroadcaster.accept(sessionSet.getSessions(), messageEnvelope); + } + + /** + * Adds a listener for specific message types. The messaging bus will automatically exclude any + * messages that are not of a matching type. + * + * @param type The message type to listen for. + * @param listener The listener that will be invoked with messages of a matching type. + */ + public void addMessageListener( + final MessageType type, final Consumer> listener) { + messageListeners.add(new MessageListener<>(type, listener)); + } + + /** + * Adds a listener that will be invoked when any message is received + * + * @param messageListener The message listener to be added, will be invoked with any message + * recieved. + */ + public void addMessageListener(final Consumer messageListener) { + anyMessageListeners.add(messageListener); + } + + @SuppressWarnings("unchecked") + void onMessage( + final WebSocketSession session, final MessageEnvelope envelope) { + anyMessageListeners.forEach(listener -> listener.accept(envelope)); + + determineMatchingMessageType(envelope) + .ifPresent( + messageType -> { + final T payload = (T) envelope.getPayload(messageType.getPayloadType()); + + getListenersForMessageTypeId(envelope.getMessageTypeId()) + .map(messageListener -> (MessageListener) messageListener) + .forEach( + messageListener -> + messageListener.listener.accept( + WebSocketMessageContext.builder() + .messagingBus(this) + .senderSession(session) + .message(payload) + .build())); + }); + } + + private Optional> determineMatchingMessageType(final MessageEnvelope envelope) { + return messageListeners.stream() + .filter(matchListenersWithMessageTypeId(envelope.getMessageTypeId())) + .findAny() + .map(messageListener -> messageListener.messageType); + } + + private static Predicate> matchListenersWithMessageTypeId( + final String messageTypeId) { + return messageListener -> messageListener.messageType.getMessageTypeId().equals(messageTypeId); + } + + private Stream> getListenersForMessageTypeId(final String messageTypeId) { + return messageListeners.stream() + .filter( + messageListener -> + messageListener.messageType.getMessageTypeId().equals(messageTypeId)); + } + + public void addSessionDisconnectListener( + final BiConsumer listener) { + sessionClosedListeners.add(listener); + } + + void onClose(final WebSocketSession session) { + sessionSet.remove(session); + sessionClosedListeners.forEach(listener -> listener.accept(this, session)); + } + + void onOpen(final WebSocketSession session) { + sessionSet.put(session); + } + + void onError(final WebSocketSession session, final Throwable throwable) { + final String errorId = UUID.randomUUID().toString(); + log.error( + "Error-id processing websocket message, returning an error message to user. " + + "Error id: {}", + errorId, + throwable); + + messageSender.accept( + session, + new ServerErrorMessage( + "Server error, error-id#" + errorId + ", please report this to TripleA") + .toEnvelope()); + } +} diff --git a/src/main/java/org/triplea/web/socket/WebSocketSession.java b/src/main/java/org/triplea/web/socket/WebSocketSession.java new file mode 100644 index 0000000..52b6c44 --- /dev/null +++ b/src/main/java/org/triplea/web/socket/WebSocketSession.java @@ -0,0 +1,20 @@ +package org.triplea.web.socket; + +import java.net.InetAddress; +import javax.websocket.CloseReason; + +public interface WebSocketSession { + boolean isOpen(); + + InetAddress getRemoteAddress(); + + default void close() { + close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, "Session closed by server")); + } + + void close(CloseReason closeReason); + + void sendText(String text); + + String getId(); +} diff --git a/src/main/java/org/triplea/web/socket/WebSocketSessionAdapter.java b/src/main/java/org/triplea/web/socket/WebSocketSessionAdapter.java new file mode 100644 index 0000000..5011ca5 --- /dev/null +++ b/src/main/java/org/triplea/web/socket/WebSocketSessionAdapter.java @@ -0,0 +1,88 @@ +package org.triplea.web.socket; + +import java.io.IOException; +import java.net.InetAddress; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import javax.websocket.CloseReason; +import javax.websocket.Session; +import lombok.experimental.UtilityClass; +import org.java_websocket.WebSocket; +import org.slf4j.LoggerFactory; + +/** + * Converts 'session' objects that we receive as parameters to websocket servers to implementations + * of the unified interface 'WebSocketSession'. + */ +@UtilityClass +public class WebSocketSessionAdapter { + static WebSocketSession fromSession(final Session session) { + return new WebSocketSession() { + @Override + public boolean isOpen() { + return session.isOpen(); + } + + @Override + public InetAddress getRemoteAddress() { + return InetExtractor.extract(session.getUserProperties()); + } + + @Override + public void close(final CloseReason closeReason) { + try { + session.close(closeReason); + } catch (final IOException e) { + LoggerFactory.getLogger(WebSocketSessionAdapter.class) + .warn("Error closing websocket session", e); + } + } + + @Override + public void sendText(final String text) { + try { + session.getAsyncRemote().sendText(text).get(); + } catch (final InterruptedException | ExecutionException e) { + LoggerFactory.getLogger(WebSocketSessionAdapter.class) + .error("Error sending websocket message", e); + } + } + + @Override + public String getId() { + return session.getId(); + } + }; + } + + static WebSocketSession fromWebSocket(final WebSocket webSocket) { + return new WebSocketSession() { + private final String id = UUID.randomUUID().toString(); + + @Override + public boolean isOpen() { + return webSocket != null && webSocket.isOpen(); + } + + @Override + public InetAddress getRemoteAddress() { + return webSocket.getRemoteSocketAddress().getAddress(); + } + + @Override + public void close(final CloseReason closeReason) { + webSocket.close(closeReason.getCloseCode().getCode(), closeReason.getReasonPhrase()); + } + + @Override + public void sendText(final String text) { + webSocket.send(text); + } + + @Override + public String getId() { + return id; + } + }; + } +} diff --git a/server/dropwizard-server/src/main/resources/configuration.yml b/src/main/resources/configuration.yml similarity index 100% rename from server/dropwizard-server/src/main/resources/configuration.yml rename to src/main/resources/configuration.yml diff --git a/server/lobby-module/src/test/java/org/triplea/TestData.java b/src/test/java/org/triplea/TestData.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/TestData.java rename to src/test/java/org/triplea/TestData.java diff --git a/server/lobby-module/src/test/java/org/triplea/db/LobbyModuleDatabaseTestSupport.java b/src/test/java/org/triplea/db/LobbyModuleDatabaseTestSupport.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/db/LobbyModuleDatabaseTestSupport.java rename to src/test/java/org/triplea/db/LobbyModuleDatabaseTestSupport.java diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/access/log/AccessLogDaoTest.java b/src/test/java/org/triplea/db/dao/access/log/AccessLogDaoTest.java similarity index 98% rename from server/lobby-module/src/test/java/org/triplea/db/dao/access/log/AccessLogDaoTest.java rename to src/test/java/org/triplea/db/dao/access/log/AccessLogDaoTest.java index 9f89cd6..1486b49 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/access/log/AccessLogDaoTest.java +++ b/src/test/java/org/triplea/db/dao/access/log/AccessLogDaoTest.java @@ -14,12 +14,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class AccessLogDaoTest { private static final String EMPTY_ACCESS_LOG = "access_log/user_role.yml,access_log/lobby_user.yml"; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoTest.java b/src/test/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoTest.java similarity index 95% rename from server/lobby-module/src/test/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoTest.java rename to src/test/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoTest.java index 64851c9..6544097 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoTest.java +++ b/src/test/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoTest.java @@ -10,12 +10,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class GameHostingApiKeyDaoTest { private final GameHostingApiKeyDao gameHostApiKeyDao; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoWrapperTest.java b/src/test/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoWrapperTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoWrapperTest.java rename to src/test/java/org/triplea/db/dao/api/key/GameHostingApiKeyDaoWrapperTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoTest.java b/src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoTest.java similarity index 98% rename from server/lobby-module/src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoTest.java rename to src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoTest.java index b44cc1e..cd17831 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoTest.java +++ b/src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoTest.java @@ -14,7 +14,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; import org.triplea.db.dao.user.role.UserRole; -import org.triplea.test.common.RequiresDatabase; @DataSet( value = @@ -25,7 +24,6 @@ @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class PlayerApiKeyDaoTest { private static final int USER_ID = 50; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoWrapperTest.java b/src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoWrapperTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoWrapperTest.java rename to src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyDaoWrapperTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyLookupRecordTest.java b/src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyLookupRecordTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyLookupRecordTest.java rename to src/test/java/org/triplea/db/dao/api/key/PlayerApiKeyLookupRecordTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/chat/history/LobbyChatHistoryDaoTest.java b/src/test/java/org/triplea/db/dao/chat/history/LobbyChatHistoryDaoTest.java similarity index 93% rename from server/lobby-module/src/test/java/org/triplea/db/dao/chat/history/LobbyChatHistoryDaoTest.java rename to src/test/java/org/triplea/db/dao/chat/history/LobbyChatHistoryDaoTest.java index 94414a3..733a6bb 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/chat/history/LobbyChatHistoryDaoTest.java +++ b/src/test/java/org/triplea/db/dao/chat/history/LobbyChatHistoryDaoTest.java @@ -7,12 +7,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class LobbyChatHistoryDaoTest { private final LobbyChatHistoryDao lobbyChatHistoryDao; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/lobby/games/LobbyGameDaoTest.java b/src/test/java/org/triplea/db/dao/lobby/games/LobbyGameDaoTest.java similarity index 96% rename from server/lobby-module/src/test/java/org/triplea/db/dao/lobby/games/LobbyGameDaoTest.java rename to src/test/java/org/triplea/db/dao/lobby/games/LobbyGameDaoTest.java index 1a2fcdf..bf632d0 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/lobby/games/LobbyGameDaoTest.java +++ b/src/test/java/org/triplea/db/dao/lobby/games/LobbyGameDaoTest.java @@ -11,12 +11,10 @@ import org.triplea.domain.data.ApiKey; import org.triplea.http.client.lobby.game.lobby.watcher.ChatMessageUpload; import org.triplea.http.client.lobby.game.lobby.watcher.LobbyGameListing; -import org.triplea.test.common.RequiresDatabase; @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class LobbyGameDaoTest { private final LobbyGameDao lobbyGameDao; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/BadWordsDaoTest.java b/src/test/java/org/triplea/db/dao/moderator/BadWordsDaoTest.java similarity index 97% rename from server/lobby-module/src/test/java/org/triplea/db/dao/moderator/BadWordsDaoTest.java rename to src/test/java/org/triplea/db/dao/moderator/BadWordsDaoTest.java index 2ccc6ca..855c74a 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/BadWordsDaoTest.java +++ b/src/test/java/org/triplea/db/dao/moderator/BadWordsDaoTest.java @@ -15,13 +15,11 @@ import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.ValueSource; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @DataSet(value = "bad_words/bad_word.yml", useSequenceFiltering = false) @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class BadWordsDaoTest { private static final List expectedBadWords = List.of("aaa", "one", "two", "zzz"); diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryDaoTest.java b/src/test/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryDaoTest.java similarity index 98% rename from server/lobby-module/src/test/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryDaoTest.java rename to src/test/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryDaoTest.java index 09e30f0..8bc5a6f 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryDaoTest.java +++ b/src/test/java/org/triplea/db/dao/moderator/ModeratorAuditHistoryDaoTest.java @@ -16,7 +16,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @RequiredArgsConstructor @DataSet( @@ -27,7 +26,6 @@ useSequenceFiltering = false) @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class ModeratorAuditHistoryDaoTest { private static final int MODERATOR_ID = 900000; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/ModeratorsDaoTest.java b/src/test/java/org/triplea/db/dao/moderator/ModeratorsDaoTest.java similarity index 97% rename from server/lobby-module/src/test/java/org/triplea/db/dao/moderator/ModeratorsDaoTest.java rename to src/test/java/org/triplea/db/dao/moderator/ModeratorsDaoTest.java index d85bef0..17f1518 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/ModeratorsDaoTest.java +++ b/src/test/java/org/triplea/db/dao/moderator/ModeratorsDaoTest.java @@ -15,7 +15,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; import org.triplea.db.dao.user.role.UserRole; -import org.triplea.test.common.RequiresDatabase; @DataSet( value = "moderators/user_role.yml, moderators/lobby_user.yml, moderators/access_log.yml", @@ -23,7 +22,6 @@ @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class ModeratorsDaoTest { private static final int NOT_MODERATOR_ID = 100000; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/chat/history/ChatHistoryRecordTest.java b/src/test/java/org/triplea/db/dao/moderator/chat/history/ChatHistoryRecordTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/db/dao/moderator/chat/history/ChatHistoryRecordTest.java rename to src/test/java/org/triplea/db/dao/moderator/chat/history/ChatHistoryRecordTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/chat/history/GameChatHistoryDaoTest.java b/src/test/java/org/triplea/db/dao/moderator/chat/history/GameChatHistoryDaoTest.java similarity index 98% rename from server/lobby-module/src/test/java/org/triplea/db/dao/moderator/chat/history/GameChatHistoryDaoTest.java rename to src/test/java/org/triplea/db/dao/moderator/chat/history/GameChatHistoryDaoTest.java index 1855849..b077478 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/chat/history/GameChatHistoryDaoTest.java +++ b/src/test/java/org/triplea/db/dao/moderator/chat/history/GameChatHistoryDaoTest.java @@ -14,7 +14,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @DataSet( value = @@ -25,7 +24,6 @@ @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class GameChatHistoryDaoTest { private static final String SIR_HOSTS_A_LOT = "sir_hosts_a_lot"; private static final String SIR_HOSTS_A_LITTLE = "sir_hosts_a_little"; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/player/info/PlayerAliasRecordTest.java b/src/test/java/org/triplea/db/dao/moderator/player/info/PlayerAliasRecordTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/db/dao/moderator/player/info/PlayerAliasRecordTest.java rename to src/test/java/org/triplea/db/dao/moderator/player/info/PlayerAliasRecordTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/player/info/PlayerBanRecordTest.java b/src/test/java/org/triplea/db/dao/moderator/player/info/PlayerBanRecordTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/db/dao/moderator/player/info/PlayerBanRecordTest.java rename to src/test/java/org/triplea/db/dao/moderator/player/info/PlayerBanRecordTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/player/info/PlayerInfoForModeratorDaoTest.java b/src/test/java/org/triplea/db/dao/moderator/player/info/PlayerInfoForModeratorDaoTest.java similarity index 98% rename from server/lobby-module/src/test/java/org/triplea/db/dao/moderator/player/info/PlayerInfoForModeratorDaoTest.java rename to src/test/java/org/triplea/db/dao/moderator/player/info/PlayerInfoForModeratorDaoTest.java index 8e45e1f..40babb5 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/moderator/player/info/PlayerInfoForModeratorDaoTest.java +++ b/src/test/java/org/triplea/db/dao/moderator/player/info/PlayerInfoForModeratorDaoTest.java @@ -14,12 +14,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class PlayerInfoForModeratorDaoTest { private final PlayerInfoForModeratorDao playerInfoForModeratorDao; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/temp/password/TempPasswordDaoTest.java b/src/test/java/org/triplea/db/dao/temp/password/TempPasswordDaoTest.java similarity index 97% rename from server/lobby-module/src/test/java/org/triplea/db/dao/temp/password/TempPasswordDaoTest.java rename to src/test/java/org/triplea/db/dao/temp/password/TempPasswordDaoTest.java index 89b3841..28ebe28 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/temp/password/TempPasswordDaoTest.java +++ b/src/test/java/org/triplea/db/dao/temp/password/TempPasswordDaoTest.java @@ -11,7 +11,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @DataSet( value = @@ -22,7 +21,6 @@ @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class TempPasswordDaoTest { private static final String USERNAME = "username"; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/temp/password/TempPasswordHistoryDaoTest.java b/src/test/java/org/triplea/db/dao/temp/password/TempPasswordHistoryDaoTest.java similarity index 95% rename from server/lobby-module/src/test/java/org/triplea/db/dao/temp/password/TempPasswordHistoryDaoTest.java rename to src/test/java/org/triplea/db/dao/temp/password/TempPasswordHistoryDaoTest.java index c4f52c5..a146866 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/temp/password/TempPasswordHistoryDaoTest.java +++ b/src/test/java/org/triplea/db/dao/temp/password/TempPasswordHistoryDaoTest.java @@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @DataSet( cleanBefore = true, @@ -16,7 +15,6 @@ useSequenceFiltering = false) @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) -@RequiresDatabase class TempPasswordHistoryDaoTest { private static final String USERNAME = "username"; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/user/UserJdbiDaoTest.java b/src/test/java/org/triplea/db/dao/user/UserJdbiDaoTest.java similarity index 97% rename from server/lobby-module/src/test/java/org/triplea/db/dao/user/UserJdbiDaoTest.java rename to src/test/java/org/triplea/db/dao/user/UserJdbiDaoTest.java index 2afeaf7..9c65aac 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/user/UserJdbiDaoTest.java +++ b/src/test/java/org/triplea/db/dao/user/UserJdbiDaoTest.java @@ -14,13 +14,11 @@ import org.triplea.db.LobbyModuleDatabaseTestSupport; import org.triplea.db.dao.user.role.UserRole; import org.triplea.db.dao.user.role.UserRoleLookup; -import org.triplea.test.common.RequiresDatabase; @DataSet(value = "user/user_role.yml,user/lobby_user.yml", useSequenceFiltering = false) @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class UserJdbiDaoTest { private static final int USER_ID = 900000; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/user/ban/UserBanDaoTest.java b/src/test/java/org/triplea/db/dao/user/ban/UserBanDaoTest.java similarity index 98% rename from server/lobby-module/src/test/java/org/triplea/db/dao/user/ban/UserBanDaoTest.java rename to src/test/java/org/triplea/db/dao/user/ban/UserBanDaoTest.java index ecf2d16..4d9e36a 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/user/ban/UserBanDaoTest.java +++ b/src/test/java/org/triplea/db/dao/user/ban/UserBanDaoTest.java @@ -19,12 +19,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class UserBanDaoTest { private final UserBanDao userBanDao; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/user/role/UserRoleDaoTest.java b/src/test/java/org/triplea/db/dao/user/role/UserRoleDaoTest.java similarity index 93% rename from server/lobby-module/src/test/java/org/triplea/db/dao/user/role/UserRoleDaoTest.java rename to src/test/java/org/triplea/db/dao/user/role/UserRoleDaoTest.java index 5af20cd..878dc92 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/user/role/UserRoleDaoTest.java +++ b/src/test/java/org/triplea/db/dao/user/role/UserRoleDaoTest.java @@ -9,13 +9,11 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @DataSet(value = "user_role/initial.yml", useSequenceFiltering = false) @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class UserRoleDaoTest { private final UserRoleDao userRoleDao; diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/user/role/UserRoleTest.java b/src/test/java/org/triplea/db/dao/user/role/UserRoleTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/db/dao/user/role/UserRoleTest.java rename to src/test/java/org/triplea/db/dao/user/role/UserRoleTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/db/dao/username/ban/UsernameBanDaoTest.java b/src/test/java/org/triplea/db/dao/username/ban/UsernameBanDaoTest.java similarity index 97% rename from server/lobby-module/src/test/java/org/triplea/db/dao/username/ban/UsernameBanDaoTest.java rename to src/test/java/org/triplea/db/dao/username/ban/UsernameBanDaoTest.java index 65dd824..bd27923 100644 --- a/server/lobby-module/src/test/java/org/triplea/db/dao/username/ban/UsernameBanDaoTest.java +++ b/src/test/java/org/triplea/db/dao/username/ban/UsernameBanDaoTest.java @@ -14,12 +14,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class UsernameBanDaoTest { private final UsernameBanDao usernameBanDao; diff --git a/server/server-lib/src/test/java/org/triplea/dropwizard/common/IpAddressExtractorTest.java b/src/test/java/org/triplea/dropwizard/common/IpAddressExtractorTest.java similarity index 100% rename from server/server-lib/src/test/java/org/triplea/dropwizard/common/IpAddressExtractorTest.java rename to src/test/java/org/triplea/dropwizard/common/IpAddressExtractorTest.java diff --git a/http-clients/github-client/src/test/java/org/triplea/http/client/github/GithubApiClientTest.java b/src/test/java/org/triplea/http/client/github/GithubApiClientTest.java similarity index 100% rename from http-clients/github-client/src/test/java/org/triplea/http/client/github/GithubApiClientTest.java rename to src/test/java/org/triplea/http/client/github/GithubApiClientTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/chat/ChattersTest.java b/src/test/java/org/triplea/modules/chat/ChattersTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/chat/ChattersTest.java rename to src/test/java/org/triplea/modules/chat/ChattersTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/ChatMessageListenerTest.java b/src/test/java/org/triplea/modules/chat/event/processing/ChatMessageListenerTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/ChatMessageListenerTest.java rename to src/test/java/org/triplea/modules/chat/event/processing/ChatMessageListenerTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/ChatParticipantAdapterTest.java b/src/test/java/org/triplea/modules/chat/event/processing/ChatParticipantAdapterTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/ChatParticipantAdapterTest.java rename to src/test/java/org/triplea/modules/chat/event/processing/ChatParticipantAdapterTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/PlayerConnectedListenerTest.java b/src/test/java/org/triplea/modules/chat/event/processing/PlayerConnectedListenerTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/PlayerConnectedListenerTest.java rename to src/test/java/org/triplea/modules/chat/event/processing/PlayerConnectedListenerTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/PlayerIsMutedMessageTest.java b/src/test/java/org/triplea/modules/chat/event/processing/PlayerIsMutedMessageTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/PlayerIsMutedMessageTest.java rename to src/test/java/org/triplea/modules/chat/event/processing/PlayerIsMutedMessageTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/PlayerLeftListenerTest.java b/src/test/java/org/triplea/modules/chat/event/processing/PlayerLeftListenerTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/PlayerLeftListenerTest.java rename to src/test/java/org/triplea/modules/chat/event/processing/PlayerLeftListenerTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/SlapListenerTest.java b/src/test/java/org/triplea/modules/chat/event/processing/SlapListenerTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/SlapListenerTest.java rename to src/test/java/org/triplea/modules/chat/event/processing/SlapListenerTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/StatusUpdateListenerTest.java b/src/test/java/org/triplea/modules/chat/event/processing/StatusUpdateListenerTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/chat/event/processing/StatusUpdateListenerTest.java rename to src/test/java/org/triplea/modules/chat/event/processing/StatusUpdateListenerTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/forgot/password/ForgotPasswordModuleTest.java b/src/test/java/org/triplea/modules/forgot/password/ForgotPasswordModuleTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/forgot/password/ForgotPasswordModuleTest.java rename to src/test/java/org/triplea/modules/forgot/password/ForgotPasswordModuleTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/forgot/password/PasswordGeneratorTest.java b/src/test/java/org/triplea/modules/forgot/password/PasswordGeneratorTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/forgot/password/PasswordGeneratorTest.java rename to src/test/java/org/triplea/modules/forgot/password/PasswordGeneratorTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/forgot/password/TempPasswordPersistenceTest.java b/src/test/java/org/triplea/modules/forgot/password/TempPasswordPersistenceTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/forgot/password/TempPasswordPersistenceTest.java rename to src/test/java/org/triplea/modules/forgot/password/TempPasswordPersistenceTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/game/listing/GameListingTest.java b/src/test/java/org/triplea/modules/game/listing/GameListingTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/game/listing/GameListingTest.java rename to src/test/java/org/triplea/modules/game/listing/GameListingTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/game/listing/GameTtlExpiredListenerTest.java b/src/test/java/org/triplea/modules/game/listing/GameTtlExpiredListenerTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/game/listing/GameTtlExpiredListenerTest.java rename to src/test/java/org/triplea/modules/game/listing/GameTtlExpiredListenerTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/game/lobby/watcher/ChatUploadModuleTest.java b/src/test/java/org/triplea/modules/game/lobby/watcher/ChatUploadModuleTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/game/lobby/watcher/ChatUploadModuleTest.java rename to src/test/java/org/triplea/modules/game/lobby/watcher/ChatUploadModuleTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/game/lobby/watcher/ConnectivityCheckTest.java b/src/test/java/org/triplea/modules/game/lobby/watcher/ConnectivityCheckTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/game/lobby/watcher/ConnectivityCheckTest.java rename to src/test/java/org/triplea/modules/game/lobby/watcher/ConnectivityCheckTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/game/lobby/watcher/GamePostingModuleTest.java b/src/test/java/org/triplea/modules/game/lobby/watcher/GamePostingModuleTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/game/lobby/watcher/GamePostingModuleTest.java rename to src/test/java/org/triplea/modules/game/lobby/watcher/GamePostingModuleTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/moderation/access/log/AccessLogServiceTest.java b/src/test/java/org/triplea/modules/moderation/access/log/AccessLogServiceTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/moderation/access/log/AccessLogServiceTest.java rename to src/test/java/org/triplea/modules/moderation/access/log/AccessLogServiceTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/moderation/audit/history/ModeratorAuditHistoryServiceTest.java b/src/test/java/org/triplea/modules/moderation/audit/history/ModeratorAuditHistoryServiceTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/moderation/audit/history/ModeratorAuditHistoryServiceTest.java rename to src/test/java/org/triplea/modules/moderation/audit/history/ModeratorAuditHistoryServiceTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/moderation/bad/words/BadWordsServiceTest.java b/src/test/java/org/triplea/modules/moderation/bad/words/BadWordsServiceTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/moderation/bad/words/BadWordsServiceTest.java rename to src/test/java/org/triplea/modules/moderation/bad/words/BadWordsServiceTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/moderation/ban/name/UsernameBanServiceTest.java b/src/test/java/org/triplea/modules/moderation/ban/name/UsernameBanServiceTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/moderation/ban/name/UsernameBanServiceTest.java rename to src/test/java/org/triplea/modules/moderation/ban/name/UsernameBanServiceTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/moderation/ban/user/BannedPlayerEventHandlerTest.java b/src/test/java/org/triplea/modules/moderation/ban/user/BannedPlayerEventHandlerTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/moderation/ban/user/BannedPlayerEventHandlerTest.java rename to src/test/java/org/triplea/modules/moderation/ban/user/BannedPlayerEventHandlerTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/moderation/ban/user/UserBanServiceTest.java b/src/test/java/org/triplea/modules/moderation/ban/user/UserBanServiceTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/moderation/ban/user/UserBanServiceTest.java rename to src/test/java/org/triplea/modules/moderation/ban/user/UserBanServiceTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/moderation/chat/history/FetchGameChatHistoryModuleTest.java b/src/test/java/org/triplea/modules/moderation/chat/history/FetchGameChatHistoryModuleTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/moderation/chat/history/FetchGameChatHistoryModuleTest.java rename to src/test/java/org/triplea/modules/moderation/chat/history/FetchGameChatHistoryModuleTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/moderation/disconnect/user/DisconnectUserActionTest.java b/src/test/java/org/triplea/modules/moderation/disconnect/user/DisconnectUserActionTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/moderation/disconnect/user/DisconnectUserActionTest.java rename to src/test/java/org/triplea/modules/moderation/disconnect/user/DisconnectUserActionTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/moderation/moderators/ModeratorsServiceTest.java b/src/test/java/org/triplea/modules/moderation/moderators/ModeratorsServiceTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/moderation/moderators/ModeratorsServiceTest.java rename to src/test/java/org/triplea/modules/moderation/moderators/ModeratorsServiceTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/moderation/remote/actions/RemoteActionsModuleTest.java b/src/test/java/org/triplea/modules/moderation/remote/actions/RemoteActionsModuleTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/moderation/remote/actions/RemoteActionsModuleTest.java rename to src/test/java/org/triplea/modules/moderation/remote/actions/RemoteActionsModuleTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/player/info/FetchPlayerInfoModuleTest.java b/src/test/java/org/triplea/modules/player/info/FetchPlayerInfoModuleTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/player/info/FetchPlayerInfoModuleTest.java rename to src/test/java/org/triplea/modules/player/info/FetchPlayerInfoModuleTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/NameIsAvailableValidationTest.java b/src/test/java/org/triplea/modules/user/account/NameIsAvailableValidationTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/NameIsAvailableValidationTest.java rename to src/test/java/org/triplea/modules/user/account/NameIsAvailableValidationTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/NameValidationTest.java b/src/test/java/org/triplea/modules/user/account/NameValidationTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/NameValidationTest.java rename to src/test/java/org/triplea/modules/user/account/NameValidationTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/PasswordBCrypterTest.java b/src/test/java/org/triplea/modules/user/account/PasswordBCrypterTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/PasswordBCrypterTest.java rename to src/test/java/org/triplea/modules/user/account/PasswordBCrypterTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/create/AccountCreatorTest.java b/src/test/java/org/triplea/modules/user/account/create/AccountCreatorTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/create/AccountCreatorTest.java rename to src/test/java/org/triplea/modules/user/account/create/AccountCreatorTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/create/CreateAccountModuleTest.java b/src/test/java/org/triplea/modules/user/account/create/CreateAccountModuleTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/create/CreateAccountModuleTest.java rename to src/test/java/org/triplea/modules/user/account/create/CreateAccountModuleTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/create/CreateAccountValidationTest.java b/src/test/java/org/triplea/modules/user/account/create/CreateAccountValidationTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/create/CreateAccountValidationTest.java rename to src/test/java/org/triplea/modules/user/account/create/CreateAccountValidationTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/create/EmailValidationTest.java b/src/test/java/org/triplea/modules/user/account/create/EmailValidationTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/create/EmailValidationTest.java rename to src/test/java/org/triplea/modules/user/account/create/EmailValidationTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/create/PasswordValidationTest.java b/src/test/java/org/triplea/modules/user/account/create/PasswordValidationTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/create/PasswordValidationTest.java rename to src/test/java/org/triplea/modules/user/account/create/PasswordValidationTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/login/AccessLogUpdaterTest.java b/src/test/java/org/triplea/modules/user/account/login/AccessLogUpdaterTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/login/AccessLogUpdaterTest.java rename to src/test/java/org/triplea/modules/user/account/login/AccessLogUpdaterTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/login/LobbyLoginMessageDaoTest.java b/src/test/java/org/triplea/modules/user/account/login/LobbyLoginMessageDaoTest.java similarity index 91% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/login/LobbyLoginMessageDaoTest.java rename to src/test/java/org/triplea/modules/user/account/login/LobbyLoginMessageDaoTest.java index 46d274e..1f3db4e 100644 --- a/server/lobby-module/src/test/java/org/triplea/modules/user/account/login/LobbyLoginMessageDaoTest.java +++ b/src/test/java/org/triplea/modules/user/account/login/LobbyLoginMessageDaoTest.java @@ -9,12 +9,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.triplea.db.LobbyModuleDatabaseTestSupport; -import org.triplea.test.common.RequiresDatabase; @RequiredArgsConstructor @ExtendWith(LobbyModuleDatabaseTestSupport.class) @ExtendWith(DBUnitExtension.class) -@RequiresDatabase class LobbyLoginMessageDaoTest { private final LobbyLoginMessageDao lobbyLoginMessageDao; diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/login/LoginModuleTest.java b/src/test/java/org/triplea/modules/user/account/login/LoginModuleTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/login/LoginModuleTest.java rename to src/test/java/org/triplea/modules/user/account/login/LoginModuleTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/login/authorizer/anonymous/AnonymousLoginTest.java b/src/test/java/org/triplea/modules/user/account/login/authorizer/anonymous/AnonymousLoginTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/login/authorizer/anonymous/AnonymousLoginTest.java rename to src/test/java/org/triplea/modules/user/account/login/authorizer/anonymous/AnonymousLoginTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/login/authorizer/registered/PasswordCheckTest.java b/src/test/java/org/triplea/modules/user/account/login/authorizer/registered/PasswordCheckTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/login/authorizer/registered/PasswordCheckTest.java rename to src/test/java/org/triplea/modules/user/account/login/authorizer/registered/PasswordCheckTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/login/authorizer/temp/password/TempPasswordLoginTest.java b/src/test/java/org/triplea/modules/user/account/login/authorizer/temp/password/TempPasswordLoginTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/login/authorizer/temp/password/TempPasswordLoginTest.java rename to src/test/java/org/triplea/modules/user/account/login/authorizer/temp/password/TempPasswordLoginTest.java diff --git a/server/lobby-module/src/test/java/org/triplea/modules/user/account/update/UpdateAccountServiceTest.java b/src/test/java/org/triplea/modules/user/account/update/UpdateAccountServiceTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/modules/user/account/update/UpdateAccountServiceTest.java rename to src/test/java/org/triplea/modules/user/account/update/UpdateAccountServiceTest.java diff --git a/server/database-test-support/src/main/java/org/triplea/spitfire/database/DatabaseTestSupport.java b/src/test/java/org/triplea/spitfire/database/DatabaseTestSupport.java similarity index 100% rename from server/database-test-support/src/main/java/org/triplea/spitfire/database/DatabaseTestSupport.java rename to src/test/java/org/triplea/spitfire/database/DatabaseTestSupport.java diff --git a/server/database-test-support/src/main/java/org/triplea/spitfire/database/DbRiderTestExtension.java b/src/test/java/org/triplea/spitfire/database/DbRiderTestExtension.java similarity index 100% rename from server/database-test-support/src/main/java/org/triplea/spitfire/database/DbRiderTestExtension.java rename to src/test/java/org/triplea/spitfire/database/DbRiderTestExtension.java diff --git a/src/test/java/org/triplea/test/common/CustomMatcher.java b/src/test/java/org/triplea/test/common/CustomMatcher.java new file mode 100644 index 0000000..e0ff307 --- /dev/null +++ b/src/test/java/org/triplea/test/common/CustomMatcher.java @@ -0,0 +1,50 @@ +package org.triplea.test.common; + +import java.util.function.Function; +import java.util.function.Predicate; +import javax.annotation.Nonnull; +import lombok.Builder; +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +/** + * Convenience class for building a type safe hamcrest matcher. See Test cases for more example + * usages. Example usage: + * + *
{@code
+ * assertThat(testValue, customMatcher("valueToMatch"));
+ *
+ * private static Matcher customMatcher(final String expectedValue) {
+ *   return MatchBuilder.builder()
+ *       .description("We expect the test value to be equal to: " + expectedValue)
+ *       .checkCondition(String::equals)
+ *       .debug(testValue -> "This can be used to print more debug output when there is a failure"
+ *          + ", it is optional, when omitted you will get a 'testValue.toString()' by default")
+ *       .build();
+ * }
+ * }
+ * + * @param The result type which we will be checking. For example, if we are testing a 'HashMap' + * has a specific value, then this would be of type 'HashMap' + */ +@Builder +public final class CustomMatcher extends TypeSafeMatcher { + @Nonnull private final String description; + @Nonnull private final Predicate checkCondition; + @Builder.Default @Nonnull private final Function debug = Object::toString; + + @Override + protected boolean matchesSafely(final T item) { + return checkCondition.test(item); + } + + @Override + protected void describeMismatchSafely(final T item, final Description mismatchDescription) { + mismatchDescription.appendText(debug.apply(item)); + } + + @Override + public void describeTo(final Description description) { + description.appendText(this.description); + } +} diff --git a/src/test/java/org/triplea/test/common/IsInstant.java b/src/test/java/org/triplea/test/common/IsInstant.java new file mode 100644 index 0000000..4a17e29 --- /dev/null +++ b/src/test/java/org/triplea/test/common/IsInstant.java @@ -0,0 +1,44 @@ +package org.triplea.test.common; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsEqual.equalTo; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import lombok.experimental.UtilityClass; +import org.hamcrest.Matcher; + +@UtilityClass +public class IsInstant { + + /** + * Matches if a given instant has the equivalent date as defined by the parameters (parameters are + * assumed to be UTC). + * + *

Example usage: + * assertThat(Instant.now(), isInstant(2020, 12, 24, 23, 59, 59)); + *
+ * The above is equivalent to: + * assertThat(Instant.now(), is(Instant.parse("2020-12-24T23:59:59Z"))); + * + * + * @param year The year to match (should be YYYY format, eg: 2020) + * @param month The month to match (1-12) + * @param day The day to match (1-31) + * @param hour The hour of day to match (1-23) + * @param minute The minute of the hour to match (0-59) + * @param second The second of the minute to match (0-59) + */ + public static Matcher isInstant( + final int year, + final int month, + final int day, + final int hour, + final int minute, + final int second) { + return is( + equalTo( + LocalDateTime.of(year, month, day, hour, minute, second).toInstant(ZoneOffset.UTC))); + } +} diff --git a/src/test/java/org/triplea/test/common/JsonUtil.java b/src/test/java/org/triplea/test/common/JsonUtil.java new file mode 100644 index 0000000..91495c9 --- /dev/null +++ b/src/test/java/org/triplea/test/common/JsonUtil.java @@ -0,0 +1,26 @@ +package org.triplea.test.common; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import lombok.experimental.UtilityClass; + +@UtilityClass +public class JsonUtil { + private static final ObjectMapper objectMapper; + + static { + objectMapper = new ObjectMapper(); + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + objectMapper.registerModule(new JavaTimeModule()); + } + + public static String toJson(final T object) { + try { + return objectMapper.writeValueAsString(object); + } catch (final JsonProcessingException e) { + throw new RuntimeException("Failed to convert to JSON string: " + object, e); + } + } +} diff --git a/src/test/java/org/triplea/test/common/StringToInputStream.java b/src/test/java/org/triplea/test/common/StringToInputStream.java new file mode 100644 index 0000000..4cf1314 --- /dev/null +++ b/src/test/java/org/triplea/test/common/StringToInputStream.java @@ -0,0 +1,17 @@ +package org.triplea.test.common; + +import com.google.common.base.Strings; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import lombok.experimental.UtilityClass; + +@UtilityClass +public class StringToInputStream { + + /** Converts a {@code String} to an equivalent {@code InputStream}. */ + public static InputStream asInputStream(final String inputString) { + return new ByteArrayInputStream( + Strings.nullToEmpty(inputString).getBytes(StandardCharsets.UTF_8)); + } +} diff --git a/src/test/java/org/triplea/test/common/TestDataFileReader.java b/src/test/java/org/triplea/test/common/TestDataFileReader.java new file mode 100644 index 0000000..41b7b56 --- /dev/null +++ b/src/test/java/org/triplea/test/common/TestDataFileReader.java @@ -0,0 +1,62 @@ +package org.triplea.test.common; + +import com.google.common.annotations.VisibleForTesting; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Optional; +import lombok.experimental.UtilityClass; + +@UtilityClass +public class TestDataFileReader { + + /** + * Reads file contents, file is expected to be located at either the project root or in + * "src/test/resources". + * + * @param filePath Path to the file relative to 'src/test/resources' or relative to the project + * root. + * @return Contents of the file read. + * @throws TestDataFileNotFound Thrown if file does not exist. + */ + public static String readContents(final String filePath) { + return readFromProjectRoot(filePath) + // current context can be from a sub-project, or can be from the top-most level of the + // project. Check up a directory in case context is sub-project. + .or(() -> readFromProjectRoot("../" + filePath)) + .or(() -> readFromProjectRoot("../../" + filePath)) + .or(() -> readFromResources(filePath)) + .orElseThrow(() -> new TestDataFileNotFound(filePath)); + } + + private Optional readFromProjectRoot(final String filePath) { + try { + final List lines = Files.readAllLines(Path.of(filePath), StandardCharsets.UTF_8); + return Optional.of(String.join("\n", lines)); + } catch (final IOException e) { + return Optional.empty(); + } + } + + @SuppressWarnings("ConstantConditions") + private Optional readFromResources(final String filePath) { + final ClassLoader classLoader = TestDataFileReader.class.getClassLoader(); + try (InputStream inputStream = classLoader.getResourceAsStream(filePath)) { + return Optional.of(new String(inputStream.readAllBytes(), StandardCharsets.UTF_8)); + } catch (final NullPointerException | IOException e) { + return Optional.empty(); + } + } + + @VisibleForTesting + static class TestDataFileNotFound extends RuntimeException { + private static final long serialVersionUID = 6122387967083038888L; + + TestDataFileNotFound(final String filePath) { + super("Failed to find file: " + filePath); + } + } +} diff --git a/src/test/java/org/triplea/test/common/matchers/CollectionMatchers.java b/src/test/java/org/triplea/test/common/matchers/CollectionMatchers.java new file mode 100644 index 0000000..41aaf15 --- /dev/null +++ b/src/test/java/org/triplea/test/common/matchers/CollectionMatchers.java @@ -0,0 +1,42 @@ +package org.triplea.test.common.matchers; + +import static org.hamcrest.core.IsNot.not; + +import java.util.Collection; +import java.util.function.Function; +import java.util.stream.Collectors; +import lombok.experimental.UtilityClass; +import org.hamcrest.Matcher; +import org.triplea.test.common.CustomMatcher; + +@UtilityClass +public class CollectionMatchers { + + /** + * Matcher for a collection that maps the contents of the collection and checks if any mapped + * items match a given item. + * + *

For example, to check a list of numbers for a square that is equal to 25, the following + * would be true: {@code assertThat(List.of(1, 3, 5), containsMappedItem(i -> i*i, 25));} + * + * @param mappingFunction The mapping function to apply to the collection. + * @param mappedItem The given item to assert is contained in the mapped collection. + */ + public static Matcher> containsMappedItem( + final Function mappingFunction, final X mappedItem) { + + return CustomMatcher.>builder() + .checkCondition( + itemList -> itemList.stream().map(mappingFunction).anyMatch(mappedItem::equals)) + .description("Collection containing sub-element: " + mappedItem) + .debug( + collection -> + collection.stream().map(mappingFunction).collect(Collectors.toList()).toString()) + .build(); + } + + public static Matcher> doesNotContainMappedItem( + final Function mappingFunction, final X mappedItem) { + return not(containsMappedItem(mappingFunction, mappedItem)); + } +} diff --git a/src/test/java/org/triplea/test/common/security/TestSecurityUtils.java b/src/test/java/org/triplea/test/common/security/TestSecurityUtils.java new file mode 100644 index 0000000..afaa9de --- /dev/null +++ b/src/test/java/org/triplea/test/common/security/TestSecurityUtils.java @@ -0,0 +1,71 @@ +package org.triplea.test.common.security; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.io.ByteStreams; +import java.io.IOException; +import java.io.InputStream; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; + +/** A collection of useful methods for writing tests that involve security functions. */ +public final class TestSecurityUtils { + private static final String RSA_ALGORITHM = "RSA"; + + private TestSecurityUtils() {} + + /** + * Loads the global RSA key pair. + * + * @return The global RSA key pair. + * @throws IOException If an I/O error occurs while reading the RSA key pair. + * @throws GeneralSecurityException If the RSA key pair cannot be created from the persistent + * data. + */ + public static KeyPair loadRsaKeyPair() throws IOException, GeneralSecurityException { + return loadRsaKeyPair(TestSecurityUtils.class); + } + + /** + * Loads the RSA key pair for the specified type. + * + * @param type The type whose RSA key pair is to be loaded. + * @return The RSA key pair for the specified type. + * @throws IOException If an I/O error occurs while reading the RSA key pair. + * @throws GeneralSecurityException If the RSA key pair cannot be created from the persistent + * data. + */ + public static KeyPair loadRsaKeyPair(final Class type) + throws IOException, GeneralSecurityException { + checkNotNull(type); + + final KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM); + + final X509EncodedKeySpec publicKeySpec; + try (InputStream is = type.getResourceAsStream(getPublicKeyFileName(type))) { + publicKeySpec = new X509EncodedKeySpec(ByteStreams.toByteArray(is)); + } + final PublicKey publicKey = keyFactory.generatePublic(publicKeySpec); + + final PKCS8EncodedKeySpec privateKeySpec; + try (InputStream is = type.getResourceAsStream(getPrivateKeyFileName(type))) { + privateKeySpec = new PKCS8EncodedKeySpec(ByteStreams.toByteArray(is)); + } + final PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec); + + return new KeyPair(publicKey, privateKey); + } + + private static String getPublicKeyFileName(final Class type) { + return type.getSimpleName() + "-public.key"; + } + + private static String getPrivateKeyFileName(final Class type) { + return type.getSimpleName() + "-private.key"; + } +} diff --git a/src/test/java/org/triplea/test/common/swing/DisabledInHeadlessGraphicsEnvironment.java b/src/test/java/org/triplea/test/common/swing/DisabledInHeadlessGraphicsEnvironment.java new file mode 100644 index 0000000..b6f9bef --- /dev/null +++ b/src/test/java/org/triplea/test/common/swing/DisabledInHeadlessGraphicsEnvironment.java @@ -0,0 +1,22 @@ +package org.triplea.test.common.swing; + +import com.google.common.annotations.VisibleForTesting; +import java.awt.GraphicsEnvironment; +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** An extension that disables tests when run in a headless graphics environment. */ +public final class DisabledInHeadlessGraphicsEnvironment implements ExecutionCondition { + @Override + public ConditionEvaluationResult evaluateExecutionCondition(final ExtensionContext context) { + return evaluateExecutionCondition(GraphicsEnvironment.isHeadless()); + } + + @VisibleForTesting + static ConditionEvaluationResult evaluateExecutionCondition(final boolean headless) { + return headless + ? ConditionEvaluationResult.disabled("Test disabled in headless graphics environment") + : ConditionEvaluationResult.enabled(null); + } +} diff --git a/src/test/java/org/triplea/test/common/swing/SwingComponentWrapper.java b/src/test/java/org/triplea/test/common/swing/SwingComponentWrapper.java new file mode 100644 index 0000000..4254d9c --- /dev/null +++ b/src/test/java/org/triplea/test/common/swing/SwingComponentWrapper.java @@ -0,0 +1,52 @@ +package org.triplea.test.common.swing; + +import java.awt.Component; +import java.awt.Container; +import java.util.Arrays; +import java.util.Optional; +import javax.annotation.Nonnull; +import lombok.Value; + +/** A decorator or wrapper for a javax.swing Component that adds methods useful for testing. */ +@Value(staticConstructor = "of") +public class SwingComponentWrapper { + + @Nonnull private final Component component; + + /** + * Recursively searches the wrapped component for a swing component whose name matches the + * parameter. + * + * @param The expected type of the component that we are trying to find. + * @param childName Component name to find, searching current component or any of its children. + * @param classType The component type to return. + * @throws ClassCastException Thrown if the matched component has a type that is different from + * the expected type. + * @throws AssertionError Thrown when failing to match any components by name. + */ + void findChildByName(final String childName, final Class classType) { + findChildByNameRecursive(childName, classType) + .orElseThrow( + () -> new AssertionError("Expected to find a component with name: " + childName)); + } + + private Optional findChildByNameRecursive( + final String childName, final Class classType) { + return childName.equals(component.getName()) + ? Optional.of(classType.cast(component)) + : (component instanceof Container) + ? Arrays.stream(((Container) component).getComponents()) + .map( + childComponent -> + SwingComponentWrapper.of(childComponent) + .findChildByNameRecursive(childName, classType)) + .filter(Optional::isPresent) + .findAny() + .orElse(Optional.empty()) + : Optional.empty(); + } + + public void assertHasComponentByName(final String childName) { + findChildByName(childName, Object.class); + } +} diff --git a/src/test/java/org/triplea/web/socket/ExampleMessage.java b/src/test/java/org/triplea/web/socket/ExampleMessage.java new file mode 100644 index 0000000..53cecf4 --- /dev/null +++ b/src/test/java/org/triplea/web/socket/ExampleMessage.java @@ -0,0 +1,24 @@ +package org.triplea.web.socket; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import org.triplea.http.client.web.socket.MessageEnvelope; +import org.triplea.http.client.web.socket.messages.MessageType; +import org.triplea.http.client.web.socket.messages.WebSocketMessage; + +@Getter +@EqualsAndHashCode +public class ExampleMessage implements WebSocketMessage { + public static final MessageType TYPE = MessageType.of(ExampleMessage.class); + + private final String messageData; + + public ExampleMessage(final String messageData) { + this.messageData = messageData; + } + + @Override + public MessageEnvelope toEnvelope() { + return MessageEnvelope.packageMessage(TYPE, this); + } +} diff --git a/src/test/java/org/triplea/web/socket/GenericWebSocketTest.java b/src/test/java/org/triplea/web/socket/GenericWebSocketTest.java new file mode 100644 index 0000000..6ab51cc --- /dev/null +++ b/src/test/java/org/triplea/web/socket/GenericWebSocketTest.java @@ -0,0 +1,150 @@ +package org.triplea.web.socket; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.github.benmanes.caffeine.cache.Cache; +import com.github.benmanes.caffeine.cache.Caffeine; +import com.google.gson.Gson; +import java.net.InetAddress; +import java.time.Duration; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Predicate; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.triplea.http.client.web.socket.MessageEnvelope; +import org.triplea.http.client.web.socket.messages.envelopes.ServerErrorMessage; +import org.triplea.java.IpAddressParser; + +@SuppressWarnings({"SameParameterValue", "InnerClassMayBeStatic"}) +@ExtendWith(MockitoExtension.class) +class GenericWebSocketTest { + + @Mock private WebSocketSession session; + + @Mock private MessageSender messageSender; + + @Mock private WebSocketMessagingBus webSocketMessagingBus; + + @Mock private Predicate banCheck; + + @InjectMocks private GenericWebSocket genericWebSocket; + + private final Cache cache = + Caffeine.newBuilder().expireAfterWrite(Duration.ofSeconds(60)).build(); + + private final ArgumentCaptor messageCaptor = + ArgumentCaptor.forClass(MessageEnvelope.class); + + @Test + void verifyBannedSessionsAreDisconnected() { + givenIpInSession("1.1.1.1"); + when(banCheck.test(IpAddressParser.fromString("1.1.1.1"))).thenReturn(true); + + genericWebSocket.onOpen(session); + + verify(webSocketMessagingBus, never()).onOpen(any()); + verify(session).close(any()); + } + + @Test + void verifyNotBannedSessionsAreSentToMessagingBux() { + givenOnOpenSessionWithIp("1.1.1.1"); + when(banCheck.test(IpAddressParser.fromString("1.1.1.1"))).thenReturn(false); + + genericWebSocket.onOpen(session); + + verify(webSocketMessagingBus).onOpen(session); + verify(session, never()).close(any()); + } + + void givenOnOpenSessionWithIp(final String ip) { + when(session.getRemoteAddress()).thenReturn(IpAddressParser.fromString(ip)); + } + + @Test + @DisplayName( + "Verify server responds to a bad message with error and increments bad message tracking") + void invalidMessageButNotBurned() { + givenIpInSession("1.1.1.1"); + + genericWebSocket.onMessage(session, "message", cache); + + verify(messageSender).accept(eq(session), messageCaptor.capture()); + assertThat( + "Server should responsd back with an error message, while under the bad message burn limit", + messageCaptor.getValue().getMessageTypeId(), + is(ServerErrorMessage.TYPE.getMessageTypeId())); + assertThat( + "Verify cache has been populated and incremented", + cache.getIfPresent(IpAddressParser.fromString("1.1.1.1")).get(), + is(1)); + } + + @Test + void verifyBadMessageCacheIsIncremented() { + givenIpInSession("1.1.1.1"); + givenIpHasBadMessageCount("1.1.1.1", 1); + + genericWebSocket.onMessage(session, "message", cache); + + assertThat( + "Verify cache has been incremented", + cache.getIfPresent(IpAddressParser.fromString("1.1.1.1")).get(), + is(2)); + } + + private void givenIpInSession(final String ip) { + when(session.getRemoteAddress()).thenReturn(IpAddressParser.fromString(ip)); + } + + @DisplayName("If a session has hit max bad messages, we ignore all messages from that session") + @ParameterizedTest + @MethodSource + void atMaxBadMessagesWillBurnMessages(final String message) { + givenIpInSession("1.1.1.1"); + givenIpHasBadMessageCount("1.1.1.1", GenericWebSocket.MAX_BAD_MESSAGES + 1); + + genericWebSocket.onMessage(session, message, cache); + + verify(webSocketMessagingBus, never()).onMessage(any(), any()); + } + + @SuppressWarnings("unused") + private static List atMaxBadMessagesWillBurnMessages() { + return List.of( + "invalid json message", new Gson().toJson(new ExampleMessage("valid json").toEnvelope())); + } + + private void givenIpHasBadMessageCount(final String ip, final int count) { + cache.put(IpAddressParser.fromString(ip), new AtomicInteger(count)); + } + + @Test + @DisplayName("Happy case - Valid messages when under bad message limit are processed") + void validMessageUnderLimit() { + givenIpInSession("1.1.1.1"); + givenIpHasBadMessageCount("1.1.1.1", 1); + //noinspection ConstantConditions + assertThat("Verify test assumptions", 1 < GenericWebSocket.MAX_BAD_MESSAGES, is(true)); + + final var messageEnvelope = new ExampleMessage("status").toEnvelope(); + + genericWebSocket.onMessage(session, new Gson().toJson(messageEnvelope)); + + verify(webSocketMessagingBus).onMessage(session, messageEnvelope); + } +} diff --git a/src/test/java/org/triplea/web/socket/InetExtractorTest.java b/src/test/java/org/triplea/web/socket/InetExtractorTest.java new file mode 100644 index 0000000..d0930b7 --- /dev/null +++ b/src/test/java/org/triplea/web/socket/InetExtractorTest.java @@ -0,0 +1,28 @@ +package org.triplea.web.socket; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import java.net.InetAddress; +import java.util.Map; +import org.junit.jupiter.api.Test; + +class InetExtractorTest { + + private static final String IP_ADDRESS = "127.0.0.1"; + + @Test + void verify() throws Exception { + final Map propertiesMap = + Map.of(InetExtractor.IP_ADDRESS_KEY, "/" + IP_ADDRESS + ":42840"); + + assertThat(InetExtractor.extract(propertiesMap), is(InetAddress.getByName(IP_ADDRESS))); + } + + @Test + void verifyCanParseSimpleAddress() throws Exception { + final Map propertiesMap = Map.of(InetExtractor.IP_ADDRESS_KEY, IP_ADDRESS); + + assertThat(InetExtractor.extract(propertiesMap), is(InetAddress.getByName(IP_ADDRESS))); + } +} diff --git a/src/test/java/org/triplea/web/socket/MessageBroadcasterTest.java b/src/test/java/org/triplea/web/socket/MessageBroadcasterTest.java new file mode 100644 index 0000000..e63cc69 --- /dev/null +++ b/src/test/java/org/triplea/web/socket/MessageBroadcasterTest.java @@ -0,0 +1,40 @@ +package org.triplea.web.socket; + +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Set; +import java.util.function.BiConsumer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.triplea.http.client.web.socket.MessageEnvelope; + +@ExtendWith(MockitoExtension.class) +class MessageBroadcasterTest { + + @Mock private WebSocketSession session0; + @Mock private WebSocketSession session1; + @Mock private WebSocketSession session2; + @Mock private MessageEnvelope messageEnvelope; + + @Mock private BiConsumer singleMessageSender; + @InjectMocks private MessageBroadcaster messageBroadcaster; + + @Test + void accept() { + when(session0.isOpen()).thenReturn(true); + when(session1.isOpen()).thenReturn(true); + when(session2.isOpen()).thenReturn(false); + + messageBroadcaster.accept(Set.of(session0, session1, session2), messageEnvelope); + + verify(singleMessageSender).accept(session0, messageEnvelope); + verify(singleMessageSender).accept(session1, messageEnvelope); + // session2 is not open, should not be used + verify(singleMessageSender, never()).accept(session2, messageEnvelope); + } +} diff --git a/src/test/java/org/triplea/web/socket/MessageSenderTest.java b/src/test/java/org/triplea/web/socket/MessageSenderTest.java new file mode 100644 index 0000000..2ef25ba --- /dev/null +++ b/src/test/java/org/triplea/web/socket/MessageSenderTest.java @@ -0,0 +1,58 @@ +package org.triplea.web.socket; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.google.gson.Gson; +import lombok.AllArgsConstructor; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.triplea.http.client.web.socket.MessageEnvelope; +import org.triplea.http.client.web.socket.messages.MessageType; +import org.triplea.http.client.web.socket.messages.WebSocketMessage; + +@ExtendWith(MockitoExtension.class) +class MessageSenderTest { + + private static final MessageEnvelope MESSAGE_ENVELOPE = + new StringMessage("message!").toEnvelope(); + + private static final String SERVER_MESSAGE_JSON = new Gson().toJson(MESSAGE_ENVELOPE); + + @Mock private WebSocketSession session; + + @AllArgsConstructor + private static class StringMessage implements WebSocketMessage { + private static final MessageType TYPE = MessageType.of(StringMessage.class); + + @SuppressWarnings("unused") + private final String message; + + @Override + public MessageEnvelope toEnvelope() { + return MessageEnvelope.packageMessage(TYPE, this); + } + } + + @Test + void sendToOnlyOpenSession() { + new MessageSender().accept(session, MESSAGE_ENVELOPE); + + verify(session, timeout(500)).isOpen(); + verify(session, never()).sendText(any()); + } + + @Test + void sendMessage() { + when(session.isOpen()).thenReturn(true); + + new MessageSender().accept(session, MESSAGE_ENVELOPE); + + verify(session, timeout(1000)).sendText(SERVER_MESSAGE_JSON); + } +} diff --git a/server/lobby-module/src/test/java/org/triplea/web/socket/SessionBannedCheckTest.java b/src/test/java/org/triplea/web/socket/SessionBannedCheckTest.java similarity index 100% rename from server/lobby-module/src/test/java/org/triplea/web/socket/SessionBannedCheckTest.java rename to src/test/java/org/triplea/web/socket/SessionBannedCheckTest.java diff --git a/src/test/java/org/triplea/web/socket/SessionSetTest.java b/src/test/java/org/triplea/web/socket/SessionSetTest.java new file mode 100644 index 0000000..300616b --- /dev/null +++ b/src/test/java/org/triplea/web/socket/SessionSetTest.java @@ -0,0 +1,216 @@ +package org.triplea.web.socket; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsCollectionContaining.hasItem; +import static org.hamcrest.core.IsCollectionContaining.hasItems; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.net.InetAddress; +import java.util.Collection; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.triplea.java.IpAddressParser; + +@ExtendWith(MockitoExtension.class) +class SessionSetTest { + private static final InetAddress IP_0 = IpAddressParser.fromString("99.99.99.0"); + private static final InetAddress IP_1 = IpAddressParser.fromString("99.99.99.11"); + + private final SessionSet sessionSet = new SessionSet(); + + @Mock private WebSocketSession session; + @Mock private WebSocketSession session0; + @Mock private WebSocketSession session1; + @Mock private WebSocketSession session2; + @Mock private WebSocketSession session3; + + @Nested + class Put { + @Test + @DisplayName("Simple add of a single session") + void addSession() { + sessionSet.put(session); + + assertThat(sessionSet.getSessions(), hasSize(1)); + assertThat(sessionSet.getSessions(), hasItem(session)); + } + + @Test + @DisplayName("Add multiple sessions") + void addMultipleSessions() { + sessionSet.put(session); + sessionSet.put(session0); + + assertThat(sessionSet.getSessions(), hasSize(2)); + assertThat(sessionSet.getSessions(), hasItems(session, session0)); + } + } + + @Nested + class Values { + @Test + @DisplayName("Verify session count starts empty at zero") + void initiallyEmpty() { + assertThat(sessionSet.values(), is(empty())); + } + + @Test + @DisplayName("Simply add a session, verify session count is one") + void addASession() { + when(session.isOpen()).thenReturn(true); + sessionSet.put(session); + assertThat(sessionSet.values(), hasSize(1)); + } + + @Test + @DisplayName("Add a session, then remove, should be no sessions present") + void removeSession() { + sessionSet.put(session); + sessionSet.remove(session); + + assertThat(sessionSet.values(), is(empty())); + } + + @Test + void removeSessionThatDoesNotExistIsNoOp() { + sessionSet.remove(session); + + assertThat(sessionSet.values(), is(empty())); + } + + @Test + @DisplayName("Verify a closed session is not returned") + void closedSessionsArePruned() { + when(session.isOpen()).thenReturn(false); + sessionSet.put(session); + assertThat(sessionSet.values(), is(empty())); + } + + @Test + @DisplayName("Add multiple sessions, verify the non-closed sessions are returned") + void verifyWithMultipleSessions() { + when(session.isOpen()).thenReturn(false); + sessionSet.put(session); + when(session0.isOpen()).thenReturn(true); + sessionSet.put(session0); + when(session1.isOpen()).thenReturn(true); + sessionSet.put(session1); + + assertThat("Added two open sessions", sessionSet.values(), hasSize(2)); + } + } + + @Nested + class GetSessionsByIp { + @Test + @DisplayName("No sessions to match, expect no sessions to be returned") + void noSessions() { + final Collection matches = sessionSet.getSessionsByIp(IP_0); + + assertThat("session set contains no sessions to match", matches, is(empty())); + } + + @Test + @DisplayName("No sessions with a matching IP, expect none to be returned") + void noMatchingSessions() { + givenSessionIsOpenAndHasIp(session, IP_1); + + final Collection matches = sessionSet.getSessionsByIp(IP_0); + + assertThat("IP_1 is in the set, but IP_0 is not", matches, is(empty())); + } + + @Test + @DisplayName("One matching sessions is closed, expect no sessions to be returned") + void matchingSessionIsClosed() { + when(session.isOpen()).thenReturn(false); + sessionSet.put(session); + + final Collection matches = sessionSet.getSessionsByIp(IP_0); + + assertThat("IP_0 matches, but the session is closed", matches, is(empty())); + } + + @Test + @DisplayName("Verify sessions filtering, multiple IPs, some open, some closed") + void matchingSessionsOneClosedAndMultipleMatching() { + givenSessionIsOpenAndHasIp(session, IP_0); + givenSessionIsOpenAndHasIp(session0, IP_0); + givenSessionIsClosedAndHasIp(session1, IP_0); + + givenSessionIsOpenAndHasIp(session2, IP_1); + givenSessionIsClosedAndHasIp(session3, IP_1); + + final var matches = sessionSet.getSessionsByIp(IP_0); + + assertThat("Two open sessions match IP_0", matches, hasSize(2)); + assertThat(matches, hasItems(session, session0)); + } + } + + @Nested + class CloseSessionsByIp { + @Test + @DisplayName("No sessions present to close") + void noSessions() { + sessionSet.closeSessionsByIp(IP_0); + } + + @Test + @DisplayName("Session is already closed") + void sessionAlreadyClosed() { + givenSessionIsClosedAndHasIp(session, IP_0); + sessionSet.closeSessionsByIp(IP_0); + verify(session, never()).close(); + } + + @Test + @DisplayName("Multiple matching sessions, expect open sessions to be closed") + void multipleSessionsToClose() { + givenSessionIsClosedAndHasIp(session, IP_0); + givenSessionIsOpenAndHasIp(session0, IP_0); + givenSessionIsOpenAndHasIp(session1, IP_0); + givenSessionIsOpenAndHasIp(session2, IP_1); + + sessionSet.closeSessionsByIp(IP_0); + + // Session is closed (even though IP matches). + verify(session, never()).close(); + + // open sessions with matching IPs + verify(session0).close(); + verify(session1).close(); + + // Session is open, but IP does not match + verify(session2, never()).close(); + } + } + + private void givenSessionIsOpenAndHasIp(final WebSocketSession session, final InetAddress ip) { + givenSessionWithIp(session, ip, true); + } + + private void givenSessionIsClosedAndHasIp(final WebSocketSession session, final InetAddress ip) { + givenSessionWithIp(session, ip, false); + } + + private void givenSessionWithIp( + final WebSocketSession session, final InetAddress ip, final boolean isOpen) { + when(session.isOpen()).thenReturn(isOpen); + + if (isOpen) { + when(session.getRemoteAddress()).thenReturn(ip); + } + + sessionSet.put(session); + } +} diff --git a/src/test/java/org/triplea/web/socket/WebSocketMessagingBusTest.java b/src/test/java/org/triplea/web/socket/WebSocketMessagingBusTest.java new file mode 100644 index 0000000..050766c --- /dev/null +++ b/src/test/java/org/triplea/web/socket/WebSocketMessagingBusTest.java @@ -0,0 +1,233 @@ +package org.triplea.web.socket; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; +import static org.hamcrest.core.IsSame.sameInstance; +import static org.hamcrest.core.StringContains.containsString; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Collection; +import java.util.List; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.triplea.http.client.web.socket.MessageEnvelope; +import org.triplea.http.client.web.socket.messages.MessageType; +import org.triplea.http.client.web.socket.messages.WebSocketMessage; +import org.triplea.http.client.web.socket.messages.envelopes.ServerErrorMessage; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("InnerClassMayBeStatic") +class WebSocketMessagingBusTest { + @Mock private Consumer> booleanMessageListener; + @Mock private Consumer> booleanMessageListenerSecond; + @Mock private Consumer> stringMessageListener; + @Mock private WebSocketSession session; + + private static class StringMessage implements WebSocketMessage { + private static final MessageType TYPE = MessageType.of(StringMessage.class); + + @Override + public MessageEnvelope toEnvelope() { + return MessageEnvelope.packageMessage(TYPE, this); + } + } + + @EqualsAndHashCode + @AllArgsConstructor + private static class BooleanMessage implements WebSocketMessage { + private static final MessageType TYPE = MessageType.of(BooleanMessage.class); + + private final boolean value; + + @Override + public MessageEnvelope toEnvelope() { + return MessageEnvelope.packageMessage(TYPE, this); + } + } + + @Nested + class MessageListening { + + @SuppressWarnings("unchecked") + @Test + @DisplayName("Add a listener, trigger message receipt, verify listener is invoked") + void invokeListener() { + final WebSocketMessagingBus webSocketMessagingBus = new WebSocketMessagingBus(); + webSocketMessagingBus.addMessageListener(BooleanMessage.TYPE, booleanMessageListener); + + // trigger message + final BooleanMessage message = new BooleanMessage(true); + webSocketMessagingBus.onMessage(session, message.toEnvelope()); + + // capture argument passed to listener + final ArgumentCaptor> argumentCaptor = + ArgumentCaptor.forClass(WebSocketMessageContext.class); + verify(booleanMessageListener).accept(argumentCaptor.capture()); + + // verify arg values + final WebSocketMessageContext arg = argumentCaptor.getValue(); + assertThat("Message received should be equal to message sent", arg.getMessage(), is(message)); + assertThat( + "Expect new object created from JSON string", + arg.getMessage(), + not(sameInstance(message))); + assertThat( + "Session should be passed along to the listener", arg.getSenderSession(), is(session)); + } + + @DisplayName( + "Add listeners of different types, trigger message receipt, " + + "verify listener of matching type is invoked") + @Test + void invokesCorrectListener() { + final WebSocketMessagingBus webSocketMessagingBus = new WebSocketMessagingBus(); + webSocketMessagingBus.addMessageListener(BooleanMessage.TYPE, booleanMessageListener); + webSocketMessagingBus.addMessageListener(StringMessage.TYPE, stringMessageListener); + + webSocketMessagingBus.onMessage(session, new BooleanMessage(true).toEnvelope()); + + verify(booleanMessageListener).accept(any()); + verify(stringMessageListener, never()).accept(any()); + } + + @DisplayName( + "Add multiple listeners of same type, trigger message, verify all listeners invoked") + @Test + void invokesMultipleListeners() { + final WebSocketMessagingBus webSocketMessagingBus = new WebSocketMessagingBus(); + webSocketMessagingBus.addMessageListener(BooleanMessage.TYPE, booleanMessageListener); + webSocketMessagingBus.addMessageListener(BooleanMessage.TYPE, booleanMessageListenerSecond); + + webSocketMessagingBus.onMessage(session, new BooleanMessage(true).toEnvelope()); + + verify(booleanMessageListener).accept(any()); + verify(booleanMessageListenerSecond).accept(any()); + } + } + + @Nested + class SendMessages { + @Mock private MessageSender messageSender; + @Mock private MessageBroadcaster messageBroadcaster; + @Mock private SessionSet sessionSet; + @InjectMocks private WebSocketMessagingBus webSocketMessagingBus; + + @Mock private WebSocketSession session; + + @Test + @DisplayName("Send response should forward to message sender implementation") + void sendResponse() { + final var booleanMessage = new BooleanMessage(true); + + webSocketMessagingBus.sendResponse(session, booleanMessage); + + verify(messageSender).accept(session, booleanMessage.toEnvelope()); + } + + @Test + @DisplayName( + "Broadcast should forward all sessions from session set " + + "and the broadcasted message to broadcaster") + void broadcast() { + final Collection sessions = List.of(session); + when(sessionSet.getSessions()).thenReturn(sessions); + final var booleanMessage = new BooleanMessage(true); + + webSocketMessagingBus.broadcastMessage(booleanMessage); + + verify(messageBroadcaster).accept(sessions, booleanMessage.toEnvelope()); + } + } + + @Nested + class SessionDisconnectedListener { + @Mock private MessageSender messageSender; + @Mock private MessageBroadcaster messageBroadcaster; + @Mock private SessionSet sessionSet; + @InjectMocks private WebSocketMessagingBus webSocketMessagingBus; + + @Mock private BiConsumer disconnectListener; + @Mock private WebSocketSession session; + + @Test + void invokeSessionDisconnectedListener() { + webSocketMessagingBus.addSessionDisconnectListener(disconnectListener); + + webSocketMessagingBus.onClose(session); + + verify(disconnectListener).accept(webSocketMessagingBus, session); + } + + @Test + void sessionCloseRemoveSessionFromSessionSet() { + webSocketMessagingBus.onClose(session); + + verify(sessionSet).remove(session); + } + } + + @Nested + class OnOpen { + @Mock private MessageSender messageSender; + @Mock private MessageBroadcaster messageBroadcaster; + @Mock private SessionSet sessionSet; + @InjectMocks private WebSocketMessagingBus webSocketMessagingBus; + + @Mock private WebSocketSession session; + + @Test + void onOpenAddsToSessionSet() { + webSocketMessagingBus.onOpen(session); + + verify(sessionSet).put(session); + } + } + + @Nested + class OnError { + @Mock private MessageSender messageSender; + @Mock private MessageBroadcaster messageBroadcaster; + @Mock private SessionSet sessionSet; + @InjectMocks private WebSocketMessagingBus webSocketMessagingBus; + + @Mock private WebSocketSession session; + + @Test + void onOpenAddsToSessionSet() { + final var throwable = new Throwable("error message"); + webSocketMessagingBus.onError(session, throwable); + + final ArgumentCaptor messageCaptor = + ArgumentCaptor.forClass(MessageEnvelope.class); + verify(messageSender).accept(eq(session), messageCaptor.capture()); + + assertThat( + "Make sure message type id is error message", + messageCaptor.getValue().getMessageTypeId(), + is(ServerErrorMessage.TYPE.getMessageTypeId())); + + assertThat( + "Make sure the return message to the user does *not* contain the " + + "error message from the throwable. If a user can craft an interesting error " + + "message, it could potentially be used in an attack. Therefore we return an error " + + "ID to the user instead of returning the underlying error message", + messageCaptor.getValue().getPayload(ServerErrorMessage.TYPE.getPayloadType()).getError(), + not(containsString("error message"))); + } + } +} diff --git a/server/lobby-module/src/test/resources/datasets/access_log/access_log.yml b/src/test/resources/datasets/access_log/access_log.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/access_log/access_log.yml rename to src/test/resources/datasets/access_log/access_log.yml diff --git a/server/lobby-module/src/test/resources/datasets/access_log/access_log_post_insert.yml b/src/test/resources/datasets/access_log/access_log_post_insert.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/access_log/access_log_post_insert.yml rename to src/test/resources/datasets/access_log/access_log_post_insert.yml diff --git a/server/lobby-module/src/test/resources/datasets/access_log/lobby_user.yml b/src/test/resources/datasets/access_log/lobby_user.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/access_log/lobby_user.yml rename to src/test/resources/datasets/access_log/lobby_user.yml diff --git a/server/lobby-module/src/test/resources/datasets/access_log/user_role.yml b/src/test/resources/datasets/access_log/user_role.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/access_log/user_role.yml rename to src/test/resources/datasets/access_log/user_role.yml diff --git a/server/lobby-module/src/test/resources/datasets/bad_words/bad_word.yml b/src/test/resources/datasets/bad_words/bad_word.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/bad_words/bad_word.yml rename to src/test/resources/datasets/bad_words/bad_word.yml diff --git a/server/lobby-module/src/test/resources/datasets/bad_words/bad_word_post_insert.yml b/src/test/resources/datasets/bad_words/bad_word_post_insert.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/bad_words/bad_word_post_insert.yml rename to src/test/resources/datasets/bad_words/bad_word_post_insert.yml diff --git a/server/lobby-module/src/test/resources/datasets/bad_words/bad_word_post_remove.yml b/src/test/resources/datasets/bad_words/bad_word_post_remove.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/bad_words/bad_word_post_remove.yml rename to src/test/resources/datasets/bad_words/bad_word_post_remove.yml diff --git a/server/lobby-module/src/test/resources/datasets/game_chat_history/game_chat_history.yml b/src/test/resources/datasets/game_chat_history/game_chat_history.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/game_chat_history/game_chat_history.yml rename to src/test/resources/datasets/game_chat_history/game_chat_history.yml diff --git a/server/lobby-module/src/test/resources/datasets/game_chat_history/game_hosting_api_key.yml b/src/test/resources/datasets/game_chat_history/game_hosting_api_key.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/game_chat_history/game_hosting_api_key.yml rename to src/test/resources/datasets/game_chat_history/game_hosting_api_key.yml diff --git a/server/lobby-module/src/test/resources/datasets/game_chat_history/lobby_game.yml b/src/test/resources/datasets/game_chat_history/lobby_game.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/game_chat_history/lobby_game.yml rename to src/test/resources/datasets/game_chat_history/lobby_game.yml diff --git a/server/lobby-module/src/test/resources/datasets/game_hosting_api_key/insert_key_after.yml b/src/test/resources/datasets/game_hosting_api_key/insert_key_after.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/game_hosting_api_key/insert_key_after.yml rename to src/test/resources/datasets/game_hosting_api_key/insert_key_after.yml diff --git a/server/lobby-module/src/test/resources/datasets/game_hosting_api_key/insert_key_before.yml b/src/test/resources/datasets/game_hosting_api_key/insert_key_before.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/game_hosting_api_key/insert_key_before.yml rename to src/test/resources/datasets/game_hosting_api_key/insert_key_before.yml diff --git a/server/lobby-module/src/test/resources/datasets/game_hosting_api_key/key_exists.yml b/src/test/resources/datasets/game_hosting_api_key/key_exists.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/game_hosting_api_key/key_exists.yml rename to src/test/resources/datasets/game_hosting_api_key/key_exists.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_api_key/delete_old_keys_after.yml b/src/test/resources/datasets/lobby_api_key/delete_old_keys_after.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_api_key/delete_old_keys_after.yml rename to src/test/resources/datasets/lobby_api_key/delete_old_keys_after.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_api_key/delete_old_keys_before.yml b/src/test/resources/datasets/lobby_api_key/delete_old_keys_before.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_api_key/delete_old_keys_before.yml rename to src/test/resources/datasets/lobby_api_key/delete_old_keys_before.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_api_key/empty_lobby_api_key.yml b/src/test/resources/datasets/lobby_api_key/empty_lobby_api_key.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_api_key/empty_lobby_api_key.yml rename to src/test/resources/datasets/lobby_api_key/empty_lobby_api_key.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_api_key/lobby_api_key.yml b/src/test/resources/datasets/lobby_api_key/lobby_api_key.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_api_key/lobby_api_key.yml rename to src/test/resources/datasets/lobby_api_key/lobby_api_key.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_api_key/lobby_api_key_post_insert.yml b/src/test/resources/datasets/lobby_api_key/lobby_api_key_post_insert.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_api_key/lobby_api_key_post_insert.yml rename to src/test/resources/datasets/lobby_api_key/lobby_api_key_post_insert.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_api_key/lobby_user.yml b/src/test/resources/datasets/lobby_api_key/lobby_user.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_api_key/lobby_user.yml rename to src/test/resources/datasets/lobby_api_key/lobby_user.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_api_key/user_role.yml b/src/test/resources/datasets/lobby_api_key/user_role.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_api_key/user_role.yml rename to src/test/resources/datasets/lobby_api_key/user_role.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_chat_history/lobby_api_key.yml b/src/test/resources/datasets/lobby_chat_history/lobby_api_key.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_chat_history/lobby_api_key.yml rename to src/test/resources/datasets/lobby_chat_history/lobby_api_key.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_chat_history/lobby_chat_history_post_insert.yml b/src/test/resources/datasets/lobby_chat_history/lobby_chat_history_post_insert.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_chat_history/lobby_chat_history_post_insert.yml rename to src/test/resources/datasets/lobby_chat_history/lobby_chat_history_post_insert.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_chat_history/lobby_user.yml b/src/test/resources/datasets/lobby_chat_history/lobby_user.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_chat_history/lobby_user.yml rename to src/test/resources/datasets/lobby_chat_history/lobby_user.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_chat_history/user_role.yml b/src/test/resources/datasets/lobby_chat_history/user_role.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_chat_history/user_role.yml rename to src/test/resources/datasets/lobby_chat_history/user_role.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_games/game_chat_history_post_insert.yml b/src/test/resources/datasets/lobby_games/game_chat_history_post_insert.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_games/game_chat_history_post_insert.yml rename to src/test/resources/datasets/lobby_games/game_chat_history_post_insert.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_games/game_hosting_api_key.yml b/src/test/resources/datasets/lobby_games/game_hosting_api_key.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_games/game_hosting_api_key.yml rename to src/test/resources/datasets/lobby_games/game_hosting_api_key.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_games/lobby_game.yml b/src/test/resources/datasets/lobby_games/lobby_game.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_games/lobby_game.yml rename to src/test/resources/datasets/lobby_games/lobby_game.yml diff --git a/server/lobby-module/src/test/resources/datasets/lobby_games/lobby_game_post_insert.yml b/src/test/resources/datasets/lobby_games/lobby_game_post_insert.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/lobby_games/lobby_game_post_insert.yml rename to src/test/resources/datasets/lobby_games/lobby_game_post_insert.yml diff --git a/server/lobby-module/src/test/resources/datasets/moderator_audit/empty_moderator_action_history.yml b/src/test/resources/datasets/moderator_audit/empty_moderator_action_history.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/moderator_audit/empty_moderator_action_history.yml rename to src/test/resources/datasets/moderator_audit/empty_moderator_action_history.yml diff --git a/server/lobby-module/src/test/resources/datasets/moderator_audit/lobby_user.yml b/src/test/resources/datasets/moderator_audit/lobby_user.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/moderator_audit/lobby_user.yml rename to src/test/resources/datasets/moderator_audit/lobby_user.yml diff --git a/server/lobby-module/src/test/resources/datasets/moderator_audit/moderator_action_history.yml b/src/test/resources/datasets/moderator_audit/moderator_action_history.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/moderator_audit/moderator_action_history.yml rename to src/test/resources/datasets/moderator_audit/moderator_action_history.yml diff --git a/server/lobby-module/src/test/resources/datasets/moderator_audit/moderator_action_history_post_insert.yml b/src/test/resources/datasets/moderator_audit/moderator_action_history_post_insert.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/moderator_audit/moderator_action_history_post_insert.yml rename to src/test/resources/datasets/moderator_audit/moderator_action_history_post_insert.yml diff --git a/server/lobby-module/src/test/resources/datasets/moderator_audit/user_role.yml b/src/test/resources/datasets/moderator_audit/user_role.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/moderator_audit/user_role.yml rename to src/test/resources/datasets/moderator_audit/user_role.yml diff --git a/server/lobby-module/src/test/resources/datasets/moderator_player_lookup/access_log.yml b/src/test/resources/datasets/moderator_player_lookup/access_log.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/moderator_player_lookup/access_log.yml rename to src/test/resources/datasets/moderator_player_lookup/access_log.yml diff --git a/server/lobby-module/src/test/resources/datasets/moderator_player_lookup/banned_user.yml b/src/test/resources/datasets/moderator_player_lookup/banned_user.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/moderator_player_lookup/banned_user.yml rename to src/test/resources/datasets/moderator_player_lookup/banned_user.yml diff --git a/server/lobby-module/src/test/resources/datasets/moderators/access_log.yml b/src/test/resources/datasets/moderators/access_log.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/moderators/access_log.yml rename to src/test/resources/datasets/moderators/access_log.yml diff --git a/server/lobby-module/src/test/resources/datasets/moderators/lobby_user.yml b/src/test/resources/datasets/moderators/lobby_user.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/moderators/lobby_user.yml rename to src/test/resources/datasets/moderators/lobby_user.yml diff --git a/server/lobby-module/src/test/resources/datasets/moderators/lobby_user_post_update_roles.yml b/src/test/resources/datasets/moderators/lobby_user_post_update_roles.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/moderators/lobby_user_post_update_roles.yml rename to src/test/resources/datasets/moderators/lobby_user_post_update_roles.yml diff --git a/server/lobby-module/src/test/resources/datasets/moderators/user_role.yml b/src/test/resources/datasets/moderators/user_role.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/moderators/user_role.yml rename to src/test/resources/datasets/moderators/user_role.yml diff --git a/server/lobby-module/src/test/resources/datasets/temp_password/lobby_user.yml b/src/test/resources/datasets/temp_password/lobby_user.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/temp_password/lobby_user.yml rename to src/test/resources/datasets/temp_password/lobby_user.yml diff --git a/server/lobby-module/src/test/resources/datasets/temp_password/temp_password_request.yml b/src/test/resources/datasets/temp_password/temp_password_request.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/temp_password/temp_password_request.yml rename to src/test/resources/datasets/temp_password/temp_password_request.yml diff --git a/server/lobby-module/src/test/resources/datasets/temp_password/user_role.yml b/src/test/resources/datasets/temp_password/user_role.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/temp_password/user_role.yml rename to src/test/resources/datasets/temp_password/user_role.yml diff --git a/server/lobby-module/src/test/resources/datasets/temp_password_history/sample.yml b/src/test/resources/datasets/temp_password_history/sample.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/temp_password_history/sample.yml rename to src/test/resources/datasets/temp_password_history/sample.yml diff --git a/server/lobby-module/src/test/resources/datasets/user/change_password_after.yml b/src/test/resources/datasets/user/change_password_after.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user/change_password_after.yml rename to src/test/resources/datasets/user/change_password_after.yml diff --git a/server/lobby-module/src/test/resources/datasets/user/create_user_after.yml b/src/test/resources/datasets/user/create_user_after.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user/create_user_after.yml rename to src/test/resources/datasets/user/create_user_after.yml diff --git a/server/lobby-module/src/test/resources/datasets/user/empty_lobby_user.yml b/src/test/resources/datasets/user/empty_lobby_user.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user/empty_lobby_user.yml rename to src/test/resources/datasets/user/empty_lobby_user.yml diff --git a/server/lobby-module/src/test/resources/datasets/user/lobby_user.yml b/src/test/resources/datasets/user/lobby_user.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user/lobby_user.yml rename to src/test/resources/datasets/user/lobby_user.yml diff --git a/server/lobby-module/src/test/resources/datasets/user/post_change_email.yml b/src/test/resources/datasets/user/post_change_email.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user/post_change_email.yml rename to src/test/resources/datasets/user/post_change_email.yml diff --git a/server/lobby-module/src/test/resources/datasets/user/user_role.yml b/src/test/resources/datasets/user/user_role.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user/user_role.yml rename to src/test/resources/datasets/user/user_role.yml diff --git a/server/lobby-module/src/test/resources/datasets/user_ban/add_ban_after.yml b/src/test/resources/datasets/user_ban/add_ban_after.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user_ban/add_ban_after.yml rename to src/test/resources/datasets/user_ban/add_ban_after.yml diff --git a/server/lobby-module/src/test/resources/datasets/user_ban/add_ban_before.yml b/src/test/resources/datasets/user_ban/add_ban_before.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user_ban/add_ban_before.yml rename to src/test/resources/datasets/user_ban/add_ban_before.yml diff --git a/server/lobby-module/src/test/resources/datasets/user_ban/banned_by_ip.yml b/src/test/resources/datasets/user_ban/banned_by_ip.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user_ban/banned_by_ip.yml rename to src/test/resources/datasets/user_ban/banned_by_ip.yml diff --git a/server/lobby-module/src/test/resources/datasets/user_ban/lookup_bans.yml b/src/test/resources/datasets/user_ban/lookup_bans.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user_ban/lookup_bans.yml rename to src/test/resources/datasets/user_ban/lookup_bans.yml diff --git a/server/lobby-module/src/test/resources/datasets/user_ban/lookup_username_by_ban_id.yml b/src/test/resources/datasets/user_ban/lookup_username_by_ban_id.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user_ban/lookup_username_by_ban_id.yml rename to src/test/resources/datasets/user_ban/lookup_username_by_ban_id.yml diff --git a/server/lobby-module/src/test/resources/datasets/user_ban/remove_ban_after.yml b/src/test/resources/datasets/user_ban/remove_ban_after.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user_ban/remove_ban_after.yml rename to src/test/resources/datasets/user_ban/remove_ban_after.yml diff --git a/server/lobby-module/src/test/resources/datasets/user_ban/remove_ban_before.yml b/src/test/resources/datasets/user_ban/remove_ban_before.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user_ban/remove_ban_before.yml rename to src/test/resources/datasets/user_ban/remove_ban_before.yml diff --git a/server/lobby-module/src/test/resources/datasets/user_role/initial.yml b/src/test/resources/datasets/user_role/initial.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/user_role/initial.yml rename to src/test/resources/datasets/user_role/initial.yml diff --git a/server/lobby-module/src/test/resources/datasets/username_ban/add_banned_username_after.yml b/src/test/resources/datasets/username_ban/add_banned_username_after.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/username_ban/add_banned_username_after.yml rename to src/test/resources/datasets/username_ban/add_banned_username_after.yml diff --git a/server/lobby-module/src/test/resources/datasets/username_ban/add_banned_username_before.yml b/src/test/resources/datasets/username_ban/add_banned_username_before.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/username_ban/add_banned_username_before.yml rename to src/test/resources/datasets/username_ban/add_banned_username_before.yml diff --git a/server/lobby-module/src/test/resources/datasets/username_ban/get_banned_usernames.yml b/src/test/resources/datasets/username_ban/get_banned_usernames.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/username_ban/get_banned_usernames.yml rename to src/test/resources/datasets/username_ban/get_banned_usernames.yml diff --git a/server/lobby-module/src/test/resources/datasets/username_ban/remove_banned_username_after.yml b/src/test/resources/datasets/username_ban/remove_banned_username_after.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/username_ban/remove_banned_username_after.yml rename to src/test/resources/datasets/username_ban/remove_banned_username_after.yml diff --git a/server/lobby-module/src/test/resources/datasets/username_ban/remove_banned_username_before.yml b/src/test/resources/datasets/username_ban/remove_banned_username_before.yml similarity index 100% rename from server/lobby-module/src/test/resources/datasets/username_ban/remove_banned_username_before.yml rename to src/test/resources/datasets/username_ban/remove_banned_username_before.yml diff --git a/server/lobby-module/src/test/resources/db-cleanup.sql b/src/test/resources/db-cleanup.sql similarity index 100% rename from server/lobby-module/src/test/resources/db-cleanup.sql rename to src/test/resources/db-cleanup.sql diff --git a/server/lobby-module/src/test/resources/dbunit.yml b/src/test/resources/dbunit.yml similarity index 100% rename from server/lobby-module/src/test/resources/dbunit.yml rename to src/test/resources/dbunit.yml diff --git a/http-clients/github-client/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml similarity index 79% rename from http-clients/github-client/src/test/resources/logback-test.xml rename to src/test/resources/logback-test.xml index 2222e34..aa811da 100644 --- a/http-clients/github-client/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -8,4 +8,7 @@ + + + diff --git a/http-clients/github-client/src/test/resources/sample_responses/branch_listing_response.json b/src/test/resources/sample_responses/branch_listing_response.json similarity index 100% rename from http-clients/github-client/src/test/resources/sample_responses/branch_listing_response.json rename to src/test/resources/sample_responses/branch_listing_response.json diff --git a/http-clients/github-client/src/test/resources/sample_responses/latest_release_response.json b/src/test/resources/sample_responses/latest_release_response.json similarity index 100% rename from http-clients/github-client/src/test/resources/sample_responses/latest_release_response.json rename to src/test/resources/sample_responses/latest_release_response.json diff --git a/http-clients/github-client/src/test/resources/sample_responses/repo_listing_response_page1.json b/src/test/resources/sample_responses/repo_listing_response_page1.json similarity index 100% rename from http-clients/github-client/src/test/resources/sample_responses/repo_listing_response_page1.json rename to src/test/resources/sample_responses/repo_listing_response_page1.json diff --git a/http-clients/github-client/src/test/resources/sample_responses/repo_listing_response_page2.json b/src/test/resources/sample_responses/repo_listing_response_page2.json similarity index 100% rename from http-clients/github-client/src/test/resources/sample_responses/repo_listing_response_page2.json rename to src/test/resources/sample_responses/repo_listing_response_page2.json diff --git a/verify.sh b/verify.sh index 0dd0f50..3609816 100755 --- a/verify.sh +++ b/verify.sh @@ -48,4 +48,4 @@ set -eu checkDependency "docker" || installDocker "$scriptDir/gradlew" spotlessApply check $@ -"$scriptDir/.build/code-convention-checks/check-custom-style" +