From f538a43690b15a6626c2323c5d6dd09ceefe198b Mon Sep 17 00:00:00 2001 From: Sebastian Becker Date: Fri, 3 Mar 2023 10:12:34 +0100 Subject: [PATCH] Fix vulnerabilities (#44) * Migrate to properties files to exclude snakeyaml and resolve further vulnerabilities * Migrate tests to JUnit5 Signed-off-by: Sebastian Becker --- .../NOTICE | 17 ++ .../commons-codec_commons-codec/NOTICE.txt | 17 -- .../LICENSE | 0 .../NOTICE | 2 +- .../LICENSE | 0 .../NOTICE} | 6 +- .../LICENSE} | 0 .../NOTICE | 6 + .../org.slf4j_slf4j-api/LICENSE.txt | 21 ++ amphora-common/3RD-PARTY-LICENSES/sbom.xml | 66 +++--- amphora-common/pom.xml | 24 +-- .../amphora/common/AmphoraServiceUri.java | 8 +- .../amphora/common/AmphoraServiceUriTest.java | 40 ++-- .../common/entities/MaskedInputDataTest.java | 10 +- .../common/entities/MaskedInputTest.java | 14 +- .../amphora/common/entities/MetadataTest.java | 25 +-- .../entities/OutputDeliveryObjectTest.java | 18 +- .../common/entities/SecretShareTest.java | 31 ++- .../common/entities/TagFilterTest.java | 16 +- .../amphora/common/entities/TagTest.java | 45 ++-- .../AmphoraClientExceptionTest.java | 8 +- .../NOTICE | 17 ++ .../LICENSE | 0 .../NOTICE | 6 + .../LICENSE | 26 +++ .../NOTICE | 6 + .../3RD-PARTY-LICENSES/sbom.xml | 34 ++- amphora-java-client/pom.xml | 28 ++- .../AmphoraCommunicationClientTest.java | 92 ++++---- .../DefaultAmphoraClientBuilderTest.java | 84 ++++---- .../client/DefaultAmphoraClientTest.java | 160 +++++++------- .../DefaultAmphoraInterVcpClientTest.java | 35 ++- .../DefaultAmphoraIntraVcpClientTest.java | 40 ++-- .../amphora/client/SecretShareUtilTest.java | 20 +- .../ch.qos.reload4j_reload4j/LICENSE | 202 ++++++++++++++++++ .../ch.qos.reload4j_reload4j}/NOTICE | 5 +- .../NOTICE | 17 ++ .../NOTICE | 17 ++ .../{LICENSE.txt => LICENSE} | 0 .../LICENSE | 202 ++++++++++++++++++ .../NOTICE | 6 + .../LICENSE | 202 ++++++++++++++++++ .../NOTICE | 6 + .../org.apache.logging.log4j_log4j-api/NOTICE | 2 +- .../org.apache.logging.log4j_log4j-jul/NOTICE | 2 +- .../NOTICE | 2 +- .../org.slf4j_slf4j-reload4j/LICENSE.txt | 21 ++ amphora-service/3RD-PARTY-LICENSES/sbom.xml | 89 +++++--- amphora-service/pom.xml | 78 +++++-- .../persistence/metadata/SecretEntity.java | 3 +- .../persistence/metadata/TagEntity.java | 6 +- .../application-cache-redis.properties | 11 + .../resources/application-cache-redis.yml | 10 - ...pplication-entitystore-postgres.properties | 18 ++ .../application-entitystore-postgres.yml | 19 -- .../main/resources/application-k8s.properties | 13 ++ .../src/main/resources/application-k8s.yml | 11 - ...lication-secretsharestore-minio.properties | 13 ++ .../application-secretsharestore-minio.yml | 12 -- .../src/main/resources/application.properties | 39 ++++ .../src/main/resources/application.yml | 45 ---- amphora-service/src/main/resources/banner.txt | 4 +- .../src/main/resources/log4j.properties | 14 ++ amphora-service/src/main/resources/log4j2.xml | 16 -- .../service/AmphoraServiceSystemTest.java | 46 ++-- .../OutputDeliveryServiceTest.java | 44 ++-- .../calculation/SecretShareUtilTest.java | 18 +- .../config/BigIntegerConverterTest.java | 16 +- .../cache/InputMaskStoreRedisIT.java | 35 +-- .../persistence/cache/InputMaskStoreTest.java | 32 +-- .../cache/InterimValueCachingServiceTest.java | 24 +-- .../MinioSecretShareDataStoreTest.java | 34 ++- .../FilterPagingAndNestedSortingIT.java | 60 +++--- .../persistence/metadata/StorageIT.java | 54 ++--- .../metadata/StorageServiceTest.java | 143 ++++++------- .../rest/InputMaskShareControllerTest.java | 38 ++-- .../service/rest/InterVcpControllerTest.java | 14 +- .../service/rest/IntraVcpControllerTest.java | 22 +- .../rest/MaskedInputControllerTest.java | 22 +- .../rest/SecretShareControllerTest.java | 37 ++-- .../service/rest/TagsControllerTest.java | 37 ++-- .../resources/application-test.properties | 36 ++++ .../src/test/resources/application-test.yml | 43 ---- pom.xml | 47 +++- 84 files changed, 1821 insertions(+), 988 deletions(-) create mode 100644 amphora-common/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE delete mode 100644 amphora-common/3RD-PARTY-LICENSES/commons-codec_commons-codec/NOTICE.txt rename amphora-common/3RD-PARTY-LICENSES/{org.apache.httpcomponents_httpclient => org.apache.httpcomponents.client5_httpclient5}/LICENSE (100%) rename amphora-common/3RD-PARTY-LICENSES/{org.apache.httpcomponents_httpclient => org.apache.httpcomponents.client5_httpclient5}/NOTICE (70%) rename amphora-common/3RD-PARTY-LICENSES/{org.apache.httpcomponents_httpcore => org.apache.httpcomponents.core5_httpcore5-h2}/LICENSE (100%) rename amphora-common/3RD-PARTY-LICENSES/{commons-logging_commons-logging/NOTICE.txt => org.apache.httpcomponents.core5_httpcore5-h2/NOTICE} (54%) rename amphora-common/3RD-PARTY-LICENSES/{commons-codec_commons-codec/LICENSE.txt => org.apache.httpcomponents.core5_httpcore5/LICENSE} (100%) create mode 100644 amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE create mode 100644 amphora-common/3RD-PARTY-LICENSES/org.slf4j_slf4j-api/LICENSE.txt create mode 100644 amphora-java-client/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE rename amphora-common/3RD-PARTY-LICENSES/commons-logging_commons-logging/LICENSE.txt => amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/LICENSE (100%) create mode 100644 amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/NOTICE rename amphora-service/3RD-PARTY-LICENSES/org.yaml_snakeyaml/LICENSE.txt => amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/LICENSE (89%) create mode 100644 amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE create mode 100644 amphora-service/3RD-PARTY-LICENSES/ch.qos.reload4j_reload4j/LICENSE rename {amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents_httpcore => amphora-service/3RD-PARTY-LICENSES/ch.qos.reload4j_reload4j}/NOTICE (60%) create mode 100644 amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE create mode 100644 amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-core/NOTICE rename amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.datatype_jackson-datatype-jdk8/{LICENSE.txt => LICENSE} (100%) create mode 100644 amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/LICENSE create mode 100644 amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/NOTICE create mode 100644 amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/LICENSE create mode 100644 amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE create mode 100644 amphora-service/3RD-PARTY-LICENSES/org.slf4j_slf4j-reload4j/LICENSE.txt create mode 100644 amphora-service/src/main/resources/application-cache-redis.properties delete mode 100644 amphora-service/src/main/resources/application-cache-redis.yml create mode 100644 amphora-service/src/main/resources/application-entitystore-postgres.properties delete mode 100644 amphora-service/src/main/resources/application-entitystore-postgres.yml create mode 100644 amphora-service/src/main/resources/application-k8s.properties delete mode 100644 amphora-service/src/main/resources/application-k8s.yml create mode 100644 amphora-service/src/main/resources/application-secretsharestore-minio.properties delete mode 100644 amphora-service/src/main/resources/application-secretsharestore-minio.yml create mode 100644 amphora-service/src/main/resources/application.properties delete mode 100644 amphora-service/src/main/resources/application.yml create mode 100644 amphora-service/src/main/resources/log4j.properties delete mode 100644 amphora-service/src/main/resources/log4j2.xml create mode 100644 amphora-service/src/test/resources/application-test.properties delete mode 100644 amphora-service/src/test/resources/application-test.yml diff --git a/amphora-common/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE b/amphora-common/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE new file mode 100644 index 0000000..d226e89 --- /dev/null +++ b/amphora-common/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE @@ -0,0 +1,17 @@ +# Jackson JSON processor + +Jackson is a high-performance, Free/Open Source JSON processing library. +It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has +been in development since 2007. +It is currently developed by a community of developers. + +## Licensing + +Jackson 2.x core and extension components are licensed under Apache License 2.0 +To find the details that apply to this artifact see the accompanying LICENSE file. + +## Credits + +A list of contributors may be found from CREDITS(-2.x) file, which is included +in some artifacts (usually source distributions); but is always available +from the source code management (SCM) system project uses. diff --git a/amphora-common/3RD-PARTY-LICENSES/commons-codec_commons-codec/NOTICE.txt b/amphora-common/3RD-PARTY-LICENSES/commons-codec_commons-codec/NOTICE.txt deleted file mode 100644 index 32257bc..0000000 --- a/amphora-common/3RD-PARTY-LICENSES/commons-codec_commons-codec/NOTICE.txt +++ /dev/null @@ -1,17 +0,0 @@ -Apache Commons Codec -Copyright 2002-2021 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (https://www.apache.org/). - -src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java -contains test data from http://aspell.net/test/orig/batch0.tab. -Copyright (C) 2002 Kevin Atkinson (kevina@gnu.org) - -=============================================================================== - -The content of package org.apache.commons.codec.language.bm has been translated -from the original php source code available at http://stevemorse.org/phoneticinfo.htm -with permission from the original authors. -Original source copyright: -Copyright (c) 2008 Alexander Beider & Stephen P. Morse. diff --git a/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents_httpclient/LICENSE b/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.client5_httpclient5/LICENSE similarity index 100% rename from amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents_httpclient/LICENSE rename to amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.client5_httpclient5/LICENSE diff --git a/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents_httpclient/NOTICE b/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.client5_httpclient5/NOTICE similarity index 70% rename from amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents_httpclient/NOTICE rename to amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.client5_httpclient5/NOTICE index 0b9e10c..067323d 100644 --- a/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents_httpclient/NOTICE +++ b/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.client5_httpclient5/NOTICE @@ -1,6 +1,6 @@ Apache HttpClient -Copyright 1999-2022 The Apache Software Foundation +Copyright 1999-2021 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents_httpcore/LICENSE b/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/LICENSE similarity index 100% rename from amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents_httpcore/LICENSE rename to amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/LICENSE diff --git a/amphora-common/3RD-PARTY-LICENSES/commons-logging_commons-logging/NOTICE.txt b/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/NOTICE similarity index 54% rename from amphora-common/3RD-PARTY-LICENSES/commons-logging_commons-logging/NOTICE.txt rename to amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/NOTICE index db6d857..6f490b4 100644 --- a/amphora-common/3RD-PARTY-LICENSES/commons-logging_commons-logging/NOTICE.txt +++ b/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/NOTICE @@ -1,6 +1,6 @@ -Apache Commons Logging -Copyright 2003-2016 The Apache Software Foundation + +Apache HttpComponents Core HTTP/2 +Copyright 2005-2021 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). - diff --git a/amphora-common/3RD-PARTY-LICENSES/commons-codec_commons-codec/LICENSE.txt b/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/LICENSE similarity index 100% rename from amphora-common/3RD-PARTY-LICENSES/commons-codec_commons-codec/LICENSE.txt rename to amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/LICENSE diff --git a/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE b/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE new file mode 100644 index 0000000..65b6fc6 --- /dev/null +++ b/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE @@ -0,0 +1,6 @@ + +Apache HttpComponents Core HTTP/1.1 +Copyright 2005-2021 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/amphora-common/3RD-PARTY-LICENSES/org.slf4j_slf4j-api/LICENSE.txt b/amphora-common/3RD-PARTY-LICENSES/org.slf4j_slf4j-api/LICENSE.txt new file mode 100644 index 0000000..f687729 --- /dev/null +++ b/amphora-common/3RD-PARTY-LICENSES/org.slf4j_slf4j-api/LICENSE.txt @@ -0,0 +1,21 @@ +Copyright (c) 2004-2022 QOS.ch Sarl (Switzerland) +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/amphora-common/3RD-PARTY-LICENSES/sbom.xml b/amphora-common/3RD-PARTY-LICENSES/sbom.xml index 589786a..e15ad29 100644 --- a/amphora-common/3RD-PARTY-LICENSES/sbom.xml +++ b/amphora-common/3RD-PARTY-LICENSES/sbom.xml @@ -1,11 +1,11 @@ - Apache Commons Codec - commons-codec - commons-codec - 1.11 - http://commons.apache.org/proper/commons-codec/ + Apache HttpClient + org.apache.httpcomponents.client5 + httpclient5 + 5.2.1 + https://hc.apache.org/httpcomponents-client-5.0.x/5.2.1/httpclient5/ Apache License, Version 2.0 @@ -14,41 +14,28 @@ - Apache Commons Logging - commons-logging - commons-logging - 1.2 - http://commons.apache.org/proper/commons-logging/ - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - - Apache HttpClient - org.apache.httpcomponents - httpclient - 4.5.14 - http://hc.apache.org/httpcomponents-client-ga + Apache HttpComponents Core HTTP/1.1 + org.apache.httpcomponents.core5 + httpcore5 + 5.2 + https://hc.apache.org/httpcomponents-core-5.2.x/5.2/httpcore5/ Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt - Apache HttpCore - org.apache.httpcomponents - httpcore - 4.4.16 - http://hc.apache.org/httpcomponents-core-ga + Apache HttpComponents Core HTTP/2 + org.apache.httpcomponents.core5 + httpcore5-h2 + 5.2 + https://hc.apache.org/httpcomponents-core-5.2.x/5.2/httpcore5-h2/ Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt @@ -68,7 +55,7 @@ Jackson-annotations com.fasterxml.jackson.core jackson-annotations - 2.14.1 + 2.14.2 https://github.com/FasterXML/jackson @@ -81,7 +68,7 @@ Jackson-core com.fasterxml.jackson.core jackson-core - 2.14.1 + 2.14.2 https://github.com/FasterXML/jackson-core @@ -94,7 +81,7 @@ jackson-databind com.fasterxml.jackson.core jackson-databind - 2.14.1 + 2.14.2 https://github.com/FasterXML/jackson @@ -116,6 +103,19 @@ + + SLF4J API Module + org.slf4j + slf4j-api + 2.0.6 + http://www.slf4j.org + + + MIT License + http://www.opensource.org/licenses/mit-license.php + + + Vavr io.vavr diff --git a/amphora-common/pom.xml b/amphora-common/pom.xml index 8e9a715..9879afa 100644 --- a/amphora-common/pom.xml +++ b/amphora-common/pom.xml @@ -18,8 +18,7 @@ - 2.14.1 - 4.5.14 + 5.2.1 @@ -27,12 +26,6 @@ io.carbynestack mp-spdz-integration - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - com.fasterxml.jackson.core jackson-databind @@ -43,8 +36,8 @@ vavr - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 ${httpclient.version} @@ -55,9 +48,14 @@ - junit - junit - ${junit.version} + org.assertj + assertj-core + test + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} test diff --git a/amphora-common/src/main/java/io/carbynestack/amphora/common/AmphoraServiceUri.java b/amphora-common/src/main/java/io/carbynestack/amphora/common/AmphoraServiceUri.java index b85c025..164a785 100644 --- a/amphora-common/src/main/java/io/carbynestack/amphora/common/AmphoraServiceUri.java +++ b/amphora-common/src/main/java/io/carbynestack/amphora/common/AmphoraServiceUri.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -15,7 +15,7 @@ import lombok.AccessLevel; import lombok.Data; import lombok.Setter; -import org.apache.http.client.utils.URIBuilder; +import org.apache.hc.core5.net.URIBuilder; /** * A class, that manages an Amphora Service's URI and provides correct paths for all endpoints. Uses @@ -131,8 +131,8 @@ URI attachPathParameter(URI uri, String param) { path = String.format( "%s%s%s", - path == null || path.length() == 0 ? "" : path, - path != null && path.length() > 0 && path.lastIndexOf('/') == path.length() ? "" : "/", + path == null || path.isEmpty() ? "" : path, + path != null && path.endsWith("/") ? "" : "/", param); uriBuilder.setPath(path); return Try.of(uriBuilder::build) diff --git a/amphora-common/src/test/java/io/carbynestack/amphora/common/AmphoraServiceUriTest.java b/amphora-common/src/test/java/io/carbynestack/amphora/common/AmphoraServiceUriTest.java index 83e202e..7481442 100644 --- a/amphora-common/src/test/java/io/carbynestack/amphora/common/AmphoraServiceUriTest.java +++ b/amphora-common/src/test/java/io/carbynestack/amphora/common/AmphoraServiceUriTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -9,25 +9,24 @@ import static io.carbynestack.amphora.common.AmphoraServiceUri.INVALID_SERVICE_ADDRESS_EXCEPTION_MSG; import static io.carbynestack.amphora.common.rest.AmphoraRestApiEndpoints.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.net.URI; import lombok.SneakyThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AmphoraServiceUriTest { @Test - public void - givenNullAsServiceAddress_whenCreatingAmphoraServiceUri_thenThrowIllegalArgumentException() { + void givenNullAsServiceAddress_whenCreatingAmphoraServiceUri_thenThrowIllegalArgumentException() { IllegalArgumentException expectedException = assertThrows(IllegalArgumentException.class, () -> new AmphoraServiceUri(null)); assertEquals("serviceAddress must not be empty!", expectedException.getMessage()); } @Test - public void + void givenEmptyStringAsServiceAddress_whenCreatingAmphoraServiceUri_thenThrowIllegalArgumentException() { IllegalArgumentException iae = assertThrows(IllegalArgumentException.class, () -> new AmphoraServiceUri("")); @@ -35,23 +34,21 @@ public class AmphoraServiceUriTest { } @Test - public void - givenNoSchemeDefined_whenCreatingAmphoraServiceUri_thenThrowIllegalArgumentException() { + void givenNoSchemeDefined_whenCreatingAmphoraServiceUri_thenThrowIllegalArgumentException() { IllegalArgumentException iae = assertThrows(IllegalArgumentException.class, () -> new AmphoraServiceUri("localhost:8080")); assertEquals(INVALID_SERVICE_ADDRESS_EXCEPTION_MSG, iae.getMessage()); } @Test - public void - givenInvalidUriString_whenCreatingAmphoraServiceUri_thenThrowIllegalArgumentException() { + void givenInvalidUriString_whenCreatingAmphoraServiceUri_thenThrowIllegalArgumentException() { IllegalArgumentException iae = assertThrows(IllegalArgumentException.class, () -> new AmphoraServiceUri("invalidUri")); assertEquals(INVALID_SERVICE_ADDRESS_EXCEPTION_MSG, iae.getMessage()); } @Test - public void + void givenUriStringWithDomain_whenCreatingAmphoraServiceUri_thenCreateExpectedAmphoraServiceUri() { AmphoraServiceUri aUri = new AmphoraServiceUri("https://amphora.carbynestack.io:8080"); assertEquals("https://amphora.carbynestack.io:8080", aUri.getServiceUri().toString()); @@ -60,7 +57,7 @@ public class AmphoraServiceUriTest { } @Test - public void + void givenUriStringWithIpAndPort_whenCreatingAmphoraServiceUri_thenCreateExpectedAmphoraServiceUri() { AmphoraServiceUri aUri = new AmphoraServiceUri("http://127.0.0.1:8080"); assertEquals("http://127.0.0.1:8080", aUri.getServiceUri().toString()); @@ -69,7 +66,7 @@ public class AmphoraServiceUriTest { } @Test - public void + void givenUriStringWithoutPort_whenCreatingAmphoraServiceUri_thenCreateExpectedAmphoraServiceUri() { AmphoraServiceUri aUri = new AmphoraServiceUri("https://amphora.carbynestack.io"); assertEquals("https://amphora.carbynestack.io", aUri.getServiceUri().toString()); @@ -77,8 +74,7 @@ public class AmphoraServiceUriTest { } @Test - public void - givenUriStringWithPath_whenCreatingAmphoraServiceUri_thenCreateExpectedAmphoraServiceUri() { + void givenUriStringWithPath_whenCreatingAmphoraServiceUri_thenCreateExpectedAmphoraServiceUri() { AmphoraServiceUri aUri = new AmphoraServiceUri("https://amphora.carbynestack.io/myService"); assertEquals("https://amphora.carbynestack.io/myService", aUri.getServiceUri().toString()); assertEquals("amphora.carbynestack.io", aUri.getServiceUri().getHost()); @@ -86,7 +82,7 @@ public class AmphoraServiceUriTest { } @Test - public void + void givenUriStringWithPortAndPath_whenCreatingAmphoraServiceUri_thenCreateExpectedAmphoraServiceUri() { AmphoraServiceUri aUri = new AmphoraServiceUri("https://amphora.carbynestack.io:8081/my/service"); @@ -98,7 +94,7 @@ public class AmphoraServiceUriTest { } @Test - public void givenAmphoraServiceUri_whenGetSecretShareUri_thenReturnExpectedUri() { + void givenAmphoraServiceUri_whenGetSecretShareUri_thenReturnExpectedUri() { AmphoraServiceUri aUri = new AmphoraServiceUri("https://amphora.carbynestack.io:8081/my/service"); URI secretShareUri = aUri.getSecretShareUri(); @@ -111,7 +107,7 @@ public void givenAmphoraServiceUri_whenGetSecretShareUri_thenReturnExpectedUri() } @Test - public void givenAmphoraServiceUri_whenGetMaskedInputUri_thenReturnExpectedUri() { + void givenAmphoraServiceUri_whenGetMaskedInputUri_thenReturnExpectedUri() { AmphoraServiceUri aUri = new AmphoraServiceUri("https://amphora.carbynestack.io:8081/my/service"); URI maskedInputUri = aUri.getMaskedInputUri(); @@ -126,7 +122,7 @@ public void givenAmphoraServiceUri_whenGetMaskedInputUri_thenReturnExpectedUri() } @Test - public void givenAmphoraServiceUri_whenGetInputMaskUri_thenReturnExpectedUri() { + void givenAmphoraServiceUri_whenGetInputMaskUri_thenReturnExpectedUri() { AmphoraServiceUri aUri = new AmphoraServiceUri("https://amphora.carbynestack.io:8081/my/service/"); URI inputMaskUri = aUri.getInputMaskUri(); @@ -141,7 +137,7 @@ public void givenAmphoraServiceUri_whenGetInputMaskUri_thenReturnExpectedUri() { } @Test - public void + void givenUriStringWithTrailingSlash_whenCreateAmphoraServiceUri_thenReturnExpectedAmphoraServiceUri() { AmphoraServiceUri aUri = new AmphoraServiceUri("https://amphora.carbynestack.io:8081/"); URI inputMaskUri = aUri.getInputMaskUri(); @@ -155,7 +151,7 @@ public void givenAmphoraServiceUri_whenGetInputMaskUri_thenReturnExpectedUri() { @SneakyThrows @Test - public void givenValidPathSegments_whenBuildingResourceUri_thenReturnExpectedUri() { + void givenValidPathSegments_whenBuildingResourceUri_thenReturnExpectedUri() { String baseUri = "https://amphora.carbynestack.io/amphora"; String pathVariable = "1234"; AmphoraServiceUri amphoraServiceUri = new AmphoraServiceUri(baseUri); diff --git a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MaskedInputDataTest.java b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MaskedInputDataTest.java index 8d42e30..50813de 100644 --- a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MaskedInputDataTest.java +++ b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MaskedInputDataTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -7,17 +7,17 @@ package io.carbynestack.amphora.common.entities; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import io.carbynestack.amphora.common.MaskedInputData; import io.carbynestack.mpspdz.integration.MpSpdzIntegrationUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MaskedInputDataTest { @Test - public void givenInvalidValue_whenCreatingMaskedInputData_thenThrowException() { + void givenInvalidValue_whenCreatingMaskedInputData_thenThrowException() { IllegalArgumentException actualIae = assertThrows( IllegalArgumentException.class, diff --git a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MaskedInputTest.java b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MaskedInputTest.java index 6e4bb69..014ffbc 100644 --- a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MaskedInputTest.java +++ b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MaskedInputTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -8,7 +8,7 @@ package io.carbynestack.amphora.common.entities; import static java.util.Collections.emptyList; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import io.carbynestack.amphora.common.MaskedInput; import io.carbynestack.amphora.common.MaskedInputData; @@ -17,12 +17,12 @@ import java.util.Collections; import java.util.List; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MaskedInputTest { @Test - public void givenIdIsNull_whenCreatingNewSecret_thenThrowException() { + void givenIdIsNull_whenCreatingNewSecret_thenThrowException() { UUID nullId = null; List maskedInputData = emptyList(); List tags = emptyList(); @@ -33,14 +33,14 @@ public void givenIdIsNull_whenCreatingNewSecret_thenThrowException() { } @Test - public void givenTagsAreNull_whenCreatingMaskedInput_thenUseEmptyListInstead() { + void givenTagsAreNull_whenCreatingMaskedInput_thenUseEmptyListInstead() { UUID secretId = UUID.fromString("80fbba1b-3da8-4b1e-8a2c-cebd65229fad"); List maskedInputData = Collections.singletonList(MaskedInputData.of(new byte[MpSpdzIntegrationUtils.WORD_WIDTH])); MaskedInput maskedInput = new MaskedInput(secretId, maskedInputData, emptyList()); assertEquals(secretId, maskedInput.getSecretId()); assertEquals(maskedInputData, maskedInput.getData()); - assertNotNull("Tags must be replaced by empty list", maskedInput.getTags()); - assertTrue("Tags must be empty", maskedInput.getTags().isEmpty()); + assertNotNull(maskedInput.getTags(), "Tags must be replaced by empty list"); + assertTrue(maskedInput.getTags().isEmpty(), "Tags must be empty"); } } diff --git a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MetadataTest.java b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MetadataTest.java index 495fb0a..db24cf3 100644 --- a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MetadataTest.java +++ b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/MetadataTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -7,31 +7,26 @@ package io.carbynestack.amphora.common.entities; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import io.carbynestack.amphora.common.Metadata; import io.carbynestack.amphora.common.Tag; import java.util.*; -import org.hamcrest.CoreMatchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MetadataTest { @Test - public void givenIdIsNull_whenCallingBuildOnBuilder_thenThrowException() { + void givenIdIsNull_whenCallingBuildOnBuilder_thenThrowException() { Metadata.MetadataBuilder builder = Metadata.builder(); NullPointerException actualNpe = assertThrows(NullPointerException.class, builder::build); - assertThat( - actualNpe.getMessage(), - CoreMatchers.allOf(startsWith("secretId"), containsString("is null"))); + assertThat(actualNpe.getMessage()).startsWith("secretId").contains("is null"); } @Test - public void givenListWithNullTags_whenSettingTagsOnBuilder_thenRemoveNullTagsFromList() { + void givenListWithNullTags_whenSettingTagsOnBuilder_thenRemoveNullTagsFromList() { UUID secretId = UUID.fromString("80fbba1b-3da8-4b1e-8a2c-cebd65229fad"); List expectedTags = Arrays.asList(Tag.builder().key("key1").build(), Tag.builder().key("key2").build()); @@ -44,8 +39,8 @@ public void givenListWithNullTags_whenSettingTagsOnBuilder_thenRemoveNullTagsFro .tags(Collections.unmodifiableList(tagListWithNullEntries)) .build(); assertEquals(secretId, metadata.getSecretId()); - assertThat(metadata.getTags(), CoreMatchers.hasItems(expectedTags.toArray(new Tag[0]))); + assertThat(metadata.getTags()).containsOnly(expectedTags.toArray(new Tag[0])); assertEquals(metadata.getTags().size(), expectedTags.size()); - assertThat(metadata.getTags(), CoreMatchers.instanceOf(ArrayList.class)); + assertThat(metadata.getTags()).isInstanceOf(ArrayList.class); } } diff --git a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/OutputDeliveryObjectTest.java b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/OutputDeliveryObjectTest.java index 33ccbf0..4fa8ac3 100644 --- a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/OutputDeliveryObjectTest.java +++ b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/OutputDeliveryObjectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -7,17 +7,17 @@ package io.carbynestack.amphora.common.entities; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import io.carbynestack.amphora.common.OutputDeliveryObject; import io.carbynestack.mpspdz.integration.MpSpdzIntegrationUtils; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class OutputDeliveryObjectTest { @Test - public void givenValidBuilderConfiguration_whenCallingBuildOnBuilder_thenReturnObject() { + void givenValidBuilderConfiguration_whenCallingBuildOnBuilder_thenReturnObject() { UUID secretId = UUID.fromString("80fbba1b-3da8-4b1e-8a2c-cebd65229fad"); byte[] secretShares = new byte[MpSpdzIntegrationUtils.WORD_WIDTH]; byte[] rShares = new byte[MpSpdzIntegrationUtils.WORD_WIDTH]; @@ -42,7 +42,7 @@ public void givenValidBuilderConfiguration_whenCallingBuildOnBuilder_thenReturnO } @Test - public void + void givenRSharesOfDifferentLengthThanSecretShares_whenCallingBuildOnBuilder_thenThrowException() { OutputDeliveryObject.OutputDeliveryObjectBuilder outputDeliveryObjectBuilder = getValidTestODO(2).toBuilder().rShares(new byte[MpSpdzIntegrationUtils.WORD_WIDTH]); @@ -52,7 +52,7 @@ public void givenValidBuilderConfiguration_whenCallingBuildOnBuilder_thenReturnO } @Test - public void + void givenWSharesOfDifferentLengthThanSecretShares_whenCallingBuildOnBuilder_thenThrowException() { OutputDeliveryObject.OutputDeliveryObjectBuilder outputDeliveryObjectBuilder = getValidTestODO(2).toBuilder().wShares(new byte[MpSpdzIntegrationUtils.WORD_WIDTH]); @@ -62,7 +62,7 @@ public void givenValidBuilderConfiguration_whenCallingBuildOnBuilder_thenReturnO } @Test - public void + void givenUSharesOfDifferentLengthThanSecretShares_whenCallingBuildOnBuilder_thenThrowException() { OutputDeliveryObject.OutputDeliveryObjectBuilder outputDeliveryObjectBuilder = getValidTestODO(2).toBuilder().uShares(new byte[MpSpdzIntegrationUtils.WORD_WIDTH]); @@ -72,7 +72,7 @@ public void givenValidBuilderConfiguration_whenCallingBuildOnBuilder_thenReturnO } @Test - public void + void givenVSharesOfDifferentLengthThanSecretShares_whenCallingBuildOnBuilder_thenThrowException() { OutputDeliveryObject.OutputDeliveryObjectBuilder outputDeliveryObjectBuilder = getValidTestODO(2).toBuilder().vShares(new byte[MpSpdzIntegrationUtils.WORD_WIDTH]); diff --git a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/SecretShareTest.java b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/SecretShareTest.java index c587abb..be59cfd 100644 --- a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/SecretShareTest.java +++ b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/SecretShareTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -8,9 +8,8 @@ package io.carbynestack.amphora.common.entities; import static io.carbynestack.amphora.common.SecretShare.INVALID_LENGTH_EXCEPTION_MSG; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import com.fasterxml.jackson.databind.ObjectMapper; import io.carbynestack.amphora.common.SecretShare; @@ -18,15 +17,14 @@ import io.carbynestack.mpspdz.integration.MpSpdzIntegrationUtils; import java.util.*; import lombok.SneakyThrows; -import org.hamcrest.CoreMatchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SecretShareTest { final Random random = new Random(42); final UUID testSecretId = UUID.fromString("80fbba1b-3da8-4b1e-8a2c-cebd65229fad"); @Test - public void givenDataOfInvalidLength_whenBuildSecretShare_thenThrowIllegalArgumentException() { + void givenDataOfInvalidLength_whenBuildSecretShare_thenThrowIllegalArgumentException() { byte[] dataInvalidLength = new byte[MpSpdzIntegrationUtils.SHARE_WIDTH - 1]; SecretShare.SecretShareBuilder secretShareBuilder = SecretShare.builder(); IllegalArgumentException iae = @@ -38,7 +36,7 @@ public void givenDataOfInvalidLength_whenBuildSecretShare_thenThrowIllegalArgume } @Test - public void givenTwoSecretShareWithSameContent_whenCompareEqual_thenMatch() { + void givenTwoSecretSharesWithSameContent_whenCompareEqual_thenMatch() { byte[] data = new byte[MpSpdzIntegrationUtils.SHARE_WIDTH]; random.nextBytes(data); SecretShare secretShare1 = @@ -49,7 +47,7 @@ public void givenTwoSecretShareWithSameContent_whenCompareEqual_thenMatch() { } @Test - public void givenDataOfVariableButValidLength_whenBuildSecretShare_thenSucceed() { + void givenDataOfVariableButValidLength_whenBuildSecretShare_thenSucceed() { for (int i = 0; i < 100; i++) { byte[] expectedData = new byte[MpSpdzIntegrationUtils.SHARE_WIDTH * i]; random.nextBytes(expectedData); @@ -66,7 +64,7 @@ public void givenDataOfVariableButValidLength_whenBuildSecretShare_thenSucceed() @SneakyThrows @Test - public void givenSecretShareObject_whenSerialize_thenReturnExpectedJsonString() { + void givenSecretShareObject_whenSerialize_thenReturnExpectedJsonString() { ObjectMapper om = new ObjectMapper(); byte[] data = new byte[MpSpdzIntegrationUtils.SHARE_WIDTH]; random.nextBytes(data); @@ -74,12 +72,11 @@ public void givenSecretShareObject_whenSerialize_thenReturnExpectedJsonString() Collections.singletonList(Tag.builder().key("theKey").value("someValue").build()); SecretShare share = SecretShare.builder().secretId(testSecretId).data(data).tags(tags).build(); - assertThat( - om.writeValueAsString(share), - CoreMatchers.equalTo( - String.format( - "{\"secretId\":\"%s\",\"tags\":%s,\"data\":%s}", - testSecretId, om.writeValueAsString(tags), om.writeValueAsString(data)))); + assertEquals( + String.format( + "{\"secretId\":\"%s\",\"tags\":%s,\"data\":%s}", + testSecretId, om.writeValueAsString(tags), om.writeValueAsString(data)), + om.writeValueAsString(share)); } @Test @@ -99,6 +96,6 @@ public void givenValidSecretShareJsonString_whenDeserialize_thenReturnExpectedOb String.format( "{\"secretId\":\"%s\",\"tags\":%s,\"data\":%s}", testSecretId, om.writeValueAsString(tags), om.writeValueAsString(data))); - assertThat(actualShare, CoreMatchers.equalTo(expectedShare)); + assertEquals(expectedShare, actualShare); } } diff --git a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/TagFilterTest.java b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/TagFilterTest.java index f0816ed..a7c403c 100644 --- a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/TagFilterTest.java +++ b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/TagFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -7,17 +7,17 @@ package io.carbynestack.amphora.common.entities; import static io.carbynestack.amphora.common.TagFilter.ILLEGAL_TAGFILTER_FORMAT_EXCEPTION_MSG; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import io.carbynestack.amphora.common.TagFilter; import io.carbynestack.amphora.common.TagFilterOperator; import java.io.UnsupportedEncodingException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TagFilterTest { @Test - public void givenTagFilterStringWithoutKey_whenFromString_thenThrowExpectedException() { + void givenTagFilterStringWithoutKey_whenFromString_thenThrowExpectedException() { String invalidTagFilterString = TagFilterOperator.EQUALS + "42"; IllegalArgumentException actualIAE = @@ -30,7 +30,7 @@ public void givenTagFilterStringWithoutKey_whenFromString_thenThrowExpectedExcep } @Test - public void givenTagFilterStringWithInvalidOperator_whenFromString_thenThrowExpectedException() { + void givenTagFilterStringWithInvalidOperator_whenFromString_thenThrowExpectedException() { String invalidTagFilterString = "key<>Value"; IllegalArgumentException actualIAE = @@ -43,7 +43,7 @@ public void givenTagFilterStringWithInvalidOperator_whenFromString_thenThrowExpe } @Test - public void givenTagFilterStringWithoutValue_whenFromString_thenThrowExpectedException() { + void givenTagFilterStringWithoutValue_whenFromString_thenThrowExpectedException() { String invalidTagFilterString = "key" + TagFilterOperator.EQUALS; IllegalArgumentException actualIAE = @@ -56,7 +56,7 @@ public void givenTagFilterStringWithoutValue_whenFromString_thenThrowExpectedExc } @Test - public void givenValidTagFilterString_whenFromString_thenReturnExpectedTagFilter() + void givenValidTagFilterString_whenFromString_thenReturnExpectedTagFilter() throws UnsupportedEncodingException { TagFilter expectedTagFilter = TagFilter.with("time", "42", TagFilterOperator.LESS_THAN); String validTagFilterString = diff --git a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/TagTest.java b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/TagTest.java index e6a84f4..c61442d 100644 --- a/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/TagTest.java +++ b/amphora-common/src/test/java/io/carbynestack/amphora/common/entities/TagTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -8,10 +8,8 @@ package io.carbynestack.amphora.common.entities; import static io.carbynestack.amphora.common.Tag.INVALID_KEY_STRING_EXCEPTION_MSG; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.*; import com.fasterxml.jackson.databind.ObjectMapper; import io.carbynestack.amphora.common.Tag; @@ -20,7 +18,7 @@ import io.carbynestack.amphora.common.TagValueType; import java.util.Arrays; import lombok.SneakyThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TagTest { private final String dummyKey = "dummy-key"; @@ -28,18 +26,18 @@ public class TagTest { private final long dummyLongValue = 12345L; @Test - public void givenKeyWithTooManyCharacters_whenBuildingTag_thenThrowIllegalArgumentException() { + void givenKeyWithTooManyCharacters_whenBuildingTag_thenThrowIllegalArgumentException() { char[] array = new char[129]; Arrays.fill(array, 'a'); String key = new String(array); Tag.TagBuilder tagBuilder = Tag.builder().key(key).value(dummyStringValue); IllegalArgumentException actualIae = assertThrows(IllegalArgumentException.class, () -> tagBuilder.build()); - assertThat(actualIae.getMessage(), containsString("longer then 128 characters")); + assertThat(actualIae.getMessage()).contains("longer then 128 characters"); } @Test - public void givenKeyWithMaximumLength_whenBuildingTag_thenSucceed() { + void givenKeyWithMaximumLength_whenBuildingTag_thenSucceed() { char[] array = new char[128]; Arrays.fill(array, 'a'); String key = new String(array); @@ -48,7 +46,7 @@ public void givenKeyWithMaximumLength_whenBuildingTag_thenSucceed() { } @Test - public void givenKeyWithInvalidCharacter_whenBuildingTag_thenThrowIllegalArgumentException() { + void givenKeyWithInvalidCharacter_whenBuildingTag_thenThrowIllegalArgumentException() { String key = "#123"; Tag.TagBuilder tagBuilder = Tag.builder().key(key).value(dummyStringValue); IllegalArgumentException iae = @@ -57,7 +55,7 @@ public void givenKeyWithInvalidCharacter_whenBuildingTag_thenThrowIllegalArgumen } @Test - public void givenNullAsKey_whenBuildingTag_thenThrowIllegalArgumentException() { + void givenNullAsKey_whenBuildingTag_thenThrowIllegalArgumentException() { Tag.TagBuilder tagBuilder = Tag.builder(); NullPointerException actualNpe = assertThrows(NullPointerException.class, () -> tagBuilder.key(null)); @@ -65,7 +63,7 @@ public void givenNullAsKey_whenBuildingTag_thenThrowIllegalArgumentException() { } @Test - public void giveKeyIsEmptyString_whenBuildingTag_thenThrowIllegalArgumentException() { + void giveKeyIsEmptyString_whenBuildingTag_thenThrowIllegalArgumentException() { Tag.TagBuilder tagBuilder = Tag.builder().key("").value(dummyStringValue); IllegalArgumentException actualIae = assertThrows(IllegalArgumentException.class, tagBuilder::build); @@ -73,7 +71,7 @@ public void giveKeyIsEmptyString_whenBuildingTag_thenThrowIllegalArgumentExcepti } @Test - public void givenNullAsValue_whenBuildingTag_thenThrowIllegalArgumentException() { + void givenNullAsValue_whenBuildingTag_thenThrowIllegalArgumentException() { Tag.TagBuilder tagBuilder = Tag.builder().key(dummyKey); NullPointerException actualNpe = assertThrows(NullPointerException.class, () -> tagBuilder.value(null)); @@ -81,7 +79,7 @@ public void givenNullAsValue_whenBuildingTag_thenThrowIllegalArgumentException() } @Test - public void givenValueIsEmptyString_whenBuildingTag_thenCreateExpectedTag() { + void givenValueIsEmptyString_whenBuildingTag_thenCreateExpectedTag() { String expectedTagValue = ""; Tag tag = Tag.builder().key(dummyKey).value("").build(); assertEquals(TagValueType.STRING, tag.getValueType()); @@ -90,7 +88,7 @@ public void givenValueIsEmptyString_whenBuildingTag_thenCreateExpectedTag() { } @Test - public void givenKeyWithSupportedCharacters_whenBuildingTag_thenSucceed() { + void givenKeyWithSupportedCharacters_whenBuildingTag_thenSucceed() { String expectedKey = "abcDEF456-."; Tag tag = Tag.builder().key(expectedKey).value(dummyStringValue).build(); assertEquals(TagValueType.STRING, tag.getValueType()); @@ -99,20 +97,19 @@ public void givenKeyWithSupportedCharacters_whenBuildingTag_thenSucceed() { } @Test - public void givenValueWithTooManyCharacters_whenBuildingTag_thenThrowIllegaArgumentException() { + void givenValueWithTooManyCharacters_whenBuildingTag_thenThrowIllegaArgumentException() { char[] array = new char[257]; Arrays.fill(array, 'a'); String value = new String(array); Tag.TagBuilder tagBuilder = Tag.builder().key(dummyKey).value(value); IllegalArgumentException actualIae = assertThrows(IllegalArgumentException.class, tagBuilder::build); - assertThat( - actualIae.getMessage(), - startsWith("The given value exceeds the maximum length of 256: (257)")); + assertThat(actualIae.getMessage()) + .startsWith("The given value exceeds the maximum length of 256: (257)"); } @Test - public void givenValueWithMaximumLength_whenBuildingTag_thenSucceed() { + void givenValueWithMaximumLength_whenBuildingTag_thenSucceed() { char[] array = new char[256]; Arrays.fill(array, 'a'); String expectedValue = new String(array); @@ -123,7 +120,7 @@ public void givenValueWithMaximumLength_whenBuildingTag_thenSucceed() { } @Test - public void givenLongStringAsValueAndLongAsValueType_whenBuildingTag_thenCreateExpectedTag() { + void givenLongStringAsValueAndLongAsValueType_whenBuildingTag_thenCreateExpectedTag() { Tag tag = Tag.builder() .key(dummyKey) @@ -136,7 +133,7 @@ public void givenLongStringAsValueAndLongAsValueType_whenBuildingTag_thenCreateE } @Test - public void givenOnlyKeyAsInput_whenBuildingTag_thenUseDefaultValues() { + void givenOnlyKeyAsInput_whenBuildingTag_thenUseDefaultValues() { Tag tag = Tag.builder().key(dummyKey).build(); assertEquals(TagValueType.STRING, tag.getValueType()); assertEquals(dummyKey, tag.getKey()); @@ -145,7 +142,7 @@ public void givenOnlyKeyAsInput_whenBuildingTag_thenUseDefaultValues() { @SneakyThrows @Test - public void givenTagObject_whenSerializingAndDeserializingData_thenRecreateOrigin() { + void givenTagObject_whenSerializingAndDeserializingData_thenRecreateOrigin() { Tag tag = Tag.builder() .key(dummyKey) @@ -158,7 +155,7 @@ public void givenTagObject_whenSerializingAndDeserializingData_thenRecreateOrigi @SneakyThrows @Test - public void givenTagFilterObject_whenSerializingAndDeserializingData_thenRecreateOrigin() { + void givenTagFilterObject_whenSerializingAndDeserializingData_thenRecreateOrigin() { TagFilter filter = TagFilter.with(dummyKey, Long.toString(dummyLongValue), TagFilterOperator.EQUALS); ObjectMapper om = new ObjectMapper(); diff --git a/amphora-common/src/test/java/io/carbynestack/amphora/common/exceptions/AmphoraClientExceptionTest.java b/amphora-common/src/test/java/io/carbynestack/amphora/common/exceptions/AmphoraClientExceptionTest.java index a446295..a022fce 100644 --- a/amphora-common/src/test/java/io/carbynestack/amphora/common/exceptions/AmphoraClientExceptionTest.java +++ b/amphora-common/src/test/java/io/carbynestack/amphora/common/exceptions/AmphoraClientExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -7,14 +7,14 @@ package io.carbynestack.amphora.common.exceptions; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AmphoraClientExceptionTest { @Test - public void givenMessageAndCause_whenInstantiatingException_thenSetValuesCorrectly() { + void givenMessageAndCause_whenInstantiatingException_thenSetValuesCorrectly() { String msg = "Description"; String causeMsg = "Root of all evil"; Throwable cause = new NullPointerException(causeMsg); diff --git a/amphora-java-client/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE b/amphora-java-client/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE new file mode 100644 index 0000000..d226e89 --- /dev/null +++ b/amphora-java-client/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE @@ -0,0 +1,17 @@ +# Jackson JSON processor + +Jackson is a high-performance, Free/Open Source JSON processing library. +It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has +been in development since 2007. +It is currently developed by a community of developers. + +## Licensing + +Jackson 2.x core and extension components are licensed under Apache License 2.0 +To find the details that apply to this artifact see the accompanying LICENSE file. + +## Credits + +A list of contributors may be found from CREDITS(-2.x) file, which is included +in some artifacts (usually source distributions); but is always available +from the source code management (SCM) system project uses. diff --git a/amphora-common/3RD-PARTY-LICENSES/commons-logging_commons-logging/LICENSE.txt b/amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/LICENSE similarity index 100% rename from amphora-common/3RD-PARTY-LICENSES/commons-logging_commons-logging/LICENSE.txt rename to amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/LICENSE diff --git a/amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/NOTICE b/amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/NOTICE new file mode 100644 index 0000000..6f490b4 --- /dev/null +++ b/amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/NOTICE @@ -0,0 +1,6 @@ + +Apache HttpComponents Core HTTP/2 +Copyright 2005-2021 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/amphora-service/3RD-PARTY-LICENSES/org.yaml_snakeyaml/LICENSE.txt b/amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/LICENSE similarity index 89% rename from amphora-service/3RD-PARTY-LICENSES/org.yaml_snakeyaml/LICENSE.txt rename to amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/LICENSE index d9a10c0..d645695 100644 --- a/amphora-service/3RD-PARTY-LICENSES/org.yaml_snakeyaml/LICENSE.txt +++ b/amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/LICENSE @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -174,3 +175,28 @@ of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE b/amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE new file mode 100644 index 0000000..65b6fc6 --- /dev/null +++ b/amphora-java-client/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE @@ -0,0 +1,6 @@ + +Apache HttpComponents Core HTTP/1.1 +Copyright 2005-2021 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/amphora-java-client/3RD-PARTY-LICENSES/sbom.xml b/amphora-java-client/3RD-PARTY-LICENSES/sbom.xml index 3ceb93b..8ae4ce0 100644 --- a/amphora-java-client/3RD-PARTY-LICENSES/sbom.xml +++ b/amphora-java-client/3RD-PARTY-LICENSES/sbom.xml @@ -77,6 +77,32 @@ + + Apache HttpComponents Core HTTP/1.1 + org.apache.httpcomponents.core5 + httpcore5 + 5.2 + https://hc.apache.org/httpcomponents-core-5.2.x/5.2/httpcore5/ + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + + Apache HttpComponents Core HTTP/2 + org.apache.httpcomponents.core5 + httpcore5-h2 + 5.2 + https://hc.apache.org/httpcomponents-core-5.2.x/5.2/httpcore5-h2/ + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + Apache HttpCore org.apache.httpcomponents @@ -118,7 +144,7 @@ castor-common io.carbynestack castor-common - 0.1-SNAPSHOT-4191841095-22-1721229 + 0.1-SNAPSHOT-4321261594-23-40a9faa Apache-2.0 @@ -221,7 +247,7 @@ Jackson-annotations com.fasterxml.jackson.core jackson-annotations - 2.14.1 + 2.14.2 https://github.com/FasterXML/jackson @@ -234,7 +260,7 @@ Jackson-core com.fasterxml.jackson.core jackson-core - 2.14.1 + 2.14.2 https://github.com/FasterXML/jackson-core @@ -247,7 +273,7 @@ jackson-databind com.fasterxml.jackson.core jackson-databind - 2.14.1 + 2.14.2 https://github.com/FasterXML/jackson diff --git a/amphora-java-client/pom.xml b/amphora-java-client/pom.xml index ac7a4a0..d4aada8 100644 --- a/amphora-java-client/pom.xml +++ b/amphora-java-client/pom.xml @@ -1,6 +1,6 @@ + + org.assertj + assertj-core + test + org.apache.logging.log4j log4j-core + ${log4j.version} test org.apache.logging.log4j log4j-slf4j-impl + ${log4j.version} test - junit - junit + org.slf4j + slf4j-simple + ${slf4j.version} test - org.mockito - mockito-inline + org.junit.jupiter + junit-jupiter test - org.powermock - powermock-module-junit4 - 2.0.9 + org.mockito + mockito-inline test - org.powermock - powermock-api-mockito2 - 2.0.9 + org.mockito + mockito-junit-jupiter test diff --git a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/AmphoraCommunicationClientTest.java b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/AmphoraCommunicationClientTest.java index d17c675..5278f71 100644 --- a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/AmphoraCommunicationClientTest.java +++ b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/AmphoraCommunicationClientTest.java @@ -1,15 +1,14 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 */ package io.carbynestack.amphora.client; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; import com.google.common.collect.ImmutableList; @@ -25,21 +24,19 @@ import java.util.Map; import java.util.stream.Collectors; import lombok.SneakyThrows; -import org.hamcrest.CoreMatchers; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.MockedConstruction; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class AmphoraCommunicationClientTest { +@ExtendWith(MockitoExtension.class) +class AmphoraCommunicationClientTest { private final String testExceptionMessage = "Totally expected :O"; private final URI testUri = new URI("https://amphora.carbynestack.io:8080"); private final URI testUri2 = new URI("https://amphora.carbynestack.io:8081"); private final String response1 = "response1"; - private final String response2 = "response2"; private final String body1 = "body1"; private final String body2 = "body2"; @@ -50,7 +47,7 @@ public class AmphoraCommunicationClientTest { public AmphoraCommunicationClientTest() throws URISyntaxException {} @SneakyThrows - @Before + @BeforeEach public void setUp() { try (MockedConstruction httpClientMockedConstruction = mockConstruction(CsHttpClient.class)) { @@ -62,7 +59,7 @@ public void setUp() { @SneakyThrows @Test - public void givenSuccessfulRequest_whenFetchingDataFromOnePlayer_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenFetchingDataFromOnePlayer_thenReturnExpectedContent() { when(specsHttpClient.getForObject(testUri, Collections.emptyList(), String.class)) .thenReturn(response1); String result = @@ -76,7 +73,7 @@ public void givenSuccessfulRequest_whenFetchingDataFromOnePlayer_thenReturnExpec @SneakyThrows @Test - public void givenHttpClientThrowsException_whenFetchingDataFromOnePlayer_thenForwardException() { + void givenHttpClientThrowsException_whenFetchingDataFromOnePlayer_thenForwardException() { CsHttpClientException expectedException = new CsHttpClientException(testExceptionMessage); when(specsHttpClient.getForObject(testUri, Collections.emptyList(), String.class)) .thenThrow(expectedException); @@ -95,26 +92,25 @@ public void givenHttpClientThrowsException_whenFetchingDataFromOnePlayer_thenFor @SneakyThrows @Test - public void - givenSuccessfulRequest_whenFetchingDataFromMultiplePlayers_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenFetchingDataFromMultiplePlayers_thenReturnExpectedContent() { int numberOfProviders = 2; when(specsHttpClient.getForObject(testUri, Collections.emptyList(), String.class)) .thenReturn(response1); + String response2 = "response2"; when(specsHttpClient.getForObject(testUri2, Collections.emptyList(), String.class)) .thenReturn(response2); List params = new ArrayList<>(); params.add(AmphoraCommunicationClient.RequestParameters.of(testUri, ImmutableList.of())); params.add(AmphoraCommunicationClient.RequestParameters.of(testUri2, ImmutableList.of())); Map> result = amphoraCommunicationClient.download(params, String.class); - assertThat(result.size(), is(equalTo(numberOfProviders))); - assertThat(result.get(testUri), is(equalTo(Try.success(response1)))); - assertThat(result.get(testUri2), is(equalTo(Try.success(response2)))); + assertEquals(numberOfProviders, result.size()); + assertEquals(Try.success(response1), result.get(testUri)); + assertEquals(Try.success(response2), result.get(testUri2)); } @SneakyThrows @Test - public void - givenOneRequestFails_whenFetchingDataFromMultiplePlayers_thenReturnExpectedResultMap() { + void givenOneRequestFails_whenFetchingDataFromMultiplePlayers_thenReturnExpectedResultMap() { when(specsHttpClient.getForObject(testUri, Collections.emptyList(), String.class)) .thenReturn(response1); when(specsHttpClient.getForObject(testUri2, Collections.emptyList(), String.class)) @@ -124,22 +120,22 @@ public void givenHttpClientThrowsException_whenFetchingDataFromOnePlayer_thenFor params.add(AmphoraCommunicationClient.RequestParameters.of(testUri2, ImmutableList.of())); Map> result = amphoraCommunicationClient.download(params, String.class); assertThat( - result.entrySet().parallelStream() - .filter(e -> e.getValue().isSuccess()) - .map(Map.Entry::getKey) - .collect(Collectors.toList()), - CoreMatchers.hasItems(testUri)); + result.entrySet().parallelStream() + .filter(e -> e.getValue().isSuccess()) + .map(Map.Entry::getKey) + .collect(Collectors.toList())) + .containsOnly(testUri); assertThat( - result.entrySet().parallelStream() - .filter(e -> e.getValue().isFailure()) - .map(Map.Entry::getKey) - .collect(Collectors.toList()), - CoreMatchers.hasItems(testUri2)); + result.entrySet().parallelStream() + .filter(e -> e.getValue().isFailure()) + .map(Map.Entry::getKey) + .collect(Collectors.toList())) + .containsOnly(testUri2); } @SneakyThrows @Test - public void givenSuccessfulRequest_whenUploadingToOnePlayer_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenUploadingToOnePlayer_thenReturnExpectedContent() { when(specsHttpClient.postForObject(eq(testUri), anyList(), eq(body1), eq(String.class))) .thenReturn(response1); String result = @@ -154,7 +150,7 @@ public void givenSuccessfulRequest_whenUploadingToOnePlayer_thenReturnExpectedCo @SneakyThrows @Test - public void givenHttpClientThrowsException_whenUploadingToOnePlayer_thenForwardException() { + void givenHttpClientThrowsException_whenUploadingToOnePlayer_thenForwardException() { CsHttpClientException expectedException = new CsHttpClientException(testExceptionMessage); when(specsHttpClient.postForObject(eq(testUri), any(List.class), eq(body1), eq(String.class))) .thenThrow(expectedException); @@ -173,7 +169,7 @@ public void givenHttpClientThrowsException_whenUploadingToOnePlayer_thenForwardE @SneakyThrows @Test - public void givenOneRequestFails_whenUploadingToMultiplePlayers_thenReturnExpectedResultMap() { + void givenOneRequestFails_whenUploadingToMultiplePlayers_thenReturnExpectedResultMap() { int numberOfProviders = 2; CsHttpClientException expectedException = new CsHttpClientException(testExceptionMessage); List> params = @@ -189,16 +185,16 @@ public void givenOneRequestFails_whenUploadingToMultiplePlayers_thenReturnExpect when(specsHttpClient.postForObject(eq(testUri2), anyList(), eq(body2), eq(String.class))) .thenThrow(expectedException); Map> result = amphoraCommunicationClient.upload(params, String.class); - assertThat(result.size(), is(equalTo(numberOfProviders))); - assertThat(result.get(testUri), is(Try.success(null))); + assertEquals(numberOfProviders, result.size()); + assertEquals(Try.success(null), result.get(testUri)); assertTrue( - String.format("Try for %s should've failed", testUri2), result.get(testUri2).isFailure()); + result.get(testUri2).isFailure(), String.format("Try for %s should've failed", testUri2)); assertEquals(expectedException, result.get(testUri2).getCause()); } @SneakyThrows @Test - public void givenOneRequestFails_whenUpdatingOnMultiplePlayers_thenReturnExpectedResultMap() { + void givenOneRequestFails_whenUpdatingOnMultiplePlayers_thenReturnExpectedResultMap() { CsHttpClientException expectedException = new CsHttpClientException(testExceptionMessage); List> params = Lists.newArrayList(); @@ -213,13 +209,13 @@ public void givenOneRequestFails_whenUpdatingOnMultiplePlayers_thenReturnExpecte assertEquals(params.size(), updateResults.size()); List> failedResults = updateResults.stream().filter(Try::isFailure).collect(Collectors.toList()); - assertEquals("Exactly one request should've failed", 1, failedResults.size()); + assertEquals(1, failedResults.size(), "Exactly one request should've failed"); assertEquals(expectedException, failedResults.get(0).getCause()); } @SneakyThrows @Test - public void givenSuccessfulRequest_whenDeletingOnOnePlayer_thenSucceed() { + void givenSuccessfulRequest_whenDeletingOnOnePlayer_thenSucceed() { amphoraCommunicationClient.delete( Lists.newArrayList( AmphoraCommunicationClient.RequestParameters.of(testUri, ImmutableList.of()))); @@ -229,20 +225,20 @@ public void givenSuccessfulRequest_whenDeletingOnOnePlayer_thenSucceed() { @SneakyThrows @Test - public void givenRequestFails_whenDeletingOnOnePlayer_thenForwardException() { + void givenRequestFails_whenDeletingOnOnePlayer_thenForwardException() { CsHttpClientException expectedException = new CsHttpClientException(testExceptionMessage); doThrow(expectedException).when(specsHttpClient).delete(testUri, Collections.emptyList()); List> deleteRequest = amphoraCommunicationClient.delete( Lists.newArrayList( AmphoraCommunicationClient.RequestParameters.of(testUri, ImmutableList.of()))); - assertTrue("Request should've failed", deleteRequest.get(0).isFailure()); + assertTrue(deleteRequest.get(0).isFailure(), "Request should've failed"); assertEquals(expectedException, deleteRequest.get(0).getCause()); } @SneakyThrows @Test - public void givenSuccessfulRequest_whenDeletingFromMultiplePlayer_thenSucceed() { + void givenSuccessfulRequest_whenDeletingFromMultiplePlayer_thenSucceed() { List params = new ArrayList<>(); params.add(AmphoraCommunicationClient.RequestParameters.of(testUri, ImmutableList.of())); params.add(AmphoraCommunicationClient.RequestParameters.of(testUri2, ImmutableList.of())); @@ -250,12 +246,12 @@ public void givenSuccessfulRequest_whenDeletingFromMultiplePlayer_thenSucceed() verify(specsHttpClient, times(1)).delete(testUri, Collections.emptyList()); verify(specsHttpClient, times(1)).delete(testUri2, Collections.emptyList()); verifyNoMoreInteractions(specsHttpClient); - actualResult.forEach(t -> assertTrue("Request should've been successful", t.isSuccess())); + actualResult.forEach(t -> assertTrue(t.isSuccess(), "Request should've been successful")); } @SneakyThrows @Test - public void givenOneRequestFails_whenDeletingFromMultiplePlayers_thenReturnExpectedResult() { + void givenOneRequestFails_whenDeletingFromMultiplePlayers_thenReturnExpectedResult() { CsHttpClientException expectedException = new CsHttpClientException(testExceptionMessage); doThrow(expectedException).when(specsHttpClient).delete(testUri2, Collections.emptyList()); List params = new ArrayList<>(); @@ -265,7 +261,7 @@ public void givenOneRequestFails_whenDeletingFromMultiplePlayers_thenReturnExpec assertEquals(params.size(), deleteRequests.size()); List> failedResults = deleteRequests.stream().filter(Try::isFailure).collect(Collectors.toList()); - assertEquals("Exactly one request should've failed", 1, failedResults.size()); + assertEquals(1, failedResults.size(), "Exactly one request should've failed"); assertEquals(expectedException, failedResults.get(0).getCause()); } } diff --git a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraClientBuilderTest.java b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraClientBuilderTest.java index 92832d4..400b524 100644 --- a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraClientBuilderTest.java +++ b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraClientBuilderTest.java @@ -1,41 +1,33 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 */ package io.carbynestack.amphora.client; -import static org.hamcrest.CoreMatchers.hasItems; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.times; -import static org.powermock.api.mockito.PowerMockito.whenNew; import com.google.common.collect.Lists; import io.carbynestack.amphora.common.AmphoraServiceUri; import java.io.File; import java.math.BigInteger; import java.nio.file.Files; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import lombok.SneakyThrows; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.MockedConstruction; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(PowerMockRunner.class) -@PrepareForTest(DefaultAmphoraClientBuilder.class) -public class DefaultAmphoraClientBuilderTest { +@ExtendWith(MockitoExtension.class) +class DefaultAmphoraClientBuilderTest { @SneakyThrows @Test - public void givenEndpointsNotDefined_whenBuildingClient_thenThrowException() { + void givenEndpointsNotDefined_whenBuildingClient_thenThrowException() { DefaultAmphoraClientBuilder builder = DefaultAmphoraClient.builder(); builder.r(BigInteger.ZERO).rInv(BigInteger.ONE).prime(BigInteger.TEN); IllegalArgumentException iae = @@ -45,7 +37,7 @@ public void givenEndpointsNotDefined_whenBuildingClient_thenThrowException() { @SneakyThrows @Test - public void givenPrimeOmitted_whenBuildingClient_thenThrowNullPointerException() { + void givenPrimeOmitted_whenBuildingClient_thenThrowNullPointerException() { DefaultAmphoraClientBuilder builder = DefaultAmphoraClient.builder(); builder .r(BigInteger.ZERO) @@ -57,7 +49,7 @@ public void givenPrimeOmitted_whenBuildingClient_thenThrowNullPointerException() @SneakyThrows @Test - public void givenRInvOmitted_whenBuildingClient_thenThrowNullPointerException() { + void givenRInvOmitted_whenBuildingClient_thenThrowNullPointerException() { DefaultAmphoraClientBuilder builder = DefaultAmphoraClient.builder(); builder .prime(BigInteger.TEN) @@ -70,7 +62,7 @@ public void givenRInvOmitted_whenBuildingClient_thenThrowNullPointerException() @SneakyThrows @Test - public void givenROmitted_whenBuildingClient_thenThrowNullPointerException() { + void givenROmitted_whenBuildingClient_thenThrowNullPointerException() { DefaultAmphoraClientBuilder builder = DefaultAmphoraClient.builder(); builder .prime(BigInteger.TEN) @@ -82,10 +74,7 @@ public void givenROmitted_whenBuildingClient_thenThrowNullPointerException() { @SneakyThrows @Test - public void givenValidConfiguration_whenBuildingClient_thenCallConstructorWithBuilder() { - ArgumentCaptor builderArgumentCaptor = - ArgumentCaptor.forClass(DefaultAmphoraClientBuilder.class); - + void givenValidConfiguration_whenBuildingClient_thenCallConstructorWithBuilder() { List endpointList = Arrays.asList( new AmphoraServiceUri("https://amphora.carbynestack.io:80"), @@ -102,9 +91,29 @@ public void givenValidConfiguration_whenBuildingClient_thenCallConstructorWithBu BigInteger rInv = BigInteger.TEN; BearerTokenProvider bearerTokenProvider = o -> null; - try (MockedConstruction ignored = - mockConstruction(DefaultAmphoraClient.class)) { - whenNew(DefaultAmphoraClient.class).withAnyArguments().thenReturn(null); + try (MockedConstruction mockedConstruction = + mockConstruction( + DefaultAmphoraClient.class, + (context, settings) -> { + DefaultAmphoraClientBuilder actualBuilder = + (DefaultAmphoraClientBuilder) settings.arguments().get(0); + assertEquals(prime, actualBuilder.prime()); + assertEquals(r, actualBuilder.r()); + assertEquals(rInv, actualBuilder.rInv()); + assertEquals(bearerTokenProvider, actualBuilder.bearerTokenProvider()); + assertEquals(3, actualBuilder.trustedCertificates().size()); + assertEquals(3, actualBuilder.serviceUris().size()); + assertTrue(actualBuilder.noSslValidation()); + assertThat(actualBuilder.trustedCertificates()) + .containsOnly( + Lists.asList( + singleTrustedCertificate, trustedCertificateList.toArray(new File[0])) + .toArray(new File[0])); + assertThat(actualBuilder.serviceUris()) + .containsOnly( + Lists.asList(singleEndpoint, endpointList.toArray(new AmphoraServiceUri[0])) + .toArray(new AmphoraServiceUri[0])); + })) { DefaultAmphoraClient.builder() .prime(prime) .r(r) @@ -116,26 +125,7 @@ public void givenValidConfiguration_whenBuildingClient_thenCallConstructorWithBu .bearerTokenProvider(bearerTokenProvider) .withoutSslCertificateValidation() .build(); - PowerMockito.verifyNew(DefaultAmphoraClient.class, times(1)) - .withArguments(builderArgumentCaptor.capture()); + assertEquals(1, mockedConstruction.constructed().size()); } - DefaultAmphoraClientBuilder actualBuilder = builderArgumentCaptor.getValue(); - assertEquals(prime, actualBuilder.prime()); - assertEquals(r, actualBuilder.r()); - assertEquals(rInv, actualBuilder.rInv()); - assertEquals(bearerTokenProvider, actualBuilder.bearerTokenProvider()); - assertEquals(3, actualBuilder.trustedCertificates().size()); - assertEquals(3, actualBuilder.serviceUris().size()); - assertTrue(actualBuilder.noSslValidation()); - assertThat( - (ArrayList) actualBuilder.trustedCertificates(), - hasItems( - Lists.asList(singleTrustedCertificate, trustedCertificateList.toArray(new File[0])) - .toArray(new File[0]))); - assertThat( - actualBuilder.serviceUris(), - hasItems( - Lists.asList(singleEndpoint, endpointList.toArray(new AmphoraServiceUri[0])) - .toArray(new AmphoraServiceUri[0]))); } } diff --git a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraClientTest.java b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraClientTest.java index 99dec07..fc8c964 100644 --- a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraClientTest.java +++ b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -13,10 +13,8 @@ import static io.carbynestack.amphora.common.TagFilterOperator.LESS_THAN; import static io.carbynestack.amphora.common.rest.AmphoraRestApiEndpoints.*; import static io.carbynestack.mpspdz.integration.MpSpdzIntegrationUtils.WORD_WIDTH; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; @@ -41,15 +39,14 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import lombok.SneakyThrows; -import org.hamcrest.CoreMatchers; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.*; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class DefaultAmphoraClientTest { +@ExtendWith(MockitoExtension.class) +class DefaultAmphoraClientTest { private final String testUri = "https://dev.bar.com"; private final String testUri2 = "https://dev.foo.com"; private final List testServiceUris = @@ -67,7 +64,7 @@ public class DefaultAmphoraClientTest { private MpSpdzIntegrationUtils spdzUtil; - @Before + @BeforeEach public void setUp() { spdzUtil = MpSpdzIntegrationUtils.of( @@ -87,7 +84,7 @@ public void setUp() { @SneakyThrows @Test - public void givenBuilderConfiguration_whenCreatingClient_thenInstantiateAccordingly() { + void givenBuilderConfiguration_whenCreatingClient_thenInstantiateAccordingly() { List expectedServiceUriList = Arrays.asList( new AmphoraServiceUri("https://testUri:80"), @@ -161,7 +158,7 @@ private DefaultAmphoraClientBuilder getMockedDefaultAmphoraClientBuilder( @SneakyThrows @Test - public void givenInvalidCertFile_whenCreatingClient_thenThrowException() { + void givenInvalidCertFile_whenCreatingClient_thenThrowException() { CsHttpClientException expectedException = new CsHttpClientException("Expectedly failed"); DefaultAmphoraClientBuilder mockedDefaultAmphoraClientBuilder = mock(DefaultAmphoraClientBuilder.class); @@ -192,7 +189,7 @@ public void givenInvalidCertFile_whenCreatingClient_thenThrowException() { @SneakyThrows @Test - public void givenSecretsOfVariousSize_whenSharingAndRecombining_thenRecoverInitialData() { + void givenSecretsOfVariousSize_whenSharingAndRecombining_thenRecoverInitialData() { ArgumentCaptor>> requestCaptor = ArgumentCaptor.forClass(List.class); Map> uriResponseMap = getSuccessUriResponseMap(); @@ -206,7 +203,6 @@ public void givenSecretsOfVariousSize_whenSharingAndRecombining_thenRecoverIniti Map inputMaskShares = getInputMaskShares(secretSize); when(amphoraCommunicationClient.download(anyList(), eq(TupleList.class))) .thenReturn(TestUtils.wrap(inputMaskShares)); - when(amphoraCommunicationClient.upload(anyList(), eq(UUID.class))).thenReturn(uriResponseMap); UUID storeResult = amphoraClient.createSecret(getObject(secrets)); assertNotNull(storeResult); verify(amphoraCommunicationClient, times(1)).upload(requestCaptor.capture(), any()); @@ -239,7 +235,7 @@ public void givenSecretsOfVariousSize_whenSharingAndRecombining_thenRecoverIniti @SneakyThrows @Test - public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClientException() { + void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClientException() { Map> uriResponseMap = getErrorUriResponseMap(); when(amphoraCommunicationClient.download(anyList(), eq(TupleList.class))) .thenReturn(TestUtils.wrap(getInputMaskShares(1))); @@ -250,16 +246,13 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie () -> amphoraClient.createSecret( getObject(new BigInteger[] {BigInteger.valueOf(secret)}))); - assertThat( - actualAce.getMessage(), - CoreMatchers.endsWith( - String.format(REQUEST_FOR_ENDPOINT_FAILED_EXCEPTION_MSG, testUri, 500))); + assertThat(actualAce.getMessage()) + .endsWith(String.format(REQUEST_FOR_ENDPOINT_FAILED_EXCEPTION_MSG, testUri, 500)); } @SneakyThrows @Test - public void - givenOutPutDeliveryObjectsOfVariousSize_whenDownloadingObject_thenReturnExpectedContent() { + void givenOutputDeliveryObjectsOfVariousSize_whenDownloadingObject_thenReturnExpectedContent() { for (int i = 0; i < 100; i++) { int secretSize = random.nextInt(1000) + 1; // make sure it is no 0 BigInteger[] secrets = @@ -272,14 +265,13 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie .thenReturn(TestUtils.wrap(getOutputDeliveryObjectsForSecrets(testSecretId, secrets))); Secret result = amphoraClient.getSecret(testSecretId); assertEquals(secretSize, result.getData().length); - assertThat(Arrays.asList(result.getData()), CoreMatchers.hasItems(secrets)); + assertThat(result.getData()).containsExactly(secrets); } } @SneakyThrows @Test - public void - givenDownloadDataFromOnePlayerFails_whenDownloadingObject_thenThrowAmphoraClientException() { + void givenDownloadDataFromOnePlayerFails_whenDownloadingObject_thenThrowAmphoraClientException() { BigInteger[] secrets = new BigInteger[] {BigInteger.valueOf(42), BigInteger.valueOf(24)}; Map> results = TestUtils.wrap(getOutputDeliveryObjectsForSecrets(testSecretId, secrets)); @@ -290,25 +282,23 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie .thenReturn(results); AmphoraClientException ace = assertThrows(AmphoraClientException.class, () -> amphoraClient.getSecret(testSecretId)); - assertThat( - ace.getMessage(), CoreMatchers.startsWith("Error(s) occurred while processing responses")); - assertThat(ace.getMessage(), CoreMatchers.containsString("Call failed")); + assertThat(ace.getMessage()).startsWith("Error(s) occurred while processing responses"); + assertThat(ace.getMessage()).contains("Call failed"); } @SneakyThrows @Test - public void - givenSuccessfulRequest_whenListingObjects_thenConstructExpectedRequestAndReturnResult() { + void givenSuccessfulRequest_whenListingObjects_thenConstructExpectedRequestAndReturnResult() { MetadataPage metadataPage = getObjectMetadataPage(); when(amphoraCommunicationClient.download(any(RequestParameters.class), eq(MetadataPage.class))) .thenReturn(Try.success(metadataPage)); List secrets = amphoraClient.getSecrets(); - assertThat(secrets, is(equalTo(metadataPage.getContent()))); + assertEquals(metadataPage.getContent(), secrets); } @SneakyThrows @Test - public void + void givenSuccessfulRequest_whenListingObjectsWithEqualsFilter_thenConstructExpectedRequestAndReturnResult() { MetadataPage metadataPage = getObjectMetadataPage(); String key = "key"; @@ -334,12 +324,12 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie argThat( (ArgumentMatcher) r -> r.getUri().toString().equals(uriString)), eq(MetadataPage.class)); - assertThat(secrets, is(equalTo(metadataPage.getContent()))); + assertEquals(metadataPage.getContent(), secrets); } @SneakyThrows @Test - public void + void givenSuccessfulRequest_whenListingObjectsWithLessThanFilter_thenConstructExpectedRequestAndReturnResult() { MetadataPage metadataPage = getObjectMetadataPage(); String key = "key"; @@ -365,12 +355,12 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie argThat( (ArgumentMatcher) r -> r.getUri().toString().equals(uriString)), eq(MetadataPage.class)); - assertThat(secrets, is(equalTo(metadataPage.getContent()))); + assertEquals(metadataPage.getContent(), secrets); } @SneakyThrows @Test - public void + void givenSuccessfulRequest_whenListingObjectsWithTwoFilters_thenConstructExpectedRequestAndReturnResult() { MetadataPage metadataPage = getObjectMetadataPage(); String key1 = "key"; @@ -403,12 +393,12 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie argThat( (ArgumentMatcher) r -> r.getUri().toString().equals(uriString)), eq(MetadataPage.class)); - assertThat(secrets, is(equalTo(metadataPage.getContent()))); + assertEquals(metadataPage.getContent(), secrets); } @SneakyThrows @Test - public void + void givenSuccessfulRequest_whenListingObjectsWithFilterAndEmptyValue_thenConstructExpectedRequestAndReturnResult() { MetadataPage metadataPage = getObjectMetadataPage(); String key1 = "key"; @@ -441,12 +431,12 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie argThat( (ArgumentMatcher) r -> r.getUri().toString().equals(uriString)), eq(MetadataPage.class)); - assertThat(secrets, is(equalTo(metadataPage.getContent()))); + assertEquals(metadataPage.getContent(), secrets); } @SneakyThrows @Test - public void + void givenSuccessfulRequest_whenListingObjectsWithPagination_thenConstructExpectedRequestAndReturnResult() { MetadataPage metadataPage = getObjectMetadataPage(); ArrayList filters = new ArrayList<>(); @@ -474,12 +464,12 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie argThat( (ArgumentMatcher) r -> r.getUri().toString().equals(uriString)), eq(MetadataPage.class)); - assertThat(secrets.getContent(), is(equalTo(metadataPage.getContent()))); + assertEquals(metadataPage.getContent(), secrets.getContent()); } @SneakyThrows @Test - public void + void givenSuccessfulRequest_whenListingObjectsWithPaginationAndSorting_thenConstructExpectedRequestAndReturnResult() { MetadataPage metadataPage = getObjectMetadataPage(); ArrayList filters = new ArrayList<>(); @@ -521,12 +511,12 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie argThat( (ArgumentMatcher) r -> r.getUri().toString().equals(uriString)), eq(MetadataPage.class)); - assertThat(secrets.getContent(), is(equalTo(metadataPage.getContent()))); + assertEquals(metadataPage.getContent(), secrets.getContent()); } @SneakyThrows @Test - public void + void givenSuccessfulRequest_whenListingObjectsWithSorting_thenConstructExpectedRequestAndReturnResult() { MetadataPage metadataPage = getObjectMetadataPage(); String property = "key1"; @@ -553,12 +543,12 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie argThat( (ArgumentMatcher) r -> r.getUri().toString().equals(uriString)), eq(MetadataPage.class)); - assertThat(secrets, is(equalTo(metadataPage.getContent()))); + assertEquals(metadataPage.getContent(), secrets); } @SneakyThrows @Test - public void + void givenSuccessfulRequest_whenListingObjectsWithFilterAndSorting_thenConstructExpectedRequestAndReturnResult() { MetadataPage metadataPage = getObjectMetadataPage(); ArrayList filters = new ArrayList<>(); @@ -595,12 +585,12 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie argThat( (ArgumentMatcher) r -> r.getUri().toString().equals(uriString)), eq(MetadataPage.class)); - assertThat(secrets, is(equalTo(metadataPage.getContent()))); + assertEquals(metadataPage.getContent(), secrets); } @SneakyThrows @Test - public void + void givenSuccessfulRequest_whenListingObjectsWithFiltersAndPaginationAndSorting_thenConstructExpectedRequestAndReturnResult() { MetadataPage metadataPage = getObjectMetadataPage(); ArrayList filters = new ArrayList<>(); @@ -649,12 +639,12 @@ public void givenUploadingMaskedInputFails_whenCreateObject_thenThrowAmphoraClie argThat( (ArgumentMatcher) r -> r.getUri().toString().equals(uriString)), eq(MetadataPage.class)); - assertThat(secrets.getContent(), is(equalTo(metadataPage.getContent()))); + assertEquals(metadataPage.getContent(), secrets.getContent()); } @SneakyThrows @Test - public void givenSuccessfulRequest_whenListTags_thenReturnExpectedResult() { + void givenSuccessfulRequest_whenListTags_thenReturnExpectedResult() { Tag[] tagArray = getTags().toArray(new Tag[0]); ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(RequestParameters.class); @@ -663,14 +653,14 @@ public void givenSuccessfulRequest_whenListTags_thenReturnExpectedResult() { List result = amphoraClient.getTags(testSecretId); String expectedPath = testServiceUris.get(0).getSecretShareResourceTagsUri(testSecretId).getPath(); - assertThat(requestCaptor.getValue().getUri().getPath(), is(equalTo(expectedPath))); - assertThat(result.size(), is(equalTo(getTags().size()))); - assertThat(result.get(0), is(equalTo(getTags().get(0)))); - assertThat(result.get(1), is(equalTo(getTags().get(1)))); + assertEquals(expectedPath, requestCaptor.getValue().getUri().getPath()); + assertEquals(getTags().size(), result.size()); + assertEquals(getTags().get(0), result.get(0)); + assertEquals(getTags().get(1), result.get(1)); } @Test - public void givenCommunicationClientFails_whenGetTag_thenThrowAmphoraClientException() { + void givenCommunicationClientFails_whenGetTag_thenThrowAmphoraClientException() { String expectedRandomKey = "tagKey"; when(amphoraCommunicationClient.download(any(RequestParameters.class), eq(Tag.class))) .thenReturn(Try.failure(new RuntimeException())); @@ -686,21 +676,21 @@ public void givenCommunicationClientFails_whenGetTag_thenThrowAmphoraClientExcep @SneakyThrows @Test - public void givenSuccessfulRequest_whenCreateTag_thenExecuteExpectedRequest() { + void givenSuccessfulRequest_whenCreateTag_thenExecuteExpectedRequest() { when(amphoraCommunicationClient.upload(requestParamsWithBodyCaptor.capture(), eq(URI.class))) .thenReturn(getSuccessUriResponseMap()); amphoraClient.createTag(testSecretId, testTag); String expectedPath = testServiceUris.get(0).getSecretShareResourceTagsUri(testSecretId).getPath(); List> actualParams = requestParamsWithBodyCaptor.getValue(); - assertThat(actualParams.size(), is(equalTo(testServiceUris.size()))); + assertEquals(testServiceUris.size(), actualParams.size()); assertTrue(actualParams.stream().allMatch(r -> r.getBody().equals(testTag))); - assertThat(actualParams.get(0).getUri().getPath(), is(equalTo(expectedPath))); - assertThat(actualParams.get(1).getUri().getPath(), is(equalTo(expectedPath))); + assertEquals(expectedPath, actualParams.get(0).getUri().getPath()); + assertEquals(expectedPath, actualParams.get(1).getUri().getPath()); } @Test - public void givenRequestReturnsFailure_whenCreateTag_thenThrowAmphoraClientException() { + void givenRequestReturnsFailure_whenCreateTag_thenThrowAmphoraClientException() { when(amphoraCommunicationClient.upload( argThat( (ArgumentMatcher>>) @@ -710,15 +700,13 @@ public void givenRequestReturnsFailure_whenCreateTag_thenThrowAmphoraClientExcep AmphoraClientException actualAce = assertThrows( AmphoraClientException.class, () -> amphoraClient.createTag(testSecretId, testTag)); - assertThat( - actualAce.getMessage(), - CoreMatchers.endsWith( - String.format(REQUEST_FOR_ENDPOINT_FAILED_EXCEPTION_MSG, testUri, 500))); + assertThat(actualAce.getMessage()) + .endsWith(String.format(REQUEST_FOR_ENDPOINT_FAILED_EXCEPTION_MSG, testUri, 500)); } @SneakyThrows @Test - public void givenSuccessfulRequest_whenOverwriteTags_thenPerformExpectedRequest() { + void givenSuccessfulRequest_whenOverwriteTags_thenPerformExpectedRequest() { List tags = new ArrayList<>(); tags.add(testTag); amphoraClient.overwriteTags(testSecretId, tags); @@ -726,14 +714,14 @@ public void givenSuccessfulRequest_whenOverwriteTags_thenPerformExpectedRequest( String expectedPath = testServiceUris.get(0).getSecretShareResourceTagsUri(testSecretId).getPath(); List> actualParams = requestParamsWithBodyCaptor.getValue(); - assertThat(actualParams.size(), is(equalTo(testServiceUris.size()))); - assertThat(actualParams.get(0).getUri().getPath(), is(equalTo(expectedPath))); - assertThat(actualParams.get(1).getUri().getPath(), is(equalTo(expectedPath))); + assertEquals(testServiceUris.size(), actualParams.size()); + assertEquals(expectedPath, actualParams.get(0).getUri().getPath()); + assertEquals(expectedPath, actualParams.get(1).getUri().getPath()); } @SneakyThrows @Test - public void givenSuccessfulRequest_whenGetTag_thenReturnExpectedResult() { + void givenSuccessfulRequest_whenGetTag_thenReturnExpectedResult() { String tagKey = testTag.getKey(); ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(RequestParameters.class); @@ -742,13 +730,13 @@ public void givenSuccessfulRequest_whenGetTag_thenReturnExpectedResult() { Tag result = amphoraClient.getTag(testSecretId, tagKey); String expectedPath = testServiceUris.get(0).getSecretShareResourceUriTagResource(testSecretId, tagKey).getPath(); - assertThat(requestCaptor.getValue().getUri().getPath(), is(equalTo(expectedPath))); - assertThat(result, is(equalTo(testTag))); + assertEquals(expectedPath, requestCaptor.getValue().getUri().getPath()); + assertEquals(testTag, result); } @SneakyThrows @Test - public void givenSuccessfulRequest_whenUpdateTag_thenPerformExpectedRequest() { + void givenSuccessfulRequest_whenUpdateTag_thenPerformExpectedRequest() { amphoraClient.updateTag(testSecretId, testTag); verify(amphoraCommunicationClient, times(1)).update(requestParamsWithBodyCaptor.capture()); String expectedPath = @@ -757,27 +745,27 @@ public void givenSuccessfulRequest_whenUpdateTag_thenPerformExpectedRequest() { .getSecretShareResourceUriTagResource(testSecretId, testTag.getKey()) .getPath(); List> actualParams = requestParamsWithBodyCaptor.getValue(); - assertThat(actualParams.size(), is(equalTo(testServiceUris.size()))); - assertThat(actualParams.get(0).getUri().getPath(), is(equalTo(expectedPath))); - assertThat(actualParams.get(1).getUri().getPath(), is(equalTo(expectedPath))); + assertEquals(testServiceUris.size(), actualParams.size()); + assertEquals(expectedPath, actualParams.get(0).getUri().getPath()); + assertEquals(expectedPath, actualParams.get(1).getUri().getPath()); } @SneakyThrows @Test - public void givenSuccessfulRequest_whenDeleteTag_thenPerformExpectedRequest() { + void givenSuccessfulRequest_whenDeleteTag_thenPerformExpectedRequest() { String tagKey = testTag.getKey(); ArgumentCaptor> requestCaptor = ArgumentCaptor.forClass(List.class); amphoraClient.deleteTag(testSecretId, tagKey); verify(amphoraCommunicationClient, times(1)).delete(requestCaptor.capture()); String expectedPath = testServiceUris.get(0).getSecretShareResourceUriTagResource(testSecretId, tagKey).getPath(); - assertThat(requestCaptor.getValue().size(), is(equalTo(testServiceUris.size()))); - assertThat(requestCaptor.getValue().get(0).getUri().getPath(), is(equalTo(expectedPath))); - assertThat(requestCaptor.getValue().get(1).getUri().getPath(), is(equalTo(expectedPath))); + assertEquals(testServiceUris.size(), requestCaptor.getValue().size()); + assertEquals(expectedPath, requestCaptor.getValue().get(0).getUri().getPath()); + assertEquals(expectedPath, requestCaptor.getValue().get(1).getUri().getPath()); } @Test - public void givenRequestReturnsFailure_whenDeleteTag_thenThrowAmphoraClientException() { + void givenRequestReturnsFailure_whenDeleteTag_thenThrowAmphoraClientException() { String expectedErrorDetails = "Secret Not found"; when(amphoraCommunicationClient.delete(any())) .thenReturn( @@ -785,11 +773,9 @@ public void givenRequestReturnsFailure_whenDeleteTag_thenThrowAmphoraClientExcep Try.failure(new AmphoraClientException(expectedErrorDetails)))); AmphoraClientException actualAce = assertThrows(AmphoraClientException.class, () -> amphoraClient.deleteSecret(testSecretId)); - assertThat( - actualAce.getMessage(), - CoreMatchers.allOf( - CoreMatchers.startsWith("At least one request has failed"), - CoreMatchers.containsString(expectedErrorDetails))); + assertThat(actualAce.getMessage()) + .startsWith("At least one request has failed") + .contains(expectedErrorDetails); } @SneakyThrows diff --git a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraInterVcpClientTest.java b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraInterVcpClientTest.java index c996ec3..b94b11b 100644 --- a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraInterVcpClientTest.java +++ b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraInterVcpClientTest.java @@ -1,14 +1,14 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 */ package io.carbynestack.amphora.client; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; @@ -24,16 +24,15 @@ import java.util.*; import java.util.stream.Collectors; import lombok.SneakyThrows; -import org.hamcrest.CoreMatchers; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.MockedStatic; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class DefaultAmphoraInterVcpClientTest { +@ExtendWith(MockitoExtension.class) +class DefaultAmphoraInterVcpClientTest { private final String testUrl1 = "https://amphora.carbynestack.io:8080"; private final String testUrl2 = "https://amphora.carbynestack.io:8081"; private final UUID testOperationId = UUID.fromString("72753ecc-464f-42c5-954c-9efa7a5b886c"); @@ -45,14 +44,14 @@ public class DefaultAmphoraInterVcpClientTest { private final List amphoraServiceUris = Arrays.asList(new AmphoraServiceUri(testUrl1), new AmphoraServiceUri(testUrl2)); - @Before + @BeforeEach public void setUp() { this.amphoraInterVcpClient = new DefaultAmphoraInterVcpClient(amphoraServiceUris, amphoraCommunicationClient); } @Test - public void givenNoServiceUriDefined_whenBuildingInterVcClient_thenThrowException() { + void givenNoServiceUriDefined_whenBuildingInterVcClient_thenThrowException() { try (MockedStatic communicationClientMockedStatic = mockStatic(AmphoraCommunicationClient.class)) { DefaultAmphoraInterVcpClient.DefaultAmphoraInterVcpClientBuilder clientBuilder = @@ -65,7 +64,7 @@ public void givenNoServiceUriDefined_whenBuildingInterVcClient_thenThrowExceptio @SneakyThrows @Test - public void givenValidExchangeObject_whenOpeningValues_thenSucceed() { + void givenValidExchangeObject_whenOpeningValues_thenSucceed() { MultiplicationExchangeObject exchangeObject = getMultiplicationExchangeObject(testOperationId); List> params = @@ -86,7 +85,7 @@ public void givenValidExchangeObject_whenOpeningValues_thenSucceed() { } @Test - public void givenOnePlayerCannotBeReached_whenOpeningValues_thenThrowException() { + void givenOnePlayerCannotBeReached_whenOpeningValues_thenThrowException() { MultiplicationExchangeObject exchangeObject = getMultiplicationExchangeObject(testOperationId); List> params = @@ -108,7 +107,7 @@ public void givenOnePlayerCannotBeReached_whenOpeningValues_thenThrowException() } @Test - public void givenOnePlayerRespondsUnsuccessful_whenOpeningValues_thenThrowException() { + void givenOnePlayerRespondsUnsuccessful_whenOpeningValues_thenThrowException() { MultiplicationExchangeObject exchangeObject = getMultiplicationExchangeObject(testOperationId); List> params = @@ -130,11 +129,11 @@ public void givenOnePlayerRespondsUnsuccessful_whenOpeningValues_thenThrowExcept } @Test - public void givenMissingOperationId_whenOpeningValues_thenThrowException() { + void givenMissingOperationId_whenOpeningValues_thenThrowException() { MultiplicationExchangeObject exchangeObject = getMultiplicationExchangeObject(null); NullPointerException npe = assertThrows(NullPointerException.class, () -> amphoraInterVcpClient.open(exchangeObject)); - assertThat(npe.getMessage(), CoreMatchers.containsString("OperationId must not be null")); + assertThat(npe.getMessage()).contains("OperationId must not be null"); verify(amphoraCommunicationClient, never()).upload(anyList(), any()); } diff --git a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraIntraVcpClientTest.java b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraIntraVcpClientTest.java index a2cf881..e5b82b0 100644 --- a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraIntraVcpClientTest.java +++ b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/DefaultAmphoraIntraVcpClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -8,9 +8,9 @@ import static io.carbynestack.amphora.client.TestData.getTags; import static io.carbynestack.amphora.common.rest.AmphoraRestApiEndpoints.SECRET_SHARES_ENDPOINT; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; @@ -28,16 +28,15 @@ import java.util.UUID; import lombok.SneakyThrows; import org.apache.commons.lang3.ArrayUtils; -import org.hamcrest.CoreMatchers; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.MockedStatic; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class DefaultAmphoraIntraVcpClientTest { +@ExtendWith(MockitoExtension.class) +class DefaultAmphoraIntraVcpClientTest { private final String testUrl = "https://amphora.carbynestack.io"; private final UUID testSecretId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); @@ -51,7 +50,7 @@ public class DefaultAmphoraIntraVcpClientTest { private final Random rnd = new Random(42); - @Before + @BeforeEach public void setUp() { spdzUtil = MpSpdzIntegrationUtils.of( @@ -63,21 +62,20 @@ public void setUp() { } @Test - public void givenNoServiceUriDefined_whenBuildingInterVcClient_thenThrowException() { + void givenNoServiceUriDefined_whenBuildingInterVcpClient_thenThrowException() { try (MockedStatic communicationClientMockedStatic = mockStatic(AmphoraCommunicationClient.class)) { DefaultAmphoraIntraVcpClient.DefaultAmphoraIntraVcpClientBuilder clientBuilder = DefaultAmphoraIntraVcpClient.Builder(); NullPointerException actualNpe = - assertThrows(NullPointerException.class, () -> clientBuilder.build()); - assertThat( - actualNpe.getMessage(), CoreMatchers.containsString("Service URI must not be null")); + assertThrows(NullPointerException.class, clientBuilder::build); + assertThat(actualNpe.getMessage()).contains("Service URI must not be null"); } } @SneakyThrows @Test - public void givenShareIsValid_whenUploadSecretShare_thenSucceed() { + void givenShareIsValid_whenUploadSecretShare_thenSucceed() { URI expectedUri = URI.create(testUrl + SECRET_SHARES_ENDPOINT + "/" + testSecretId); SecretShare secretShare = getSecretShare(testSecretId); when(amphoraCommunicationClient.upload( @@ -90,7 +88,7 @@ public void givenShareIsValid_whenUploadSecretShare_thenSucceed() { @SneakyThrows @Test - public void givenIdIsValid_whenDownloadingSecretShare_thenReturnSecretShare() { + void givenIdIsValid_whenDownloadingSecretShare_thenReturnSecretShare() { SecretShare secretShare = getSecretShare(testSecretId); when(amphoraCommunicationClient.download( RequestParameters.of( @@ -101,15 +99,15 @@ public void givenIdIsValid_whenDownloadingSecretShare_thenReturnSecretShare() { } @Test - public void givenIdIsNull_whenDownloadingSecretShare_thenThrowException() { + void givenIdIsNull_whenDownloadingSecretShare_thenThrowException() { NullPointerException npe = assertThrows(NullPointerException.class, () -> amphoraIntraVcpClient.getSecretShare(null)); - assertThat(npe.getMessage(), CoreMatchers.containsString("SecretId must not be null")); + assertThat(npe.getMessage()).contains("SecretId must not be null"); verify(amphoraCommunicationClient, never()).download(any(RequestParameters.class), any()); } @Test - public void givenSecretShareWithIdDoesNotExist_whenDownloadingSecretShare_thenThrowException() { + void givenSecretShareWithIdDoesNotExist_whenDownloadingSecretShare_thenThrowException() { when(amphoraCommunicationClient.download( RequestParameters.of( amphoraServiceUri.getS2SSecretShareResourceUri(testSecretId), ImmutableList.of()), diff --git a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/SecretShareUtilTest.java b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/SecretShareUtilTest.java index 7763fcf..c0bea80 100644 --- a/amphora-java-client/src/test/java/io/carbynestack/amphora/client/SecretShareUtilTest.java +++ b/amphora-java-client/src/test/java/io/carbynestack/amphora/client/SecretShareUtilTest.java @@ -1,13 +1,14 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 */ package io.carbynestack.amphora.client; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertThrows; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; import io.carbynestack.amphora.common.exceptions.SecretVerificationException; import java.math.BigInteger; @@ -15,10 +16,9 @@ import java.util.Random; import java.util.stream.Collectors; import java.util.stream.IntStream; -import org.hamcrest.CoreMatchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SecretShareUtilTest { +class SecretShareUtilTest { private final Random rnd = new Random(42); private final SecretShareUtil secretShareUtil = @@ -28,7 +28,7 @@ public class SecretShareUtilTest { new BigInteger("133854242216446749056083838363708373830")); @Test - public void givenAllValid_whenVerifyingSecrets_thenDontThrowException() { + void givenAllValid_whenVerifyingSecrets_thenDontThrowException() { int numberOfValues = 5; List secrets = IntStream.range(0, numberOfValues) @@ -50,11 +50,11 @@ public void givenAllValid_whenVerifyingSecrets_thenDontThrowException() { IntStream.range(0, numberOfValues) .mapToObj(i -> vs.get(i).multiply(rs.get(i))) .collect(Collectors.toList()); - secretShareUtil.verifySecrets(secrets, rs, us, vs, ws); + assertDoesNotThrow(() -> secretShareUtil.verifySecrets(secrets, rs, us, vs, ws)); } @Test - public void givenWsContainingInvalidValue_whenVerifyingSecrets_thenThrowException() { + void givenWsContainingInvalidValue_whenVerifyingSecrets_thenThrowException() { int numberOfValues = 5; List secrets = IntStream.range(0, numberOfValues) @@ -81,6 +81,6 @@ public void givenWsContainingInvalidValue_whenVerifyingSecrets_thenThrowExceptio assertThrows( SecretVerificationException.class, () -> secretShareUtil.verifySecrets(secrets, rs, us, vs, ws)); - assertThat(ove.getMessage(), CoreMatchers.startsWith("Verification of secret has failed")); + assertThat(ove.getMessage()).startsWith("Verification of secret has failed"); } } diff --git a/amphora-service/3RD-PARTY-LICENSES/ch.qos.reload4j_reload4j/LICENSE b/amphora-service/3RD-PARTY-LICENSES/ch.qos.reload4j_reload4j/LICENSE new file mode 100644 index 0000000..6279e52 --- /dev/null +++ b/amphora-service/3RD-PARTY-LICENSES/ch.qos.reload4j_reload4j/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2005 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents_httpcore/NOTICE b/amphora-service/3RD-PARTY-LICENSES/ch.qos.reload4j_reload4j/NOTICE similarity index 60% rename from amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents_httpcore/NOTICE rename to amphora-service/3RD-PARTY-LICENSES/ch.qos.reload4j_reload4j/NOTICE index 352aae7..5e6e39b 100644 --- a/amphora-common/3RD-PARTY-LICENSES/org.apache.httpcomponents_httpcore/NOTICE +++ b/amphora-service/3RD-PARTY-LICENSES/ch.qos.reload4j_reload4j/NOTICE @@ -1,6 +1,5 @@ - -Apache HttpCore -Copyright 2005-2022 The Apache Software Foundation +Apache log4j +Copyright 2007 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE b/amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE new file mode 100644 index 0000000..d226e89 --- /dev/null +++ b/amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-annotations/NOTICE @@ -0,0 +1,17 @@ +# Jackson JSON processor + +Jackson is a high-performance, Free/Open Source JSON processing library. +It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has +been in development since 2007. +It is currently developed by a community of developers. + +## Licensing + +Jackson 2.x core and extension components are licensed under Apache License 2.0 +To find the details that apply to this artifact see the accompanying LICENSE file. + +## Credits + +A list of contributors may be found from CREDITS(-2.x) file, which is included +in some artifacts (usually source distributions); but is always available +from the source code management (SCM) system project uses. diff --git a/amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-core/NOTICE b/amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-core/NOTICE new file mode 100644 index 0000000..d226e89 --- /dev/null +++ b/amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.core_jackson-core/NOTICE @@ -0,0 +1,17 @@ +# Jackson JSON processor + +Jackson is a high-performance, Free/Open Source JSON processing library. +It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has +been in development since 2007. +It is currently developed by a community of developers. + +## Licensing + +Jackson 2.x core and extension components are licensed under Apache License 2.0 +To find the details that apply to this artifact see the accompanying LICENSE file. + +## Credits + +A list of contributors may be found from CREDITS(-2.x) file, which is included +in some artifacts (usually source distributions); but is always available +from the source code management (SCM) system project uses. diff --git a/amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.datatype_jackson-datatype-jdk8/LICENSE.txt b/amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.datatype_jackson-datatype-jdk8/LICENSE similarity index 100% rename from amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.datatype_jackson-datatype-jdk8/LICENSE.txt rename to amphora-service/3RD-PARTY-LICENSES/com.fasterxml.jackson.datatype_jackson-datatype-jdk8/LICENSE diff --git a/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/LICENSE b/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/NOTICE b/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/NOTICE new file mode 100644 index 0000000..cb4f1ac --- /dev/null +++ b/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5-h2/NOTICE @@ -0,0 +1,6 @@ + +Apache HttpComponents Core HTTP/2 +Copyright 2005-2020 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/LICENSE b/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE b/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE new file mode 100644 index 0000000..78b44bf --- /dev/null +++ b/amphora-service/3RD-PARTY-LICENSES/org.apache.httpcomponents.core5_httpcore5/NOTICE @@ -0,0 +1,6 @@ + +Apache HttpComponents Core HTTP/1.1 +Copyright 2005-2020 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-api/NOTICE b/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-api/NOTICE index 63ef267..b9db92b 100644 --- a/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-api/NOTICE +++ b/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-api/NOTICE @@ -1,6 +1,6 @@ Apache Log4j API -Copyright 1999-2022 The Apache Software Foundation +Copyright 1999-2023 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-jul/NOTICE b/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-jul/NOTICE index 529da52..1edea3a 100644 --- a/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-jul/NOTICE +++ b/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-jul/NOTICE @@ -1,6 +1,6 @@ Apache Log4j JUL Adapter -Copyright 1999-2022 The Apache Software Foundation +Copyright 1999-2023 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-slf4j-impl/NOTICE b/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-slf4j-impl/NOTICE index f193203..7dee9d4 100644 --- a/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-slf4j-impl/NOTICE +++ b/amphora-service/3RD-PARTY-LICENSES/org.apache.logging.log4j_log4j-slf4j-impl/NOTICE @@ -1,6 +1,6 @@ Apache Log4j SLF4J Binding -Copyright 1999-2022 The Apache Software Foundation +Copyright 1999-2023 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/amphora-service/3RD-PARTY-LICENSES/org.slf4j_slf4j-reload4j/LICENSE.txt b/amphora-service/3RD-PARTY-LICENSES/org.slf4j_slf4j-reload4j/LICENSE.txt new file mode 100644 index 0000000..f687729 --- /dev/null +++ b/amphora-service/3RD-PARTY-LICENSES/org.slf4j_slf4j-reload4j/LICENSE.txt @@ -0,0 +1,21 @@ +Copyright (c) 2004-2022 QOS.ch Sarl (Switzerland) +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/amphora-service/3RD-PARTY-LICENSES/sbom.xml b/amphora-service/3RD-PARTY-LICENSES/sbom.xml index c78e8d4..11e0112 100644 --- a/amphora-service/3RD-PARTY-LICENSES/sbom.xml +++ b/amphora-service/3RD-PARTY-LICENSES/sbom.xml @@ -115,6 +115,32 @@ + + Apache HttpComponents Core HTTP/1.1 + org.apache.httpcomponents.core5 + httpcore5 + 5.1.3 + https://hc.apache.org/httpcomponents-core-5.1.x/5.1.3/httpcore5/ + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + + Apache HttpComponents Core HTTP/2 + org.apache.httpcomponents.core5 + httpcore5-h2 + 5.1.3 + https://hc.apache.org/httpcomponents-core-5.1.x/5.1.3/httpcore5-h2/ + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + Apache HttpCore org.apache.httpcomponents @@ -132,7 +158,7 @@ Apache Log4j API org.apache.logging.log4j log4j-api - 2.19.0 + 2.20.0 https://logging.apache.org/log4j/2.x/log4j-api/ @@ -145,7 +171,7 @@ Apache Log4j Core org.apache.logging.log4j log4j-core - 2.19.0 + 2.20.0 https://logging.apache.org/log4j/2.x/log4j-core/ @@ -158,7 +184,7 @@ Apache Log4j JUL Adapter org.apache.logging.log4j log4j-jul - 2.17.2 + 2.20.0 https://logging.apache.org/log4j/2.x/log4j-jul/ @@ -171,7 +197,7 @@ Apache Log4j SLF4J Binding org.apache.logging.log4j log4j-slf4j-impl - 2.19.0 + 2.20.0 https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/ @@ -247,7 +273,7 @@ castor-common io.carbynestack castor-common - 0.1-SNAPSHOT-4191841095-22-1721229 + 0.1-SNAPSHOT-4321261594-23-40a9faa Apache-2.0 @@ -259,7 +285,7 @@ castor-java-client io.carbynestack castor-java-client - 0.1-SNAPSHOT-4191841095-22-1721229 + 0.1-SNAPSHOT-4321261594-23-40a9faa Apache-2.0 @@ -483,7 +509,7 @@ Jackson datatype: jdk8 com.fasterxml.jackson.datatype jackson-datatype-jdk8 - 2.12.6 + 2.14.2 https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jdk8 @@ -496,7 +522,7 @@ Jackson datatype: JSR310 com.fasterxml.jackson.datatype jackson-datatype-jsr310 - 2.12.6 + 2.14.2 https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jsr310 @@ -509,12 +535,12 @@ Jackson-annotations com.fasterxml.jackson.core jackson-annotations - 2.12.6 - http://github.com/FasterXML/jackson + 2.14.2 + https://github.com/FasterXML/jackson The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt @@ -522,12 +548,12 @@ Jackson-core com.fasterxml.jackson.core jackson-core - 2.12.6 + 2.14.2 https://github.com/FasterXML/jackson-core The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt @@ -535,12 +561,12 @@ jackson-databind com.fasterxml.jackson.core jackson-databind - 2.12.6.1 - http://github.com/FasterXML/jackson + 2.14.2 + https://github.com/FasterXML/jackson The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt @@ -548,7 +574,7 @@ Jackson-module-parameter-names com.fasterxml.jackson.module jackson-module-parameter-names - 2.12.6 + 2.14.2 https://github.com/FasterXML/jackson-modules-java8/jackson-module-parameter-names @@ -724,7 +750,7 @@ JUL to SLF4J bridge org.slf4j jul-to-slf4j - 1.7.36 + 2.0.6 http://www.slf4j.org @@ -915,6 +941,19 @@ + + reload4j + ch.qos.reload4j + reload4j + 1.2.24 + https://reload4j.qos.ch + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + Simple XML (safe) com.carrotsearch.thirdparty @@ -942,15 +981,15 @@ - SnakeYAML - org.yaml - snakeyaml - 1.28 - http://www.snakeyaml.org + SLF4J Reload4j Binding + org.slf4j + slf4j-reload4j + 2.0.6 + http://reload4j.qos.ch - Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + MIT License + http://www.opensource.org/licenses/mit-license.php diff --git a/amphora-service/pom.xml b/amphora-service/pom.xml index ba70337..4d08f6b 100644 --- a/amphora-service/pom.xml +++ b/amphora-service/pom.xml @@ -37,13 +37,14 @@ 8.5.1 4.10.0 42.5.1 + 1.2.24 2.5.14 Hoxton.SR12 2.7.7 9.0.71 - 1.15.3 + 1.17.6 @@ -90,6 +91,42 @@ + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + ${jackson.version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson.version} + + + + com.fasterxml.jackson.module + jackson-module-parameter-names + ${jackson.version} + - junit - junit + org.mockito + mockito-inline test org.mockito - mockito-inline + mockito-junit-jupiter test @@ -230,7 +272,13 @@ org.testcontainers postgresql - ${testcontainer.postgresql.version} + ${testcontainer.version} + test + + + org.testcontainers + junit-jupiter + ${testcontainer.version} test @@ -254,7 +302,7 @@ ${project.basedir}/src/main/resources true - **/*.yml + **/*.properties banner.txt diff --git a/amphora-service/src/main/java/io/carbynestack/amphora/service/persistence/metadata/SecretEntity.java b/amphora-service/src/main/java/io/carbynestack/amphora/service/persistence/metadata/SecretEntity.java index c63d294..748e218 100644 --- a/amphora-service/src/main/java/io/carbynestack/amphora/service/persistence/metadata/SecretEntity.java +++ b/amphora-service/src/main/java/io/carbynestack/amphora/service/persistence/metadata/SecretEntity.java @@ -20,7 +20,8 @@ @Entity @Table(name = SecretEntity.TABLE_NAME) @EntityListeners(AuditingEntityListener.class) -@Data +@Getter +@Setter @Accessors(chain = true) @NoArgsConstructor(access = AccessLevel.PROTECTED) public class SecretEntity implements Serializable { diff --git a/amphora-service/src/main/java/io/carbynestack/amphora/service/persistence/metadata/TagEntity.java b/amphora-service/src/main/java/io/carbynestack/amphora/service/persistence/metadata/TagEntity.java index f986375..cbadf02 100644 --- a/amphora-service/src/main/java/io/carbynestack/amphora/service/persistence/metadata/TagEntity.java +++ b/amphora-service/src/main/java/io/carbynestack/amphora/service/persistence/metadata/TagEntity.java @@ -14,14 +14,16 @@ import java.util.*; import java.util.stream.Collectors; import javax.persistence.*; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; import lombok.experimental.Accessors; import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.util.CollectionUtils; @Entity @Table(name = TagEntity.TABLE_NAME) -@Data +@Getter +@Setter @Accessors(chain = true) @EntityListeners(AuditingEntityListener.class) public class TagEntity implements Serializable { diff --git a/amphora-service/src/main/resources/application-cache-redis.properties b/amphora-service/src/main/resources/application-cache-redis.properties new file mode 100644 index 0000000..bbceff5 --- /dev/null +++ b/amphora-service/src/main/resources/application-cache-redis.properties @@ -0,0 +1,11 @@ +# +# Copyright (c) 2023 - for information on the respective copyright owner +# see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. +# +# SPDX-License-Identifier: Apache-2.0 +# + +spring.config.activate.on-profile=cache-redis + +carbynestack.amphora.cache.host=${REDIS_HOST} +carbynestack.amphora.cache.port=${REDIS_PORT} diff --git a/amphora-service/src/main/resources/application-cache-redis.yml b/amphora-service/src/main/resources/application-cache-redis.yml deleted file mode 100644 index 6e89ea3..0000000 --- a/amphora-service/src/main/resources/application-cache-redis.yml +++ /dev/null @@ -1,10 +0,0 @@ -spring: - config: - activate: - on-profile: cache-redis - -carbynestack: - amphora: - cache: - host: ${REDIS_HOST} - port: ${REDIS_PORT} diff --git a/amphora-service/src/main/resources/application-entitystore-postgres.properties b/amphora-service/src/main/resources/application-entitystore-postgres.properties new file mode 100644 index 0000000..e0bcf83 --- /dev/null +++ b/amphora-service/src/main/resources/application-entitystore-postgres.properties @@ -0,0 +1,18 @@ +# +# Copyright (c) 2023 - for information on the respective copyright owner +# see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. +# +# SPDX-License-Identifier: Apache-2.0 +# + +spring.config.activate.on-profile=entitystore-postgres + +spring.datasource.driver-class-name=org.postgresql.Driver +spring.datasource.url=jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/amphora +spring.datasource.username=${DB_USER} +spring.datasource.password=${DB_PASSWORD:} +spring.jpa.database=postgresql +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect +spring.jpa.hibernate.connection.autocommit=true +spring.jpa.hibernate.ddl-auto=update +spring.jpa.hibernate.hbm2ddl.auto=update diff --git a/amphora-service/src/main/resources/application-entitystore-postgres.yml b/amphora-service/src/main/resources/application-entitystore-postgres.yml deleted file mode 100644 index d5a13cd..0000000 --- a/amphora-service/src/main/resources/application-entitystore-postgres.yml +++ /dev/null @@ -1,19 +0,0 @@ -spring: - config: - activate: - on-profile: entitystore-postgres - - datasource: - driver-class-name: org.postgresql.Driver - url: jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/amphora - username: ${DB_USER} - password: ${DB_PASSWORD} - jpa: - database: postgresql - database-platform: org.hibernate.dialect.PostgreSQLDialect - hibernate: - connection: - autocommit: true - ddl-auto: update - hbm2ddl: - auto: update diff --git a/amphora-service/src/main/resources/application-k8s.properties b/amphora-service/src/main/resources/application-k8s.properties new file mode 100644 index 0000000..f144438 --- /dev/null +++ b/amphora-service/src/main/resources/application-k8s.properties @@ -0,0 +1,13 @@ +# +# Copyright (c) 2023 - for information on the respective copyright owner +# see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. +# +# SPDX-License-Identifier: Apache-2.0 +# + +# Configuration for profile docker. +spring.config.activate.on-profile=k8s + +logging.level.ROOT=INFO +logging.level.io.carbynestack=${LOG_LEVEL:INFO} +logging.level.org.springframework=${LOG_LEVEL:INFO} diff --git a/amphora-service/src/main/resources/application-k8s.yml b/amphora-service/src/main/resources/application-k8s.yml deleted file mode 100644 index 99f10f2..0000000 --- a/amphora-service/src/main/resources/application-k8s.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Configuration for profile docker. -spring: - config: - activate: - on-profile: k8s - -logging: - level: - ROOT: INFO - io.carbynestack: ${LOG_LEVEL:INFO} - org.springframework: INFO diff --git a/amphora-service/src/main/resources/application-secretsharestore-minio.properties b/amphora-service/src/main/resources/application-secretsharestore-minio.properties new file mode 100644 index 0000000..6d95afa --- /dev/null +++ b/amphora-service/src/main/resources/application-secretsharestore-minio.properties @@ -0,0 +1,13 @@ +# +# Copyright (c) 2023 - for information on the respective copyright owner +# see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. +# +# SPDX-License-Identifier: Apache-2.0 +# + +spring.config.activate.on-profile=secretsharestore-minio + +carbynestack.amphora.minio.endpoint=${MINIO_ENDPOINT} +carbynestack.amphora.minio.bucket=minio-amphora-bucket +carbynestack.amphora.minio.access-key=dummy-key +carbynestack.amphora.minio.secret-key=dummy-secret diff --git a/amphora-service/src/main/resources/application-secretsharestore-minio.yml b/amphora-service/src/main/resources/application-secretsharestore-minio.yml deleted file mode 100644 index 83d28e8..0000000 --- a/amphora-service/src/main/resources/application-secretsharestore-minio.yml +++ /dev/null @@ -1,12 +0,0 @@ -spring: - config: - activate: - on-profile: secretsharestore-minio - -carbynestack: - amphora: - minio: - endpoint: ${MINIO_ENDPOINT} - bucket: minio-amphora-bucket - access-key: dummy-key - secret-key: dummy-secret diff --git a/amphora-service/src/main/resources/application.properties b/amphora-service/src/main/resources/application.properties new file mode 100644 index 0000000..aa7c134 --- /dev/null +++ b/amphora-service/src/main/resources/application.properties @@ -0,0 +1,39 @@ +# +# Copyright (c) 2023 - for information on the respective copyright owner +# see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. +# +# SPDX-License-Identifier: Apache-2.0 +# + +spring.profiles.group.k8s=secretsharestore-minio,entitystore-postgres,cache-redis + +# Configuration of Acutator info endpoint +info.name="@project.name@" +info.description="@project.description@" +info.groupId="@project.groupId@" +info.artifactId="@project.artifactId@" +info.version="@project.version@" +info.apiVersion="@project.version@" + +# Actuator config +server.port=${AMPHORA_SERVICE_PORT:10000} +server.servlet.context-path=/ + +management.endpoints.web.exposure.include=info,health,prometheus + +carbynestack.spdz.mac-key=${MAC_KEY} +carbynestack.spdz.prime=${SPDZ_PRIME} +carbynestack.spdz.r=${SPDZ_R} +carbynestack.spdz.rInv=${SPDZ_R_INV} +carbynestack.amphora.vcPartners=${AMPHORA_VC_PARTNERS:} +carbynestack.amphora.openingTimeout=${AMPHORA_OPENING_TIMEOUT:5000} +carbynestack.amphora.playerId=${PLAYER_ID:0} +carbynestack.amphora.no-ssl-validation=${NO_SSL_VALIDATION:false} +# list of trusted certificates comma separated (absolute path) +carbynestack.amphora.trusted-certificates=${TRUSTED_CERTIFICATES:} +carbynestack.amphora.cache.input-mask-store=input-mask-store +carbynestack.amphora.cache.interim-value-store=interim-value-store +carbynestack.castor.no-ssl-validation=${NO_SSL_VALIDATION:false} +# list of trusted certificates comma separated (absolute path) +carbynestack.castor.trusted-certificates=${TRUSTED_CERTIFICATES:} +carbynestack.castor.service-uri=${CASTOR_SERVICE_URI:} diff --git a/amphora-service/src/main/resources/application.yml b/amphora-service/src/main/resources/application.yml deleted file mode 100644 index 54cc9dc..0000000 --- a/amphora-service/src/main/resources/application.yml +++ /dev/null @@ -1,45 +0,0 @@ -spring: - profiles: - group: - k8s: secretsharestore-minio, entitystore-postgres, cache-redis - -# Configuration of Acutator info endpoint -info: - name: "@project.name@" - description: "@project.description@" - groupId: "@project.groupId@" - artifactId: "@project.artifactId@" - version: "@project.version@" - apiVersion: "@project.version@" - -# Actuator config -server: - port: ${AMPHORA_SERVICE_PORT:10000} - servlet: - context-path: / - -management: - endpoints: - web: - exposure: - include: info,health,prometheus - -carbynestack: - spdz: - mac-key: ${MAC_KEY:""} - prime: ${SPDZ_PRIME:""} - r: ${SPDZ_R:""} - rInv: ${SPDZ_R_INV:""} - amphora: - vcPartners: ${AMPHORA_VC_PARTNERS:} - openingTimeout: ${AMPHORA_OPENING_TIMEOUT:5000} - playerId: ${PLAYER_ID:0} - no-ssl-validation: ${NO_SSL_VALIDATION:false} - trusted-certificates: ${TRUSTED_CERTIFICATES:} # list of trusted certificates comma separated (absolute path) - cache: - input-mask-store: "input-mask-store" - interim-value-store: "interim-value-store" - castor: - no-ssl-validation: ${NO_SSL_VALIDATION:false} - trusted-certificates: ${TRUSTED_CERTIFICATES:} # list of trusted certificates comma separated (absolute path) - service-uri: ${CASTOR_SERVICE_URI} diff --git a/amphora-service/src/main/resources/banner.txt b/amphora-service/src/main/resources/banner.txt index c1c6751..c01c801 100644 --- a/amphora-service/src/main/resources/banner.txt +++ b/amphora-service/src/main/resources/banner.txt @@ -6,6 +6,6 @@ $$$$$$$$$$$$$ \__,_|_| |_| |_| .__/|_| |_|\___/|_| \__,_| $$OOOOOOOOO$$ |_| $$$$$$$$$$$ - OOOOOOOOO ${project.name} ${project.version} + OOOOOOOOO ${project.artifactId} ${project.version} OOOOO - OOOOOOO \ No newline at end of file + OOOOOOO diff --git a/amphora-service/src/main/resources/log4j.properties b/amphora-service/src/main/resources/log4j.properties new file mode 100644 index 0000000..f6b92b2 --- /dev/null +++ b/amphora-service/src/main/resources/log4j.properties @@ -0,0 +1,14 @@ +# +# Copyright (c) 2023 - for information on the respective copyright owner +# see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. +# +# SPDX-License-Identifier: Apache-2.0 +# + +log4j.rootLogger=WARN, stdout +log4j.logger.io.carbynestack=${env:LOG_LEVEL:-ERROR} +log4j.logger.org.springframework=${env:LOG_LEVEL:-ERROR} + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %5p [%8.8t] %-30.30c{1} : %m%n%x diff --git a/amphora-service/src/main/resources/log4j2.xml b/amphora-service/src/main/resources/log4j2.xml deleted file mode 100644 index 25e8d4d..0000000 --- a/amphora-service/src/main/resources/log4j2.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/AmphoraServiceSystemTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/AmphoraServiceSystemTest.java index 49d6b11..5ff6536 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/AmphoraServiceSystemTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/AmphoraServiceSystemTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -11,8 +11,8 @@ import static java.util.Arrays.asList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasItems; -import static org.junit.Assert.assertEquals; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; +import static org.springframework.test.util.AssertionErrors.assertEquals; import io.carbynestack.amphora.common.Metadata; import io.carbynestack.amphora.common.MetadataPage; @@ -30,37 +30,39 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.RandomUtils; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest( webEnvironment = RANDOM_PORT, classes = {AmphoraServiceApplication.class}) @ActiveProfiles(profiles = {"test"}) @Slf4j +@Testcontainers public class AmphoraServiceSystemTest { private final UUID testSecretId1 = UUID.fromString("82a73814-321c-4261-abcd-27c6c0ebfb26"); private final UUID testSecretId2 = UUID.fromString("82a73814-321c-4261-abcd-27c6c0ebfb27"); private final UUID testSecretId3 = UUID.fromString("82a73814-321c-4261-abcd-27c6c0ebfb28"); private final UUID testSecretId4 = UUID.fromString("82a73814-321c-4261-abcd-27c6c0ebfb29"); - @ClassRule + @Container public static ReusableRedisContainer reusableRedisContainer = ReusableRedisContainer.getInstance(); - @ClassRule + @Container public static ReusableMinioContainer reusableMinioContainer = ReusableMinioContainer.getInstance(); - @ClassRule + @Container public static ReusablePostgreSQLContainer reusablePostgreSQLContainer = ReusablePostgreSQLContainer.getInstance(); @@ -109,13 +111,13 @@ public class AmphoraServiceSystemTest { .tags(Collections.singletonList(Tag.builder().key("empty-value").value("").build())) .build(); - @Before + @BeforeEach public void setUp() { testEnvironment.clearAllData(); } @Test - public void givenSuccessfulRequest_whenPostSecretShares_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenPostSecretShares_thenReturnExpectedContent() { String expectedPath = INTRA_VCP_OPERATIONS_SEGMENT + SECRET_SHARES_ENDPOINT @@ -128,7 +130,7 @@ public void givenSuccessfulRequest_whenPostSecretShares_thenReturnExpectedConten } @Test - public void givenSuccessfulRequest_whenListSecrets_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenListSecrets_thenReturnExpectedContent() { createTestSecretShares(); MetadataPage response = restTemplate.getForObject(SECRET_SHARES_ENDPOINT, MetadataPage.class); assertEquals( @@ -139,7 +141,7 @@ public void givenSuccessfulRequest_whenListSecrets_thenReturnExpectedContent() { } @Test - public void + void givenSuccessfulRequest_whenListSecretsWithNumberComparisonFilter_thenReturnExpectedContent() { createTestSecretShares(); MetadataPage response = @@ -153,8 +155,7 @@ public void givenSuccessfulRequest_whenListSecrets_thenReturnExpectedContent() { } @Test - public void - givenSuccessfulRequest_whenListSecretsWithStringEqualFilter_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenListSecretsWithStringEqualFilter_thenReturnExpectedContent() { createTestSecretShares(); MetadataPage response = restTemplate.getForObject( @@ -167,7 +168,7 @@ public void givenSuccessfulRequest_whenListSecrets_thenReturnExpectedContent() { } @Test - public void + void givenSuccessfulRequest_whenListSecretsWithStringAndNumberComparisonFilters_thenReturnExpectedContent() { createTestSecretShares(); MetadataPage response = @@ -181,8 +182,7 @@ public void givenSuccessfulRequest_whenListSecrets_thenReturnExpectedContent() { } @Test - public void - givenSuccessfulRequest_whenListSecretsWithNPaginationConfig_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenListSecretsWithNPaginationConfig_thenReturnExpectedContent() { createTestSecretShares(); MetadataPage response = restTemplate.getForObject( @@ -196,7 +196,7 @@ public void givenSuccessfulRequest_whenListSecrets_thenReturnExpectedContent() { @SneakyThrows @Test - public void givenSuccessfulRequest_whenDeleteSecret_thenReturnRemoveAndDoNoLongerReturn() { + void givenSuccessfulRequest_whenDeleteSecret_thenReturnRemoveAndDoNoLongerReturn() { createTestSecretShares(); MetadataPage responsePreDel = restTemplate.getForObject(SECRET_SHARES_ENDPOINT, MetadataPage.class); @@ -216,7 +216,7 @@ public void givenSuccessfulRequest_whenDeleteSecret_thenReturnRemoveAndDoNoLonge @SneakyThrows @Test - public void givenUnknownSecretId_whenDeleteSecretShare_thenDoNotTouchOtherSecrets() { + void givenUnknownSecretId_whenDeleteSecretShare_thenDoNotTouchOtherSecrets() { createTestSecretShares(); MetadataPage responsePreDel = restTemplate.getForObject(SECRET_SHARES_ENDPOINT, MetadataPage.class); @@ -237,7 +237,7 @@ public void givenUnknownSecretId_whenDeleteSecretShare_thenDoNotTouchOtherSecret } @Test - public void givenSuccessfulRequest_whenListSecretsWithNSorting_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenListSecretsWithNSorting_thenReturnExpectedContent() { createTestSecretShares(); MetadataPage response = restTemplate.getForObject( diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/calculation/OutputDeliveryServiceTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/calculation/OutputDeliveryServiceTest.java index a215797..22cc1d8 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/calculation/OutputDeliveryServiceTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/calculation/OutputDeliveryServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -9,8 +9,8 @@ import static io.carbynestack.castor.common.entities.TupleType.INPUT_MASK_GFP; import static io.carbynestack.castor.common.entities.TupleType.MULTIPLICATION_TRIPLE_GFP; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*; import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream; @@ -43,15 +43,15 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; @Slf4j -@RunWith(MockitoJUnitRunner.class) -public class OutputDeliveryServiceTest { +@ExtendWith(MockitoExtension.class) +class OutputDeliveryServiceTest { private final MpSpdzIntegrationUtils spdzUtil = MpSpdzIntegrationUtils.of( new BigInteger("198766463529478683931867765928436695041"), @@ -197,11 +197,8 @@ private byte[] bigIntegerListToGfpByteArray(List input) { .toArray(Byte[]::new)); } - @Before + @BeforeEach public void setup() { - when(amphoraServicePropertiesMock.getPlayerId()).thenReturn(testPlayerId); - when(amphoraServicePropertiesMock.getVcPartners()).thenReturn(testVcPartners); - when(amphoraServicePropertiesMock.getOpeningTimeout()).thenReturn(10); outputDeliveryService = new OutputDeliveryService( amphoraServicePropertiesMock, @@ -213,7 +210,7 @@ public void setup() { @Test @SneakyThrows - public void given_FetchingTriplesFails_whenMultiplyingShares_thenThrowException() { + void given_FetchingTriplesFails_whenMultiplyingShares_thenThrowException() { when(castorIntraVcpClientMock.downloadTupleShares( expectedOperationId, MULTIPLICATION_TRIPLE_GFP, @@ -230,7 +227,7 @@ public void given_FetchingTriplesFails_whenMultiplyingShares_thenThrowException( @Test @SneakyThrows - public void givenDistributingValuesFails_whenMultiplyingShares_thenThrowException() { + void givenDistributingValuesFails_whenMultiplyingShares_thenThrowException() { when(castorIntraVcpClientMock.downloadTupleShares( expectedOperationId, MULTIPLICATION_TRIPLE_GFP, @@ -254,7 +251,10 @@ public void givenDistributingValuesFails_whenMultiplyingShares_thenThrowExceptio @Test @SneakyThrows - public void givenReceivingAllOpenedSharesFails_whenMultiplyingShares_thenThrowException() { + void givenReceivingAllOpenedSharesFails_whenMultiplyingShares_thenThrowException() { + when(amphoraServicePropertiesMock.getPlayerId()).thenReturn(testPlayerId); + when(amphoraServicePropertiesMock.getVcPartners()).thenReturn(testVcPartners); + when(amphoraServicePropertiesMock.getOpeningTimeout()).thenReturn(10); when(castorIntraVcpClientMock.downloadTupleShares( expectedOperationId, MULTIPLICATION_TRIPLE_GFP, @@ -284,7 +284,10 @@ public void givenReceivingAllOpenedSharesFails_whenMultiplyingShares_thenThrowEx @Test @SneakyThrows - public void givenSuccessfulRequest_whenMultiplyingShares_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenMultiplyingShares_thenReturnExpectedContent() { + when(amphoraServicePropertiesMock.getPlayerId()).thenReturn(testPlayerId); + when(amphoraServicePropertiesMock.getVcPartners()).thenReturn(testVcPartners); + when(amphoraServicePropertiesMock.getOpeningTimeout()).thenReturn(10); when(castorIntraVcpClientMock.downloadTupleShares( expectedOperationId, MULTIPLICATION_TRIPLE_GFP, @@ -309,7 +312,7 @@ public void givenSuccessfulRequest_whenMultiplyingShares_thenReturnExpectedConte @SneakyThrows @Test - public void + void givenCastorClientDoesNotReturnInputMasks_whenComputingOutputDeliveryObject_thenThrowException() { when(castorIntraVcpClientMock.downloadTupleShares( expectedRequestId, INPUT_MASK_GFP, testSecretShareDataSize * 2)) @@ -324,7 +327,7 @@ public void givenSuccessfulRequest_whenMultiplyingShares_thenReturnExpectedConte @SneakyThrows @Test - public void givenSuccessfulRequest_whenComputingOutputDeliveryObject_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenComputingOutputDeliveryObject_thenReturnExpectedContent() { final OutputDeliveryObject expectedOutputDeliveryObject = OutputDeliveryObject.builder() .secretId(SECRET_SHARE.getSecretId()) @@ -356,6 +359,9 @@ public void givenSuccessfulRequest_whenComputingOutputDeliveryObject_thenReturnE .tags(SECRET_SHARE.getTags()) .build(); + when(amphoraServicePropertiesMock.getPlayerId()).thenReturn(testPlayerId); + when(amphoraServicePropertiesMock.getVcPartners()).thenReturn(testVcPartners); + when(amphoraServicePropertiesMock.getOpeningTimeout()).thenReturn(10); when(castorIntraVcpClientMock.downloadTupleShares( expectedRequestId, INPUT_MASK_GFP, testSecretShareDataSize * 2)) .thenReturn(testInputMasks); diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/calculation/SecretShareUtilTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/calculation/SecretShareUtilTest.java index 45bc600..44512b5 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/calculation/SecretShareUtilTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/calculation/SecretShareUtilTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -7,8 +7,8 @@ package io.carbynestack.amphora.service.calculation; import static io.carbynestack.castor.common.entities.TupleType.INPUT_MASK_GFP; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import io.carbynestack.amphora.common.MaskedInput; import io.carbynestack.amphora.common.MaskedInputData; @@ -23,17 +23,17 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class SecretShareUtilTest { +class SecretShareUtilTest { private final UUID testSecretId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); private SpdzProperties spdzProperties; private SecretShareUtil secretShareUtil; private MpSpdzIntegrationUtils spdzUtil; - @Before + @BeforeEach public void prepare() { spdzProperties = new SpdzProperties(); spdzProperties.setPrime(new BigInteger("198766463529478683931867765928436695041")); @@ -46,7 +46,7 @@ public void prepare() { } @Test - public void + void givenLessInputMasksThanMaskedInput_whenConvertToSecretShare_thenThrowIllegalArgumentException() { List maskedInputDataList = new ArrayList<>(); maskedInputDataList.add(MaskedInputData.of(new byte[MpSpdzIntegrationUtils.WORD_WIDTH])); @@ -66,7 +66,7 @@ public void prepare() { } @Test - public void givenCorrectArguments_whenConvertToSecretShare_thenReturnExpectedResult() { + void givenCorrectArguments_whenConvertToSecretShare_thenReturnExpectedResult() { List tags = Arrays.asList( Tag.builder().key("key1").value("value1").build(), diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/config/BigIntegerConverterTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/config/BigIntegerConverterTest.java index 027adda..9eb759c 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/config/BigIntegerConverterTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/config/BigIntegerConverterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -8,23 +8,23 @@ package io.carbynestack.amphora.service.config; import static io.carbynestack.amphora.service.config.BigIntegerConverter.INVALID_VALUE_EXCEPTION_MSG; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.math.BigInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class BigIntegerConverterTest { +class BigIntegerConverterTest { @Test - public void givenValidBigIntegerAsString_whenConvert_thenReturnBigIntegerObject() { + void givenValidBigIntegerAsString_whenConvert_thenReturnBigIntegerObject() { BigInteger expected = BigInteger.valueOf(42); BigIntegerConverter bigIntegerConverter = new BigIntegerConverter(); assertEquals(expected, bigIntegerConverter.convert(expected.toString())); } @Test - public void givenNull_whenConvert_thenThrowException() { + void givenNull_whenConvert_thenThrowException() { BigIntegerConverter bigIntegerConverter = new BigIntegerConverter(); IllegalArgumentException iae = assertThrows(IllegalArgumentException.class, () -> bigIntegerConverter.convert(null)); @@ -32,7 +32,7 @@ public void givenNull_whenConvert_thenThrowException() { } @Test - public void givenEmptyString_whenConvert_thenThrowException() { + void givenEmptyString_whenConvert_thenThrowException() { String illegalInput = ""; BigIntegerConverter converter = new BigIntegerConverter(); IllegalArgumentException iae = diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InputMaskStoreRedisIT.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InputMaskStoreRedisIT.java index 5f7689f..62fbed9 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InputMaskStoreRedisIT.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InputMaskStoreRedisIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -10,7 +10,7 @@ import static io.carbynestack.amphora.service.persistence.cache.InputMaskCachingService.NO_INPUT_MASKS_FOUND_FOR_REQUEST_ID_EXCEPTION_MSG; import static io.carbynestack.castor.common.entities.TupleType.INPUT_MASK_GFP; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.when; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @@ -29,38 +29,40 @@ import java.util.UUID; import lombok.SneakyThrows; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest( webEnvironment = RANDOM_PORT, classes = {AmphoraServiceApplication.class}) @ActiveProfiles(profiles = {"test"}) +@Testcontainers public class InputMaskStoreRedisIT { private final UUID testRequestId = UUID.fromString("b380f595-f301-4577-9f44-6d78728c38c3"); private final long numberOfTuples = 42; private final TupleList testInputMasks1 = AmphoraTestData.getRandomInputMaskList(numberOfTuples); private final TupleList testInputMasks2 = AmphoraTestData.getRandomInputMaskList(numberOfTuples); - @ClassRule + @Container public static ReusableRedisContainer reusableRedisContainer = ReusableRedisContainer.getInstance(); - @ClassRule + @Container public static ReusableMinioContainer reusableMinioContainer = ReusableMinioContainer.getInstance(); - @ClassRule + @Container public static ReusablePostgreSQLContainer reusablePostgreSQLContainer = ReusablePostgreSQLContainer.getInstance(); @@ -78,7 +80,7 @@ public class InputMaskStoreRedisIT { @MockBean private CastorIntraVcpClient castorClient; - @Before + @BeforeEach public void setUp() { if (inputMaskCache == null) { inputMaskCache = cacheManager.getCache(cacheProperties.getInputMaskStore()); @@ -87,7 +89,7 @@ public void setUp() { } @Test - public void givenNoDataForKeyInCache_whenGetInputMasks_thenThrowAmphoraServiceException() { + void givenNoDataForKeyInCache_whenGetInputMasks_thenThrowAmphoraServiceException() { AmphoraServiceException ase = assertThrows( AmphoraServiceException.class, () -> inputMaskStore.getInputMasks(testRequestId)); @@ -98,7 +100,7 @@ public void givenNoDataForKeyInCache_whenGetInputMasks_thenThrowAmphoraServiceEx @SneakyThrows @Test - public void givenMultipleRequestsForSameKey_whenGetInputMasks_thenReturnSameResult() { + void givenMultipleRequestsForSameKey_whenGetInputMasks_thenReturnSameResult() { when(castorClient.downloadTupleShares(testRequestId, INPUT_MASK_GFP, testInputMasks1.size())) .thenReturn(testInputMasks1); inputMaskStore.fetchAndCacheInputMasks(testRequestId, testInputMasks1.size()); @@ -112,8 +114,7 @@ public void givenMultipleRequestsForSameKey_whenGetInputMasks_thenReturnSameResu @SneakyThrows @Test - public void - givenConsecutiveCallsForSameKey_whenFetchAndCacheInputMasks_thenReplaceExistingData() { + void givenConsecutiveCallsForSameKey_whenFetchAndCacheInputMasks_thenReplaceExistingData() { when(castorClient.downloadTupleShares(testRequestId, INPUT_MASK_GFP, testInputMasks1.size())) .thenReturn(testInputMasks1) .thenReturn(testInputMasks2); @@ -133,7 +134,7 @@ public void givenMultipleRequestsForSameKey_whenGetInputMasks_thenReturnSameResu @SneakyThrows @Test - public void givenSuccessfulRequest_whenRemoveInputMasks_thenDeleteFromCache() { + void givenSuccessfulRequest_whenRemoveInputMasks_thenDeleteFromCache() { inputMaskCache.put(testRequestId, testInputMasks1); assertThat( inputMaskStore.getInputMasks(testRequestId), diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InputMaskStoreTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InputMaskStoreTest.java index 995ef83..2894c50 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InputMaskStoreTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InputMaskStoreTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -9,8 +9,8 @@ import static io.carbynestack.amphora.service.persistence.cache.InputMaskCachingService.NO_INPUT_MASKS_FOUND_FOR_REQUEST_ID_EXCEPTION_MSG; import static io.carbynestack.castor.common.entities.TupleType.INPUT_MASK_GFP; import static java.util.Collections.singletonList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*; import io.carbynestack.amphora.common.exceptions.AmphoraServiceException; @@ -24,17 +24,17 @@ import java.util.List; import java.util.UUID; import lombok.SneakyThrows; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.redis.cache.CacheKeyPrefix; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; -@RunWith(MockitoJUnitRunner.class) -public class InputMaskStoreTest { +@ExtendWith(MockitoExtension.class) +class InputMaskStoreTest { private final CastorServiceUri castorServiceUri = new CastorServiceUri("https://castor.carbynestack.io"); private final List castorServiceUris = singletonList(castorServiceUri); @@ -50,10 +50,9 @@ public class InputMaskStoreTest { private InputMaskCachingService inputMaskCache; - @Before + @BeforeEach public void setup() { when(amphoraCachePropertiesMock.getInputMaskStore()).thenReturn(testCacheName); - when(redisTemplateMock.opsForValue()).thenReturn(valueOperationsMock); inputMaskCache = new InputMaskCachingService( interVcpClientMock, redisTemplateMock, amphoraCachePropertiesMock); @@ -61,10 +60,11 @@ public void setup() { @SneakyThrows @Test - public void givenSuccessfulRequest_whenPutInputMasks_thenStoreInCacheAndReturnList() { + void givenSuccessfulRequest_whenPutInputMasks_thenStoreInCacheAndReturnList() { TupleList, Field.Gfp> inputMasks = AmphoraTestData.getRandomInputMaskList(5); + when(redisTemplateMock.opsForValue()).thenReturn(valueOperationsMock); when(interVcpClientMock.downloadTupleShares(testRequestId, INPUT_MASK_GFP, inputMasks.size())) .thenReturn(inputMasks); assertEquals( @@ -73,15 +73,17 @@ public void givenSuccessfulRequest_whenPutInputMasks_thenStoreInCacheAndReturnLi } @Test - public void givenInputMasksInCache_whenGetInputMasks_thenReturnList() { + void givenInputMasksInCache_whenGetInputMasks_thenReturnList() { TupleList, Field.Gfp> inputMasks = AmphoraTestData.getRandomInputMaskList(5); + when(redisTemplateMock.opsForValue()).thenReturn(valueOperationsMock); when(valueOperationsMock.get(testCachePrefix + testRequestId)).thenReturn(inputMasks); assertEquals(inputMasks, inputMaskCache.getInputMasks(testRequestId)); } @Test - public void givenInputMasksNotInCache_whenGetInputMasks_thenThrowException() { + void givenInputMasksNotInCache_whenGetInputMasks_thenThrowException() { + when(redisTemplateMock.opsForValue()).thenReturn(valueOperationsMock); when(valueOperationsMock.get(testCachePrefix + testRequestId)).thenReturn(null); AmphoraServiceException ase = assertThrows( @@ -92,7 +94,7 @@ public void givenInputMasksNotInCache_whenGetInputMasks_thenThrowException() { } @Test - public void givenSuccessfulRequest_whenRemoveInputMasks_thenRemoveFromCache() { + void givenSuccessfulRequest_whenRemoveInputMasks_thenRemoveFromCache() { inputMaskCache.removeInputMasks(testRequestId); verify(redisTemplateMock, times(1)).delete(testCachePrefix + testRequestId); } diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InterimValueCachingServiceTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InterimValueCachingServiceTest.java index db732b4..c2921fc 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InterimValueCachingServiceTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/cache/InterimValueCachingServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -7,7 +7,7 @@ package io.carbynestack.amphora.service.persistence.cache; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.*; import io.carbynestack.amphora.common.FactorPair; @@ -20,17 +20,17 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.redis.cache.CacheKeyPrefix; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; -@RunWith(MockitoJUnitRunner.class) -public class InterimValueCachingServiceTest { +@ExtendWith(MockitoExtension.class) +class InterimValueCachingServiceTest { @Mock RedisTemplate redisTemplateMock; @Mock AmphoraCacheProperties amphoraCachePropertiesMock; @Mock private ValueOperations valueOperationsMock; @@ -41,7 +41,7 @@ public class InterimValueCachingServiceTest { private InterimValueCachingService interimValueCachingService; - @Before + @BeforeEach public void setup() { when(amphoraCachePropertiesMock.getInterimValueStore()).thenReturn(testCacheName); when(redisTemplateMock.opsForValue()).thenReturn(valueOperationsMock); @@ -50,14 +50,14 @@ public void setup() { } @Test - public void givenSuccessfulRequest_whenPuttingInterimValue_thenStoreInCacheWithCorrectKey() { + void givenSuccessfulRequest_whenPuttingInterimValue_thenStoreInCacheWithCorrectKey() { MultiplicationExchangeObject exchangeObject = createExchangeObject(); interimValueCachingService.putInterimValues(exchangeObject); verify(valueOperationsMock, times(1)).set(getCacheKey(exchangeObject), exchangeObject); } @Test - public void + void givenValuesPresentForIdAndPlayer_whenGettingInterimValues_thenReturnOptionWithObjectAndEvict() { MultiplicationExchangeObject exchangeObject = createExchangeObject(); when(redisTemplateMock.hasKey(getCacheKey(exchangeObject))).thenReturn(true); @@ -73,7 +73,7 @@ public void givenSuccessfulRequest_whenPuttingInterimValue_thenStoreInCacheWithC } @Test - public void + void givenValuesNotPresentForIdAndPlayer_whenGettingInterimValues_thenReturnFailedOptionAndDontCallEvict() { UUID operationId = UUID.fromString("a7d4970c-36de-4880-b91b-6656dff3bac9"); int playerId = 0; diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/datastore/MinioSecretShareDataStoreTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/datastore/MinioSecretShareDataStoreTest.java index 21162f5..119dec3 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/datastore/MinioSecretShareDataStoreTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/datastore/MinioSecretShareDataStoreTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -8,7 +8,7 @@ package io.carbynestack.amphora.service.persistence.datastore; import static io.carbynestack.amphora.service.persistence.datastore.MinioSecretShareDataStore.*; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; @@ -25,15 +25,15 @@ import org.apache.commons.io.IOUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class MinioSecretShareDataStoreTest { +@ExtendWith(MockitoExtension.class) +class MinioSecretShareDataStoreTest { private final UUID testSecretId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); @Mock private MinioClient minioClientMock; @@ -42,7 +42,7 @@ public class MinioSecretShareDataStoreTest { private SecretShareDataStore secretShareDataStore; - @Before + @BeforeEach public void setUp() { secretShareDataStore = new MinioSecretShareDataStore(minioClientMock, new MinioProperties().setBucket(BUCKET)); @@ -50,7 +50,7 @@ public void setUp() { @SneakyThrows @Test - public void + void givenMakingMinioBucketFails_whenInstantiatingMinioSecretShareDataStore_thenThrowAmphoraServiceException() { MinioProperties minioProperties = new MinioProperties().setBucket(BUCKET); InternalException expectedCause = new InternalException(BUCKET, ""); @@ -70,7 +70,7 @@ public void setUp() { @SneakyThrows @Test - public void givenSuccessfulRequest_whenStoreSecretShareData_thenWriteExpectedDataToMinio() { + void givenSuccessfulRequest_whenStoreSecretShareData_thenWriteExpectedDataToMinio() { SecretShare secretShare = AmphoraTestData.getRandomSecretShare(testSecretId); secretShareDataStore.storeSecretShareData(secretShare.getSecretId(), secretShare.getData()); @@ -85,7 +85,7 @@ public void givenSuccessfulRequest_whenStoreSecretShareData_thenWriteExpectedDat @SneakyThrows @Test - public void givenSuccessfulRequest_whenGetSecretShareData_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenGetSecretShareData_thenReturnExpectedContent() { SecretShare secretShare = AmphoraTestData.getRandomSecretShare(testSecretId); doReturn( new GetObjectResponse( @@ -107,8 +107,7 @@ public void givenSuccessfulRequest_whenGetSecretShareData_thenReturnExpectedCont } @Test - public void - givenNoDataAvailableForGivenId_whenGetSecretShareData_thenThrowAmphoraServiceException() { + void givenNoDataAvailableForGivenId_whenGetSecretShareData_thenThrowAmphoraServiceException() { UUID unknownSecretId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); AmphoraServiceException ase = assertThrows( @@ -121,8 +120,7 @@ public void givenSuccessfulRequest_whenGetSecretShareData_thenReturnExpectedCont @SneakyThrows @Test - public void - givenMinioThrowsException_whenStoreSecretShareData_thenWrapInAmphoraServiceException() { + void givenMinioThrowsException_whenStoreSecretShareData_thenWrapInAmphoraServiceException() { SecretShare secretShare = AmphoraTestData.getRandomSecretShare(testSecretId); byte[] shareData = secretShare.getData(); IOException expectedCause = new IOException("Totally expected that move.."); @@ -139,7 +137,7 @@ public void givenSuccessfulRequest_whenGetSecretShareData_thenReturnExpectedCont @SneakyThrows @Test - public void givenSuccessfulRequest_whenDeleteSecretShareData_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenDeleteSecretShareData_thenReturnExpectedContent() { SecretShare secretShare = AmphoraTestData.getRandomSecretShare(testSecretId); doReturn( @@ -162,7 +160,7 @@ public void givenSuccessfulRequest_whenDeleteSecretShareData_thenReturnExpectedC @SneakyThrows @Test - public void + void givenDeleteCallOnMinioClientFails_whenDeleteSecretShareData_thenWrapExceptionInAmphoraServiceException() { SecretShare secretShare = AmphoraTestData.getRandomSecretShare(testSecretId); IOException expectedCause = new IOException("Totally expected that move.."); diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/FilterPagingAndNestedSortingIT.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/FilterPagingAndNestedSortingIT.java index 9f70fe9..0382b30 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/FilterPagingAndNestedSortingIT.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/FilterPagingAndNestedSortingIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -12,7 +12,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsInRelativeOrder; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; import io.carbynestack.amphora.common.Metadata; @@ -34,24 +34,25 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.commons.lang3.ArrayUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.domain.Page; import org.springframework.data.domain.Sort; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.Base58; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest( webEnvironment = RANDOM_PORT, classes = {AmphoraServiceApplication.class}) @ActiveProfiles(profiles = {"test"}) +@Testcontainers public class FilterPagingAndNestedSortingIT { public static final String LONG_KEY = "LONG_KEY"; @@ -64,15 +65,15 @@ public class FilterPagingAndNestedSortingIT { private final Tag testTagLongValue99 = Tag.builder().key(LONG_KEY).value("99").build(); private final Tag testTagLongValue100 = Tag.builder().key(LONG_KEY).value("100").build(); - @ClassRule + @Container public static ReusableRedisContainer reusableRedisContainer = ReusableRedisContainer.getInstance(); - @ClassRule + @Container public static ReusableMinioContainer reusableMinioContainer = ReusableMinioContainer.getInstance(); - @ClassRule + @Container public static ReusablePostgreSQLContainer reusablePostgreSQLContainer = ReusablePostgreSQLContainer.getInstance(); @@ -82,7 +83,7 @@ public class FilterPagingAndNestedSortingIT { @Autowired private PersistenceTestEnvironment testEnvironment; - @Before + @BeforeEach public void setUp() { testEnvironment.clearAllData(); } @@ -93,7 +94,7 @@ private void persistObjectWithIdAndTags(UUID id, Tag... tags) { } @Test - public void + void givenMultipleObjectsStoredButOnlyOneMatchingTagFilter_whenGetObjectListWithFilter_thenReturnExpectedContent() { persistObjectWithIdAndTags(testSecretId, testTag, testTag2); persistObjectWithIdAndTags(testSecretId2, testTag, testTag3); @@ -107,7 +108,7 @@ private void persistObjectWithIdAndTags(UUID id, Tag... tags) { } @Test - public void + void givenMultipleObjectsStoredButNoneMatchingFilterCriteria_whenGetObjectListWithFilter_thenReturnExpectedContent() { persistObjectWithIdAndTags(testSecretId, testTag, testTag2); persistObjectWithIdAndTags(testSecretId2, testTag, testTag3); @@ -120,7 +121,7 @@ private void persistObjectWithIdAndTags(UUID id, Tag... tags) { } @Test - public void + void givenMultipleObjectsStoredMatchingFilterCriteria_whenGetObjectListWithFilter_thenReturnExpectedContent() { Metadata[] expectedMetadataItems = { Metadata.builder().secretId(testSecretId).tags(asList(testTag, testTag2)).build(), @@ -143,7 +144,7 @@ private void persistObjectWithIdAndTags(UUID id, Tag... tags) { } @Test - public void + void givenObjectTagsWithLongValues_whenGetObjectListWithLongLessThanFilter_thenReturnExpectedResult() { persistObjectWithIdAndTags(testSecretId, testTagLongValue99); persistObjectWithIdAndTags(testSecretId2, testTagLongValue100); @@ -160,8 +161,7 @@ private void persistObjectWithIdAndTags(UUID id, Tag... tags) { } @Test - public void - givenObjectsWithMixedTagValueTypes_whenGetObjectListWithFilter_thenReturnExpectedContent() { + void givenObjectsWithMixedTagValueTypes_whenGetObjectListWithFilter_thenReturnExpectedContent() { persistObjectWithIdAndTags(testSecretId, testTagLongValue99); persistObjectWithIdAndTags(testSecretId2, testTag, testTagLongValue100); List tagFilters = @@ -177,7 +177,7 @@ private void persistObjectWithIdAndTags(UUID id, Tag... tags) { } @Test - public void + void givenObjectTagsWithLongValues_whenGetObjectListWithLongGreaterThanFilter_thenReturnExpectedResult() { persistObjectWithIdAndTags(testSecretId, testTag2, testTagLongValue99); persistObjectWithIdAndTags(testSecretId2, testTagLongValue100); @@ -191,7 +191,7 @@ private void persistObjectWithIdAndTags(UUID id, Tag... tags) { } @Test - public void + void givenTagValueEqualToGreaterThanFilterValue_whenGetObjectListWithFilter_thenDoNotReturnRelatedObject() { persistObjectWithIdAndTags(testSecretId, testTag, testTagLongValue99); persistObjectWithIdAndTags(testSecretId2, testTag, testTagLongValue100); @@ -205,7 +205,7 @@ private void persistObjectWithIdAndTags(UUID id, Tag... tags) { } @Test - public void + void givenNumberComparisonFilterWithNonParsableValue_whenCreateTagFilter_thenThrowIllegalArgumentException() { persistObjectWithIdAndTags(testSecretId, testTagLongValue99); persistObjectWithIdAndTags(testSecretId2, testTagLongValue100); @@ -216,7 +216,7 @@ private void persistObjectWithIdAndTags(UUID id, Tag... tags) { } @Test - public void givenTagsWithLongValue_whenRequestingAscSortedList_thenReturnProperResult() { + void givenTagsWithLongValue_whenRequestingAscSortedList_thenReturnProperResult() { String tagKey = Base58.randomString(5); Metadata[] expectedMetadata = getSortLongTestMetadata(tagKey, Sort.Direction.ASC); Page actualMetadataPage = storageService.getSecretList(Sort.by(tagKey).ascending()); @@ -229,7 +229,7 @@ public void givenTagsWithLongValue_whenRequestingAscSortedList_thenReturnProperR } @Test - public void givenTagsWithLongValue_whenRequestingDescSortedList_thenReturnProperResult() { + void givenTagsWithLongValue_whenRequestingDescSortedList_thenReturnProperResult() { String tagKey = Base58.randomString(5); Metadata[] expectedMetadata = getSortLongTestMetadata(tagKey, Sort.Direction.DESC); Page actualMetadataPage = storageService.getSecretList(Sort.by(tagKey).descending()); @@ -239,7 +239,7 @@ public void givenTagsWithLongValue_whenRequestingDescSortedList_thenReturnProper } @Test - public void givenTagsWithStringValue_whenRequestingAscSortedList_thenReturnProperResult() { + void givenTagsWithStringValue_whenRequestingAscSortedList_thenReturnProperResult() { String tagKey = Base58.randomString(5); Metadata[] expectedMetadata = getSortStringTestMetadata(tagKey, Sort.Direction.ASC); Page actualMetadataPage = storageService.getSecretList(Sort.by(tagKey).ascending()); @@ -252,7 +252,7 @@ public void givenTagsWithStringValue_whenRequestingAscSortedList_thenReturnPrope } @Test - public void givenTagsWithStringValue_whenRequestingDescSortedList_thenReturnProperResult() { + void givenTagsWithStringValue_whenRequestingDescSortedList_thenReturnProperResult() { String tagKey = Base58.randomString(5); Metadata[] expectedMetadata = getSortStringTestMetadata(tagKey, Sort.Direction.DESC); Page actualMetadataPage = storageService.getSecretList(Sort.by(tagKey).descending()); @@ -265,8 +265,7 @@ public void givenTagsWithStringValue_whenRequestingDescSortedList_thenReturnProp } @Test - public void - givenMultipleEntitiesButMixedValueTypes_whenRequestingSortedList_thenThrowException() { + void givenMultipleEntitiesButMixedValueTypes_whenRequestingSortedList_thenThrowException() { String tagKey = Base58.randomString(5); Metadata longTypeMetadata = Metadata.builder() @@ -299,15 +298,14 @@ public void givenTagsWithStringValue_whenRequestingDescSortedList_thenReturnProp } Sort sortConfig = Sort.by(tagKey).ascending(); AmphoraServiceException ase = - Assert.assertThrows( - AmphoraServiceException.class, () -> storageService.getSecretList(sortConfig)); + assertThrows(AmphoraServiceException.class, () -> storageService.getSecretList(sortConfig)); assertEquals( "The TagValueType of the tags used for sorting have different configurations.", ase.getMessage()); } @Test - public void givenNoTagWithSortingKey_whenRequestingSortedList_thenActAsNoSortingApplied() { + void givenNoTagWithSortingKey_whenRequestingSortedList_thenActAsNoSortingApplied() { String actualTagKey = Base58.randomString(5); String wrongTagKey = Base58.randomString(5) + "wrong"; Metadata[] expectedMetadata = getUnorderedStringTestMetadata(actualTagKey); diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/StorageIT.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/StorageIT.java index e7e4261..fd9ad5a 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/StorageIT.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/StorageIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -12,7 +12,7 @@ import static io.carbynestack.amphora.service.persistence.metadata.TagEntity.setFromTagList; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; import static org.springframework.util.CollectionUtils.isEmpty; @@ -35,37 +35,39 @@ import java.util.List; import java.util.UUID; import lombok.SneakyThrows; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.domain.Page; import org.springframework.data.domain.Sort; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest( webEnvironment = RANDOM_PORT, classes = {AmphoraServiceApplication.class}) @ActiveProfiles(profiles = {"test"}) +@Testcontainers public class StorageIT { private final UUID unknownId = UUID.fromString("d6d0f4ff-df28-4c96-b7df-95170320eaee"); private final UUID testSecretId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); private final UUID testSecretId2 = UUID.fromString("0e7cd962-d98e-4eea-82ae-4641399c9ad7"); private final Tag testTag = Tag.builder().key("TEST_KEY").value("TEST_VALUE").build(); - @ClassRule + @Container public static ReusableRedisContainer reusableRedisContainer = ReusableRedisContainer.getInstance(); - @ClassRule + @Container public static ReusableMinioContainer reusableMinioContainer = ReusableMinioContainer.getInstance(); - @ClassRule + @Container public static ReusablePostgreSQLContainer reusablePostgreSQLContainer = ReusablePostgreSQLContainer.getInstance(); @@ -80,7 +82,7 @@ public class StorageIT { @Autowired private MinioClient minioClient; @Autowired private MinioProperties minioProperties; - @Before + @BeforeEach public void setUp() { testEnvironment.clearAllData(); } @@ -91,7 +93,7 @@ private SecretEntity persistObjectWithIdAndTags(UUID id, Tag... tags) { } @Test - public void givenSuccessfulRequest_whenStoreTag_thenPersist() { + void givenSuccessfulRequest_whenStoreTag_thenPersist() { persistObjectWithIdAndTags(testSecretId, testTag); storageService.storeTag( testSecretId, Tag.builder().key("ANOTHER_KEY").value(testTag.getValue()).build()); @@ -100,7 +102,7 @@ public void givenSuccessfulRequest_whenStoreTag_thenPersist() { } @Test - public void givenSuccessfulRequest_whenGetObjectList_thenReturnExpectedResult() { + void givenSuccessfulRequest_whenGetObjectList_thenReturnExpectedResult() { Metadata expectedMetadata = Metadata.builder().secretId(testSecretId).tags(singletonList(testTag)).build(); persistObjectWithIdAndTags(testSecretId, testTag); @@ -109,7 +111,7 @@ public void givenSuccessfulRequest_whenGetObjectList_thenReturnExpectedResult() } @Test - public void givenNoObjectWithReferencedIdDefined_whenRetrieveTags_thenThrowNotFoundException() { + void givenNoObjectWithReferencedIdDefined_whenRetrieveTags_thenThrowNotFoundException() { NotFoundException nfe = assertThrows(NotFoundException.class, () -> storageService.retrieveTags(testSecretId)); assertEquals( @@ -117,7 +119,7 @@ public void givenNoObjectWithReferencedIdDefined_whenRetrieveTags_thenThrowNotFo } @Test - public void givenSecretIdUnknown_whenStoreTag_thenThrowNotFoundException() { + void givenSecretIdUnknown_whenStoreTag_thenThrowNotFoundException() { NotFoundException nfe = assertThrows(NotFoundException.class, () -> storageService.storeTag(unknownId, testTag)); assertEquals( @@ -125,8 +127,7 @@ public void givenSecretIdUnknown_whenStoreTag_thenThrowNotFoundException() { } @Test - public void - givenSuccessfulRequests_whenStoreAndRetrieveTag_thenPersistAndReturnExpectedContent() { + void givenSuccessfulRequests_whenStoreAndRetrieveTag_thenPersistAndReturnExpectedContent() { persistObjectWithIdAndTags(testSecretId); storageService.storeTag(testSecretId, testTag); List tags = storageService.retrieveTags(testSecretId); @@ -135,14 +136,14 @@ public void givenSecretIdUnknown_whenStoreTag_thenThrowNotFoundException() { } @Test - public void givenObjectWithoutTagsDefined_whenRetrieveTags_thenReturnEmptyList() { + void givenObjectWithoutTagsDefined_whenRetrieveTags_thenReturnEmptyList() { persistObjectWithIdAndTags(testSecretId); assertEquals(Collections.emptyList(), storageService.retrieveTags(testSecretId)); } @SneakyThrows @Test - public void givenObjectWithoutTagsDefined_whenRetrieveSecretShare_thenReturnEmptyListForTags() { + void givenObjectWithoutTagsDefined_whenRetrieveSecretShare_thenReturnEmptyListForTags() { persistObjectWithIdAndTags(testSecretId); minioClient.putObject( PutObjectArgs.builder() @@ -154,7 +155,7 @@ public void givenObjectWithoutTagsDefined_whenRetrieveSecretShare_thenReturnEmpt } @Test - public void givenObjectHasNoDataPersisted_whenGetSecretShare_thenThrowAmphoraServiceException() { + void givenObjectHasNoDataPersisted_whenGetSecretShare_thenThrowAmphoraServiceException() { persistObjectWithIdAndTags(testSecretId); AmphoraServiceException ase = assertThrows( @@ -166,7 +167,7 @@ public void givenObjectHasNoDataPersisted_whenGetSecretShare_thenThrowAmphoraSer } @Test - public void givenSecretIdUnknown_whenReplaceTags_thenThrowNotFoundException() { + void givenSecretIdUnknown_whenReplaceTags_thenThrowNotFoundException() { List tags = singletonList(testTag); NotFoundException nfe = assertThrows( @@ -179,7 +180,7 @@ public void givenSecretIdUnknown_whenReplaceTags_thenThrowNotFoundException() { } @Test - public void givenSuccessfulRequest_whenDeleteTag_thenDoNoLongerReturn() { + void givenSuccessfulRequest_whenDeleteTag_thenDoNoLongerReturn() { SecretEntity secretEntity = persistObjectWithIdAndTags(testSecretId, testTag); Tag expectedTag = Tag.builder().key(testTag.getKey() + "new").value(testTag.getValue()).build(); TagEntity expectedTagEntity = TagEntity.fromTag(expectedTag).setSecret(secretEntity); @@ -203,7 +204,7 @@ public void givenSuccessfulRequest_whenDeleteTag_thenDoNoLongerReturn() { } @Test - public void givenObjectHasNoTagWithRequestedKey_whenDeleteKey_thenThrowNotFoundException() { + void givenObjectHasNoTagWithRequestedKey_whenDeleteKey_thenThrowNotFoundException() { String unknownKey = "unknown_key"; persistObjectWithIdAndTags(testSecretId, testTag); persistObjectWithIdAndTags(testSecretId2, testTag); @@ -218,8 +219,7 @@ public void givenObjectHasNoTagWithRequestedKey_whenDeleteKey_thenThrowNotFoundE } @Test - public void - givenMultipleObjectsWIthIdenticalTag_whenDeleteTagOnOneObject_thenKeepTagForOtherObjects() { + void givenMultipleObjectsWIthIdenticalTag_whenDeleteTagOnOneObject_thenKeepTagForOtherObjects() { persistObjectWithIdAndTags(testSecretId, testTag); persistObjectWithIdAndTags(testSecretId2, testTag); storageService.deleteTag(testSecretId, testTag.getKey()); @@ -237,7 +237,7 @@ public void givenObjectHasNoTagWithRequestedKey_whenDeleteKey_thenThrowNotFoundE } @Test - public void givenAnUnknownId_whenStoringATag_thenThrow() { + void givenAnUnknownId_whenStoringATag_thenThrow() { NotFoundException nfe = assertThrows(NotFoundException.class, () -> storageService.storeTag(testSecretId, testTag)); assertEquals( diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/StorageServiceTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/StorageServiceTest.java index aaba0a6..49b803a 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/StorageServiceTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/persistence/metadata/StorageServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -14,7 +14,7 @@ import static java.util.Collections.*; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; import static org.mockito.Mockito.any; @@ -34,16 +34,16 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.RandomUtils; import org.hamcrest.MatcherAssert; -import org.junit.Test; -import org.junit.runner.RunWith; +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.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.domain.*; -@RunWith(MockitoJUnitRunner.class) -public class StorageServiceTest { +@ExtendWith(MockitoExtension.class) +class StorageServiceTest { private final UUID testSecretId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); private final UUID testSecretId2 = UUID.fromString("0e7cd962-d98e-4eea-82ae-4641399c9ad7"); private final Tag testTag = Tag.builder().key("TEST_KEY").value("TEST_VALUE").build(); @@ -62,7 +62,7 @@ public class StorageServiceTest { @InjectMocks private StorageService storageService; @Test - public void givenIdIsAlreadyInUse_whenCreateSecret_thenThrowAlreadyExistsException() { + void givenIdIsAlreadyInUse_whenCreateSecret_thenThrowAlreadyExistsException() { MaskedInput testMaskedInput = new MaskedInput( testSecretId, @@ -80,8 +80,7 @@ public void givenIdIsAlreadyInUse_whenCreateSecret_thenThrowAlreadyExistsExcepti } @Test - public void - givenMaskedInputHasTagsWithSameKey_whenCreateObject_thenThrowIllegalArgumentException() { + void givenMaskedInputHasTagsWithSameKey_whenCreateObject_thenThrowIllegalArgumentException() { Tag tagWithSameKeyAsTestTag = Tag.builder() .key(testTag.getKey()) @@ -103,7 +102,7 @@ public void givenIdIsAlreadyInUse_whenCreateSecret_thenThrowAlreadyExistsExcepti } @Test - public void givenMaskedInputWithReservedKey_whenCreateObject_thenReplaceReservedKey() { + void givenMaskedInputWithReservedKey_whenCreateObject_thenReplaceReservedKey() { MaskedInput maskedInput = new MaskedInput( testSecretId, @@ -128,9 +127,9 @@ public void givenMaskedInputWithReservedKey_whenCreateObject_thenReplaceReserved .thenThrow(expectedAbortTestException); assertThrows( - expectedAbortTestException.getMessage(), RuntimeException.class, - () -> storageService.createSecret(maskedInput)); + () -> storageService.createSecret(maskedInput), + expectedAbortTestException.getMessage()); SecretEntity capturedSecretEntity = secretEntityArgumentCaptor.getValue(); List actualTags = TagEntity.setToTagList(capturedSecretEntity.getTags()); assertEquals(2, actualTags.size()); @@ -144,7 +143,7 @@ public void givenMaskedInputWithReservedKey_whenCreateObject_thenReplaceReserved } @Test - public void givenSuccessfulRequest_whenCreateObject_thenReturnSecretId() { + void givenSuccessfulRequest_whenCreateObject_thenReturnSecretId() { MaskedInput maskedInput = new MaskedInput( testSecretId, @@ -188,7 +187,7 @@ public void givenSuccessfulRequest_whenCreateObject_thenReturnSecretId() { } @Test - public void givenIdIsAlreadyInUse_whenStoreSecretShare_thenThrowAlreadyExistsException() { + void givenIdIsAlreadyInUse_whenStoreSecretShare_thenThrowAlreadyExistsException() { SecretShare secretShare = SecretShare.builder() .secretId(testSecretId) @@ -205,8 +204,7 @@ public void givenIdIsAlreadyInUse_whenStoreSecretShare_thenThrowAlreadyExistsExc } @Test - public void - givenSecretShareHasTagsWithSameKey_whenStoreObject_thenThrowIllegalArgumentException() { + void givenSecretShareHasTagsWithSameKey_whenStoreObject_thenThrowIllegalArgumentException() { Tag tagWithSameKeyAsTestTag = Tag.builder() .key(testTag.getKey()) @@ -227,7 +225,7 @@ public void givenIdIsAlreadyInUse_whenStoreSecretShare_thenThrowAlreadyExistsExc } @Test - public void givenSecretShareWithReservedKey_whenStoreSecretShare_thenReplaceReservedKey() { + void givenSecretShareWithReservedKey_whenStoreSecretShare_thenReplaceReservedKey() { SecretShare secretShare = SecretShare.builder() .secretId(testSecretId) @@ -242,9 +240,9 @@ public void givenSecretShareWithReservedKey_whenStoreSecretShare_thenReplaceRese .thenThrow(expectedAbortTestException); assertThrows( - expectedAbortTestException.getMessage(), RuntimeException.class, - () -> storageService.storeSecretShare(secretShare)); + () -> storageService.storeSecretShare(secretShare), + expectedAbortTestException.getMessage()); SecretEntity capturedSecretEntity = secretEntityArgumentCaptor.getValue(); List actualTags = TagEntity.setToTagList(capturedSecretEntity.getTags()); assertEquals(2, actualTags.size()); @@ -259,7 +257,7 @@ public void givenSecretShareWithReservedKey_whenStoreSecretShare_thenReplaceRese } @Test - public void givenSuccessfulRequest_whenStoreSecretShare_thenReturnSecretId() { + void givenSuccessfulRequest_whenStoreSecretShare_thenReturnSecretId() { SecretShare secretShare = SecretShare.builder() .secretId(testSecretId) @@ -275,7 +273,7 @@ public void givenSuccessfulRequest_whenStoreSecretShare_thenReturnSecretId() { } @Test - public void givenSuccessfulRequest_whenGetObjectListWithPageable_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenGetObjectListWithPageable_thenReturnExpectedContent() { List expectedMetadataList = asList( Metadata.builder().secretId(testSecretId).tags(singletonList(testTag)).build(), @@ -296,7 +294,7 @@ public void givenSuccessfulRequest_whenGetObjectListWithPageable_thenReturnExpec } @Test - public void givenSuccessfulRequest_whenGetObjectListWithSortConfig_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenGetObjectListWithSortConfig_thenReturnExpectedContent() { List expectedMetadataList = asList( Metadata.builder().secretId(testSecretId).tags(singletonList(testTag)).build(), @@ -321,8 +319,7 @@ public void givenSuccessfulRequest_whenGetObjectListWithSortConfig_thenReturnExp } @Test - public void - givenSuccessfulRequest_whenGetObjectListWithFilterAndPageable_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenGetObjectListWithFilterAndPageable_thenReturnExpectedContent() { List tagFilters = singletonList( TagFilter.with(testTag.getKey(), testTag.getValue(), TagFilterOperator.EQUALS)); @@ -349,8 +346,7 @@ public void givenSuccessfulRequest_whenGetObjectListWithSortConfig_thenReturnExp } @Test - public void - givenSuccessfulRequest_whenGetObjectListWithFilterAndSortConfig_thenReturnExpectedContent() { + void givenSuccessfulRequest_whenGetObjectListWithFilterAndSortConfig_thenReturnExpectedContent() { List tagFilters = singletonList( TagFilter.with(testTag.getKey(), testTag.getValue(), TagFilterOperator.EQUALS)); @@ -380,8 +376,7 @@ public void givenSuccessfulRequest_whenGetObjectListWithSortConfig_thenReturnExp } @Test - public void - givenNoSecretShareWithGivenIdInDatabase_whenGetSecretShare_thenThrowNotFoundException() { + void givenNoSecretShareWithGivenIdInDatabase_whenGetSecretShare_thenThrowNotFoundException() { when(secretEntityRepository.findById(testSecretId.toString())).thenReturn(Optional.empty()); NotFoundException nfe = @@ -391,7 +386,7 @@ public void givenSuccessfulRequest_whenGetObjectListWithSortConfig_thenReturnExp } @Test - public void givenDataCannotBeRetrieved_whenGetSecretShare_thenThrowAmphoraServiceException() { + void givenDataCannotBeRetrieved_whenGetSecretShare_thenThrowAmphoraServiceException() { AmphoraServiceException expectedAse = new AmphoraServiceException("Expected this one"); SecretEntity secretEntity = new SecretEntity(); when(secretEntityRepository.findById(testSecretId.toString())) @@ -399,13 +394,13 @@ public void givenDataCannotBeRetrieved_whenGetSecretShare_thenThrowAmphoraServic when(secretShareDataStore.getSecretShareData(testSecretId)).thenThrow(expectedAse); assertThrows( - expectedAse.getMessage(), AmphoraServiceException.class, - () -> storageService.getSecretShare(testSecretId)); + () -> storageService.getSecretShare(testSecretId), + expectedAse.getMessage()); } @Test - public void givenSuccessfulRequest_whenGetSecretShare_thenReturnContent() { + void givenSuccessfulRequest_whenGetSecretShare_thenReturnContent() { List expectedTags = singletonList(testTag); byte[] expectedData = RandomUtils.nextBytes(MpSpdzIntegrationUtils.SHARE_WIDTH); SecretEntity existingSecretEntity = @@ -426,8 +421,7 @@ public void givenSuccessfulRequest_whenGetSecretShare_thenReturnContent() { } @Test - public void - givenNoSecretShareWithGivenIdInDatabase_whenDeleteObject_thenThrowNotFoundException() { + void givenNoSecretShareWithGivenIdInDatabase_whenDeleteObject_thenThrowNotFoundException() { when(secretEntityRepository.deleteBySecretId(testSecretId.toString())).thenReturn(0L); NotFoundException nfe = @@ -437,19 +431,19 @@ public void givenSuccessfulRequest_whenGetSecretShare_thenReturnContent() { } @Test - public void givenDeleteObjectDataFails_whenDeleteObject_thenThrowGivenException() { + void givenDeleteObjectDataFails_whenDeleteObject_thenThrowGivenException() { AmphoraServiceException expectedAse = new AmphoraServiceException("Expected this one"); when(secretEntityRepository.deleteBySecretId(testSecretId.toString())).thenReturn(1L); when(secretShareDataStore.deleteSecretShareData(testSecretId)).thenThrow(expectedAse); assertThrows( - expectedAse.getMessage(), AmphoraServiceException.class, - () -> storageService.deleteSecret(testSecretId)); + () -> storageService.deleteSecret(testSecretId), + expectedAse.getMessage()); } @Test - public void givenSuccessfulRequest_whenDeleteObject_thenDeleteObjectAndData() { + void givenSuccessfulRequest_whenDeleteObject_thenDeleteObjectAndData() { when(secretEntityRepository.deleteBySecretId(testSecretId.toString())).thenReturn(1L); storageService.deleteSecret(testSecretId); @@ -457,7 +451,7 @@ public void givenSuccessfulRequest_whenDeleteObject_thenDeleteObjectAndData() { } @Test - public void givenTagHasReservedKey_whenStoreTag_thenThrowIllegalArgumentException() { + void givenTagHasReservedKey_whenStoreTag_thenThrowIllegalArgumentException() { IllegalArgumentException iae = assertThrows( IllegalArgumentException.class, @@ -468,7 +462,7 @@ public void givenTagHasReservedKey_whenStoreTag_thenThrowIllegalArgumentExceptio } @Test - public void givenNoSecretShareWithGivenIdInDatabase_whenStoreTag_thenThrowNotFoundException() { + void givenNoSecretShareWithGivenIdInDatabase_whenStoreTag_thenThrowNotFoundException() { when(secretEntityRepository.existsById(testSecretId.toString())).thenReturn(false); NotFoundException nfe = assertThrows(NotFoundException.class, () -> storageService.storeTag(testSecretId, testTag)); @@ -477,7 +471,7 @@ public void givenNoSecretShareWithGivenIdInDatabase_whenStoreTag_thenThrowNotFou } @Test - public void givenObjectAlreadyHasTagWithGivenKey_whenStoreTag_thenThrowAlreadyExistsException() { + void givenObjectAlreadyHasTagWithGivenKey_whenStoreTag_thenThrowAlreadyExistsException() { SecretEntity existingSecretEntity = new SecretEntity().setSecretId(testSecretId.toString()); TagEntity existingTagEntity = TagEntity.fromTag(testTag); when(secretEntityRepository.existsById(testSecretId.toString())).thenReturn(true); @@ -497,7 +491,7 @@ public void givenObjectAlreadyHasTagWithGivenKey_whenStoreTag_thenThrowAlreadyEx } @Test - public void givenSuccessfulRequest_whenStoreTag_thenPersistTag() { + void givenSuccessfulRequest_whenStoreTag_thenPersistTag() { SecretEntity existingSecretEntity = new SecretEntity().setSecretId(testSecretId.toString()); TagEntity expectedTagEntity = TagEntity.fromTag(testTag); ArgumentCaptor tagEntityArgumentCaptor = ArgumentCaptor.forClass(TagEntity.class); @@ -520,7 +514,7 @@ public void givenSuccessfulRequest_whenStoreTag_thenPersistTag() { } @Test - public void givenListHasTagsWithSameKey_whenReplaceTags_thenThrowIllegalArgumentException() { + void givenListHasTagsWithSameKey_whenReplaceTags_thenThrowIllegalArgumentException() { Tag tagWithSameKeyAsTestTag = Tag.builder() .key(testTag.getKey()) @@ -537,7 +531,7 @@ public void givenListHasTagsWithSameKey_whenReplaceTags_thenThrowIllegalArgument } @Test - public void givenNoSecretShareWithGivenIdInDatabase_whenReplaceTags_thenThrowNotFoundException() { + void givenNoSecretShareWithGivenIdInDatabase_whenReplaceTags_thenThrowNotFoundException() { when(secretEntityRepository.existsById(testSecretId.toString())).thenReturn(false); List emptyTags = emptyList(); NotFoundException nfe = @@ -548,7 +542,7 @@ public void givenNoSecretShareWithGivenIdInDatabase_whenReplaceTags_thenThrowNot } @Test - public void givenListHasTagWithReservedKey_whenReplaceTags_thenReplaceByExistingTagAndPersist() { + void givenListHasTagWithReservedKey_whenReplaceTags_thenReplaceByExistingTagAndPersist() { List tagListWithReservedKey = asList(testTag, testTagReservedCreationDateKey); TagEntity existingCreationTagEntity = TagEntity.fromTag( @@ -581,8 +575,7 @@ public void givenListHasTagWithReservedKey_whenReplaceTags_thenReplaceByExisting } @Test - public void - givenNoSecretShareWithGivenIdInDatabase_whenRetrieveTags_thenThrowNotFoundException() { + void givenNoSecretShareWithGivenIdInDatabase_whenRetrieveTags_thenThrowNotFoundException() { when(secretEntityRepository.findById(testSecretId.toString())).thenReturn(Optional.empty()); NotFoundException nfe = @@ -592,7 +585,7 @@ public void givenListHasTagWithReservedKey_whenReplaceTags_thenReplaceByExisting } @Test - public void givenSuccessfulRequest_whenRetrieveTags_thenReturnContent() { + void givenSuccessfulRequest_whenRetrieveTags_thenReturnContent() { List expectedTags = asList(testTag, testTag2); SecretEntity existingSecretEntity = new SecretEntity(testSecretId.toString(), TagEntity.setFromTagList(expectedTags)); @@ -605,7 +598,7 @@ public void givenSuccessfulRequest_whenRetrieveTags_thenReturnContent() { } @Test - public void givenNoSecretShareWithGivenIdInDatabase_whenRetrieveTag_thenThrowNotFoundException() { + void givenNoSecretShareWithGivenIdInDatabase_whenRetrieveTag_thenThrowNotFoundException() { when(secretEntityRepository.existsById(testSecretId.toString())).thenReturn(false); String key = testTag.getKey(); NotFoundException nfe = @@ -615,8 +608,7 @@ public void givenNoSecretShareWithGivenIdInDatabase_whenRetrieveTag_thenThrowNot } @Test - public void - givenNoTagWithGivenKeyInDatabaseForGivenObject_whenRetrieveTag_thenThrowNotFoundException() { + void givenNoTagWithGivenKeyInDatabaseForGivenObject_whenRetrieveTag_thenThrowNotFoundException() { String key = testTag.getKey(); SecretEntity existingSecretEntity = new SecretEntity(testSecretId.toString(), emptySet()); when(secretEntityRepository.existsById(testSecretId.toString())).thenReturn(true); @@ -624,18 +616,17 @@ public void givenNoSecretShareWithGivenIdInDatabase_whenRetrieveTag_thenThrowNot when(tagRepository.findBySecretAndKey(existingSecretEntity, testTag.getKey())) .thenReturn(Optional.empty()); - NotFoundException nfe = - assertThrows( - String.format( - NO_TAG_WITH_KEY_EXISTS_FOR_SECRET_WITH_ID_EXCEPTION_MSG, - testTag.getKey(), - existingSecretEntity.getSecretId()), - NotFoundException.class, - () -> storageService.retrieveTag(testSecretId, key)); + assertThrows( + NotFoundException.class, + () -> storageService.retrieveTag(testSecretId, key), + String.format( + NO_TAG_WITH_KEY_EXISTS_FOR_SECRET_WITH_ID_EXCEPTION_MSG, + testTag.getKey(), + existingSecretEntity.getSecretId())); } @Test - public void givenSuccessfulRequest_whenRetrieveTag_thenReturnContent() { + void givenSuccessfulRequest_whenRetrieveTag_thenReturnContent() { TagEntity existingTagEntity = TagEntity.fromTag(testTag); SecretEntity existingSecretEntity = new SecretEntity(testSecretId.toString(), singleton(existingTagEntity)); @@ -648,7 +639,7 @@ public void givenSuccessfulRequest_whenRetrieveTag_thenReturnContent() { } @Test - public void givenTagHasReservedKey_whenUpdateTag_thenThrowIllegalArgumentException() { + void givenTagHasReservedKey_whenUpdateTag_thenThrowIllegalArgumentException() { IllegalArgumentException iae = assertThrows( IllegalArgumentException.class, @@ -659,7 +650,7 @@ public void givenTagHasReservedKey_whenUpdateTag_thenThrowIllegalArgumentExcepti } @Test - public void givenNoSecretShareWithGivenIdInDatabase_whenUpdateTag_thenThrowNotFoundException() { + void givenNoSecretShareWithGivenIdInDatabase_whenUpdateTag_thenThrowNotFoundException() { when(secretEntityRepository.existsById(testSecretId.toString())).thenReturn(false); NotFoundException nfe = @@ -670,8 +661,7 @@ public void givenNoSecretShareWithGivenIdInDatabase_whenUpdateTag_thenThrowNotFo } @Test - public void - givenNoTagWithGivenKeyInDatabaseForGivenObject_whenUpdateTag_thenThrowNotFoundException() { + void givenNoTagWithGivenKeyInDatabaseForGivenObject_whenUpdateTag_thenThrowNotFoundException() { SecretEntity existingSecretEntity = new SecretEntity(testSecretId.toString(), emptySet()); when(secretEntityRepository.existsById(existingSecretEntity.getSecretId())).thenReturn(true); when(secretEntityRepository.getOne(existingSecretEntity.getSecretId())) @@ -680,16 +670,16 @@ public void givenNoSecretShareWithGivenIdInDatabase_whenUpdateTag_thenThrowNotFo .thenReturn(Optional.empty()); assertThrows( + NotFoundException.class, + () -> storageService.updateTag(testSecretId, testTag), String.format( NO_TAG_WITH_KEY_EXISTS_FOR_SECRET_WITH_ID_EXCEPTION_MSG, testTag.getKey(), - existingSecretEntity.getSecretId()), - NotFoundException.class, - () -> storageService.updateTag(testSecretId, testTag)); + existingSecretEntity.getSecretId())); } @Test - public void givenSuccessfulRequest_whenUpdateTag_thenUpdateTag() { + void givenSuccessfulRequest_whenUpdateTag_thenUpdateTag() { Tag newTag = Tag.builder().key(testTag.getKey()).value("123").valueType(TagValueType.LONG).build(); TagEntity existingTagEntity = TagEntity.fromTag(testTag); @@ -710,7 +700,7 @@ public void givenSuccessfulRequest_whenUpdateTag_thenUpdateTag() { } @Test - public void givenTagHasReservedKey_whenDeleteTag_thenThrowIllegalArgumentException() { + void givenTagHasReservedKey_whenDeleteTag_thenThrowIllegalArgumentException() { String reservedKey = testTagReservedCreationDateKey.getKey(); IllegalArgumentException iae = assertThrows( @@ -720,7 +710,7 @@ public void givenTagHasReservedKey_whenDeleteTag_thenThrowIllegalArgumentExcepti } @Test - public void givenNoSecretShareWithGivenIdInDatabase_whenDeleteTag_thenThrowNotFoundException() { + void givenNoSecretShareWithGivenIdInDatabase_whenDeleteTag_thenThrowNotFoundException() { String key = testTag.getKey(); when(secretEntityRepository.existsById(testSecretId.toString())).thenReturn(false); @@ -732,8 +722,7 @@ public void givenNoSecretShareWithGivenIdInDatabase_whenDeleteTag_thenThrowNotFo } @Test - public void - givenNoTagWithGivenKeyInDatabaseForGivenObject_whenDeleteTag_thenThrowNotFoundException() { + void givenNoTagWithGivenKeyInDatabaseForGivenObject_whenDeleteTag_thenThrowNotFoundException() { String key = testTag.getKey(); SecretEntity existingSecretEntity = new SecretEntity(testSecretId.toString(), emptySet()); when(secretEntityRepository.existsById(testSecretId.toString())).thenReturn(true); @@ -741,16 +730,16 @@ public void givenNoSecretShareWithGivenIdInDatabase_whenDeleteTag_thenThrowNotFo when(tagRepository.findBySecretAndKey(existingSecretEntity, key)).thenReturn(Optional.empty()); assertThrows( + NotFoundException.class, + () -> storageService.deleteTag(testSecretId, key), String.format( NO_TAG_WITH_KEY_EXISTS_FOR_SECRET_WITH_ID_EXCEPTION_MSG, testTag.getKey(), - existingSecretEntity.getSecretId()), - NotFoundException.class, - () -> storageService.deleteTag(testSecretId, key)); + existingSecretEntity.getSecretId())); } @Test - public void givenSuccessfulRequest_whenDeleteTag_thenDelete() { + void givenSuccessfulRequest_whenDeleteTag_thenDelete() { TagEntity tagEntityToDelete = TagEntity.fromTag(testTag); SecretEntity existingSecretEntity = new SecretEntity(testSecretId.toString(), singleton(tagEntityToDelete)); diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/InputMaskShareControllerTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/InputMaskShareControllerTest.java index 03baac7..4030be3 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/InputMaskShareControllerTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/InputMaskShareControllerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -12,8 +12,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; import io.carbynestack.amphora.service.AmphoraTestData; @@ -26,41 +26,37 @@ import java.util.Map; import java.util.UUID; import lombok.SneakyThrows; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +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.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -@RunWith(MockitoJUnitRunner.class) -public class InputMaskShareControllerTest { +@ExtendWith(MockitoExtension.class) +class InputMaskShareControllerTest { private final UUID testRequestId = UUID.fromString("7520e090-1437-44da-9e4e-eea5b2200fea"); private final long validNumberOfTuples = 1; private final long invalidNumberOfTuples = -1; - private final String testCastorServiceUri = "https://castor.carbynestack.io"; - private final TupleList, Field.Gfp> testInputMasks = - AmphoraTestData.getRandomInputMaskList(validNumberOfTuples); @Mock private InputMaskCachingService inputMaskStore; @InjectMocks private InputMaskShareController inputMaskShareController; - @Before - public void prepareMocks() { + @SneakyThrows + @Test + void givenSuccessfulRequest_whenGetInputMasks_thenReturnExpectedResult() { + String testCastorServiceUri = "https://castor.carbynestack.io"; + TupleList, Field.Gfp> testInputMasks = + AmphoraTestData.getRandomInputMaskList(validNumberOfTuples); Map inputMaskListMap = new HashMap<>(); - CastorServiceUri castorServiceUri = new CastorServiceUri(this.testCastorServiceUri); + CastorServiceUri castorServiceUri = new CastorServiceUri(testCastorServiceUri); inputMaskListMap.put(castorServiceUri, testInputMasks); when(inputMaskStore.fetchAndCacheInputMasks(testRequestId, testInputMasks.size())) .thenReturn(testInputMasks); - } - @SneakyThrows - @Test - public void givenSuccessfulRequest_whenGetInputMasks_thenReturnExpectedResult() { ResponseEntity, Field.Gfp>> responseEntity = inputMaskShareController.getInputMasks(testRequestId, validNumberOfTuples); @@ -69,7 +65,7 @@ public void givenSuccessfulRequest_whenGetInputMasks_thenReturnExpectedResult() } @Test - public void givenEmptyStringAsRequestId_whenGetInputMasks_thenThrowIllegalArgumentException() { + void givenEmptyStringAsRequestId_whenGetInputMasks_thenThrowIllegalArgumentException() { IllegalArgumentException iae = assertThrows( IllegalArgumentException.class, @@ -78,7 +74,7 @@ public void givenEmptyStringAsRequestId_whenGetInputMasks_thenThrowIllegalArgume } @Test - public void givenInvalidCountArgument_whenGetInputMasks_thenThrowIllegalArgumentException() { + void givenInvalidCountArgument_whenGetInputMasks_thenThrowIllegalArgumentException() { IllegalArgumentException iae = assertThrows( IllegalArgumentException.class, diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/InterVcpControllerTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/InterVcpControllerTest.java index aa6c13b..8ceebc3 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/InterVcpControllerTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/InterVcpControllerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -15,21 +15,21 @@ import io.carbynestack.amphora.service.persistence.cache.InterimValueCachingService; import java.util.Collections; import java.util.UUID; -import org.junit.Test; -import org.junit.runner.RunWith; +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.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; -@RunWith(MockitoJUnitRunner.class) -public class InterVcpControllerTest { +@ExtendWith(MockitoExtension.class) +class InterVcpControllerTest { @Mock private InterimValueCachingService interimValueCachingService; @InjectMocks private InterVcpController interVcpController; @Test - public void givenSuccessfulRequest_whenReceivingInterimValues_thenStoreValuesInCache() { + void givenSuccessfulRequest_whenReceivingInterimValues_thenStoreValuesInCache() { MultiplicationExchangeObject exchangeObject = new MultiplicationExchangeObject( UUID.fromString("ea983b9b-0e98-4cbb-8dbf-3c8362653c0d"), 0, Collections.emptyList()); diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/IntraVcpControllerTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/IntraVcpControllerTest.java index 28dce23..9a6a14e 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/IntraVcpControllerTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/IntraVcpControllerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -8,31 +8,31 @@ import static io.carbynestack.amphora.common.rest.AmphoraRestApiEndpoints.INTRA_VCP_OPERATIONS_SEGMENT; import static io.carbynestack.amphora.service.util.ServletUriComponentsBuilderUtil.runInMockedHttpRequestContextForUri; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; import io.carbynestack.amphora.common.SecretShare; import io.carbynestack.amphora.service.persistence.metadata.StorageService; import java.net.URI; import java.util.UUID; -import org.junit.Test; -import org.junit.runner.RunWith; +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.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -@RunWith(MockitoJUnitRunner.class) -public class IntraVcpControllerTest { +@ExtendWith(MockitoExtension.class) +class IntraVcpControllerTest { @Mock private StorageService storageService; @InjectMocks private IntraVcpController intraVcpController; @Test - public void givenArgumentIsNull_whenUploadSecretShare_thenThrowIllegalArgumentException() { + void givenArgumentIsNull_whenUploadSecretShare_thenThrowIllegalArgumentException() { IllegalArgumentException iae = assertThrows( IllegalArgumentException.class, () -> intraVcpController.uploadSecretShare(null)); @@ -40,7 +40,7 @@ public void givenArgumentIsNull_whenUploadSecretShare_thenThrowIllegalArgumentEx } @Test - public void givenSuccessfulRequest_whenUploadSecretShare_thenReturnCreatedWithExpectedContent() { + void givenSuccessfulRequest_whenUploadSecretShare_thenReturnCreatedWithExpectedContent() { UUID secretShareId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); URI expectedUri = URI.create( @@ -59,7 +59,7 @@ public void givenSuccessfulRequest_whenUploadSecretShare_thenReturnCreatedWithEx } @Test - public void givenSuccessfulRequest_whenDownloadSecretShare_thenReturnOkWithExpectedContent() { + void givenSuccessfulRequest_whenDownloadSecretShare_thenReturnOkWithExpectedContent() { UUID secretShareId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); SecretShare expectedSecretShare = SecretShare.builder().secretId(secretShareId).build(); diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/MaskedInputControllerTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/MaskedInputControllerTest.java index ac013e5..2cfabef 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/MaskedInputControllerTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/MaskedInputControllerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -10,8 +10,8 @@ import static io.carbynestack.amphora.service.util.ServletUriComponentsBuilderUtil.runInMockedHttpRequestContextForUri; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; import io.carbynestack.amphora.common.MaskedInput; @@ -19,30 +19,30 @@ import io.carbynestack.amphora.service.persistence.metadata.StorageService; import java.net.URI; import java.util.UUID; -import org.junit.Test; -import org.junit.runner.RunWith; +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.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -@RunWith(MockitoJUnitRunner.class) -public class MaskedInputControllerTest { +@ExtendWith(MockitoExtension.class) +class MaskedInputControllerTest { @Mock private StorageService storageService; @InjectMocks private MaskedInputController maskedInputController; @Test - public void givenArgumentIsNull_whenUpload_thenThrowIllegalArgumentException() { + void givenArgumentIsNull_whenUpload_thenThrowIllegalArgumentException() { IllegalArgumentException iae = assertThrows(IllegalArgumentException.class, () -> maskedInputController.upload(null)); assertEquals("MaskedInput must not be null", iae.getMessage()); } @Test - public void givenMaskedInputDataIsEmpty_whenUpload_thenThrowIllegalArgumentException() { + void givenMaskedInputDataIsEmpty_whenUpload_thenThrowIllegalArgumentException() { UUID expectedId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); MaskedInput maskedInput = new MaskedInput(expectedId, emptyList(), emptyList()); @@ -53,7 +53,7 @@ public void givenMaskedInputDataIsEmpty_whenUpload_thenThrowIllegalArgumentExcep } @Test - public void givenSuccessfulRequest_whenUpload_thenReturnCreatedWithExpectedContent() { + void givenSuccessfulRequest_whenUpload_thenReturnCreatedWithExpectedContent() { UUID secretShareId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); URI expectedUri = URI.create( diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/SecretShareControllerTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/SecretShareControllerTest.java index 208754e..bc7fba4 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/SecretShareControllerTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/SecretShareControllerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -12,8 +12,8 @@ import static io.carbynestack.amphora.common.rest.AmphoraRestApiEndpoints.CRITERIA_SEPARATOR; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -23,17 +23,17 @@ import java.util.List; import java.util.UUID; import lombok.SneakyThrows; -import org.junit.Test; -import org.junit.runner.RunWith; +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.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.domain.*; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -@RunWith(MockitoJUnitRunner.class) -public class SecretShareControllerTest { +@ExtendWith(MockitoExtension.class) +class SecretShareControllerTest { @Mock private OutputDeliveryService outputDeliveryService; @@ -43,7 +43,7 @@ public class SecretShareControllerTest { @SneakyThrows @Test - public void + void givenSuccessfulRequestWithoutFilterAndWithoutPaging_whenGetObjectList_thenReturnExpectedContent() { List expectedMetadataList = emptyList(); Page metadataSpringPage = new PageImpl<>(expectedMetadataList, Pageable.unpaged(), 0); @@ -67,7 +67,7 @@ public class SecretShareControllerTest { @SneakyThrows @Test - public void + void givenSuccessfulRequestWithoutFilterButWithPaging_whenGetObjectList_thenReturnExpectedContent() { List expectedMetadataList = emptyList(); Page metadataSpringPage = new PageImpl<>(expectedMetadataList, Pageable.unpaged(), 0); @@ -92,7 +92,7 @@ public class SecretShareControllerTest { @SneakyThrows @Test - public void + void givenSuccessfulRequestWithFilterAndWithoutPaging_whenGetObjectList_thenReturnExpectedContent() { List expectedMetadataList = emptyList(); Page metadataSpringPage = new PageImpl<>(expectedMetadataList, Pageable.unpaged(), 0); @@ -119,8 +119,7 @@ public class SecretShareControllerTest { @SneakyThrows @Test - public void - givenSuccessfulRequestWithFilterButWithPaging_whenGetObjectList_thenReturnExpectedContent() { + void givenSuccessfulRequestWithFilterButWithPaging_whenGetObjectList_thenReturnExpectedContent() { List expectedMetadataList = emptyList(); Page metadataSpringPage = new PageImpl<>(expectedMetadataList, Pageable.unpaged(), 0); String filter = "key" + EQUALS + "value" + CRITERIA_SEPARATOR + "key2" + LESS_THAN + "42"; @@ -145,7 +144,7 @@ public class SecretShareControllerTest { } @Test - public void givenRequestIdArgumentIsNull_whenGetSecretShare_thenThrowIllegalArgumentException() { + void givenRequestIdArgumentIsNull_whenGetSecretShare_thenThrowIllegalArgumentException() { UUID secretId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); IllegalArgumentException iae = assertThrows( @@ -155,7 +154,7 @@ public void givenRequestIdArgumentIsNull_whenGetSecretShare_thenThrowIllegalArgu } @Test - public void givenSuccessfulRequest_whenGetSecretShare_thenReturnOkAndExpectedContent() { + void givenSuccessfulRequest_whenGetSecretShare_thenReturnOkAndExpectedContent() { UUID secretId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); UUID requestId = UUID.fromString("d6d0f4ff-df28-4c96-b7df-95170320eaee"); SecretShare secretShare = SecretShare.builder().secretId(requestId).build(); @@ -171,14 +170,14 @@ public void givenSuccessfulRequest_whenGetSecretShare_thenReturnOkAndExpectedCon } @Test - public void givenSuccessfulRequest_whenDeleteSecretShare_thenReturnOk() { + void givenSuccessfulRequest_whenDeleteSecretShare_thenReturnOk() { UUID secretId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); ResponseEntity actualResponse = secretShareController.deleteSecretShare(secretId); assertEquals(HttpStatus.OK, actualResponse.getStatusCode()); } @Test - public void givenSortPropertyButInvalidDirection_whenGetSort_thenReturnSortAsc() { + void givenSortPropertyButInvalidDirection_whenGetSort_thenReturnSortAsc() { String expectedProperty = "key"; String invalidDirection = "invalid"; assertEquals( @@ -187,14 +186,14 @@ public void givenSortPropertyButInvalidDirection_whenGetSort_thenReturnSortAsc() } @Test - public void givenNoSortProperty_whenGetSort_thenReturnUnsorted() { + void givenNoSortProperty_whenGetSort_thenReturnUnsorted() { String emptyProperty = ""; String direction = Sort.Direction.ASC.toString(); assertEquals(Sort.unsorted(), secretShareController.getSort(emptyProperty, direction)); } @Test - public void givenValidConfiguration_whenGetSort_thenReturnExpectedContent() { + void givenValidConfiguration_whenGetSort_thenReturnExpectedContent() { String expectedProperty = "key"; Sort.Direction expectedDirection = Sort.Direction.DESC; assertEquals( diff --git a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/TagsControllerTest.java b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/TagsControllerTest.java index eb62c8d..5320e3b 100644 --- a/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/TagsControllerTest.java +++ b/amphora-service/src/test/java/io/carbynestack/amphora/service/rest/TagsControllerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - for information on the respective copyright owner + * Copyright (c) 2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. * * SPDX-License-Identifier: Apache-2.0 @@ -10,8 +10,8 @@ import static io.carbynestack.amphora.service.util.ServletUriComponentsBuilderUtil.runInMockedHttpRequestContextForUri; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*; import io.carbynestack.amphora.common.Tag; @@ -20,16 +20,16 @@ import java.net.URI; import java.util.List; import java.util.UUID; -import org.junit.Test; -import org.junit.runner.RunWith; +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.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -@RunWith(MockitoJUnitRunner.class) -public class TagsControllerTest { +@ExtendWith(MockitoExtension.class) +class TagsControllerTest { private final UUID testSecretId = UUID.fromString("3bcf8308-8f50-4d24-a37b-b0075bb5e779"); private final Tag testTag = Tag.builder().key("key").value("value").valueType(TagValueType.STRING).build(); @@ -39,7 +39,7 @@ public class TagsControllerTest { @InjectMocks private TagsController tagsController; @Test - public void givenSuccessfulRequest_whenGetTags_thenReturnOkWithExpectedContent() { + void givenSuccessfulRequest_whenGetTags_thenReturnOkWithExpectedContent() { List expectedList = singletonList(testTag); when(storageService.retrieveTags(testSecretId)).thenReturn(expectedList); @@ -50,7 +50,7 @@ public void givenSuccessfulRequest_whenGetTags_thenReturnOkWithExpectedContent() } @Test - public void givenTagIsNull_whenCreateTag_thenThrowIllegalArgumentException() { + void givenTagIsNull_whenCreateTag_thenThrowIllegalArgumentException() { IllegalArgumentException iae = assertThrows( IllegalArgumentException.class, () -> tagsController.createTag(testSecretId, null)); @@ -59,7 +59,7 @@ public void givenTagIsNull_whenCreateTag_thenThrowIllegalArgumentException() { } @Test - public void givenSuccessfulRequest_whenCreateTag_thenReturnCreatedWithExpectedContent() { + void givenSuccessfulRequest_whenCreateTag_thenReturnCreatedWithExpectedContent() { URI expectedUri = URI.create( "https://amphora.carbynestack.io" + INTRA_VCP_OPERATIONS_SEGMENT + "/" + testSecretId); @@ -74,7 +74,7 @@ public void givenSuccessfulRequest_whenCreateTag_thenReturnCreatedWithExpectedCo } @Test - public void givenTagsAreEmpty_whenUpdateTags_thenThrowIllegalArgumentException() { + void givenTagsAreEmpty_whenUpdateTags_thenThrowIllegalArgumentException() { List emptyTags = emptyList(); IllegalArgumentException iae = assertThrows( @@ -85,7 +85,7 @@ public void givenTagsAreEmpty_whenUpdateTags_thenThrowIllegalArgumentException() } @Test - public void givenSuccessfulRequest_whenUpdateTags_thenReturnCreatedWithExpectedContent() { + void givenSuccessfulRequest_whenUpdateTags_thenReturnCreatedWithExpectedContent() { List newTagList = singletonList(testTag); ResponseEntity actualResponse = tagsController.updateTags(testSecretId, newTagList); verify(storageService, times(1)).replaceTags(testSecretId, newTagList); @@ -93,7 +93,7 @@ public void givenSuccessfulRequest_whenUpdateTags_thenReturnCreatedWithExpectedC } @Test - public void givenSuccessfulRequest_whenGetTag_thenReturnOkWithExpectedContent() { + void givenSuccessfulRequest_whenGetTag_thenReturnOkWithExpectedContent() { when(storageService.retrieveTag(testSecretId, testTag.getKey())).thenReturn(testTag); ResponseEntity actualResponse = tagsController.getTag(testSecretId, testTag.getKey()); @@ -102,7 +102,7 @@ public void givenSuccessfulRequest_whenGetTag_thenReturnOkWithExpectedContent() } @Test - public void givenTagIsNull_whenPutTag_thenTrowIllegalArgumentException() { + void givenTagIsNull_whenPutTag_thenTrowIllegalArgumentException() { String key = testTag.getKey(); IllegalArgumentException iae = assertThrows( @@ -112,8 +112,7 @@ public void givenTagIsNull_whenPutTag_thenTrowIllegalArgumentException() { } @Test - public void - givenTagConfigurationDoesNotMatchAddressedKey_whenPutTag_thenTrowIllegalArgumentException() { + void givenTagConfigurationDoesNotMatchAddressedKey_whenPutTag_thenTrowIllegalArgumentException() { String nonMatchingKey = testTag.getKey() + "_different"; IllegalArgumentException iae = assertThrows( @@ -127,7 +126,7 @@ public void givenTagIsNull_whenPutTag_thenTrowIllegalArgumentException() { } @Test - public void givenSuccessfulRequest_whenPutTag_thenReturnOk() { + void givenSuccessfulRequest_whenPutTag_thenReturnOk() { ResponseEntity actualResponse = tagsController.putTag(testSecretId, testTag.getKey(), testTag); verify(storageService, times(1)).updateTag(testSecretId, testTag); @@ -135,7 +134,7 @@ public void givenSuccessfulRequest_whenPutTag_thenReturnOk() { } @Test - public void givenSuccessfulRequest_whenDeleteTag_thenReturnOk() { + void givenSuccessfulRequest_whenDeleteTag_thenReturnOk() { ResponseEntity actualResponse = tagsController.deleteTag(testSecretId, testTag.getKey()); verify(storageService, times(1)).deleteTag(testSecretId, testTag.getKey()); assertEquals(HttpStatus.OK, actualResponse.getStatusCode()); diff --git a/amphora-service/src/test/resources/application-test.properties b/amphora-service/src/test/resources/application-test.properties new file mode 100644 index 0000000..6b2868a --- /dev/null +++ b/amphora-service/src/test/resources/application-test.properties @@ -0,0 +1,36 @@ +# +# Copyright (c) 2023 - for information on the respective copyright owner +# see the NOTICE file and/or the repository https://github.com/carbynestack/amphora. +# +# SPDX-License-Identifier: Apache-2.0 +# + +spring.config.activate.on-profile=test + +spring.datasource.driver-class-name=org.postgresql.Driver +spring.datasource.url=${POSTGRESQL_URL} +spring.datasource.username=${POSTGRESQL_USERNAME} +spring.datasource.password=${POSTGRESQL_PASSWORD} +spring.jpa.database=postgresql +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect +spring.jpa.hibernate.connection.autocommit=true +spring.jpa.hibernate.ddl-auto=update +spring.jpa.hibernate.hbm2ddl.auto=update + +logging.level.ROOT=INFO +logging.level.io.carbynestack=DEBUG +logging.level.org.springframework=INFO + +carbynestack.amphora.vcPartners=http://amphora2.carbynestack.io +carbynestack.amphora.minio.endpoint=${MINIO_ENDPOINT} +carbynestack.amphora.minio.bucket=minio-amphora-test-bucket +carbynestack.amphora.minio.access-key=${MINIO_ACCESS_KEY} +carbynestack.amphora.minio.secret-key=${MINIO_SECRET_KEY} +carbynestack.amphora.cache.host=${REDIS_HOST} +carbynestack.amphora.cache.port=${REDIS_PORT} +carbynestack.amphora.cache.input-mask-store=input-mask-store +carbynestack.amphora.cache.interim-value-store=interim-value-store +carbynestack.spdz.prime=198766463529478683931867765928436695041 +carbynestack.spdz.r=141515903391459779531506841503331516415 +carbynestack.spdz.rInv=133854242216446749056083838363708373830 +carbynestack.castor.service-uri=http://castor.carbynestack.io diff --git a/amphora-service/src/test/resources/application-test.yml b/amphora-service/src/test/resources/application-test.yml deleted file mode 100644 index 992f367..0000000 --- a/amphora-service/src/test/resources/application-test.yml +++ /dev/null @@ -1,43 +0,0 @@ -spring: - config: - activate: - on-profile: test - - datasource: - driver-class-name: org.postgresql.Driver - url: ${POSTGRESQL_URL} - username: ${POSTGRESQL_USERNAME} - password: ${POSTGRESQL_PASSWORD} - jpa: - database: postgresql - database-platform: org.hibernate.dialect.PostgreSQLDialect - hibernate: - connection: - autocommit: true - ddl-auto: update - hbm2ddl: - auto: update - -logging: - level: - ROOT: INFO - io.carbynestack: DEBUG - org.springframework: INFO - -carbynestack: - amphora: - vcPartners: http://amphora2.carbynestack.io - minio: - endpoint: ${MINIO_ENDPOINT} - bucket: minio-amphora-test-bucket - access-key: ${MINIO_ACCESS_KEY} - secret-key: ${MINIO_SECRET_KEY} - cache: - host: ${REDIS_HOST} - port: ${REDIS_PORT} - spdz: - prime: 198766463529478683931867765928436695041 - r: 141515903391459779531506841503331516415 - rInv: 133854242216446749056083838363708373830 - castor: - service-uri: http://castor.carbynestack.io diff --git a/pom.xml b/pom.xml index 977354d..9fdf259 100644 --- a/pom.xml +++ b/pom.xml @@ -57,21 +57,22 @@ 0.8.5 3.8.1 - 3.0.0-M5 + 3.0.0-M9 3.2.0 3.2.1 - 3.0.0-M5 + 3.0.0-M9 2.0.0 - 0.1-SNAPSHOT-4191841095-22-1721229 + 0.1-SNAPSHOT-4321261594-23-40a9faa 0.2-SNAPSHOT-3541842672-11-c754bbb 0.1-SNAPSHOT-4075044562-9-8ffab9c - - 4.13.2 - 2.19.0 + 3.24.2 + 2.14.2 + 5.9.2 + 2.20.0 1.18.24 3.11.2 2.0.6 @@ -192,6 +193,16 @@ log4j-slf4j-impl ${log4j.version} + + org.apache.logging.log4j + log4j-jul + ${log4j.version} + + + org.slf4j + jul-to-slf4j + ${slf4j.version} + io.vavr vavr @@ -210,6 +221,12 @@ + + org.assertj + assertj-core + ${assertj.version} + test + org.mockito mockito-core @@ -223,9 +240,21 @@ test - junit - junit - ${junit.version} + org.mockito + mockito-junit-jupiter + ${mockito.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} test