From 517e6a5752b92a58670b7e1787c6ea27fdab31af Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 20 Jan 2026 09:20:57 +0200 Subject: [PATCH 01/36] CE-132 oap-sso: user: replace PK: email -> id --- .../main/java/oap/http/test/HttpAsserts.java | 59 +++++++++++++++++++ .../http/server/nio/NioHttpServerTest.java | 4 +- .../nio/health/HealthHttpHandlerTest.java | 19 +----- oap-http/oap-http/pom.xml | 7 ++- .../test/java/oap/ws/admin/JPathWSTest.java | 6 +- .../test/java/oap/ws/admin/SchemaWSTest.java | 4 +- .../src/test/java/oap/ws/api/ApiWSTest.java | 10 ++-- .../src/test/java/oap/ws/file/FileWSTest.java | 6 +- .../java/oap/ws/openapi/OpenapiWSTest.java | 6 +- .../java/oap/ws/sso/JwtTokenGenerator.java | 3 + .../src/main/java/oap/ws/sso/User.java | 2 + .../main/java/oap/ws/sso/UserProvider.java | 2 +- .../interceptor/JWTSecurityInterceptor.java | 2 +- .../java/oap/ws/sso/AbstractUserTest.java | 8 +++ .../src/test/java/oap/ws/ValidationTest.java | 14 ++--- .../java/oap/ws/WebServicesLocalTest.java | 4 +- .../java/oap/ws/WebServicesSessionTest.java | 14 ++--- .../src/test/java/oap/ws/WebServicesTest.java | 52 ++++++++-------- .../oap/ws/interceptor/InterceptorTest.java | 4 +- .../MethodValidatorPeerMethodTest.java | 4 +- .../oap/ws/validate/ValidationErrors.java | 3 +- pom.xml | 12 +++- 22 files changed, 157 insertions(+), 88 deletions(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 18d6336abe..8a7581bdad 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -28,16 +28,30 @@ import lombok.extern.slf4j.Slf4j; import oap.http.Client; import oap.http.Cookie; +import oap.http.Uri; import oap.json.JsonException; import oap.json.testng.JsonAsserts; +import oap.testng.Asserts; import oap.util.BiStream; +import oap.util.Maps; import oap.util.Pair; import oap.util.Stream; +import okhttp3.Headers; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import okhttp3.java.net.cookiejar.JavaNetCookieJar; import org.assertj.core.api.Assertions; import org.joda.time.DateTime; import org.testng.internal.collections.Ints; +import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; +import java.net.CookieManager; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -56,6 +70,10 @@ @Slf4j @SuppressWarnings( "unused" ) public class HttpAsserts { + public static final OkHttpClient OK_HTTP_CLIENT = new OkHttpClient.Builder() + .cookieJar( new JavaNetCookieJar( new CookieManager() ) ) + .build(); + private static final Client client = Client.custom() .setMaxConnTotal( 100_000 ) .setMaxConnPerRoute( 100_000 ) @@ -75,12 +93,49 @@ public static void reset() { client.reset(); } + @SafeVarargs + public static HttpAssertion assertGet2( String uri, Pair... params ) throws UncheckedIOException { + return assertGet2( uri, Maps.of( params ), Map.of() ); + } + + public static HttpAssertion assertGet2( String uri, Map params, Map requestHeaders ) throws UncheckedIOException { + try { + Request.Builder builder = new Request.Builder(); + + requestHeaders.forEach( ( k, v ) -> builder.header( k, v == null ? "" : v.toString() ) ); + + Request request = builder + .url( Uri.uri( uri, params ).toURL() ) + .get() + .build(); + try( Response response = OK_HTTP_CLIENT.newCall( request ).execute(); + ResponseBody body = response.body() ) { + + Headers responseHeaders = response.headers(); + ArrayList> headers = new ArrayList<>(); + responseHeaders.toMultimap().forEach( ( k, vs ) -> vs.forEach( v -> headers.add( Pair.__( k, v ) ) ) ); + byte[] bytes = body.bytes(); + return new HttpAssertion( new Client.Response( response.code(), response.message(), headers, body.contentType().toString(), new ByteArrayInputStream( bytes ) ) ); + } + } catch( IOException e ) { + throw new UncheckedIOException( e ); + } + } + + /** + * @see HttpAsserts#assertGet + */ + @Deprecated @SafeVarargs public static HttpAssertion assertGet( String uri, Pair... params ) { return new HttpAssertion( client.get( uri, params ) ); } + /** + * @see HttpAsserts#assertGet + */ + @Deprecated public static HttpAssertion assertGet( String uri, Map params, Map headers ) { return assertHttpResponse( client.get( uri, params, headers ) ); } @@ -349,6 +404,10 @@ public T unmarshal( Class clazz ) { throw Assertions.fail( e.getMessage(), e ); } } + + public Asserts.StringAssertion body() { + return assertString( response.contentString() ); + } } public static final class CookieHttpAssertion { diff --git a/oap-http/oap-http-test/src/test/java/oap/http/server/nio/NioHttpServerTest.java b/oap-http/oap-http-test/src/test/java/oap/http/server/nio/NioHttpServerTest.java index 6d3c8de6a0..8c40723432 100644 --- a/oap-http/oap-http-test/src/test/java/oap/http/server/nio/NioHttpServerTest.java +++ b/oap-http/oap-http-test/src/test/java/oap/http/server/nio/NioHttpServerTest.java @@ -40,7 +40,7 @@ import static oap.http.Http.Headers.CONNECTION; import static oap.http.Http.Headers.DATE; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static org.assertj.core.api.Assertions.assertThat; public class NioHttpServerTest extends Fixtures { @@ -120,7 +120,7 @@ public void testHttps() throws IOException { assertThat( client.get( "https://localhost:" + httpsPort + "/test" ) .contentString() ).isEqualTo( "ok" ); - assertGet( "http://localhost:" + httpPort + "/healtz" ).hasCode( Http.StatusCode.NO_CONTENT ); + assertGet2( "http://localhost:" + httpPort + "/healtz" ).hasCode( Http.StatusCode.NO_CONTENT ); } } diff --git a/oap-http/oap-http-test/src/test/java/oap/http/server/nio/health/HealthHttpHandlerTest.java b/oap-http/oap-http-test/src/test/java/oap/http/server/nio/health/HealthHttpHandlerTest.java index 1863c4c76c..16c4240792 100644 --- a/oap-http/oap-http-test/src/test/java/oap/http/server/nio/health/HealthHttpHandlerTest.java +++ b/oap-http/oap-http-test/src/test/java/oap/http/server/nio/health/HealthHttpHandlerTest.java @@ -24,9 +24,6 @@ package oap.http.server.nio.health; -//import oap.application.module.Module; -//import oap.application.testng.KernelFixture; - import oap.http.server.nio.NioHttpServer; import oap.http.test.HttpAsserts; import oap.testng.Fixtures; @@ -37,19 +34,9 @@ import java.util.Map; import static java.net.HttpURLConnection.HTTP_NO_CONTENT; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; public class HealthHttpHandlerTest extends Fixtures { - public HealthHttpHandlerTest() { -// fixture( new KernelFixture( -// urlOfTestResource( getClass(), "application.test.conf" ), -// Lists.concat( -// List.of( urlOfTestResource( getClass(), "oap-module.oap" ) ), -// Module.CONFIGURATION.urlsFromClassPath() -// ) -// ) ); - } - @Test public void health() throws IOException { int httpPort = Ports.getFreePort( getClass() ); @@ -62,8 +49,8 @@ public void health() throws IOException { httpServer.start(); - assertGet( HttpAsserts.httpUrl( httpPort, "/healtz" ) ).hasCode( HTTP_NO_CONTENT ); - assertGet( HttpAsserts.httpUrl( httpPort, "/healtz?secret=secret" ) ) + assertGet2( HttpAsserts.httpUrl( httpPort, "/healtz" ) ).hasCode( HTTP_NO_CONTENT ); + assertGet2( HttpAsserts.httpUrl( httpPort, "/healtz?secret=secret" ) ) .respondedJson( "{\"test\":{\"k1\":1, \"k2\":2}}" ); } } diff --git a/oap-http/oap-http/pom.xml b/oap-http/oap-http/pom.xml index 849d0fbcea..d5eb23fe59 100644 --- a/oap-http/oap-http/pom.xml +++ b/oap-http/oap-http/pom.xml @@ -81,10 +81,11 @@ com.squareup.okhttp3 okhttp-jvm - - 5.1.0 - + + com.squareup.okhttp3 + okhttp-java-net-cookiejar + org.projectlombok lombok diff --git a/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java b/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java index 4a9b2cfdb5..b52bf0b692 100644 --- a/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java +++ b/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java @@ -30,7 +30,7 @@ import org.testng.annotations.Ignore; import org.testng.annotations.Test; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static oap.io.Resources.urlOrThrow; @Ignore @@ -46,7 +46,7 @@ public JPathWSTest() { public void testJavaBeanPropertyAccess() { kernel.service( "oap-ws-admin-ws-test", TestService.class ).setV2( "testv" ); - assertGet( kernel.httpUrl( "/system/admin/jpath?query=oap-ws-admin-ws-test.test-service.instance.getV2()" ) ) + assertGet2( kernel.httpUrl( "/system/admin/jpath?query=oap-ws-admin-ws-test.test-service.instance.getV2()" ) ) .isOk() .hasBody( "\"testv\"" ); } @@ -54,7 +54,7 @@ public void testJavaBeanPropertyAccess() { @Test public void testPublicFieldAccess() { kernel.service( "oap-ws-admin-ws-test", TestService.class ).setV2( "testv" ); - assertGet( kernel.httpUrl( "/system/admin/jpath?query=oap-ws-admin-ws-test.test-service.instance.value" ) ) + assertGet2( kernel.httpUrl( "/system/admin/jpath?query=oap-ws-admin-ws-test.test-service.instance.value" ) ) .isOk() .hasBody( "\"testv\"" ); } diff --git a/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/SchemaWSTest.java b/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/SchemaWSTest.java index bdd70c3213..03dce9faad 100644 --- a/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/SchemaWSTest.java +++ b/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/SchemaWSTest.java @@ -29,7 +29,7 @@ import oap.testng.TestDirectoryFixture; import org.testng.annotations.Test; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static oap.io.Resources.urlOrThrow; public class SchemaWSTest extends Fixtures { @@ -42,7 +42,7 @@ public SchemaWSTest() { @Test public void testSchema() { - assertGet( kernel.httpUrl( "/system/admin/schema?path=/schema/test-schema.conf" ) ) + assertGet2( kernel.httpUrl( "/system/admin/schema?path=/schema/test-schema.conf" ) ) .isOk() .respondedJson( """ { diff --git a/oap-ws/oap-ws-api-ws/src/test/java/oap/ws/api/ApiWSTest.java b/oap-ws/oap-ws-api-ws/src/test/java/oap/ws/api/ApiWSTest.java index 8b5334ec33..21e4296ceb 100644 --- a/oap-ws/oap-ws-api-ws/src/test/java/oap/ws/api/ApiWSTest.java +++ b/oap-ws/oap-ws-api-ws/src/test/java/oap/ws/api/ApiWSTest.java @@ -30,9 +30,11 @@ import oap.testng.TestDirectoryFixture; import org.testng.annotations.Test; +import java.io.IOException; + import static oap.http.Http.ContentType.TEXT_PLAIN; import static oap.http.Http.StatusCode.OK; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static oap.io.Resources.urlOrThrow; import static oap.io.content.ContentReader.ofString; import static oap.testng.Asserts.contentOfTestResource; @@ -47,15 +49,15 @@ public ApiWSTest() { } @Test - public void api() { - assertGet( kernel.httpUrl( "/system/api" ) ) + public void api() throws IOException { + assertGet2( kernel.httpUrl( "/system/api" ) ) .responded( OK, "OK", TEXT_PLAIN, contentOfTestResource( getClass(), "api.txt", ofString() ) ); } @Test public void apiWithoutDeprecated() { - assertGet( kernel.httpUrl( "/system/api?deprecated=false" ) ) + assertGet2( kernel.httpUrl( "/system/api?deprecated=false" ) ) .responded( OK, "OK", TEXT_PLAIN, contentOfTestResource( getClass(), "apiWithoutDeprecated.txt", ofString() ) ); } diff --git a/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java b/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java index a67630ce01..ac8d3882db 100644 --- a/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java +++ b/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java @@ -33,7 +33,7 @@ of this software and associated documentation files (the "Software"), to deal import org.testng.annotations.Ignore; import org.testng.annotations.Test; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static oap.http.test.HttpAsserts.assertPost; import static oap.io.content.ContentReader.ofString; import static oap.testng.Asserts.contentOfTestResource; @@ -65,11 +65,11 @@ public void upload() { @Test public void download() { Files.write( testDirectoryFixture.testPath( "default/test.txt" ), "test", ContentWriter.ofString() ); - assertGet( kernel.httpUrl( "/file?path=test.txt" ) ) + assertGet2( kernel.httpUrl( "/file?path=test.txt" ) ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.TEXT_PLAIN, "test" ); Files.write( testDirectoryFixture.testPath( "b1/test.txt" ), "b1test", ContentWriter.ofString() ); - assertGet( kernel.httpUrl( "/file?path=test.txt&bucket=b1" ) ) + assertGet2( kernel.httpUrl( "/file?path=test.txt&bucket=b1" ) ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.TEXT_PLAIN, "b1test" ); } } diff --git a/oap-ws/oap-ws-openapi-ws/src/test/java/oap/ws/openapi/OpenapiWSTest.java b/oap-ws/oap-ws-openapi-ws/src/test/java/oap/ws/openapi/OpenapiWSTest.java index 37f1881972..b60a3bdf1f 100644 --- a/oap-ws/oap-ws-openapi-ws/src/test/java/oap/ws/openapi/OpenapiWSTest.java +++ b/oap-ws/oap-ws-openapi-ws/src/test/java/oap/ws/openapi/OpenapiWSTest.java @@ -33,7 +33,7 @@ import java.util.Map; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static oap.io.Resources.urlOrThrow; import static oap.testng.Asserts.contentOfTestResource; @@ -48,14 +48,14 @@ public OpenapiWSTest() { @Test public void openapiWithDeprecated() { - assertGet( kernel.httpUrl( "/system/openapi?skipDeprecated=false" ) ) + assertGet2( kernel.httpUrl( "/system/openapi?skipDeprecated=false" ) ) .respondedJson( Http.StatusCode.OK, "OK", contentOfTestResource( getClass(), "openapi.json", Map.of() ) ); } @Test public void openapiWithoutDeprecated() { - assertGet( kernel.httpUrl( "/system/openapi" ) ) + assertGet2( kernel.httpUrl( "/system/openapi" ) ) .respondedJson( Http.StatusCode.OK, "OK", contentOfTestResource( getClass(), "openapiWithoutDeprecated.json", Map.of() ) ); } diff --git a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/JwtTokenGenerator.java b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/JwtTokenGenerator.java index 216d997713..d89b9eb7b5 100644 --- a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/JwtTokenGenerator.java +++ b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/JwtTokenGenerator.java @@ -53,6 +53,7 @@ public Authentication.Token generateAccessToken( User user ) throws JWTCreationE Algorithm algorithm = Algorithm.HMAC256( accessSecret ); Date expiresAt = new org.joda.time.DateTime( DateTimeUtils.currentTimeMillis() + accessSecretExpiration, UTC ).toDate(); return new Authentication.Token( expiresAt, JWT.create() + .withClaim( "id", user.getId() ) .withClaim( "user", user.getEmail() ) .withClaim( "roles", user.getRoles() ) .withClaim( "counter", user.getCounter() ) @@ -65,6 +66,7 @@ public Authentication.Token generateAccessTokenWithActiveOrgId( User user, Strin Algorithm algorithm = Algorithm.HMAC256( accessSecret ); Date expiresAt = new org.joda.time.DateTime( DateTimeUtils.currentTimeMillis() + accessSecretExpiration, UTC ).toDate(); return new Authentication.Token( expiresAt, JWT.create() + .withClaim( "id", user.getId() ) .withClaim( "user", user.getEmail() ) .withClaim( "roles", user.getRoles() ) .withClaim( "counter", user.getCounter() ) @@ -78,6 +80,7 @@ public Authentication.Token generateRefreshToken( User user ) throws JWTCreation Algorithm algorithm = Algorithm.HMAC256( refreshSecret ); Date expiresAt = new org.joda.time.DateTime( DateTimeUtils.currentTimeMillis() + refreshSecretExpiration, UTC ).toDate(); return new Authentication.Token( expiresAt, JWT.create() + .withClaim( "id", user.getId() ) .withClaim( "user", user.getEmail() ) .withClaim( "counter", user.getCounter() ) .withIssuer( issuer ) diff --git a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/User.java b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/User.java index 88ac21b7b6..8afd315238 100644 --- a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/User.java +++ b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/User.java @@ -29,6 +29,8 @@ import java.util.Optional; public interface User extends Serializable { + String getId(); + String getEmail(); Optional getRole( String realm ); diff --git a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/UserProvider.java b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/UserProvider.java index 0ba5747a7a..00b17ace71 100644 --- a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/UserProvider.java +++ b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/UserProvider.java @@ -56,7 +56,7 @@ static String toAccessKey( String email ) { Optional getUser( String email ); Result getAuthenticatedByAccessToken( Optional accessToken, Optional refreshToken, - Optional sessionUser, + Optional sessionUserId, SecurityRoles roles, String realm, String... wssPermissions ); Result getAuthenticated( String email, String password, Optional tfaCode ); diff --git a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/interceptor/JWTSecurityInterceptor.java b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/interceptor/JWTSecurityInterceptor.java index a050f53f7d..81036b5b2c 100644 --- a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/interceptor/JWTSecurityInterceptor.java +++ b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/interceptor/JWTSecurityInterceptor.java @@ -84,7 +84,7 @@ public Optional before( InvocationContext context ) { String realmString = realm.get(); String[] wssPermissions = wss.get().permissions(); - validUser = userProvider.getAuthenticatedByAccessToken( Optional.ofNullable( accessToken ), refreshToken, sessionUserKey.map( User::getEmail ), roles, realmString, wssPermissions ); + validUser = userProvider.getAuthenticatedByAccessToken( Optional.ofNullable( accessToken ), refreshToken, sessionUserKey.map( User::getId ), roles, realmString, wssPermissions ); if( !validUser.isSuccess() ) { return Optional.of( new Response( UNAUTHORIZED, validUser.failureValue ) ); diff --git a/oap-ws/oap-ws-sso-api/src/test/java/oap/ws/sso/AbstractUserTest.java b/oap-ws/oap-ws-sso-api/src/test/java/oap/ws/sso/AbstractUserTest.java index 9b98e7fcf9..e0206cf6d4 100644 --- a/oap-ws/oap-ws-sso-api/src/test/java/oap/ws/sso/AbstractUserTest.java +++ b/oap-ws/oap-ws-sso-api/src/test/java/oap/ws/sso/AbstractUserTest.java @@ -26,6 +26,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; +import oap.id.Identifier; import oap.util.Pair; import org.apache.commons.lang3.RandomStringUtils; @@ -47,6 +48,7 @@ protected TestSecurityRolesProvider() { @ToString @EqualsAndHashCode public static class TestUser implements User { + public final String id; public final String email; public final String password; public final Map roles = new HashMap<>(); @@ -61,12 +63,18 @@ public TestUser( String email, String password, Pair role ) { } public TestUser( String email, String password, Pair role, boolean tfaEnabled ) { + this.id = Identifier.generate( email, 20, s -> false, 0 ); this.email = email; this.password = password; this.roles.put( role._1, role._2 ); this.tfaEnabled = tfaEnabled; } + @Override + public String getId() { + return id; + } + @Override public String getEmail() { return email; diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/ValidationTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/ValidationTest.java index c44db6231e..16a68cf8f7 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/ValidationTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/ValidationTest.java @@ -31,7 +31,7 @@ import oap.testng.TestDirectoryFixture; import org.testng.annotations.Test; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static oap.io.Resources.urlOrThrow; @Slf4j @@ -45,35 +45,35 @@ public ValidationTest() { @Test public void brokenValidator() { - assertGet( kernel.httpUrl( "/validation/service/methodWithBrokenValidator?requiredParameter=10" ) ) + assertGet2( kernel.httpUrl( "/validation/service/methodWithBrokenValidator?requiredParameter=10" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, "CausedByException", "{\"message\":\"CausedByException\"}" ); } @Test public void wrongValidatorName() { String errorMessage = "No such method wrongValidatorName with the following parameters: [int requiredParameter]"; - assertGet( kernel.httpUrl( "/validation/service/methodWithWrongValidatorName?requiredParameter=10" ) ) + assertGet2( kernel.httpUrl( "/validation/service/methodWithWrongValidatorName?requiredParameter=10" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, errorMessage, "{\"message\":\"" + errorMessage + "\"}" ); } @Test public void validatorWithWrongParameters() { String errorMessage = "missedParam required by validator wrongArgsValidator is not supplied by web method"; - assertGet( kernel.httpUrl( "/validation/service/methodWithWrongValidatorArgs?requiredParameter=10" ) ) + assertGet2( kernel.httpUrl( "/validation/service/methodWithWrongValidatorArgs?requiredParameter=10" ) ) .responded( Http.StatusCode.INTERNAL_SERVER_ERROR, errorMessage, Http.ContentType.APPLICATION_JSON, "{\"message\":\"" + errorMessage + "\"}" ); } @Test public void validatorMethodWithArgs() { - assertGet( kernel.httpUrl( "/validation/service/methodWithValidatorArgs?oddParam=1" ) ) + assertGet2( kernel.httpUrl( "/validation/service/methodWithValidatorArgs?oddParam=1" ) ) .responded( Http.StatusCode.BAD_REQUEST, "validation failed", Http.ContentType.APPLICATION_JSON, "{\"errors\":[\"" + "non odd param" + "\"]}" ); - assertGet( kernel.httpUrl( "/validation/service/methodWithValidatorArgs?oddParam=2" ) ) + assertGet2( kernel.httpUrl( "/validation/service/methodWithValidatorArgs?oddParam=2" ) ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "true" ); } @Test public void exception() { - assertGet( kernel.httpUrl( "/validation/service/exceptionRuntimeException" ) ) + assertGet2( kernel.httpUrl( "/validation/service/exceptionRuntimeException" ) ) .hasCode( Http.StatusCode.INTERNAL_SERVER_ERROR ); } } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesLocalTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesLocalTest.java index 88e4ca8e26..5476d469b8 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesLocalTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesLocalTest.java @@ -30,7 +30,7 @@ import org.testng.annotations.Test; import static oap.http.server.nio.HttpServerExchange.HttpMethod.GET; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static oap.io.Resources.urlOrThrow; public class WebServicesLocalTest extends Fixtures { @@ -43,7 +43,7 @@ public WebServicesLocalTest() { @Test public void shouldAllowRequestWhenEmptyInterceptor() { - assertGet( kernel.httpUrl( "/test/text?value=empty" ) ).isOk().hasBody( "ok" ); + assertGet2( kernel.httpUrl( "/test/text?value=empty" ) ).isOk().hasBody( "ok" ); } @SuppressWarnings( "unused" ) diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesSessionTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesSessionTest.java index b1432f4915..6872c2655c 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesSessionTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesSessionTest.java @@ -33,7 +33,7 @@ import java.util.Map; import static oap.http.server.nio.HttpServerExchange.HttpMethod.GET; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static oap.io.Resources.urlOrThrow; import static oap.ws.WsParam.From.SESSION; @@ -47,27 +47,27 @@ public WebServicesSessionTest() { @Test public void sessionViaResponse() { - assertGet( kernel.httpUrl( "/session/put" ), Map.of( "value", "vvv" ), Map.of() ) + assertGet2( kernel.httpUrl( "/session/put" ), Map.of( "value", "vvv" ), Map.of() ) .hasCode( Http.StatusCode.NO_CONTENT ); - assertGet( kernel.httpUrl( "/session/get" ) ) + assertGet2( kernel.httpUrl( "/session/get" ) ) .isOk() .hasBody( "vvv" ); } @Test public void sessionDirectly() { - assertGet( kernel.httpUrl( "/session/putDirectly" ), Map.of( "value", "vvv" ), Map.of() ) + assertGet2( kernel.httpUrl( "/session/putDirectly" ), Map.of( "value", "vvv" ), Map.of() ) .hasCode( Http.StatusCode.NO_CONTENT ); - assertGet( kernel.httpUrl( "/session/get" ) ) + assertGet2( kernel.httpUrl( "/session/get" ) ) .isOk() .hasBody( "vvv" ); } @Test public void respondHtmlContentType() { - assertGet( kernel.httpUrl( "/session/putDirectly" ), Map.of( "value", "vvv" ), Map.of() ) + assertGet2( kernel.httpUrl( "/session/putDirectly" ), Map.of( "value", "vvv" ), Map.of() ) .hasCode( Http.StatusCode.NO_CONTENT ); - assertGet( kernel.httpUrl( "/session/html" ) ) + assertGet2( kernel.httpUrl( "/session/html" ) ) .isOk() .hasBody( "vvv" ) .hasContentType( Http.ContentType.TEXT_HTML ); diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java index 1ffc594cec..ba225206f1 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java @@ -49,7 +49,7 @@ import static oap.http.Http.StatusCode.NO_CONTENT; import static oap.http.Http.StatusCode.OK; import static oap.http.server.nio.HttpServerExchange.HttpMethod.GET; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static oap.http.test.HttpAsserts.assertPost; import static oap.io.Resources.urlOrThrow; import static oap.util.Pair.__; @@ -70,63 +70,63 @@ public WebServicesTest() { @Test public void path() { - assertGet( kernel.httpUrl( "/x/v/math" ) ) + assertGet2( kernel.httpUrl( "/x/v/math" ) ) .responded( OK, "OK", APPLICATION_JSON, "2" ); } @Test public void sort() { - assertGet( kernel.httpUrl( "/x/v/math/test/sort/default" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/test/sort/default" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"__default__\"" ); - assertGet( kernel.httpUrl( "/x/v/math/test/sort/45" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/test/sort/45" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"45\"" ); } @Test public void equal() { - assertGet( kernel.httpUrl( "/x/v/math/test/sort=3/test" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/test/sort=3/test" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"3\"" ); } @Test public void header() { - assertGet( kernel.httpUrl( "/x/v/math/header" ), Map.of(), Map.of( "X-Custom-Header", "header" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/header" ), Map.of(), Map.of( "X-Custom-Header", "header" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"headerheader\"" ); } @Test public void cookie() { - assertGet( kernel.httpUrl( "/x/v/math/cookie" ), Map.of(), Map.of( "Cookie", "cookie=theCookie;Really-Cool-Cookie=ohoh" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/cookie" ), Map.of(), Map.of( "Cookie", "cookie=theCookie;Really-Cool-Cookie=ohoh" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"theCookieohoh\"" ); } @Test public void renamed() { - assertGet( kernel.httpUrl( "/x/v/math/renamed?renamed=aaa" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/renamed?renamed=aaa" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"aaa\"" ); } @Test public void invocations() { - assertGet( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, "failed", "{\"message\":\"failed\"}" ); - assertGet( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, "failed", "{\"message\":\"failed\"}" ); - assertGet( kernel.httpUrl( "/x/v/math/sumab?a=1&b=2" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/sumab?a=1&b=2" ) ) .responded( OK, "OK", APPLICATION_JSON, "3" ); - assertGet( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, "failed", "{\"message\":\"failed\"}" ); - assertGet( kernel.httpUrl( "/x/v/math/sumabopt?a=1" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/sumabopt?a=1" ) ) .responded( OK, "OK", APPLICATION_JSON, "1" ); - assertGet( kernel.httpUrl( "/x/v/math/bean?i=1&s=sss" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/bean?i=1&s=sss" ) ) .respondedJson( OK, "OK", "{\"i\":1,\"s\":\"sss\"}" ); - assertGet( kernel.httpUrl( "/x/v/math/code?code=204" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/code?code=204" ) ) .hasCode( Http.StatusCode.NO_CONTENT ); - assertGet( kernel.httpUrl( "/x/h/" ) ).hasCode( Http.StatusCode.NO_CONTENT ); - assertGet( kernel.httpUrl( "" ) ).hasCode( Http.StatusCode.NO_CONTENT ); //for default domain mapping - assertGet( kernel.httpUrl( "/" ) ).hasCode( Http.StatusCode.NO_CONTENT ); //for default domain mapping - assertGet( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) + assertGet2( kernel.httpUrl( "/x/h/" ) ).hasCode( Http.StatusCode.NO_CONTENT ); + assertGet2( kernel.httpUrl( "" ) ).hasCode( Http.StatusCode.NO_CONTENT ); //for default domain mapping + assertGet2( kernel.httpUrl( "/" ) ).hasCode( Http.StatusCode.NO_CONTENT ); //for default domain mapping + assertGet2( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, "failed", "{\"message\":\"failed\"}" ); } @@ -154,31 +154,31 @@ public void invocationInputStream() { @Test public void enumValue() { - assertGet( kernel.httpUrl( "/x/v/math/en?a=CLASS" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/en?a=CLASS" ) ) .responded( OK, "OK", Http.ContentType.APPLICATION_JSON, "\"CLASS\"" ); } @Test public void optional() { - assertGet( kernel.httpUrl( "/x/v/math/sumabopt?a=1&b=2" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/sumabopt?a=1&b=2" ) ) .responded( OK, "OK", Http.ContentType.APPLICATION_JSON, "3" ); } @Test public void parameterList() { - assertGet( kernel.httpUrl( "/x/v/math/sum?a=1&b=2&b=3" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/sum?a=1&b=2&b=3" ) ) .responded( OK, "OK", Http.ContentType.APPLICATION_JSON, "6" ); } @Test public void string() { - assertGet( kernel.httpUrl( "/x/v/math/id?a=aaa" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/id?a=aaa" ) ) .responded( OK, "OK", Http.ContentType.APPLICATION_JSON, "\"aaa\"" ); } @Test public void request() { - assertGet( kernel.httpUrl( "/x/v/math/req" ) ) + assertGet2( kernel.httpUrl( "/x/v/math/req" ) ) .responded( OK, "OK", Http.ContentType.APPLICATION_JSON, "\"/x/v/math/req-\"" ); } @@ -201,7 +201,7 @@ public void shouldVerifyGZIPRequestProcessing() throws Exception { gzip.write( "{\"i\":1,\"s\":\"sss\"}".getBytes( StandardCharsets.UTF_8 ) ); gzip.close(); - var response = Client + Client.Response response = Client .custom() .build() .post( kernel.httpUrl( "/x/v/math/json" ), @@ -217,7 +217,7 @@ public void shouldVerifyGZIPRequestProcessing() throws Exception { */ @Test public void testWsServiceDisabled() { - assertGet( kernel.httpUrl( "/test-disabled" ) ).hasCode( NO_CONTENT ); + assertGet2( kernel.httpUrl( "/test-disabled" ) ).hasCode( NO_CONTENT ); } @SuppressWarnings( "unused" ) diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/interceptor/InterceptorTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/interceptor/InterceptorTest.java index 4d1ee99540..8b81c14005 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/interceptor/InterceptorTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/interceptor/InterceptorTest.java @@ -34,7 +34,7 @@ import java.util.Optional; import static oap.http.Http.StatusCode.FORBIDDEN; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static oap.io.Resources.urlOrThrow; public class InterceptorTest extends Fixtures { @@ -47,7 +47,7 @@ public InterceptorTest() { @Test public void shouldNotAllowRequestWhenErrorInterceptor() { - assertGet( kernel.httpUrl( "/interceptor/text?value=error" ) ) + assertGet2( kernel.httpUrl( "/interceptor/text?value=error" ) ) .hasCode( FORBIDDEN ) .hasReason( "caused by interceptor" ); } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java index c773c0e760..9ddeb05821 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java @@ -36,7 +36,7 @@ import static oap.http.server.nio.HttpServerExchange.HttpMethod.GET; import static oap.http.server.nio.HttpServerExchange.HttpMethod.POST; -import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertGet2; import static oap.http.test.HttpAsserts.assertPost; import static oap.io.Resources.urlOrThrow; import static oap.ws.WsParam.From.BODY; @@ -78,7 +78,7 @@ public void validationFailCode() { @Test public void validationMethods() { - assertGet( kernel.httpUrl( "/mvpm/run/validation/methods?a=a&b=5&c=c" ) ) + assertGet2( kernel.httpUrl( "/mvpm/run/validation/methods?a=a&b=5&c=c" ) ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\":[\"a\",\"a5\",\"5a\"]}" ); } diff --git a/oap-ws/oap-ws/src/main/java/oap/ws/validate/ValidationErrors.java b/oap-ws/oap-ws/src/main/java/oap/ws/validate/ValidationErrors.java index 3331bf3b02..160dea97f5 100644 --- a/oap-ws/oap-ws/src/main/java/oap/ws/validate/ValidationErrors.java +++ b/oap-ws/oap-ws/src/main/java/oap/ws/validate/ValidationErrors.java @@ -125,10 +125,9 @@ public boolean hasDefaultCode() { return code == DEFAULT_CODE; } - @Deprecated public ValidationErrors throwIfInvalid() throws WsClientException { if( failed() ) - throw new WsClientException( errors.size() > 1 ? "validation failed" : errors.get( 0 ), code, errors ); + throw new WsClientException( errors.size() > 1 ? "validation failed" : errors.getFirst(), code, errors ); return this; } diff --git a/pom.xml b/pom.xml index 322fda5136..c52bbb0561 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,14 @@ pom import + + + com.squareup.okhttp3 + okhttp-bom + ${oap.deps.okhttp.version} + pom + import + @@ -57,7 +65,7 @@ - 25.2.1 + 25.3.1 25.0.1 25.0.0 @@ -66,7 +74,7 @@ 5.18.0 1.17.6 - 5.1.0 + 5.3.2 4.4.16 4.5.14 From f285dd51b80b5991a66ecd5baa3f0c333fe50bb8 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 20 Jan 2026 09:39:13 +0200 Subject: [PATCH 02/36] CE-132 oap-sso: user: replace PK: email -> id --- .../main/java/oap/http/test/HttpAsserts.java | 101 ++++++++++++++++-- .../java/oap/http/InputStreamRequestBody.java | 35 ++++++ .../java/oap/http/pniov3/PerformanceTest.java | 4 +- .../oap/http/pniov3/PnioHttpHandlerTest.java | 16 +-- .../src/test/java/oap/ws/file/FileWSTest.java | 6 +- .../src/test/java/oap/ws/WebServicesTest.java | 14 +-- .../MethodValidatorPeerMethodTest.java | 10 +- .../MethodValidatorPeerParamTest.java | 16 +-- .../oap/ws/validate/ValidateJsonTest.java | 18 ++-- .../ws/validate/ValidatePartialJsonTest.java | 16 +-- 10 files changed, 178 insertions(+), 58 deletions(-) create mode 100644 oap-http/oap-http/src/main/java/oap/http/InputStreamRequestBody.java diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 8a7581bdad..0e09fa4a9e 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -28,6 +28,7 @@ import lombok.extern.slf4j.Slf4j; import oap.http.Client; import oap.http.Cookie; +import oap.http.InputStreamRequestBody; import oap.http.Uri; import oap.json.JsonException; import oap.json.testng.JsonAsserts; @@ -37,13 +38,17 @@ import oap.util.Pair; import oap.util.Stream; import okhttp3.Headers; +import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; +import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.ResponseBody; import okhttp3.java.net.cookiejar.JavaNetCookieJar; import org.assertj.core.api.Assertions; import org.joda.time.DateTime; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.testng.internal.collections.Ints; import java.io.ByteArrayInputStream; @@ -109,20 +114,79 @@ public static HttpAssertion assertGet2( String uri, Map params, .get() .build(); - try( Response response = OK_HTTP_CLIENT.newCall( request ).execute(); - ResponseBody body = response.body() ) { + return getResponseAsHttpAssertion( request ); + } catch( IOException e ) { + throw new UncheckedIOException( e ); + } + } - Headers responseHeaders = response.headers(); - ArrayList> headers = new ArrayList<>(); - responseHeaders.toMultimap().forEach( ( k, vs ) -> vs.forEach( v -> headers.add( Pair.__( k, v ) ) ) ); - byte[] bytes = body.bytes(); - return new HttpAssertion( new Client.Response( response.code(), response.message(), headers, body.contentType().toString(), new ByteArrayInputStream( bytes ) ) ); - } + public static HttpAssertion assertPost2( String uri, InputStream content, @Nullable String contentType, Map requestHeaders ) { + try { + Request.Builder builder = new Request.Builder(); + + requestHeaders.forEach( ( k, v ) -> builder.header( k, v == null ? "" : v.toString() ) ); + + RequestBody requestBody = new InputStreamRequestBody( contentType != null ? MediaType.get( contentType ) : null, content ); + + Request request = builder + .url( uri ) + .post( requestBody ) + .build(); + + return getResponseAsHttpAssertion( request ); } catch( IOException e ) { throw new UncheckedIOException( e ); } } + public static HttpAssertion assertPost2( String uri, InputStream content, @Nullable String contentType ) { + return assertPost2( uri, content, contentType, Maps.of() ); + } + + public static HttpAssertion assertPost2( String uri, String content, @Nullable String contentType, Map requestHeaders ) { + try { + Request.Builder builder = new Request.Builder(); + + requestHeaders.forEach( ( k, v ) -> builder.header( k, v == null ? "" : v.toString() ) ); + + RequestBody requestBody = RequestBody.create( content, contentType != null ? MediaType.parse( contentType ) : null ); + + Request request = builder + .url( uri ) + .post( requestBody ) + .build(); + + return getResponseAsHttpAssertion( request ); + } catch( IOException e ) { + throw new UncheckedIOException( e ); + } + } + + public static HttpAssertion assertPost2( String uri, String content ) { + return assertPost2( uri, content, null, Maps.of() ); + } + + public static HttpAssertion assertPost2( String uri, String content, Map headers ) { + return assertPost2( uri, content, null, headers ); + } + + public static HttpAssertion assertPost2( String uri, String content, String contentType ) { + return assertPost2( uri, content, contentType, Maps.of() ); + } + + private static @NonNull HttpAssertion getResponseAsHttpAssertion( Request request ) throws IOException { + try( Response response = OK_HTTP_CLIENT.newCall( request ).execute(); + ResponseBody body = response.body() ) { + + Headers responseHeaders = response.headers(); + ArrayList> headers = new ArrayList<>(); + responseHeaders.toMultimap().forEach( ( k, vs ) -> vs.forEach( v -> headers.add( Pair.__( k, v ) ) ) ); + byte[] bytes = body.bytes(); + MediaType mediaType = body.contentType(); + return new HttpAssertion( new Client.Response( response.code(), response.message(), headers, mediaType != null ? mediaType.toString() : null, new ByteArrayInputStream( bytes ) ) ); + } + } + /** * @see HttpAsserts#assertGet */ @@ -140,26 +204,47 @@ public static HttpAssertion assertGet( String uri, Map params, M return assertHttpResponse( client.get( uri, params, headers ) ); } + /** + * @see HttpAsserts#assertGet + */ + @Deprecated public static HttpAssertion assertPost( String uri, String content, Map headers ) { return assertPost( uri, content, APPLICATION_JSON, headers ); } + /** + * @see HttpAsserts#assertPost + */ public static HttpAssertion assertPost( String uri, String content ) { return assertPost( uri, content, Map.of() ); } + /** + * @see HttpAsserts#assertPost + */ public static HttpAssertion assertPost( String uri, String content, String contentType, Map headers ) { return assertHttpResponse( client.post( uri, content, contentType, headers ) ); } + /** + * @see HttpAsserts#assertGet + */ + @Deprecated public static HttpAssertion assertPost( String uri, String content, String contentType ) { return assertPost( uri, content, contentType, Map.of() ); } + /** + * @see HttpAsserts#assertPost + */ public static HttpAssertion assertPost( String uri, InputStream content, String contentType ) { return assertHttpResponse( client.post( uri, content, contentType ) ); } + /** + * @see HttpAsserts#assertPost + */ + @Deprecated public static HttpAssertion assertPost( String uri, InputStream content, String contentType, Map headers ) { return assertHttpResponse( client.post( uri, content, contentType, headers ) ); } diff --git a/oap-http/oap-http/src/main/java/oap/http/InputStreamRequestBody.java b/oap-http/oap-http/src/main/java/oap/http/InputStreamRequestBody.java new file mode 100644 index 0000000000..110f2530b4 --- /dev/null +++ b/oap-http/oap-http/src/main/java/oap/http/InputStreamRequestBody.java @@ -0,0 +1,35 @@ +package oap.http; + +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okio.BufferedSink; +import okio.Okio; +import okio.Source; + +import java.io.IOException; +import java.io.InputStream; + +public class InputStreamRequestBody extends RequestBody { + private final MediaType mediaType; + private final InputStream inputStream; + + public InputStreamRequestBody( MediaType mediaType, InputStream inputStream ) { + this.mediaType = mediaType; + this.inputStream = inputStream; + } + + @Override + public MediaType contentType() { + return mediaType; + } + + // You can override contentLength() if you know the length in advance for better performance/features (e.g., S3 uploads). + // If you don't override it, OkHttp will use chunked transfer encoding for large bodies. + + @Override + public void writeTo( BufferedSink sink ) throws IOException { + try( Source source = Okio.source( inputStream ) ) { + sink.writeAll( source ); + } + } +} diff --git a/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PerformanceTest.java b/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PerformanceTest.java index efdbce2047..56096f514f 100644 --- a/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PerformanceTest.java +++ b/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PerformanceTest.java @@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import static oap.http.test.HttpAsserts.assertPost; +import static oap.http.test.HttpAsserts.assertPost2; @Test( enabled = false ) public class PerformanceTest { @@ -60,7 +60,7 @@ public void test() throws IOException { Benchmark.benchmark( "test", 100000, i -> { - assertPost( "http://localhost:" + port + "/test", "{}" ) + assertPost2( "http://localhost:" + port + "/test", "{}" ) .is( r -> { count.computeIfAbsent( r.code, k -> new LongAdder() ).increment(); } ); diff --git a/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PnioHttpHandlerTest.java b/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PnioHttpHandlerTest.java index 4ae5ecfa70..fa1e63a7f3 100644 --- a/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PnioHttpHandlerTest.java +++ b/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PnioHttpHandlerTest.java @@ -61,7 +61,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static oap.http.Http.StatusCode.OK; import static oap.http.Http.StatusCode.TOO_MANY_REQUESTS; -import static oap.http.test.HttpAsserts.assertPost; +import static oap.http.test.HttpAsserts.assertPost2; import static org.assertj.core.api.Assertions.assertThat; @Slf4j @@ -92,7 +92,7 @@ public void testProcess() throws IOException { runWithWorkflow( task, port -> { - assertPost( "http://localhost:" + port + "/test", "{}" ) + assertPost2( "http://localhost:" + port + "/test", "{}" ) .hasCode( OK ) .hasContentType( ContentType.TEXT_PLAIN ); } ); @@ -103,7 +103,7 @@ public void testProcessWithException() throws IOException { ComputeTask task = TestHandler.compute( "cpu-2", builder -> builder.runtimeException( new RuntimeException( "test exception" ) ) ); runWithWorkflow( task, port -> { - assertPost( "http://localhost:" + port + "/test", "{}" ) + assertPost2( "http://localhost:" + port + "/test", "{}" ) .hasCode( Http.StatusCode.BAD_GATEWAY ) .hasContentType( ContentType.TEXT_PLAIN ) .hasBody( "test exception" ); @@ -115,7 +115,7 @@ public void testProcessGzip() throws IOException { ComputeTask task = TestHandler.compute( "cpu-2" ); runWithWorkflow( task, port -> { - assertPost( "http://localhost:" + port + "/test", "{}" ) + assertPost2( "http://localhost:" + port + "/test", "{}" ) .hasCode( Http.StatusCode.OK ); try( CloseableHttpClient client = HttpClientBuilder.create() @@ -146,7 +146,7 @@ public void testRequestBufferOverflow() throws IOException { ComputeTask task = TestHandler.compute( "cpu-2" ); runWithWorkflow( 2, 1024, 5, 1000, Dates.s( 100 ), task, port -> { - assertPost( "http://localhost:" + port + "/test", "[{}]" ) + assertPost2( "http://localhost:" + port + "/test", "[{}]" ) .hasCode( Http.StatusCode.BAD_REQUEST ) .hasContentType( ContentType.TEXT_PLAIN ) .hasBody( "REQUEST_BUFFER_OVERFLOW" ); @@ -158,7 +158,7 @@ public void testResponseBufferOverflow() throws IOException { ComputeTask task = TestHandler.compute( "cpu-2" ); runWithWorkflow( 1024, 2, 5, 1000, Dates.s( 100 ), task, port -> { - assertPost( "http://localhost:" + port + "/test", "[{}]" ) + assertPost2( "http://localhost:" + port + "/test", "[{}]" ) .hasCode( Http.StatusCode.BAD_REQUEST ) .hasContentType( ContentType.TEXT_PLAIN ) .hasBody( "BO" ); @@ -252,11 +252,11 @@ public void testTimeoutAsync() throws IOException { }; runWithWorkflow( 1024, 1024, 1, 1000, 1000, task, port -> { - assertPost( "http://localhost:" + port + "/test", "[{}]" ) + assertPost2( "http://localhost:" + port + "/test", "[{}]" ) .hasCode( Http.StatusCode.BAD_REQUEST ) .hasContentType( ContentType.TEXT_PLAIN ) .hasBody( "TIMEOUT" ); - assertPost( "http://localhost:" + port + "/test", "[{}]" ) + assertPost2( "http://localhost:" + port + "/test", "[{}]" ) .hasCode( Http.StatusCode.BAD_REQUEST ) .hasContentType( ContentType.TEXT_PLAIN ) .hasBody( "TIMEOUT" ); diff --git a/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java b/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java index ac8d3882db..2893720fbb 100644 --- a/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java +++ b/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java @@ -34,7 +34,7 @@ of this software and associated documentation files (the "Software"), to deal import org.testng.annotations.Test; import static oap.http.test.HttpAsserts.assertGet2; -import static oap.http.test.HttpAsserts.assertPost; +import static oap.http.test.HttpAsserts.assertPost2; import static oap.io.content.ContentReader.ofString; import static oap.testng.Asserts.contentOfTestResource; import static oap.testng.Asserts.urlOfTestResource; @@ -53,11 +53,11 @@ public FileWSTest() { @Test public void upload() { - assertPost( kernel.httpUrl( "/file" ), contentOfTestResource( getClass(), "data-complex.json", ofString() ), Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/file" ), contentOfTestResource( getClass(), "data-complex.json", ofString() ), Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.TEXT_PLAIN, "file.txt" ); assertThat( testDirectoryFixture.testPath( "default/file.txt" ) ).hasContent( "test" ); - assertPost( kernel.httpUrl( "/file?bucket=b1" ), contentOfTestResource( getClass(), "data-single.json", ofString() ), Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/file?bucket=b1" ), contentOfTestResource( getClass(), "data-single.json", ofString() ), Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.TEXT_PLAIN, "file.txt" ); assertThat( testDirectoryFixture.testPath( "b1/file.txt" ) ).hasContent( "test" ); } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java index ba225206f1..0146cd6e59 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java @@ -50,7 +50,7 @@ import static oap.http.Http.StatusCode.OK; import static oap.http.server.nio.HttpServerExchange.HttpMethod.GET; import static oap.http.test.HttpAsserts.assertGet2; -import static oap.http.test.HttpAsserts.assertPost; +import static oap.http.test.HttpAsserts.assertPost2; import static oap.io.Resources.urlOrThrow; import static oap.util.Pair.__; import static oap.ws.WsParam.From.BODY; @@ -133,22 +133,22 @@ public void invocations() { @Test public void invocationBytes() { - assertPost( kernel.httpUrl( "/x/v/math/bytes" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) + assertPost2( kernel.httpUrl( "/x/v/math/bytes" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) .responded( OK, "OK", APPLICATION_JSON, "\"1234\"" ); } @Test public void invocationString() { - assertPost( kernel.httpUrl( "/x/v/math/string" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) + assertPost2( kernel.httpUrl( "/x/v/math/string" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) .responded( OK, "OK", APPLICATION_JSON, "\"1234\"" ); - assertPost( kernel.httpUrl( "/x/v/math/string" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) + assertPost2( kernel.httpUrl( "/x/v/math/string" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) .satisfies( response -> assertThat( response.headers ) .contains( __( "Content-Type", "application/json" ) ) ); } @Test public void invocationInputStream() { - assertPost( kernel.httpUrl( "/x/v/math/inputStream" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) + assertPost2( kernel.httpUrl( "/x/v/math/inputStream" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) .responded( OK, "OK", APPLICATION_JSON, "\"1234\"" ); } @@ -184,13 +184,13 @@ public void request() { @Test public void json() { - assertPost( kernel.httpUrl( "/x/v/math/json" ), "{\"i\":1,\"s\":\"sss\"}", APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/x/v/math/json" ), "{\"i\":1,\"s\":\"sss\"}", APPLICATION_JSON ) .respondedJson( "{\"i\":1,\"s\":\"sss\"}" ); } @Test public void list() { - assertPost( kernel.httpUrl( "/x/v/math/list" ), "[\"1str\", \"2str\"]", APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/x/v/math/list" ), "[\"1str\", \"2str\"]", APPLICATION_JSON ) .respondedJson( "[\"1str\",\"2str\"]" ); } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java index 9ddeb05821..dd62cb3c42 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java @@ -37,7 +37,7 @@ import static oap.http.server.nio.HttpServerExchange.HttpMethod.GET; import static oap.http.server.nio.HttpServerExchange.HttpMethod.POST; import static oap.http.test.HttpAsserts.assertGet2; -import static oap.http.test.HttpAsserts.assertPost; +import static oap.http.test.HttpAsserts.assertPost2; import static oap.io.Resources.urlOrThrow; import static oap.ws.WsParam.From.BODY; import static oap.ws.validate.ValidationErrors.empty; @@ -54,25 +54,25 @@ public MethodValidatorPeerMethodTest() { @Test public void validationDefault() { - assertPost( kernel.httpUrl( "/mvpm/run/validation/default" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost2( kernel.httpUrl( "/mvpm/run/validation/default" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "\"test\"" ); } @Test public void validationOk() { - assertPost( kernel.httpUrl( "/mvpm/run/validation/ok" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost2( kernel.httpUrl( "/mvpm/run/validation/ok" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.TEXT_PLAIN, "test" ); } @Test public void validationFail() { - assertPost( kernel.httpUrl( "/mvpm/run/validation/fail" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost2( kernel.httpUrl( "/mvpm/run/validation/fail" ), "test", Http.ContentType.TEXT_PLAIN ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\":[\"error1\",\"error2\"]}" ); } @Test public void validationFailCode() { - assertPost( kernel.httpUrl( "/mvpm/run/validation/fail-code" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost2( kernel.httpUrl( "/mvpm/run/validation/fail-code" ), "test", Http.ContentType.TEXT_PLAIN ) .respondedJson( Http.StatusCode.FORBIDDEN, "validation failed", "{\"errors\":[\"denied\"]}" ); } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerParamTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerParamTest.java index 3927d41a74..a5988b0636 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerParamTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerParamTest.java @@ -35,7 +35,7 @@ import java.util.Optional; import static oap.http.server.nio.HttpServerExchange.HttpMethod.POST; -import static oap.http.test.HttpAsserts.assertPost; +import static oap.http.test.HttpAsserts.assertPost2; import static oap.io.Resources.urlOrThrow; import static oap.ws.WsParam.From.BODY; import static oap.ws.WsParam.From.QUERY; @@ -52,43 +52,43 @@ public MethodValidatorPeerParamTest() { @Test public void validationDefault() { - assertPost( kernel.httpUrl( "/mvpp/run/validation/default?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost2( kernel.httpUrl( "/mvpp/run/validation/default?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "\"1test\"" ); } @Test public void validationOk() { - assertPost( kernel.httpUrl( "/mvpp/run/validation/ok?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost2( kernel.httpUrl( "/mvpp/run/validation/ok?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "\"1test\"" ); } @Test public void validationOkList() { - assertPost( kernel.httpUrl( "/mvpp/run/validation/ok?i=1&listString=_11&listString=_12" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost2( kernel.httpUrl( "/mvpp/run/validation/ok?i=1&listString=_11&listString=_12" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "\"1_11/_12test\"" ); } @Test public void validationOkOptional() { - assertPost( kernel.httpUrl( "/mvpp/run/validation/ok?i=1&optString=2" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost2( kernel.httpUrl( "/mvpp/run/validation/ok?i=1&optString=2" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "\"12test\"" ); } @Test public void validationFail() { - assertPost( kernel.httpUrl( "/mvpp/run/validation/fail?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost2( kernel.httpUrl( "/mvpp/run/validation/fail?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\": [\"error:1\", \"error:test\"]}" ); } @Test public void validationRequiredFailed() { - assertPost( kernel.httpUrl( "/mvpp/run/validation/ok" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost2( kernel.httpUrl( "/mvpp/run/validation/ok" ), "test", Http.ContentType.TEXT_PLAIN ) .respondedJson( Http.StatusCode.BAD_REQUEST, "'int i' is required", "{\"errors\": [\"'int i' is required\"]}" ); } @Test public void validationTypeFailed() { - assertPost( kernel.httpUrl( "/mvpp/run/validation/ok?i=unsupportedStringToIntCast" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost2( kernel.httpUrl( "/mvpp/run/validation/ok?i=unsupportedStringToIntCast" ), "test", Http.ContentType.TEXT_PLAIN ) .hasCode( Http.StatusCode.BAD_REQUEST ); } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidateJsonTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidateJsonTest.java index 9ddc8922da..d9649d836a 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidateJsonTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidateJsonTest.java @@ -33,7 +33,7 @@ import org.testng.annotations.Test; import static oap.http.server.nio.HttpServerExchange.HttpMethod.POST; -import static oap.http.test.HttpAsserts.assertPost; +import static oap.http.test.HttpAsserts.assertPost2; import static oap.io.Resources.urlOrThrow; import static oap.ws.WsParam.From.BODY; import static oap.ws.WsParam.From.QUERY; @@ -48,29 +48,29 @@ public ValidateJsonTest() { @Test public void validation1() { - assertPost( kernel.httpUrl( "/vj/run/validation/1" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vj/run/validation/1" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "{\"a\":1}" ); - assertPost( kernel.httpUrl( "/vj/run/validation/1" ), "{}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vj/run/validation/1" ), "{}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\":[\"/a: required property is missing\"]}" ); } @Test public void validation2() { - assertPost( kernel.httpUrl( "/vj/run/validation/2" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vj/run/validation/2" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "{\"a\":1}" ); - assertPost( kernel.httpUrl( "/vj/run/validation/2" ), "{}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vj/run/validation/2" ), "{}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "{}" ); - assertPost( kernel.httpUrl( "/vj/run/validation/2" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vj/run/validation/2" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\":[\"additional properties are not permitted [b]\"]}" ); } @Test public void validation3() { - assertPost( kernel.httpUrl( "/vj/run/validation/3?type=type1" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vj/run/validation/3?type=type1" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "{\"a\":1}" ); - assertPost( kernel.httpUrl( "/vj/run/validation/3?type=type2" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vj/run/validation/3?type=type2" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "{\"b\":1}" ); - assertPost( kernel.httpUrl( "/vj/run/validation/3?type=type1" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vj/run/validation/3?type=type1" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\":[\"/a: required property is missing\"]}" ); } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidatePartialJsonTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidatePartialJsonTest.java index f547860996..c6b0c60c81 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidatePartialJsonTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidatePartialJsonTest.java @@ -35,7 +35,7 @@ import java.util.ArrayList; import static oap.http.server.nio.HttpServerExchange.HttpMethod.POST; -import static oap.http.test.HttpAsserts.assertPost; +import static oap.http.test.HttpAsserts.assertPost2; import static oap.io.Resources.urlOrThrow; import static oap.ws.WsParam.From.BODY; import static oap.ws.WsParam.From.PATH; @@ -50,21 +50,21 @@ public ValidatePartialJsonTest() { @Test public void validation1() { - assertPost( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{\"id\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{\"id\":1}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.OK, "OK", "{\"a\":[{\"id\":1}],\"id\":\"id1\"}" ); - assertPost( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{\"b\":[{\"element\":\"test\"}],\"id\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{\"b\":[{\"element\":\"test\"}],\"id\":1}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.OK, "OK", "{\"a\":[{\"id\":1,\"b\":[{\"element\":\"test\"}]}],\"id\":\"id1\"}" ); - assertPost( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.BAD_REQUEST, "validation failed", Http.ContentType.APPLICATION_JSON, "{\"errors\":[\"/a/1/id: required property is missing\"]}" ); } @Test public void validation2() { - assertPost( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{\"id\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{\"id\":1}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.OK, "OK", "{\"a\":[{\"id\":1}],\"id\":\"id1\"}" ); - assertPost( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.OK, "OK", "{\"a\":[{}],\"id\":\"id1\"}" ); - assertPost( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{\"c\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{\"c\":1}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.BAD_REQUEST, "validation failed", Http.ContentType.APPLICATION_JSON, "{\"errors\":[\"/a/1: additional properties are not permitted [c]\"]}" ); } @@ -80,7 +80,7 @@ public void validation3() { TestBean bean = ( TestBean ) obj; bean.a.add( itemA ); bean.a.add( itemB ); - assertPost( kernel.httpUrl( "/vpj/run/validation/3/id1/2" ), "{\"element\":\"some text\"}", Http.ContentType.APPLICATION_JSON ) + assertPost2( kernel.httpUrl( "/vpj/run/validation/3/id1/2" ), "{\"element\":\"some text\"}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.OK, "OK", "{\"a\":[{\"id\":1},{\"id\":2,\"b\":[{\"element\":\"some text\"}]}],\"id\":\"id1\"}" ); } From 6c3d0c905d510373e06ae7fee8376791ea1fe27d Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 20 Jan 2026 09:44:34 +0200 Subject: [PATCH 03/36] CE-132 oap-sso: user: replace PK: email -> id --- .../oap-http-test/src/main/java/oap/http/test/HttpAsserts.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 0e09fa4a9e..d0009cc38b 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -65,6 +65,7 @@ import static java.net.HttpURLConnection.HTTP_OK; import static oap.http.Http.ContentType.APPLICATION_JSON; +import static oap.http.Http.ContentType.APPLICATION_OCTET_STREAM; import static oap.http.test.HttpAsserts.HttpAssertion.assertHttpResponse; import static oap.http.test.HttpAsserts.JsonHttpAssertion.assertJsonResponse; import static oap.io.content.ContentReader.ofString; @@ -183,7 +184,7 @@ public static HttpAssertion assertPost2( String uri, String content, String cont responseHeaders.toMultimap().forEach( ( k, vs ) -> vs.forEach( v -> headers.add( Pair.__( k, v ) ) ) ); byte[] bytes = body.bytes(); MediaType mediaType = body.contentType(); - return new HttpAssertion( new Client.Response( response.code(), response.message(), headers, mediaType != null ? mediaType.toString() : null, new ByteArrayInputStream( bytes ) ) ); + return new HttpAssertion( new Client.Response( response.code(), response.message(), headers, mediaType != null ? mediaType.toString() : APPLICATION_OCTET_STREAM, new ByteArrayInputStream( bytes ) ) ); } } From 1aabcf2389248e1b187a786c6d8e2a388a975d96 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 20 Jan 2026 11:36:05 +0200 Subject: [PATCH 04/36] CE-132 oap-sso: user: replace PK: email -> id --- .../main/java/oap/http/test/HttpAsserts.java | 137 ++++++------------ .../http/server/nio/NioHttpServerTest.java | 4 +- .../nio/health/HealthHttpHandlerTest.java | 6 +- oap-http/oap-http/pom.xml | 4 - .../java/oap/http/pniov3/PerformanceTest.java | 4 +- .../oap/http/pniov3/PnioHttpHandlerTest.java | 16 +- .../test/java/oap/ws/admin/JPathWSTest.java | 6 +- .../test/java/oap/ws/admin/SchemaWSTest.java | 4 +- .../src/test/java/oap/ws/api/ApiWSTest.java | 6 +- .../src/test/java/oap/ws/file/FileWSTest.java | 12 +- .../java/oap/ws/openapi/OpenapiWSTest.java | 6 +- .../src/test/java/oap/ws/ValidationTest.java | 14 +- .../java/oap/ws/WebServicesLocalTest.java | 4 +- .../java/oap/ws/WebServicesSessionTest.java | 15 +- .../src/test/java/oap/ws/WebServicesTest.java | 66 ++++----- .../oap/ws/interceptor/InterceptorTest.java | 4 +- .../MethodValidatorPeerMethodTest.java | 14 +- .../MethodValidatorPeerParamTest.java | 16 +- .../oap/ws/validate/ValidateJsonTest.java | 18 +-- .../ws/validate/ValidatePartialJsonTest.java | 16 +- 20 files changed, 163 insertions(+), 209 deletions(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index d0009cc38b..0c621eee51 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -37,14 +37,15 @@ import oap.util.Maps; import oap.util.Pair; import oap.util.Stream; +import okhttp3.CookieJar; import okhttp3.Headers; +import okhttp3.HttpUrl; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.ResponseBody; -import okhttp3.java.net.cookiejar.JavaNetCookieJar; import org.assertj.core.api.Assertions; import org.joda.time.DateTime; import org.jspecify.annotations.NonNull; @@ -55,11 +56,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; -import java.net.CookieManager; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import java.util.regex.Pattern; @@ -77,7 +78,20 @@ @SuppressWarnings( "unused" ) public class HttpAsserts { public static final OkHttpClient OK_HTTP_CLIENT = new OkHttpClient.Builder() - .cookieJar( new JavaNetCookieJar( new CookieManager() ) ) + .cookieJar( new CookieJar() { + private final ConcurrentHashMap> cookieStore = new ConcurrentHashMap<>(); + + @Override + public void saveFromResponse( @NonNull HttpUrl url, @NonNull List cookies ) { + cookieStore.put( url.host(), cookies ); + } + + @Override + public @NonNull List loadForRequest( @NonNull HttpUrl url ) { + List cookies = cookieStore.get( url.host() ); + return cookies != null ? cookies : new ArrayList<>(); + } + } ) .build(); private static final Client client = Client.custom() @@ -100,11 +114,11 @@ public static void reset() { } @SafeVarargs - public static HttpAssertion assertGet2( String uri, Pair... params ) throws UncheckedIOException { - return assertGet2( uri, Maps.of( params ), Map.of() ); + public static HttpAssertion assertGet( String uri, Pair... params ) throws UncheckedIOException { + return assertGet( uri, Maps.of( params ), Map.of() ); } - public static HttpAssertion assertGet2( String uri, Map params, Map requestHeaders ) throws UncheckedIOException { + public static HttpAssertion assertGet( String uri, Map params, Map requestHeaders ) throws UncheckedIOException { try { Request.Builder builder = new Request.Builder(); @@ -121,7 +135,7 @@ public static HttpAssertion assertGet2( String uri, Map params, } } - public static HttpAssertion assertPost2( String uri, InputStream content, @Nullable String contentType, Map requestHeaders ) { + public static HttpAssertion assertPost( String uri, InputStream content, @Nullable String contentType, Map requestHeaders ) { try { Request.Builder builder = new Request.Builder(); @@ -140,11 +154,11 @@ public static HttpAssertion assertPost2( String uri, InputStream content, @Nulla } } - public static HttpAssertion assertPost2( String uri, InputStream content, @Nullable String contentType ) { - return assertPost2( uri, content, contentType, Maps.of() ); + public static HttpAssertion assertPost( String uri, InputStream content, @Nullable String contentType ) { + return assertPost( uri, content, contentType, Maps.of() ); } - public static HttpAssertion assertPost2( String uri, String content, @Nullable String contentType, Map requestHeaders ) { + public static HttpAssertion assertPost( String uri, String content, @Nullable String contentType, Map requestHeaders ) { try { Request.Builder builder = new Request.Builder(); @@ -163,16 +177,16 @@ public static HttpAssertion assertPost2( String uri, String content, @Nullable S } } - public static HttpAssertion assertPost2( String uri, String content ) { - return assertPost2( uri, content, null, Maps.of() ); + public static HttpAssertion assertPost( String uri, String content ) { + return assertPost( uri, content, null, Maps.of() ); } - public static HttpAssertion assertPost2( String uri, String content, Map headers ) { - return assertPost2( uri, content, null, headers ); + public static HttpAssertion assertPost( String uri, String content, Map headers ) { + return assertPost( uri, content, null, headers ); } - public static HttpAssertion assertPost2( String uri, String content, String contentType ) { - return assertPost2( uri, content, contentType, Maps.of() ); + public static HttpAssertion assertPost( String uri, String content, String contentType ) { + return assertPost( uri, content, contentType, Maps.of() ); } private static @NonNull HttpAssertion getResponseAsHttpAssertion( Request request ) throws IOException { @@ -188,76 +202,6 @@ public static HttpAssertion assertPost2( String uri, String content, String cont } } - /** - * @see HttpAsserts#assertGet - */ - @Deprecated - @SafeVarargs - public static HttpAssertion assertGet( String uri, Pair... params ) { - return new HttpAssertion( client.get( uri, params ) ); - } - - /** - * @see HttpAsserts#assertGet - */ - @Deprecated - public static HttpAssertion assertGet( String uri, Map params, Map headers ) { - return assertHttpResponse( client.get( uri, params, headers ) ); - } - - /** - * @see HttpAsserts#assertGet - */ - @Deprecated - public static HttpAssertion assertPost( String uri, String content, Map headers ) { - return assertPost( uri, content, APPLICATION_JSON, headers ); - } - - /** - * @see HttpAsserts#assertPost - */ - public static HttpAssertion assertPost( String uri, String content ) { - return assertPost( uri, content, Map.of() ); - } - - /** - * @see HttpAsserts#assertPost - */ - public static HttpAssertion assertPost( String uri, String content, String contentType, Map headers ) { - return assertHttpResponse( client.post( uri, content, contentType, headers ) ); - } - - /** - * @see HttpAsserts#assertGet - */ - @Deprecated - public static HttpAssertion assertPost( String uri, String content, String contentType ) { - return assertPost( uri, content, contentType, Map.of() ); - } - - /** - * @see HttpAsserts#assertPost - */ - public static HttpAssertion assertPost( String uri, InputStream content, String contentType ) { - return assertHttpResponse( client.post( uri, content, contentType ) ); - } - - /** - * @see HttpAsserts#assertPost - */ - @Deprecated - public static HttpAssertion assertPost( String uri, InputStream content, String contentType, Map headers ) { - return assertHttpResponse( client.post( uri, content, contentType, headers ) ); - } - -// public static HttpAssertion assertUploadFile( String uri, RequestBody body ) { -// return new HttpAssertion( client.uploadFile( uri, body, Map.of() ) ); -// } - -// public static HttpAssertion assertUploadFile( String uri, RequestBody body, Map headers ) { -// return new HttpAssertion( client.uploadFile( uri, body, headers ) ); -// } - public static HttpAssertion assertPut( String uri, String content, String contentType ) { return assertHttpResponse( client.put( uri, content, contentType ) ); } @@ -307,12 +251,25 @@ public static HttpAssertion assertPatch( String uri, InputStream is, String cont return assertHttpResponse( client.patch( uri, is, contentType, headers ) ); } - public static HttpAssertion assertDelete( String uri ) { - return assertDelete( uri, Map.of() ); + public static HttpAssertion assertDelete( String uri, Map headers ) { + try { + Request.Builder builder = new Request.Builder(); + + headers.forEach( ( k, v ) -> builder.header( k, v == null ? "" : v.toString() ) ); + + Request request = builder + .url( uri ) + .delete() + .build(); + + return getResponseAsHttpAssertion( request ); + } catch( IOException e ) { + throw new UncheckedIOException( e ); + } } - public static HttpAssertion assertDelete( String uri, Map headers ) { - return assertHttpResponse( client.delete( uri, headers ) ); + public static HttpAssertion assertDelete( String uri ) { + return assertDelete( uri, Map.of() ); } @EqualsAndHashCode diff --git a/oap-http/oap-http-test/src/test/java/oap/http/server/nio/NioHttpServerTest.java b/oap-http/oap-http-test/src/test/java/oap/http/server/nio/NioHttpServerTest.java index 8c40723432..6d3c8de6a0 100644 --- a/oap-http/oap-http-test/src/test/java/oap/http/server/nio/NioHttpServerTest.java +++ b/oap-http/oap-http-test/src/test/java/oap/http/server/nio/NioHttpServerTest.java @@ -40,7 +40,7 @@ import static oap.http.Http.Headers.CONNECTION; import static oap.http.Http.Headers.DATE; -import static oap.http.test.HttpAsserts.assertGet2; +import static oap.http.test.HttpAsserts.assertGet; import static org.assertj.core.api.Assertions.assertThat; public class NioHttpServerTest extends Fixtures { @@ -120,7 +120,7 @@ public void testHttps() throws IOException { assertThat( client.get( "https://localhost:" + httpsPort + "/test" ) .contentString() ).isEqualTo( "ok" ); - assertGet2( "http://localhost:" + httpPort + "/healtz" ).hasCode( Http.StatusCode.NO_CONTENT ); + assertGet( "http://localhost:" + httpPort + "/healtz" ).hasCode( Http.StatusCode.NO_CONTENT ); } } diff --git a/oap-http/oap-http-test/src/test/java/oap/http/server/nio/health/HealthHttpHandlerTest.java b/oap-http/oap-http-test/src/test/java/oap/http/server/nio/health/HealthHttpHandlerTest.java index 16c4240792..da0fd1fa5e 100644 --- a/oap-http/oap-http-test/src/test/java/oap/http/server/nio/health/HealthHttpHandlerTest.java +++ b/oap-http/oap-http-test/src/test/java/oap/http/server/nio/health/HealthHttpHandlerTest.java @@ -34,7 +34,7 @@ import java.util.Map; import static java.net.HttpURLConnection.HTTP_NO_CONTENT; -import static oap.http.test.HttpAsserts.assertGet2; +import static oap.http.test.HttpAsserts.assertGet; public class HealthHttpHandlerTest extends Fixtures { @Test @@ -49,8 +49,8 @@ public void health() throws IOException { httpServer.start(); - assertGet2( HttpAsserts.httpUrl( httpPort, "/healtz" ) ).hasCode( HTTP_NO_CONTENT ); - assertGet2( HttpAsserts.httpUrl( httpPort, "/healtz?secret=secret" ) ) + assertGet( HttpAsserts.httpUrl( httpPort, "/healtz" ) ).hasCode( HTTP_NO_CONTENT ); + assertGet( HttpAsserts.httpUrl( httpPort, "/healtz?secret=secret" ) ) .respondedJson( "{\"test\":{\"k1\":1, \"k2\":2}}" ); } } diff --git a/oap-http/oap-http/pom.xml b/oap-http/oap-http/pom.xml index d5eb23fe59..bf71643847 100644 --- a/oap-http/oap-http/pom.xml +++ b/oap-http/oap-http/pom.xml @@ -82,10 +82,6 @@ com.squareup.okhttp3 okhttp-jvm - - com.squareup.okhttp3 - okhttp-java-net-cookiejar - org.projectlombok lombok diff --git a/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PerformanceTest.java b/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PerformanceTest.java index 56096f514f..efdbce2047 100644 --- a/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PerformanceTest.java +++ b/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PerformanceTest.java @@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import static oap.http.test.HttpAsserts.assertPost2; +import static oap.http.test.HttpAsserts.assertPost; @Test( enabled = false ) public class PerformanceTest { @@ -60,7 +60,7 @@ public void test() throws IOException { Benchmark.benchmark( "test", 100000, i -> { - assertPost2( "http://localhost:" + port + "/test", "{}" ) + assertPost( "http://localhost:" + port + "/test", "{}" ) .is( r -> { count.computeIfAbsent( r.code, k -> new LongAdder() ).increment(); } ); diff --git a/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PnioHttpHandlerTest.java b/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PnioHttpHandlerTest.java index fa1e63a7f3..4ae5ecfa70 100644 --- a/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PnioHttpHandlerTest.java +++ b/oap-http/oap-pnio-v3/src/test/java/oap/http/pniov3/PnioHttpHandlerTest.java @@ -61,7 +61,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static oap.http.Http.StatusCode.OK; import static oap.http.Http.StatusCode.TOO_MANY_REQUESTS; -import static oap.http.test.HttpAsserts.assertPost2; +import static oap.http.test.HttpAsserts.assertPost; import static org.assertj.core.api.Assertions.assertThat; @Slf4j @@ -92,7 +92,7 @@ public void testProcess() throws IOException { runWithWorkflow( task, port -> { - assertPost2( "http://localhost:" + port + "/test", "{}" ) + assertPost( "http://localhost:" + port + "/test", "{}" ) .hasCode( OK ) .hasContentType( ContentType.TEXT_PLAIN ); } ); @@ -103,7 +103,7 @@ public void testProcessWithException() throws IOException { ComputeTask task = TestHandler.compute( "cpu-2", builder -> builder.runtimeException( new RuntimeException( "test exception" ) ) ); runWithWorkflow( task, port -> { - assertPost2( "http://localhost:" + port + "/test", "{}" ) + assertPost( "http://localhost:" + port + "/test", "{}" ) .hasCode( Http.StatusCode.BAD_GATEWAY ) .hasContentType( ContentType.TEXT_PLAIN ) .hasBody( "test exception" ); @@ -115,7 +115,7 @@ public void testProcessGzip() throws IOException { ComputeTask task = TestHandler.compute( "cpu-2" ); runWithWorkflow( task, port -> { - assertPost2( "http://localhost:" + port + "/test", "{}" ) + assertPost( "http://localhost:" + port + "/test", "{}" ) .hasCode( Http.StatusCode.OK ); try( CloseableHttpClient client = HttpClientBuilder.create() @@ -146,7 +146,7 @@ public void testRequestBufferOverflow() throws IOException { ComputeTask task = TestHandler.compute( "cpu-2" ); runWithWorkflow( 2, 1024, 5, 1000, Dates.s( 100 ), task, port -> { - assertPost2( "http://localhost:" + port + "/test", "[{}]" ) + assertPost( "http://localhost:" + port + "/test", "[{}]" ) .hasCode( Http.StatusCode.BAD_REQUEST ) .hasContentType( ContentType.TEXT_PLAIN ) .hasBody( "REQUEST_BUFFER_OVERFLOW" ); @@ -158,7 +158,7 @@ public void testResponseBufferOverflow() throws IOException { ComputeTask task = TestHandler.compute( "cpu-2" ); runWithWorkflow( 1024, 2, 5, 1000, Dates.s( 100 ), task, port -> { - assertPost2( "http://localhost:" + port + "/test", "[{}]" ) + assertPost( "http://localhost:" + port + "/test", "[{}]" ) .hasCode( Http.StatusCode.BAD_REQUEST ) .hasContentType( ContentType.TEXT_PLAIN ) .hasBody( "BO" ); @@ -252,11 +252,11 @@ public void testTimeoutAsync() throws IOException { }; runWithWorkflow( 1024, 1024, 1, 1000, 1000, task, port -> { - assertPost2( "http://localhost:" + port + "/test", "[{}]" ) + assertPost( "http://localhost:" + port + "/test", "[{}]" ) .hasCode( Http.StatusCode.BAD_REQUEST ) .hasContentType( ContentType.TEXT_PLAIN ) .hasBody( "TIMEOUT" ); - assertPost2( "http://localhost:" + port + "/test", "[{}]" ) + assertPost( "http://localhost:" + port + "/test", "[{}]" ) .hasCode( Http.StatusCode.BAD_REQUEST ) .hasContentType( ContentType.TEXT_PLAIN ) .hasBody( "TIMEOUT" ); diff --git a/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java b/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java index b52bf0b692..4a9b2cfdb5 100644 --- a/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java +++ b/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java @@ -30,7 +30,7 @@ import org.testng.annotations.Ignore; import org.testng.annotations.Test; -import static oap.http.test.HttpAsserts.assertGet2; +import static oap.http.test.HttpAsserts.assertGet; import static oap.io.Resources.urlOrThrow; @Ignore @@ -46,7 +46,7 @@ public JPathWSTest() { public void testJavaBeanPropertyAccess() { kernel.service( "oap-ws-admin-ws-test", TestService.class ).setV2( "testv" ); - assertGet2( kernel.httpUrl( "/system/admin/jpath?query=oap-ws-admin-ws-test.test-service.instance.getV2()" ) ) + assertGet( kernel.httpUrl( "/system/admin/jpath?query=oap-ws-admin-ws-test.test-service.instance.getV2()" ) ) .isOk() .hasBody( "\"testv\"" ); } @@ -54,7 +54,7 @@ public void testJavaBeanPropertyAccess() { @Test public void testPublicFieldAccess() { kernel.service( "oap-ws-admin-ws-test", TestService.class ).setV2( "testv" ); - assertGet2( kernel.httpUrl( "/system/admin/jpath?query=oap-ws-admin-ws-test.test-service.instance.value" ) ) + assertGet( kernel.httpUrl( "/system/admin/jpath?query=oap-ws-admin-ws-test.test-service.instance.value" ) ) .isOk() .hasBody( "\"testv\"" ); } diff --git a/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/SchemaWSTest.java b/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/SchemaWSTest.java index 03dce9faad..bdd70c3213 100644 --- a/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/SchemaWSTest.java +++ b/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/SchemaWSTest.java @@ -29,7 +29,7 @@ import oap.testng.TestDirectoryFixture; import org.testng.annotations.Test; -import static oap.http.test.HttpAsserts.assertGet2; +import static oap.http.test.HttpAsserts.assertGet; import static oap.io.Resources.urlOrThrow; public class SchemaWSTest extends Fixtures { @@ -42,7 +42,7 @@ public SchemaWSTest() { @Test public void testSchema() { - assertGet2( kernel.httpUrl( "/system/admin/schema?path=/schema/test-schema.conf" ) ) + assertGet( kernel.httpUrl( "/system/admin/schema?path=/schema/test-schema.conf" ) ) .isOk() .respondedJson( """ { diff --git a/oap-ws/oap-ws-api-ws/src/test/java/oap/ws/api/ApiWSTest.java b/oap-ws/oap-ws-api-ws/src/test/java/oap/ws/api/ApiWSTest.java index 21e4296ceb..73295edb74 100644 --- a/oap-ws/oap-ws-api-ws/src/test/java/oap/ws/api/ApiWSTest.java +++ b/oap-ws/oap-ws-api-ws/src/test/java/oap/ws/api/ApiWSTest.java @@ -34,7 +34,7 @@ import static oap.http.Http.ContentType.TEXT_PLAIN; import static oap.http.Http.StatusCode.OK; -import static oap.http.test.HttpAsserts.assertGet2; +import static oap.http.test.HttpAsserts.assertGet; import static oap.io.Resources.urlOrThrow; import static oap.io.content.ContentReader.ofString; import static oap.testng.Asserts.contentOfTestResource; @@ -50,14 +50,14 @@ public ApiWSTest() { @Test public void api() throws IOException { - assertGet2( kernel.httpUrl( "/system/api" ) ) + assertGet( kernel.httpUrl( "/system/api" ) ) .responded( OK, "OK", TEXT_PLAIN, contentOfTestResource( getClass(), "api.txt", ofString() ) ); } @Test public void apiWithoutDeprecated() { - assertGet2( kernel.httpUrl( "/system/api?deprecated=false" ) ) + assertGet( kernel.httpUrl( "/system/api?deprecated=false" ) ) .responded( OK, "OK", TEXT_PLAIN, contentOfTestResource( getClass(), "apiWithoutDeprecated.txt", ofString() ) ); } diff --git a/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java b/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java index 2893720fbb..a67630ce01 100644 --- a/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java +++ b/oap-ws/oap-ws-file-ws/src/test/java/oap/ws/file/FileWSTest.java @@ -33,8 +33,8 @@ of this software and associated documentation files (the "Software"), to deal import org.testng.annotations.Ignore; import org.testng.annotations.Test; -import static oap.http.test.HttpAsserts.assertGet2; -import static oap.http.test.HttpAsserts.assertPost2; +import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertPost; import static oap.io.content.ContentReader.ofString; import static oap.testng.Asserts.contentOfTestResource; import static oap.testng.Asserts.urlOfTestResource; @@ -53,11 +53,11 @@ public FileWSTest() { @Test public void upload() { - assertPost2( kernel.httpUrl( "/file" ), contentOfTestResource( getClass(), "data-complex.json", ofString() ), Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/file" ), contentOfTestResource( getClass(), "data-complex.json", ofString() ), Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.TEXT_PLAIN, "file.txt" ); assertThat( testDirectoryFixture.testPath( "default/file.txt" ) ).hasContent( "test" ); - assertPost2( kernel.httpUrl( "/file?bucket=b1" ), contentOfTestResource( getClass(), "data-single.json", ofString() ), Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/file?bucket=b1" ), contentOfTestResource( getClass(), "data-single.json", ofString() ), Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.TEXT_PLAIN, "file.txt" ); assertThat( testDirectoryFixture.testPath( "b1/file.txt" ) ).hasContent( "test" ); } @@ -65,11 +65,11 @@ public void upload() { @Test public void download() { Files.write( testDirectoryFixture.testPath( "default/test.txt" ), "test", ContentWriter.ofString() ); - assertGet2( kernel.httpUrl( "/file?path=test.txt" ) ) + assertGet( kernel.httpUrl( "/file?path=test.txt" ) ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.TEXT_PLAIN, "test" ); Files.write( testDirectoryFixture.testPath( "b1/test.txt" ), "b1test", ContentWriter.ofString() ); - assertGet2( kernel.httpUrl( "/file?path=test.txt&bucket=b1" ) ) + assertGet( kernel.httpUrl( "/file?path=test.txt&bucket=b1" ) ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.TEXT_PLAIN, "b1test" ); } } diff --git a/oap-ws/oap-ws-openapi-ws/src/test/java/oap/ws/openapi/OpenapiWSTest.java b/oap-ws/oap-ws-openapi-ws/src/test/java/oap/ws/openapi/OpenapiWSTest.java index b60a3bdf1f..37f1881972 100644 --- a/oap-ws/oap-ws-openapi-ws/src/test/java/oap/ws/openapi/OpenapiWSTest.java +++ b/oap-ws/oap-ws-openapi-ws/src/test/java/oap/ws/openapi/OpenapiWSTest.java @@ -33,7 +33,7 @@ import java.util.Map; -import static oap.http.test.HttpAsserts.assertGet2; +import static oap.http.test.HttpAsserts.assertGet; import static oap.io.Resources.urlOrThrow; import static oap.testng.Asserts.contentOfTestResource; @@ -48,14 +48,14 @@ public OpenapiWSTest() { @Test public void openapiWithDeprecated() { - assertGet2( kernel.httpUrl( "/system/openapi?skipDeprecated=false" ) ) + assertGet( kernel.httpUrl( "/system/openapi?skipDeprecated=false" ) ) .respondedJson( Http.StatusCode.OK, "OK", contentOfTestResource( getClass(), "openapi.json", Map.of() ) ); } @Test public void openapiWithoutDeprecated() { - assertGet2( kernel.httpUrl( "/system/openapi" ) ) + assertGet( kernel.httpUrl( "/system/openapi" ) ) .respondedJson( Http.StatusCode.OK, "OK", contentOfTestResource( getClass(), "openapiWithoutDeprecated.json", Map.of() ) ); } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/ValidationTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/ValidationTest.java index 16a68cf8f7..c44db6231e 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/ValidationTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/ValidationTest.java @@ -31,7 +31,7 @@ import oap.testng.TestDirectoryFixture; import org.testng.annotations.Test; -import static oap.http.test.HttpAsserts.assertGet2; +import static oap.http.test.HttpAsserts.assertGet; import static oap.io.Resources.urlOrThrow; @Slf4j @@ -45,35 +45,35 @@ public ValidationTest() { @Test public void brokenValidator() { - assertGet2( kernel.httpUrl( "/validation/service/methodWithBrokenValidator?requiredParameter=10" ) ) + assertGet( kernel.httpUrl( "/validation/service/methodWithBrokenValidator?requiredParameter=10" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, "CausedByException", "{\"message\":\"CausedByException\"}" ); } @Test public void wrongValidatorName() { String errorMessage = "No such method wrongValidatorName with the following parameters: [int requiredParameter]"; - assertGet2( kernel.httpUrl( "/validation/service/methodWithWrongValidatorName?requiredParameter=10" ) ) + assertGet( kernel.httpUrl( "/validation/service/methodWithWrongValidatorName?requiredParameter=10" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, errorMessage, "{\"message\":\"" + errorMessage + "\"}" ); } @Test public void validatorWithWrongParameters() { String errorMessage = "missedParam required by validator wrongArgsValidator is not supplied by web method"; - assertGet2( kernel.httpUrl( "/validation/service/methodWithWrongValidatorArgs?requiredParameter=10" ) ) + assertGet( kernel.httpUrl( "/validation/service/methodWithWrongValidatorArgs?requiredParameter=10" ) ) .responded( Http.StatusCode.INTERNAL_SERVER_ERROR, errorMessage, Http.ContentType.APPLICATION_JSON, "{\"message\":\"" + errorMessage + "\"}" ); } @Test public void validatorMethodWithArgs() { - assertGet2( kernel.httpUrl( "/validation/service/methodWithValidatorArgs?oddParam=1" ) ) + assertGet( kernel.httpUrl( "/validation/service/methodWithValidatorArgs?oddParam=1" ) ) .responded( Http.StatusCode.BAD_REQUEST, "validation failed", Http.ContentType.APPLICATION_JSON, "{\"errors\":[\"" + "non odd param" + "\"]}" ); - assertGet2( kernel.httpUrl( "/validation/service/methodWithValidatorArgs?oddParam=2" ) ) + assertGet( kernel.httpUrl( "/validation/service/methodWithValidatorArgs?oddParam=2" ) ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "true" ); } @Test public void exception() { - assertGet2( kernel.httpUrl( "/validation/service/exceptionRuntimeException" ) ) + assertGet( kernel.httpUrl( "/validation/service/exceptionRuntimeException" ) ) .hasCode( Http.StatusCode.INTERNAL_SERVER_ERROR ); } } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesLocalTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesLocalTest.java index 5476d469b8..88e4ca8e26 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesLocalTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesLocalTest.java @@ -30,7 +30,7 @@ import org.testng.annotations.Test; import static oap.http.server.nio.HttpServerExchange.HttpMethod.GET; -import static oap.http.test.HttpAsserts.assertGet2; +import static oap.http.test.HttpAsserts.assertGet; import static oap.io.Resources.urlOrThrow; public class WebServicesLocalTest extends Fixtures { @@ -43,7 +43,7 @@ public WebServicesLocalTest() { @Test public void shouldAllowRequestWhenEmptyInterceptor() { - assertGet2( kernel.httpUrl( "/test/text?value=empty" ) ).isOk().hasBody( "ok" ); + assertGet( kernel.httpUrl( "/test/text?value=empty" ) ).isOk().hasBody( "ok" ); } @SuppressWarnings( "unused" ) diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesSessionTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesSessionTest.java index 6872c2655c..368b2bf58b 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesSessionTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesSessionTest.java @@ -26,6 +26,7 @@ import oap.application.testng.KernelFixture; import oap.http.Http; +import oap.http.test.HttpAsserts; import oap.testng.Fixtures; import oap.testng.TestDirectoryFixture; import org.testng.annotations.Test; @@ -33,7 +34,7 @@ import java.util.Map; import static oap.http.server.nio.HttpServerExchange.HttpMethod.GET; -import static oap.http.test.HttpAsserts.assertGet2; +import static oap.http.test.HttpAsserts.assertGet; import static oap.io.Resources.urlOrThrow; import static oap.ws.WsParam.From.SESSION; @@ -47,27 +48,27 @@ public WebServicesSessionTest() { @Test public void sessionViaResponse() { - assertGet2( kernel.httpUrl( "/session/put" ), Map.of( "value", "vvv" ), Map.of() ) + assertGet( kernel.httpUrl( "/session/put" ), Map.of( "value", "vvv" ), Map.of() ) .hasCode( Http.StatusCode.NO_CONTENT ); - assertGet2( kernel.httpUrl( "/session/get" ) ) + HttpAsserts.assertGet( kernel.httpUrl( "/session/get" ) ) .isOk() .hasBody( "vvv" ); } @Test public void sessionDirectly() { - assertGet2( kernel.httpUrl( "/session/putDirectly" ), Map.of( "value", "vvv" ), Map.of() ) + assertGet( kernel.httpUrl( "/session/putDirectly" ), Map.of( "value", "vvv" ), Map.of() ) .hasCode( Http.StatusCode.NO_CONTENT ); - assertGet2( kernel.httpUrl( "/session/get" ) ) + HttpAsserts.assertGet( kernel.httpUrl( "/session/get" ) ) .isOk() .hasBody( "vvv" ); } @Test public void respondHtmlContentType() { - assertGet2( kernel.httpUrl( "/session/putDirectly" ), Map.of( "value", "vvv" ), Map.of() ) + assertGet( kernel.httpUrl( "/session/putDirectly" ), Map.of( "value", "vvv" ), Map.of() ) .hasCode( Http.StatusCode.NO_CONTENT ); - assertGet2( kernel.httpUrl( "/session/html" ) ) + HttpAsserts.assertGet( kernel.httpUrl( "/session/html" ) ) .isOk() .hasBody( "vvv" ) .hasContentType( Http.ContentType.TEXT_HTML ); diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java index 0146cd6e59..caef53d5a3 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java @@ -29,6 +29,7 @@ import oap.http.Http; import oap.http.server.nio.HttpHandler; import oap.http.server.nio.HttpServerExchange; +import oap.http.test.HttpAsserts; import oap.testng.Fixtures; import oap.testng.TestDirectoryFixture; import org.apache.commons.io.IOUtils; @@ -49,8 +50,7 @@ import static oap.http.Http.StatusCode.NO_CONTENT; import static oap.http.Http.StatusCode.OK; import static oap.http.server.nio.HttpServerExchange.HttpMethod.GET; -import static oap.http.test.HttpAsserts.assertGet2; -import static oap.http.test.HttpAsserts.assertPost2; +import static oap.http.test.HttpAsserts.assertGet; import static oap.io.Resources.urlOrThrow; import static oap.util.Pair.__; import static oap.ws.WsParam.From.BODY; @@ -70,127 +70,127 @@ public WebServicesTest() { @Test public void path() { - assertGet2( kernel.httpUrl( "/x/v/math" ) ) + assertGet( kernel.httpUrl( "/x/v/math" ) ) .responded( OK, "OK", APPLICATION_JSON, "2" ); } @Test public void sort() { - assertGet2( kernel.httpUrl( "/x/v/math/test/sort/default" ) ) + assertGet( kernel.httpUrl( "/x/v/math/test/sort/default" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"__default__\"" ); - assertGet2( kernel.httpUrl( "/x/v/math/test/sort/45" ) ) + assertGet( kernel.httpUrl( "/x/v/math/test/sort/45" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"45\"" ); } @Test public void equal() { - assertGet2( kernel.httpUrl( "/x/v/math/test/sort=3/test" ) ) + assertGet( kernel.httpUrl( "/x/v/math/test/sort=3/test" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"3\"" ); } @Test public void header() { - assertGet2( kernel.httpUrl( "/x/v/math/header" ), Map.of(), Map.of( "X-Custom-Header", "header" ) ) + assertGet( kernel.httpUrl( "/x/v/math/header" ), Map.of(), Map.of( "X-Custom-Header", "header" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"headerheader\"" ); } @Test public void cookie() { - assertGet2( kernel.httpUrl( "/x/v/math/cookie" ), Map.of(), Map.of( "Cookie", "cookie=theCookie;Really-Cool-Cookie=ohoh" ) ) + assertGet( kernel.httpUrl( "/x/v/math/cookie" ), Map.of(), Map.of( "Cookie", "cookie=theCookie;Really-Cool-Cookie=ohoh" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"theCookieohoh\"" ); } @Test public void renamed() { - assertGet2( kernel.httpUrl( "/x/v/math/renamed?renamed=aaa" ) ) + assertGet( kernel.httpUrl( "/x/v/math/renamed?renamed=aaa" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"aaa\"" ); } @Test public void invocations() { - assertGet2( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) + assertGet( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, "failed", "{\"message\":\"failed\"}" ); - assertGet2( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) + assertGet( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, "failed", "{\"message\":\"failed\"}" ); - assertGet2( kernel.httpUrl( "/x/v/math/sumab?a=1&b=2" ) ) + assertGet( kernel.httpUrl( "/x/v/math/sumab?a=1&b=2" ) ) .responded( OK, "OK", APPLICATION_JSON, "3" ); - assertGet2( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) + assertGet( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, "failed", "{\"message\":\"failed\"}" ); - assertGet2( kernel.httpUrl( "/x/v/math/sumabopt?a=1" ) ) + assertGet( kernel.httpUrl( "/x/v/math/sumabopt?a=1" ) ) .responded( OK, "OK", APPLICATION_JSON, "1" ); - assertGet2( kernel.httpUrl( "/x/v/math/bean?i=1&s=sss" ) ) + assertGet( kernel.httpUrl( "/x/v/math/bean?i=1&s=sss" ) ) .respondedJson( OK, "OK", "{\"i\":1,\"s\":\"sss\"}" ); - assertGet2( kernel.httpUrl( "/x/v/math/code?code=204" ) ) + assertGet( kernel.httpUrl( "/x/v/math/code?code=204" ) ) .hasCode( Http.StatusCode.NO_CONTENT ); - assertGet2( kernel.httpUrl( "/x/h/" ) ).hasCode( Http.StatusCode.NO_CONTENT ); - assertGet2( kernel.httpUrl( "" ) ).hasCode( Http.StatusCode.NO_CONTENT ); //for default domain mapping - assertGet2( kernel.httpUrl( "/" ) ).hasCode( Http.StatusCode.NO_CONTENT ); //for default domain mapping - assertGet2( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) + assertGet( kernel.httpUrl( "/x/h/" ) ).hasCode( Http.StatusCode.NO_CONTENT ); + assertGet( kernel.httpUrl( "" ) ).hasCode( Http.StatusCode.NO_CONTENT ); //for default domain mapping + assertGet( kernel.httpUrl( "/" ) ).hasCode( Http.StatusCode.NO_CONTENT ); //for default domain mapping + assertGet( kernel.httpUrl( "/x/v/math/x?i=1&s=2" ) ) .respondedJson( Http.StatusCode.INTERNAL_SERVER_ERROR, "failed", "{\"message\":\"failed\"}" ); } @Test public void invocationBytes() { - assertPost2( kernel.httpUrl( "/x/v/math/bytes" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) + HttpAsserts.assertPost( kernel.httpUrl( "/x/v/math/bytes" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) .responded( OK, "OK", APPLICATION_JSON, "\"1234\"" ); } @Test public void invocationString() { - assertPost2( kernel.httpUrl( "/x/v/math/string" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) + HttpAsserts.assertPost( kernel.httpUrl( "/x/v/math/string" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) .responded( OK, "OK", APPLICATION_JSON, "\"1234\"" ); - assertPost2( kernel.httpUrl( "/x/v/math/string" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) + HttpAsserts.assertPost( kernel.httpUrl( "/x/v/math/string" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) .satisfies( response -> assertThat( response.headers ) - .contains( __( "Content-Type", "application/json" ) ) ); + .contains( __( "content-type", "application/json" ) ) ); } @Test public void invocationInputStream() { - assertPost2( kernel.httpUrl( "/x/v/math/inputStream" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) + HttpAsserts.assertPost( kernel.httpUrl( "/x/v/math/inputStream" ), "1234", Http.ContentType.APPLICATION_OCTET_STREAM ) .responded( OK, "OK", APPLICATION_JSON, "\"1234\"" ); } @Test public void enumValue() { - assertGet2( kernel.httpUrl( "/x/v/math/en?a=CLASS" ) ) + assertGet( kernel.httpUrl( "/x/v/math/en?a=CLASS" ) ) .responded( OK, "OK", Http.ContentType.APPLICATION_JSON, "\"CLASS\"" ); } @Test public void optional() { - assertGet2( kernel.httpUrl( "/x/v/math/sumabopt?a=1&b=2" ) ) + assertGet( kernel.httpUrl( "/x/v/math/sumabopt?a=1&b=2" ) ) .responded( OK, "OK", Http.ContentType.APPLICATION_JSON, "3" ); } @Test public void parameterList() { - assertGet2( kernel.httpUrl( "/x/v/math/sum?a=1&b=2&b=3" ) ) + assertGet( kernel.httpUrl( "/x/v/math/sum?a=1&b=2&b=3" ) ) .responded( OK, "OK", Http.ContentType.APPLICATION_JSON, "6" ); } @Test public void string() { - assertGet2( kernel.httpUrl( "/x/v/math/id?a=aaa" ) ) + assertGet( kernel.httpUrl( "/x/v/math/id?a=aaa" ) ) .responded( OK, "OK", Http.ContentType.APPLICATION_JSON, "\"aaa\"" ); } @Test public void request() { - assertGet2( kernel.httpUrl( "/x/v/math/req" ) ) + assertGet( kernel.httpUrl( "/x/v/math/req" ) ) .responded( OK, "OK", Http.ContentType.APPLICATION_JSON, "\"/x/v/math/req-\"" ); } @Test public void json() { - assertPost2( kernel.httpUrl( "/x/v/math/json" ), "{\"i\":1,\"s\":\"sss\"}", APPLICATION_JSON ) + HttpAsserts.assertPost( kernel.httpUrl( "/x/v/math/json" ), "{\"i\":1,\"s\":\"sss\"}", APPLICATION_JSON ) .respondedJson( "{\"i\":1,\"s\":\"sss\"}" ); } @Test public void list() { - assertPost2( kernel.httpUrl( "/x/v/math/list" ), "[\"1str\", \"2str\"]", APPLICATION_JSON ) + HttpAsserts.assertPost( kernel.httpUrl( "/x/v/math/list" ), "[\"1str\", \"2str\"]", APPLICATION_JSON ) .respondedJson( "[\"1str\",\"2str\"]" ); } @@ -217,7 +217,7 @@ public void shouldVerifyGZIPRequestProcessing() throws Exception { */ @Test public void testWsServiceDisabled() { - assertGet2( kernel.httpUrl( "/test-disabled" ) ).hasCode( NO_CONTENT ); + assertGet( kernel.httpUrl( "/test-disabled" ) ).hasCode( NO_CONTENT ); } @SuppressWarnings( "unused" ) diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/interceptor/InterceptorTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/interceptor/InterceptorTest.java index 8b81c14005..4d1ee99540 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/interceptor/InterceptorTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/interceptor/InterceptorTest.java @@ -34,7 +34,7 @@ import java.util.Optional; import static oap.http.Http.StatusCode.FORBIDDEN; -import static oap.http.test.HttpAsserts.assertGet2; +import static oap.http.test.HttpAsserts.assertGet; import static oap.io.Resources.urlOrThrow; public class InterceptorTest extends Fixtures { @@ -47,7 +47,7 @@ public InterceptorTest() { @Test public void shouldNotAllowRequestWhenErrorInterceptor() { - assertGet2( kernel.httpUrl( "/interceptor/text?value=error" ) ) + assertGet( kernel.httpUrl( "/interceptor/text?value=error" ) ) .hasCode( FORBIDDEN ) .hasReason( "caused by interceptor" ); } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java index dd62cb3c42..c773c0e760 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerMethodTest.java @@ -36,8 +36,8 @@ import static oap.http.server.nio.HttpServerExchange.HttpMethod.GET; import static oap.http.server.nio.HttpServerExchange.HttpMethod.POST; -import static oap.http.test.HttpAsserts.assertGet2; -import static oap.http.test.HttpAsserts.assertPost2; +import static oap.http.test.HttpAsserts.assertGet; +import static oap.http.test.HttpAsserts.assertPost; import static oap.io.Resources.urlOrThrow; import static oap.ws.WsParam.From.BODY; import static oap.ws.validate.ValidationErrors.empty; @@ -54,31 +54,31 @@ public MethodValidatorPeerMethodTest() { @Test public void validationDefault() { - assertPost2( kernel.httpUrl( "/mvpm/run/validation/default" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost( kernel.httpUrl( "/mvpm/run/validation/default" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "\"test\"" ); } @Test public void validationOk() { - assertPost2( kernel.httpUrl( "/mvpm/run/validation/ok" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost( kernel.httpUrl( "/mvpm/run/validation/ok" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.TEXT_PLAIN, "test" ); } @Test public void validationFail() { - assertPost2( kernel.httpUrl( "/mvpm/run/validation/fail" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost( kernel.httpUrl( "/mvpm/run/validation/fail" ), "test", Http.ContentType.TEXT_PLAIN ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\":[\"error1\",\"error2\"]}" ); } @Test public void validationFailCode() { - assertPost2( kernel.httpUrl( "/mvpm/run/validation/fail-code" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost( kernel.httpUrl( "/mvpm/run/validation/fail-code" ), "test", Http.ContentType.TEXT_PLAIN ) .respondedJson( Http.StatusCode.FORBIDDEN, "validation failed", "{\"errors\":[\"denied\"]}" ); } @Test public void validationMethods() { - assertGet2( kernel.httpUrl( "/mvpm/run/validation/methods?a=a&b=5&c=c" ) ) + assertGet( kernel.httpUrl( "/mvpm/run/validation/methods?a=a&b=5&c=c" ) ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\":[\"a\",\"a5\",\"5a\"]}" ); } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerParamTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerParamTest.java index a5988b0636..3927d41a74 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerParamTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/MethodValidatorPeerParamTest.java @@ -35,7 +35,7 @@ import java.util.Optional; import static oap.http.server.nio.HttpServerExchange.HttpMethod.POST; -import static oap.http.test.HttpAsserts.assertPost2; +import static oap.http.test.HttpAsserts.assertPost; import static oap.io.Resources.urlOrThrow; import static oap.ws.WsParam.From.BODY; import static oap.ws.WsParam.From.QUERY; @@ -52,43 +52,43 @@ public MethodValidatorPeerParamTest() { @Test public void validationDefault() { - assertPost2( kernel.httpUrl( "/mvpp/run/validation/default?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost( kernel.httpUrl( "/mvpp/run/validation/default?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "\"1test\"" ); } @Test public void validationOk() { - assertPost2( kernel.httpUrl( "/mvpp/run/validation/ok?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost( kernel.httpUrl( "/mvpp/run/validation/ok?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "\"1test\"" ); } @Test public void validationOkList() { - assertPost2( kernel.httpUrl( "/mvpp/run/validation/ok?i=1&listString=_11&listString=_12" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost( kernel.httpUrl( "/mvpp/run/validation/ok?i=1&listString=_11&listString=_12" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "\"1_11/_12test\"" ); } @Test public void validationOkOptional() { - assertPost2( kernel.httpUrl( "/mvpp/run/validation/ok?i=1&optString=2" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost( kernel.httpUrl( "/mvpp/run/validation/ok?i=1&optString=2" ), "test", Http.ContentType.TEXT_PLAIN ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "\"12test\"" ); } @Test public void validationFail() { - assertPost2( kernel.httpUrl( "/mvpp/run/validation/fail?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost( kernel.httpUrl( "/mvpp/run/validation/fail?i=1" ), "test", Http.ContentType.TEXT_PLAIN ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\": [\"error:1\", \"error:test\"]}" ); } @Test public void validationRequiredFailed() { - assertPost2( kernel.httpUrl( "/mvpp/run/validation/ok" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost( kernel.httpUrl( "/mvpp/run/validation/ok" ), "test", Http.ContentType.TEXT_PLAIN ) .respondedJson( Http.StatusCode.BAD_REQUEST, "'int i' is required", "{\"errors\": [\"'int i' is required\"]}" ); } @Test public void validationTypeFailed() { - assertPost2( kernel.httpUrl( "/mvpp/run/validation/ok?i=unsupportedStringToIntCast" ), "test", Http.ContentType.TEXT_PLAIN ) + assertPost( kernel.httpUrl( "/mvpp/run/validation/ok?i=unsupportedStringToIntCast" ), "test", Http.ContentType.TEXT_PLAIN ) .hasCode( Http.StatusCode.BAD_REQUEST ); } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidateJsonTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidateJsonTest.java index d9649d836a..9ddc8922da 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidateJsonTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidateJsonTest.java @@ -33,7 +33,7 @@ import org.testng.annotations.Test; import static oap.http.server.nio.HttpServerExchange.HttpMethod.POST; -import static oap.http.test.HttpAsserts.assertPost2; +import static oap.http.test.HttpAsserts.assertPost; import static oap.io.Resources.urlOrThrow; import static oap.ws.WsParam.From.BODY; import static oap.ws.WsParam.From.QUERY; @@ -48,29 +48,29 @@ public ValidateJsonTest() { @Test public void validation1() { - assertPost2( kernel.httpUrl( "/vj/run/validation/1" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vj/run/validation/1" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "{\"a\":1}" ); - assertPost2( kernel.httpUrl( "/vj/run/validation/1" ), "{}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vj/run/validation/1" ), "{}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\":[\"/a: required property is missing\"]}" ); } @Test public void validation2() { - assertPost2( kernel.httpUrl( "/vj/run/validation/2" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vj/run/validation/2" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "{\"a\":1}" ); - assertPost2( kernel.httpUrl( "/vj/run/validation/2" ), "{}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vj/run/validation/2" ), "{}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "{}" ); - assertPost2( kernel.httpUrl( "/vj/run/validation/2" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vj/run/validation/2" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\":[\"additional properties are not permitted [b]\"]}" ); } @Test public void validation3() { - assertPost2( kernel.httpUrl( "/vj/run/validation/3?type=type1" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vj/run/validation/3?type=type1" ), "{\"a\":1}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "{\"a\":1}" ); - assertPost2( kernel.httpUrl( "/vj/run/validation/3?type=type2" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vj/run/validation/3?type=type2" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.OK, "OK", Http.ContentType.APPLICATION_JSON, "{\"b\":1}" ); - assertPost2( kernel.httpUrl( "/vj/run/validation/3?type=type1" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vj/run/validation/3?type=type1" ), "{\"b\":1}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.BAD_REQUEST, "validation failed", "{\"errors\":[\"/a: required property is missing\"]}" ); } diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidatePartialJsonTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidatePartialJsonTest.java index c6b0c60c81..f547860996 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidatePartialJsonTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/validate/ValidatePartialJsonTest.java @@ -35,7 +35,7 @@ import java.util.ArrayList; import static oap.http.server.nio.HttpServerExchange.HttpMethod.POST; -import static oap.http.test.HttpAsserts.assertPost2; +import static oap.http.test.HttpAsserts.assertPost; import static oap.io.Resources.urlOrThrow; import static oap.ws.WsParam.From.BODY; import static oap.ws.WsParam.From.PATH; @@ -50,21 +50,21 @@ public ValidatePartialJsonTest() { @Test public void validation1() { - assertPost2( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{\"id\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{\"id\":1}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.OK, "OK", "{\"a\":[{\"id\":1}],\"id\":\"id1\"}" ); - assertPost2( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{\"b\":[{\"element\":\"test\"}],\"id\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{\"b\":[{\"element\":\"test\"}],\"id\":1}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.OK, "OK", "{\"a\":[{\"id\":1,\"b\":[{\"element\":\"test\"}]}],\"id\":\"id1\"}" ); - assertPost2( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vpj/run/validation/1/id1" ), "{}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.BAD_REQUEST, "validation failed", Http.ContentType.APPLICATION_JSON, "{\"errors\":[\"/a/1/id: required property is missing\"]}" ); } @Test public void validation2() { - assertPost2( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{\"id\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{\"id\":1}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.OK, "OK", "{\"a\":[{\"id\":1}],\"id\":\"id1\"}" ); - assertPost2( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.OK, "OK", "{\"a\":[{}],\"id\":\"id1\"}" ); - assertPost2( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{\"c\":1}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vpj/run/validation/2/id1" ), "{\"c\":1}", Http.ContentType.APPLICATION_JSON ) .responded( Http.StatusCode.BAD_REQUEST, "validation failed", Http.ContentType.APPLICATION_JSON, "{\"errors\":[\"/a/1: additional properties are not permitted [c]\"]}" ); } @@ -80,7 +80,7 @@ public void validation3() { TestBean bean = ( TestBean ) obj; bean.a.add( itemA ); bean.a.add( itemB ); - assertPost2( kernel.httpUrl( "/vpj/run/validation/3/id1/2" ), "{\"element\":\"some text\"}", Http.ContentType.APPLICATION_JSON ) + assertPost( kernel.httpUrl( "/vpj/run/validation/3/id1/2" ), "{\"element\":\"some text\"}", Http.ContentType.APPLICATION_JSON ) .respondedJson( Http.StatusCode.OK, "OK", "{\"a\":[{\"id\":1},{\"id\":2,\"b\":[{\"element\":\"some text\"}]}],\"id\":\"id1\"}" ); } From 975414f259e26dbe0ffc942bb679503603fbb706 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 20 Jan 2026 11:54:33 +0200 Subject: [PATCH 05/36] CE-132 oap-sso: user: replace PK: email -> id --- oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java index caef53d5a3..82a27a5ba4 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java @@ -96,7 +96,7 @@ public void header() { @Test public void cookie() { - assertGet( kernel.httpUrl( "/x/v/math/cookie" ), Map.of(), Map.of( "Cookie", "cookie=theCookie;Really-Cool-Cookie=ohoh" ) ) + assertGet( kernel.httpUrl( "/x/v/math/cookie" ), Map.of(), Map.of( "cookie", "cookie=theCookie;Really-Cool-Cookie=ohoh" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"theCookieohoh\"" ); } From fb6b6d532d6c3227da78268bcc9247b56ae02080 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 20 Jan 2026 14:40:58 +0200 Subject: [PATCH 06/36] CE-132 oap-sso: user: replace PK: email -> id --- .../main/java/oap/http/test/HttpAsserts.java | 190 ++++++++++++++---- oap-http/oap-http/pom.xml | 4 + .../src/test/java/oap/ws/WebServicesTest.java | 4 +- 3 files changed, 161 insertions(+), 37 deletions(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 0c621eee51..77bf8be8de 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -23,6 +23,7 @@ */ package oap.http.test; +import com.google.common.base.Preconditions; import lombok.EqualsAndHashCode; import lombok.ToString; import lombok.extern.slf4j.Slf4j; @@ -37,7 +38,6 @@ import oap.util.Maps; import oap.util.Pair; import oap.util.Stream; -import okhttp3.CookieJar; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.MediaType; @@ -46,6 +46,8 @@ import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.ResponseBody; +import okhttp3.java.net.cookiejar.JavaNetCookieJar; +import org.apache.commons.lang3.StringUtils; import org.assertj.core.api.Assertions; import org.joda.time.DateTime; import org.jspecify.annotations.NonNull; @@ -56,6 +58,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; +import java.net.CookieManager; +import java.net.CookiePolicy; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -77,23 +81,9 @@ @Slf4j @SuppressWarnings( "unused" ) public class HttpAsserts { - public static final OkHttpClient OK_HTTP_CLIENT = new OkHttpClient.Builder() - .cookieJar( new CookieJar() { - private final ConcurrentHashMap> cookieStore = new ConcurrentHashMap<>(); - - @Override - public void saveFromResponse( @NonNull HttpUrl url, @NonNull List cookies ) { - cookieStore.put( url.host(), cookies ); - } - - @Override - public @NonNull List loadForRequest( @NonNull HttpUrl url ) { - List cookies = cookieStore.get( url.host() ); - return cookies != null ? cookies : new ArrayList<>(); - } - } ) - .build(); + public static final ConcurrentHashMap> cookieStore = new ConcurrentHashMap<>(); + public static final OkHttpClient OK_HTTP_CLIENT; private static final Client client = Client.custom() .setMaxConnTotal( 100_000 ) .setMaxConnPerRoute( 100_000 ) @@ -101,6 +91,18 @@ public void saveFromResponse( @NonNull HttpUrl url, @NonNull List log.error( e.getMessage() ) ) .build(); + private static JavaNetCookieJar cookieJar; + + static { + CookieManager cookieManager = new CookieManager(); + cookieManager.setCookiePolicy( CookiePolicy.ACCEPT_ALL ); + + cookieJar = new JavaNetCookieJar( cookieManager ); + OK_HTTP_CLIENT = new OkHttpClient.Builder() + .cookieJar( cookieJar ) + .build(); + } + public static String httpPrefix( int port ) { return "http://localhost:" + port; } @@ -118,11 +120,11 @@ public static HttpAssertion assertGet( String uri, Pair... param return assertGet( uri, Maps.of( params ), Map.of() ); } - public static HttpAssertion assertGet( String uri, Map params, Map requestHeaders ) throws UncheckedIOException { + public static HttpAssertion assertGet( String uri, Map params, Map headers ) throws UncheckedIOException { try { Request.Builder builder = new Request.Builder(); - requestHeaders.forEach( ( k, v ) -> builder.header( k, v == null ? "" : v.toString() ) ); + setHeaders( uri, headers, builder ); Request request = builder .url( Uri.uri( uri, params ).toURL() ) @@ -135,11 +137,37 @@ public static HttpAssertion assertGet( String uri, Map params, M } } - public static HttpAssertion assertPost( String uri, InputStream content, @Nullable String contentType, Map requestHeaders ) { + private static void setHeaders( String uri, Map headers, Request.Builder builder ) { + headers.forEach( ( k, v ) -> { + if( "Cookie".equalsIgnoreCase( k ) ) { + HttpUrl httpUrl = HttpUrl.parse( uri ); + Preconditions.checkNotNull( httpUrl ); + Preconditions.checkNotNull( v ); + + ArrayList cookies = new ArrayList<>(); + + List list = cookieJar.loadForRequest( httpUrl ); + cookies.addAll( list ); + + String[] setCookies = StringUtils.split( v.toString(), ";" ); + for( String setCookie : setCookies ) { + okhttp3.Cookie cookie = okhttp3.Cookie.parse( httpUrl, setCookie ); + Preconditions.checkNotNull( cookie ); + cookies.add( cookie ); + } + + cookieJar.saveFromResponse( httpUrl, cookies ); + } else { + builder.header( k, v == null ? "" : v.toString() ); + } + } ); + } + + public static HttpAssertion assertPost( String uri, InputStream content, @Nullable String contentType, Map headers ) { try { Request.Builder builder = new Request.Builder(); - requestHeaders.forEach( ( k, v ) -> builder.header( k, v == null ? "" : v.toString() ) ); + setHeaders( uri, headers, builder ); RequestBody requestBody = new InputStreamRequestBody( contentType != null ? MediaType.get( contentType ) : null, content ); @@ -158,11 +186,11 @@ public static HttpAssertion assertPost( String uri, InputStream content, @Nullab return assertPost( uri, content, contentType, Maps.of() ); } - public static HttpAssertion assertPost( String uri, String content, @Nullable String contentType, Map requestHeaders ) { + public static HttpAssertion assertPost( String uri, String content, @Nullable String contentType, Map headers ) { try { Request.Builder builder = new Request.Builder(); - requestHeaders.forEach( ( k, v ) -> builder.header( k, v == null ? "" : v.toString() ) ); + setHeaders( uri, headers, builder ); RequestBody requestBody = RequestBody.create( content, contentType != null ? MediaType.parse( contentType ) : null ); @@ -203,59 +231,149 @@ public static HttpAssertion assertPost( String uri, String content, String conte } public static HttpAssertion assertPut( String uri, String content, String contentType ) { - return assertHttpResponse( client.put( uri, content, contentType ) ); + return assertPut( uri, content, contentType, Maps.of() ); } public static HttpAssertion assertPut( String uri, String content, String contentType, Map headers ) { - return assertHttpResponse( client.put( uri, content, contentType, headers ) ); + try { + Request.Builder builder = new Request.Builder(); + + setHeaders( uri, headers, builder ); + + RequestBody requestBody = RequestBody.create( content, contentType != null ? MediaType.parse( contentType ) : null ); + + Request request = builder + .url( uri ) + .put( requestBody ) + .build(); + + return getResponseAsHttpAssertion( request ); + } catch( IOException e ) { + throw new UncheckedIOException( e ); + } } public static HttpAssertion assertPut( String uri, byte[] content, String contentType ) { - return assertHttpResponse( client.put( uri, content, contentType ) ); + return assertPut( uri, content, contentType, Maps.of() ); } public static HttpAssertion assertPut( String uri, byte[] content, String contentType, Map headers ) { - return assertHttpResponse( client.put( uri, content, contentType, headers ) ); + try { + Request.Builder builder = new Request.Builder(); + + setHeaders( uri, headers, builder ); + + RequestBody requestBody = RequestBody.create( content, contentType != null ? MediaType.parse( contentType ) : null ); + + Request request = builder + .url( uri ) + .put( requestBody ) + .build(); + + return getResponseAsHttpAssertion( request ); + } catch( IOException e ) { + throw new UncheckedIOException( e ); + } } public static HttpAssertion assertPut( String uri, InputStream is, String contentType ) { - return assertHttpResponse( client.put( uri, is, contentType ) ); + return assertPut( uri, is, contentType, Maps.of() ); } public static HttpAssertion assertPut( String uri, InputStream is, String contentType, Map headers ) { - return assertHttpResponse( client.put( uri, is, contentType, headers ) ); + try { + Request.Builder builder = new Request.Builder(); + + setHeaders( uri, headers, builder ); + + InputStreamRequestBody requestBody = new InputStreamRequestBody( contentType != null ? MediaType.parse( contentType ) : null, is ); + + Request request = builder + .url( uri ) + .put( requestBody ) + .build(); + + return getResponseAsHttpAssertion( request ); + } catch( IOException e ) { + throw new UncheckedIOException( e ); + } } public static HttpAssertion assertPatch( String uri, byte[] content, String contentType ) { - return assertHttpResponse( client.patch( uri, content, contentType ) ); + return assertPatch( uri, content, contentType, Maps.of() ); } public static HttpAssertion assertPatch( String uri, byte[] content, String contentType, Map headers ) { - return assertHttpResponse( client.patch( uri, content, contentType, headers ) ); + try { + Request.Builder builder = new Request.Builder(); + + setHeaders( uri, headers, builder ); + + RequestBody requestBody = RequestBody.create( content, contentType != null ? MediaType.parse( contentType ) : null ); + + Request request = builder + .url( uri ) + .patch( requestBody ) + .build(); + + return getResponseAsHttpAssertion( request ); + } catch( IOException e ) { + throw new UncheckedIOException( e ); + } } public static HttpAssertion assertPatch( String uri, String content, String contentType ) { - return assertHttpResponse( client.patch( uri, content, contentType ) ); + return assertPatch( uri, content, contentType, Maps.of() ); } public static HttpAssertion assertPatch( String uri, String content, String contentType, Map headers ) { - return assertHttpResponse( client.patch( uri, content, contentType, headers ) ); + try { + Request.Builder builder = new Request.Builder(); + + setHeaders( uri, headers, builder ); + + RequestBody requestBody = RequestBody.create( content, contentType != null ? MediaType.parse( contentType ) : null ); + + Request request = builder + .url( uri ) + .patch( requestBody ) + .build(); + + return getResponseAsHttpAssertion( request ); + } catch( IOException e ) { + throw new UncheckedIOException( e ); + } } public static HttpAssertion assertPatch( String uri, InputStream is, String contentType ) { - return assertHttpResponse( client.patch( uri, is, contentType ) ); + return assertPatch( uri, is, contentType, Maps.of() ); } public static HttpAssertion assertPatch( String uri, InputStream is, String contentType, Map headers ) { - return assertHttpResponse( client.patch( uri, is, contentType, headers ) ); + try { + Request.Builder builder = new Request.Builder(); + + setHeaders( uri, headers, builder ); + + InputStreamRequestBody requestBody = new InputStreamRequestBody( contentType != null ? MediaType.parse( contentType ) : null, is ); + + Request request = builder + .url( uri ) + .patch( requestBody ) + .build(); + + return getResponseAsHttpAssertion( request ); + } catch( IOException e ) { + throw new UncheckedIOException( e ); + } } public static HttpAssertion assertDelete( String uri, Map headers ) { try { Request.Builder builder = new Request.Builder(); - headers.forEach( ( k, v ) -> builder.header( k, v == null ? "" : v.toString() ) ); + setHeaders( uri, headers, builder ); Request request = builder .url( uri ) diff --git a/oap-http/oap-http/pom.xml b/oap-http/oap-http/pom.xml index bf71643847..d5eb23fe59 100644 --- a/oap-http/oap-http/pom.xml +++ b/oap-http/oap-http/pom.xml @@ -82,6 +82,10 @@ com.squareup.okhttp3 okhttp-jvm + + com.squareup.okhttp3 + okhttp-java-net-cookiejar + org.projectlombok lombok diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java index 82a27a5ba4..3104d75aaf 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java @@ -96,7 +96,9 @@ public void header() { @Test public void cookie() { - assertGet( kernel.httpUrl( "/x/v/math/cookie" ), Map.of(), Map.of( "cookie", "cookie=theCookie;Really-Cool-Cookie=ohoh" ) ) + HttpAsserts.cookieStore.clear(); + + assertGet( kernel.httpUrl( "/x/v/math/cookie" ), Map.of(), Map.of( "Cookie", "cookie=theCookie;Really-Cool-Cookie=ohoh" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"theCookieohoh\"" ); } From 6c935a513fedd131a3cc488e3fe93ecb497ce62e Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 20 Jan 2026 15:56:47 +0200 Subject: [PATCH 07/36] CE-132 oap-sso: user: replace PK: email -> id --- oap-jpath/src/main/java/oap/jpath/JPath.java | 2 +- .../src/main/java/oap/jpath/MapPointer.java | 2 +- .../main/java/oap/jpath/PathExpression.java | 2 +- oap-ws/oap-ws-admin-ws/pom.xml | 6 ++++ .../src/main/java/oap/ws/admin/JPathWS.java | 31 ++++++++++++++++++- .../test/java/oap/ws/admin/JPathWSTest.java | 13 ++++++-- .../src/main/java/oap/ws/sso/JwtToken.java | 5 +++ 7 files changed, 55 insertions(+), 6 deletions(-) diff --git a/oap-jpath/src/main/java/oap/jpath/JPath.java b/oap-jpath/src/main/java/oap/jpath/JPath.java index 9749a78049..c0ade4ccbe 100644 --- a/oap-jpath/src/main/java/oap/jpath/JPath.java +++ b/oap-jpath/src/main/java/oap/jpath/JPath.java @@ -43,7 +43,7 @@ public static void evaluate( String expression, Map variables, J } public void evaluate( String expression, JPathOutput output ) { - var jPathParser = new JPathParser( new BufferedTokenStream( new JPathLexer( new ANTLRInputStream( expression ) ) ) ); + JPathParser jPathParser = new JPathParser( new BufferedTokenStream( new JPathLexer( new ANTLRInputStream( expression ) ) ) ); jPathParser.expr().expression.evaluate( variables, output ); } diff --git a/oap-jpath/src/main/java/oap/jpath/MapPointer.java b/oap-jpath/src/main/java/oap/jpath/MapPointer.java index 4c4a19f63a..c02d4de456 100644 --- a/oap-jpath/src/main/java/oap/jpath/MapPointer.java +++ b/oap-jpath/src/main/java/oap/jpath/MapPointer.java @@ -37,7 +37,7 @@ public MapPointer( Map map ) { @Override public Pointer resolve( AbstractPathNode n ) { if( n.type == PathType.FIELD ) { - var ret = v.get( n.name ); + Object ret = v.get( n.name ); return ret != null ? Pointer.get( ret ) : NullPointer.INSTANCE; } return super.resolve( n ); diff --git a/oap-jpath/src/main/java/oap/jpath/PathExpression.java b/oap-jpath/src/main/java/oap/jpath/PathExpression.java index cb3c23ffb6..950fa832cd 100644 --- a/oap-jpath/src/main/java/oap/jpath/PathExpression.java +++ b/oap-jpath/src/main/java/oap/jpath/PathExpression.java @@ -40,7 +40,7 @@ public void add( AbstractPathNode path ) { @SuppressWarnings( "unchecked" ) public void evaluate( Map variables, JPathOutput output ) { Pointer pointer = new MapPointer( ( Map ) ( Object ) variables ); - for( var n : list ) pointer = pointer.resolve( n ); + for( AbstractPathNode n : list ) pointer = pointer.resolve( n ); output.write( pointer ); } } diff --git a/oap-ws/oap-ws-admin-ws/pom.xml b/oap-ws/oap-ws-admin-ws/pom.xml index a016c31b6f..cc0a711c48 100644 --- a/oap-ws/oap-ws-admin-ws/pom.xml +++ b/oap-ws/oap-ws-admin-ws/pom.xml @@ -34,6 +34,12 @@ ${project.version} test + + oap + oap-stdlib-test + ${project.version} + test + org.projectlombok diff --git a/oap-ws/oap-ws-admin-ws/src/main/java/oap/ws/admin/JPathWS.java b/oap-ws/oap-ws-admin-ws/src/main/java/oap/ws/admin/JPathWS.java index 757b2c4b62..d8cd15859c 100644 --- a/oap-ws/oap-ws-admin-ws/src/main/java/oap/ws/admin/JPathWS.java +++ b/oap-ws/oap-ws-admin-ws/src/main/java/oap/ws/admin/JPathWS.java @@ -29,9 +29,11 @@ import oap.application.Kernel; import oap.http.Http; import oap.jpath.JPath; +import oap.jpath.NullPointer; import oap.ws.Response; import oap.ws.WsMethod; import oap.ws.WsParam; +import org.apache.commons.lang3.StringUtils; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; @@ -53,7 +55,34 @@ public Response get( @WsParam( from = QUERY ) String query ) { log.debug( "query = {}", query ); try { AtomicReference result = new AtomicReference<>(); - JPath.evaluate( query, ( Map ) ( Object ) kernel.services.moduleMap, pointer -> result.set( pointer.get() ) ); + + String[] fields = StringUtils.split( query, '.' ); + if( fields.length > 0 ) { + JPath.evaluate( "${" + fields[0] + "}", ( Map ) ( Object ) kernel.services.moduleMap, pointer -> { + if( !( pointer instanceof NullPointer ) ) { + result.set( fields[0] ); + } + } ); + } + + if( result.get() == null ) { + return new Response( Http.StatusCode.BAD_REQUEST ).withBody( "unknown module " + fields[0] ); + } + result.set( null ); + + if( fields.length > 1 ) { + JPath.evaluate( "${" + fields[0] + "." + fields[1] + "}", ( Map ) ( Object ) kernel.services.moduleMap, pointer -> { + if( !( pointer instanceof NullPointer ) ) { + result.set( fields[1] ); + } + } ); + } + if( result.get() == null ) { + return new Response( Http.StatusCode.BAD_REQUEST ).withBody( "unknown module service " + fields[0] + "." + fields[1] ); + } + result.set( null ); + + JPath.evaluate( "${" + query + "}", ( Map ) ( Object ) kernel.services.moduleMap, pointer -> result.set( pointer.get() ) ); return Response.jsonOk().withBody( result.get(), false ); } catch( Exception e ) { log.error( e.getMessage(), e ); diff --git a/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java b/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java index 4a9b2cfdb5..341a18fd9e 100644 --- a/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java +++ b/oap-ws/oap-ws-admin-ws/src/test/java/oap/ws/admin/JPathWSTest.java @@ -27,13 +27,12 @@ import oap.application.testng.KernelFixture; import oap.testng.Fixtures; import oap.testng.TestDirectoryFixture; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; +import static oap.http.Http.StatusCode.BAD_REQUEST; import static oap.http.test.HttpAsserts.assertGet; import static oap.io.Resources.urlOrThrow; -@Ignore public class JPathWSTest extends Fixtures { private final KernelFixture kernel; @@ -58,4 +57,14 @@ public void testPublicFieldAccess() { .isOk() .hasBody( "\"testv\"" ); } + + @Test + public void testUnknownModule() { + assertGet( kernel.httpUrl( "/system/admin/jpath?query=unknown-module.test-service.instance.value" ) ) + .hasCode( BAD_REQUEST ) + .hasBody( "unknown module unknown-module" ); + assertGet( kernel.httpUrl( "/system/admin/jpath?query=oap-ws-admin-ws-test.unknown-service.instance.value" ) ) + .hasCode( BAD_REQUEST ) + .hasBody( "unknown module service oap-ws-admin-ws-test.unknown-service" ); + } } diff --git a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/JwtToken.java b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/JwtToken.java index 9175515b05..e34af8cd39 100644 --- a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/JwtToken.java +++ b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/JwtToken.java @@ -18,6 +18,11 @@ public JwtToken( DecodedJWT decodedJWT, SecurityRoles roles ) { this.roles = roles; } + public String getUserId() { + final Claim id = decodedJWT.getClaims().get( "id" ); + return id != null ? id.asString() : null; + } + public String getUserEmail() { final Claim user = decodedJWT.getClaims().get( "user" ); return user != null ? user.asString() : null; From ba369618c02fe9954057e8bc3ea80c9ba373502c Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 20 Jan 2026 18:18:25 +0200 Subject: [PATCH 08/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/storage/MongoPersistence.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oap-storage/oap-storage-mongo/src/main/java/oap/storage/MongoPersistence.java b/oap-storage/oap-storage-mongo/src/main/java/oap/storage/MongoPersistence.java index 0d8f75befe..206fed21b1 100644 --- a/oap-storage/oap-storage-mongo/src/main/java/oap/storage/MongoPersistence.java +++ b/oap-storage/oap-storage-mongo/src/main/java/oap/storage/MongoPersistence.java @@ -136,7 +136,7 @@ protected void processRecords( CountDownLatch cdl ) { @Override protected void load() { log.debug( "loading data from {}", collection.getNamespace() ); - Consumer> cons = metadata -> storage.memory.put( storage.identifier.get( metadata.object ), metadata ); + Consumer> cons = metadata -> storage.memory.put( storage.identifier.getOrInit( metadata.object, _ -> false ), metadata ); log.info( "Loading documents from [{}] MongoDB table", collection.getNamespace() ); collection.find().forEach( cons ); log.info( storage.size() + " object(s) loaded." ); From bc323555ec8674f263e61135ca83b63825bbdec0 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 20 Jan 2026 19:15:00 +0200 Subject: [PATCH 09/36] CE-132 oap-sso: user: replace PK: email -> id --- oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java index e6c0e7854d..55f3b314c1 100644 --- a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java +++ b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java @@ -31,6 +31,7 @@ import oap.ws.Response; import oap.ws.SessionManager; import org.joda.time.DateTime; +import org.joda.time.Duration; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -65,13 +66,16 @@ public static Optional getRefreshAuthentication( HttpServerExchange exch } public static Response authenticatedResponse( Authentication authentication, String cookieDomain, Boolean cookieSecure ) { + long accessTokenMaxAge = new Duration( new DateTime( UTC ), new DateTime( authentication.accessToken.expires, UTC ) ).getStandardSeconds(); + long refreshTokenMaxAge = new Duration( new DateTime( UTC ), new DateTime( authentication.refreshToken.expires, UTC ) ).getStandardSeconds(); + return Response .jsonOk() .withHeader( AUTHENTICATION_KEY, authentication.accessToken.jwt ) .withCookie( Cookie.builder( AUTHENTICATION_KEY, authentication.accessToken.jwt ) .withDomain( cookieDomain ) .withPath( "/" ) - .withExpires( new DateTime( authentication.accessToken.expires ) ) + .withMaxAge( ( int ) accessTokenMaxAge ) .withHttpOnly( true ) .withSecure( cookieSecure ) .build() @@ -79,7 +83,7 @@ public static Response authenticatedResponse( Authentication authentication, Str .withCookie( Cookie.builder( REFRESH_TOKEN_KEY, authentication.refreshToken.jwt ) .withDomain( cookieDomain ) .withPath( "/" ) - .withExpires( new DateTime( authentication.refreshToken.expires ) ) + .withMaxAge( ( int ) refreshTokenMaxAge ) .withHttpOnly( true ) .withSecure( cookieSecure ) .build() From f9af93bc8a9585e703a51d7e9348e00cec6d3056 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 20 Jan 2026 19:34:16 +0200 Subject: [PATCH 10/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/json/testng/JsonAsserts.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/oap-stdlib-test/src/main/java/oap/json/testng/JsonAsserts.java b/oap-stdlib-test/src/main/java/oap/json/testng/JsonAsserts.java index d147c7a42a..5295aadf73 100644 --- a/oap-stdlib-test/src/main/java/oap/json/testng/JsonAsserts.java +++ b/oap-stdlib-test/src/main/java/oap/json/testng/JsonAsserts.java @@ -43,6 +43,7 @@ import static oap.io.content.ContentReader.ofJson; import static oap.io.content.ContentReader.ofString; import static oap.json.Binder.json; +import static oap.testng.Asserts.assertString; import static oap.testng.Asserts.contentOfTestResource; import static oap.util.Pair.__; import static org.assertj.core.api.Assertions.assertThat; @@ -143,7 +144,7 @@ public JsonAssertion isEqualTo( String expected, Map substitutio .map( JsonAssertion::deepSort, JsonAssertion::deepSort ) .map( e -> json.marshal( e.isLeft() ? e.leftValue : e.rightValue, true ) ); - assertThat( actualJson ).isEqualTo( expectedJson ); + assertString( actualJson ).isEqualTo( expectedJson ); return this; } @@ -167,7 +168,7 @@ public JsonAssertion isEqualTo( String expected, Function substi .map( JsonAssertion::deepSort, JsonAssertion::deepSort ) .map( e -> json.marshal( e.isLeft() ? e.leftValue : e.rightValue, true ) ); - assertThat( actualJson ).isEqualTo( expectedJson ); + assertString( actualJson ).isEqualTo( expectedJson ); return this; } From 44b19c1cb89747289fcd45bba341d1901f1fd18c Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 20 Jan 2026 19:40:46 +0200 Subject: [PATCH 11/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/json/testng/JsonAsserts.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/oap-stdlib-test/src/main/java/oap/json/testng/JsonAsserts.java b/oap-stdlib-test/src/main/java/oap/json/testng/JsonAsserts.java index 5295aadf73..64e5aeb858 100644 --- a/oap-stdlib-test/src/main/java/oap/json/testng/JsonAsserts.java +++ b/oap-stdlib-test/src/main/java/oap/json/testng/JsonAsserts.java @@ -46,7 +46,6 @@ import static oap.testng.Asserts.assertString; import static oap.testng.Asserts.contentOfTestResource; import static oap.util.Pair.__; -import static org.assertj.core.api.Assertions.assertThat; public class JsonAsserts { @Deprecated @@ -190,13 +189,13 @@ public JsonAssertion isStructurallyEqualToResource( Class contextClass, Strin } private JsonAssertion isEqualCanonically( Class clazz, String actual, String expected ) { - assertThat( json.canonicalizeWithDefaultPrettyPrinter( clazz, actual ) ) + assertString( json.canonicalizeWithDefaultPrettyPrinter( clazz, actual ) ) .isEqualTo( json.canonicalizeWithDefaultPrettyPrinter( clazz, expected ) ); return this; } private JsonAssertion isEqualCanonically( TypeRef typeRef, String actual, String expected ) { - assertThat( json.canonicalizeWithDefaultPrettyPrinter( typeRef, actual ) ) + assertString( json.canonicalizeWithDefaultPrettyPrinter( typeRef, actual ) ) .isEqualTo( json.canonicalizeWithDefaultPrettyPrinter( typeRef, expected ) ); return this; } From a06aff9194e274d467a1722f6efac941201abe8c Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Wed, 21 Jan 2026 08:26:12 +0200 Subject: [PATCH 12/36] CE-132 oap-sso: user: replace PK: email -> id --- .../main/java/oap/http/test/HttpAsserts.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 77bf8be8de..6e02364262 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -64,7 +64,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import java.util.regex.Pattern; @@ -81,25 +80,20 @@ @Slf4j @SuppressWarnings( "unused" ) public class HttpAsserts { - public static final ConcurrentHashMap> cookieStore = new ConcurrentHashMap<>(); - public static final OkHttpClient OK_HTTP_CLIENT; - private static final Client client = Client.custom() - .setMaxConnTotal( 100_000 ) - .setMaxConnPerRoute( 100_000 ) - .withCookieStore( new MockCookieStore() ) - .onError( ( c, e ) -> log.error( e.getMessage() ) ) - .build(); - private static JavaNetCookieJar cookieJar; + private static final JavaNetCookieJar cookieJar; + private static final CookieManager cookieManager; static { - CookieManager cookieManager = new CookieManager(); + cookieManager = new CookieManager(); cookieManager.setCookiePolicy( CookiePolicy.ACCEPT_ALL ); cookieJar = new JavaNetCookieJar( cookieManager ); OK_HTTP_CLIENT = new OkHttpClient.Builder() .cookieJar( cookieJar ) + .followRedirects( false ) + .followSslRedirects( false ) .build(); } @@ -112,7 +106,13 @@ public static String httpUrl( int port, String suffix ) { } public static void reset() { - client.reset(); + try { + OK_HTTP_CLIENT.cache().delete(); + OK_HTTP_CLIENT.connectionPool().evictAll(); + cookieManager.getCookieStore().removeAll(); + } catch( IOException e ) { + throw new UncheckedIOException( e ); + } } @SafeVarargs From 984d15444c2919b3db06d6b3640219d54cca2306 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Wed, 21 Jan 2026 08:43:43 +0200 Subject: [PATCH 13/36] CE-132 oap-sso: user: replace PK: email -> id --- .../oap-http-test/src/main/java/oap/http/test/HttpAsserts.java | 3 +++ oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 6e02364262..d017322d3a 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -38,6 +38,7 @@ import oap.util.Maps; import oap.util.Pair; import oap.util.Stream; +import okhttp3.Dispatcher; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.MediaType; @@ -64,6 +65,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.concurrent.Executors; import java.util.function.Consumer; import java.util.regex.Pattern; @@ -92,6 +94,7 @@ public class HttpAsserts { cookieJar = new JavaNetCookieJar( cookieManager ); OK_HTTP_CLIENT = new OkHttpClient.Builder() .cookieJar( cookieJar ) + .dispatcher( new Dispatcher( Executors.newVirtualThreadPerTaskExecutor() ) ) .followRedirects( false ) .followSslRedirects( false ) .build(); diff --git a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java index 3104d75aaf..caef53d5a3 100644 --- a/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java +++ b/oap-ws/oap-ws-test/src/test/java/oap/ws/WebServicesTest.java @@ -96,8 +96,6 @@ public void header() { @Test public void cookie() { - HttpAsserts.cookieStore.clear(); - assertGet( kernel.httpUrl( "/x/v/math/cookie" ), Map.of(), Map.of( "Cookie", "cookie=theCookie;Really-Cool-Cookie=ohoh" ) ) .responded( OK, "OK", APPLICATION_JSON, "\"theCookieohoh\"" ); } From 03055c69c5a8198afda9c91c23eaf7476c6ce955 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Wed, 21 Jan 2026 09:30:15 +0200 Subject: [PATCH 14/36] CE-132 oap-sso: user: replace PK: email -> id --- oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java index 55f3b314c1..be5a1098a7 100644 --- a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java +++ b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java @@ -76,6 +76,7 @@ public static Response authenticatedResponse( Authentication authentication, Str .withDomain( cookieDomain ) .withPath( "/" ) .withMaxAge( ( int ) accessTokenMaxAge ) + .withExpires( new DateTime( authentication.accessToken.expires ) ) .withHttpOnly( true ) .withSecure( cookieSecure ) .build() @@ -84,6 +85,7 @@ public static Response authenticatedResponse( Authentication authentication, Str .withDomain( cookieDomain ) .withPath( "/" ) .withMaxAge( ( int ) refreshTokenMaxAge ) + .withExpires( new DateTime( authentication.refreshToken.expires ) ) .withHttpOnly( true ) .withSecure( cookieSecure ) .build() From 9d4bc974d2b9729018c233daea700f31267bf68d Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Wed, 21 Jan 2026 09:52:12 +0200 Subject: [PATCH 15/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/http/test/HttpAsserts.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index d017322d3a..aca41a202c 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -109,13 +109,8 @@ public static String httpUrl( int port, String suffix ) { } public static void reset() { - try { - OK_HTTP_CLIENT.cache().delete(); - OK_HTTP_CLIENT.connectionPool().evictAll(); - cookieManager.getCookieStore().removeAll(); - } catch( IOException e ) { - throw new UncheckedIOException( e ); - } + OK_HTTP_CLIENT.connectionPool().evictAll(); + cookieManager.getCookieStore().removeAll(); } @SafeVarargs From c6d1736fe2ce788a7e2328be1cd598f2fffb3033 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Wed, 21 Jan 2026 09:53:01 +0200 Subject: [PATCH 16/36] CE-132 oap-sso: user: replace PK: email -> id --- oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java index be5a1098a7..55f3b314c1 100644 --- a/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java +++ b/oap-ws/oap-ws-sso-api/src/main/java/oap/ws/sso/SSO.java @@ -76,7 +76,6 @@ public static Response authenticatedResponse( Authentication authentication, Str .withDomain( cookieDomain ) .withPath( "/" ) .withMaxAge( ( int ) accessTokenMaxAge ) - .withExpires( new DateTime( authentication.accessToken.expires ) ) .withHttpOnly( true ) .withSecure( cookieSecure ) .build() @@ -85,7 +84,6 @@ public static Response authenticatedResponse( Authentication authentication, Str .withDomain( cookieDomain ) .withPath( "/" ) .withMaxAge( ( int ) refreshTokenMaxAge ) - .withExpires( new DateTime( authentication.refreshToken.expires ) ) .withHttpOnly( true ) .withSecure( cookieSecure ) .build() From eec09b6f74803ec61b01dcb4ec34af1f3661df98 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Wed, 21 Jan 2026 10:17:50 +0200 Subject: [PATCH 17/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/http/test/HttpAsserts.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index aca41a202c..dac5aaff73 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -503,6 +503,13 @@ public HttpAssertion containsCookie( String cookie ) { return containsCookie( Cookie.parseSetCookieHeader( cookie ) ); } + public CookieHttpAssertion cookie( String name ) { + Optional cookie = Stream.of( cookies() ).filter( c -> c.getName().equalsIgnoreCase( name ) ).findAny(); + + assertThat( cookie ).isPresent(); + return CookieHttpAssertion.assertCookie( cookie.get() ); + } + private List cookies() { return BiStream.of( response.headers ) .filter( ( name, value ) -> "Set-Cookie".equalsIgnoreCase( name ) ) From 7e687394f62990473036d3fb6f4114043404dc76 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Wed, 21 Jan 2026 11:03:05 +0200 Subject: [PATCH 18/36] CE-132 oap-sso: user: replace PK: email -> id --- .../main/java/oap/http/test/HttpAsserts.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index dac5aaff73..3a70733f80 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -485,7 +485,7 @@ public HttpAssertion containsHeader( String name, String value ) { } public HttpAssertion containsCookie( String name, Consumer assertion ) { - Optional cookie = Stream.of( cookies() ).filter( c -> c.getName().equalsIgnoreCase( name ) ).findAny(); + Optional cookie = Stream.of( getCookies() ).filter( c -> c.getName().equalsIgnoreCase( name ) ).findAny(); Assertions.assertThat( cookie ) .isNotEmpty() .withFailMessage( "no such cookie: " + name ) @@ -495,7 +495,7 @@ public HttpAssertion containsCookie( String name, Consumer assertion ) { } public HttpAssertion containsCookie( Cookie cookie ) { - Assertions.assertThat( cookies() ).contains( cookie ); + Assertions.assertThat( getCookies() ).contains( cookie ); return this; } @@ -504,13 +504,18 @@ public HttpAssertion containsCookie( String cookie ) { } public CookieHttpAssertion cookie( String name ) { - Optional cookie = Stream.of( cookies() ).filter( c -> c.getName().equalsIgnoreCase( name ) ).findAny(); + Optional cookie = Stream.of( getCookies() ).filter( c -> c.getName().equalsIgnoreCase( name ) ).findAny(); assertThat( cookie ).isPresent(); return CookieHttpAssertion.assertCookie( cookie.get() ); } - private List cookies() { + public HttpAssertion cookies( Consumer cons ) { + cons.accept( new CookiesHttpAssertion( getCookies() ) ); + return this; + } + + private List getCookies() { return BiStream.of( response.headers ) .filter( ( name, value ) -> "Set-Cookie".equalsIgnoreCase( name ) ) .mapToObj( ( name, value ) -> Cookie.parseSetCookieHeader( value ) ) @@ -576,6 +581,21 @@ public Asserts.StringAssertion body() { } } + public static final class CookiesHttpAssertion { + private final List cookies; + + public CookiesHttpAssertion( List cookies ) { + this.cookies = cookies; + } + + public CookieHttpAssertion cookie( String name ) { + Optional cookie = Stream.of( cookies ).filter( c -> c.getName().equalsIgnoreCase( name ) ).findAny(); + + assertThat( cookie ).isPresent(); + return CookieHttpAssertion.assertCookie( cookie.get() ); + } + } + public static final class CookieHttpAssertion { private final Cookie cookie; From fb98ddf9ae171a65b28f08ecac9918dea9b67997 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Wed, 21 Jan 2026 11:17:08 +0200 Subject: [PATCH 19/36] CE-132 oap-sso: user: replace PK: email -> id --- .../main/java/oap/http/test/HttpAsserts.java | 22 +++++++++---------- .../src/main/java/oap/http/Client.java | 14 +++++++----- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 3a70733f80..59bbb6b92b 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -35,6 +35,7 @@ import oap.json.testng.JsonAsserts; import oap.testng.Asserts; import oap.util.BiStream; +import oap.util.Lists; import oap.util.Maps; import oap.util.Pair; import oap.util.Stream; @@ -224,7 +225,9 @@ public static HttpAssertion assertPost( String uri, String content, String conte responseHeaders.toMultimap().forEach( ( k, vs ) -> vs.forEach( v -> headers.add( Pair.__( k, v ) ) ) ); byte[] bytes = body.bytes(); MediaType mediaType = body.contentType(); - return new HttpAssertion( new Client.Response( response.code(), response.message(), headers, mediaType != null ? mediaType.toString() : APPLICATION_OCTET_STREAM, new ByteArrayInputStream( bytes ) ) ); + return new HttpAssertion( new Client.Response( + response.request().url().toString(), + response.code(), response.message(), headers, mediaType != null ? mediaType.toString() : APPLICATION_OCTET_STREAM, new ByteArrayInputStream( bytes ) ) ); } } @@ -503,15 +506,12 @@ public HttpAssertion containsCookie( String cookie ) { return containsCookie( Cookie.parseSetCookieHeader( cookie ) ); } - public CookieHttpAssertion cookie( String name ) { - Optional cookie = Stream.of( getCookies() ).filter( c -> c.getName().equalsIgnoreCase( name ) ).findAny(); - - assertThat( cookie ).isPresent(); - return CookieHttpAssertion.assertCookie( cookie.get() ); - } - public HttpAssertion cookies( Consumer cons ) { - cons.accept( new CookiesHttpAssertion( getCookies() ) ); + HttpUrl httpUrl = HttpUrl.parse( response.url ); + assertThat( httpUrl ).isNotNull(); + List cookies = cookieJar.loadForRequest( httpUrl ); + + cons.accept( new CookiesHttpAssertion( cookies ) ); return this; } @@ -584,8 +584,8 @@ public Asserts.StringAssertion body() { public static final class CookiesHttpAssertion { private final List cookies; - public CookiesHttpAssertion( List cookies ) { - this.cookies = cookies; + public CookiesHttpAssertion( List cookies ) { + this.cookies = Lists.map( cookies, c -> Cookie.parseSetCookieHeader( c.toString() ) ); } public CookieHttpAssertion cookie( String name ) { diff --git a/oap-http/oap-http/src/main/java/oap/http/Client.java b/oap-http/oap-http/src/main/java/oap/http/Client.java index 5c327d904b..d6b85e0d16 100644 --- a/oap-http/oap-http/src/main/java/oap/http/Client.java +++ b/oap-http/oap-http/src/main/java/oap/http/Client.java @@ -441,17 +441,18 @@ private CompletableFuture execute( HttpUriRequest request, Map request.setHeader( name, value == null ? "" : value.toString() ) ); - var completableFuture = new CompletableFuture(); + CompletableFuture completableFuture = new CompletableFuture(); client.execute( request, new FutureCallback<>() { @Override public void completed( HttpResponse response ) { try { - var responseHeaders = headers( response ); + List> responseHeaders = headers( response ); Response result; if( response.getEntity() != null ) { var entity = response.getEntity(); result = new Response( + request.getURI().toString(), response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase(), responseHeaders, @@ -461,6 +462,7 @@ public void completed( HttpResponse response ) { entity.getContent() ); } else result = new Response( + request.getURI().toString(), response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase(), responseHeaders @@ -560,6 +562,7 @@ public void close() { @ToString( exclude = { "inputStream", "content" }, doNotUseGetters = true ) public static class Response implements Closeable, AutoCloseable { + public final String url; public final int code; public final String reasonPhrase; public final String contentType; @@ -567,7 +570,8 @@ public static class Response implements Closeable, AutoCloseable { private InputStream inputStream; private volatile byte[] content = null; - public Response( int code, String reasonPhrase, List> headers, @Nonnull String contentType, InputStream inputStream ) { + public Response( String url, int code, String reasonPhrase, List> headers, @Nonnull String contentType, InputStream inputStream ) { + this.url = url; this.code = code; this.reasonPhrase = reasonPhrase; this.headers = headers; @@ -575,8 +579,8 @@ public Response( int code, String reasonPhrase, List> heade this.inputStream = inputStream; } - public Response( int code, String reasonPhrase, List> headers ) { - this( code, reasonPhrase, headers, BiStream.of( headers ) + public Response( String url, int code, String reasonPhrase, List> headers ) { + this( url, code, reasonPhrase, headers, BiStream.of( headers ) .filter( ( name, value ) -> "Content-type".equalsIgnoreCase( name ) ) .mapToObj( ( name, value ) -> value ) .findAny() From e8753eebdef698d09e25081c1c79c675c93248f6 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Wed, 21 Jan 2026 11:48:49 +0200 Subject: [PATCH 20/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/http/test/HttpAsserts.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 59bbb6b92b..f557fb4353 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -62,6 +62,7 @@ import java.io.UncheckedIOException; import java.net.CookieManager; import java.net.CookiePolicy; +import java.net.HttpCookie; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -509,7 +510,7 @@ public HttpAssertion containsCookie( String cookie ) { public HttpAssertion cookies( Consumer cons ) { HttpUrl httpUrl = HttpUrl.parse( response.url ); assertThat( httpUrl ).isNotNull(); - List cookies = cookieJar.loadForRequest( httpUrl ); + List cookies = cookieManager.getCookieStore().get( httpUrl.uri() ); cons.accept( new CookiesHttpAssertion( cookies ) ); return this; @@ -584,7 +585,7 @@ public Asserts.StringAssertion body() { public static final class CookiesHttpAssertion { private final List cookies; - public CookiesHttpAssertion( List cookies ) { + public CookiesHttpAssertion( List cookies ) { this.cookies = Lists.map( cookies, c -> Cookie.parseSetCookieHeader( c.toString() ) ); } From 21c236a6db0a3232077b983659fb4316d6fe6a27 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Wed, 21 Jan 2026 12:23:12 +0200 Subject: [PATCH 21/36] CE-132 oap-sso: user: replace PK: email -> id --- .../main/java/oap/http/test/HttpAsserts.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index f557fb4353..00256e1d20 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -25,6 +25,7 @@ import com.google.common.base.Preconditions; import lombok.EqualsAndHashCode; +import lombok.SneakyThrows; import lombok.ToString; import lombok.extern.slf4j.Slf4j; import oap.http.Client; @@ -60,10 +61,12 @@ import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; +import java.lang.reflect.Field; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.HttpCookie; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Optional; @@ -89,6 +92,8 @@ public class HttpAsserts { private static final JavaNetCookieJar cookieJar; private static final CookieManager cookieManager; + private static Field whenCreatedField; + static { cookieManager = new CookieManager(); cookieManager.setCookiePolicy( CookiePolicy.ACCEPT_ALL ); @@ -100,6 +105,13 @@ public class HttpAsserts { .followRedirects( false ) .followSslRedirects( false ) .build(); + + try { + whenCreatedField = HttpCookie.class.getDeclaredField( "whenCreated" ); + whenCreatedField.setAccessible( true ); + } catch( NoSuchFieldException e ) { + throw new RuntimeException( e ); + } } public static String httpPrefix( int port ) { @@ -392,6 +404,11 @@ public static HttpAssertion assertDelete( String uri ) { return assertDelete( uri, Map.of() ); } + @SneakyThrows + private static long whenCreatedFieldGet( HttpCookie cookie ) { + return ( long ) whenCreatedField.get( cookie ); + } + @EqualsAndHashCode @ToString public static final class HttpAssertion { @@ -585,8 +602,19 @@ public Asserts.StringAssertion body() { public static final class CookiesHttpAssertion { private final List cookies; + @SneakyThrows public CookiesHttpAssertion( List cookies ) { - this.cookies = Lists.map( cookies, c -> Cookie.parseSetCookieHeader( c.toString() ) ); + this.cookies = Lists.map( cookies, c -> Cookie.builder( c.getName(), c.getValue() ) + .withPath( c.getPath() ) + .withDomain( c.getDomain() ) + .withMaxAge( c.getMaxAge() < 0 ? null : ( int ) c.getMaxAge() ) + .withExpires( c.getMaxAge() <= 0 ? null : new Date( ( whenCreatedFieldGet( c ) + c.getMaxAge() ) * 1000L ) ) + .withDiscard( c.getDiscard() ) + .withSecure( c.getSecure() ) + .withHttpOnly( c.isHttpOnly() ) + .withVersion( c.getVersion() ) + .withComment( c.getComment() ) + .build() ); } public CookieHttpAssertion cookie( String name ) { From 427bb902be98b41e9ebab4e1e5062ff3bc38f50c Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Wed, 21 Jan 2026 13:27:29 +0200 Subject: [PATCH 22/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/http/test/HttpAsserts.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 00256e1d20..9843ae301b 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -51,6 +51,7 @@ import okhttp3.ResponseBody; import okhttp3.java.net.cookiejar.JavaNetCookieJar; import org.apache.commons.lang3.StringUtils; +import org.assertj.core.api.AbstractIntegerAssert; import org.assertj.core.api.Assertions; import org.joda.time.DateTime; import org.jspecify.annotations.NonNull; @@ -665,6 +666,10 @@ public CookieHttpAssertion hasPath( String path ) { return this; } + public AbstractIntegerAssert maxAge() { + return assertThat( cookie.getMaxAge() ); + } + public CookieHttpAssertion hasNotMaxAge() { return hasMaxAge( -1 ); } From 1befcf589e0cadf5f242bc64463f3d556cb22d5a Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Fri, 23 Jan 2026 09:16:51 +0200 Subject: [PATCH 23/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/storage/mongo/MongoClient.java | 7 ++++--- .../src/main/resources/META-INF/oap-module.oap | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MongoClient.java b/oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MongoClient.java index 28d0b11e08..96a0c75517 100644 --- a/oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MongoClient.java +++ b/oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MongoClient.java @@ -42,6 +42,7 @@ import javax.annotation.Nonnull; import java.io.Closeable; import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -52,7 +53,7 @@ public class MongoClient implements Closeable { final com.mongodb.client.MongoClient mongoClient; private final MongoDatabase database; - private final String migrationPackage; + private final List migrationPackage; public boolean throwIfMigrationFailed = true; private ConnectionString connectionString; @@ -60,7 +61,7 @@ public MongoClient( String connectionString ) { this( connectionString, null ); } - public MongoClient( String connectionString, @Nonnull String migrationPackage ) { + public MongoClient( String connectionString, @Nonnull List migrationPackage ) { this.connectionString = new ConnectionString( connectionString ); this.migrationPackage = migrationPackage; @@ -114,7 +115,7 @@ public void preStart() { if( migrationPackage != null ) { MongockStandalone .builder() - .addMigrationScanPackage( migrationPackage ) + .addMigrationScanPackages( migrationPackage ) .setDriver( driver ) .buildRunner() .execute(); diff --git a/oap-storage/oap-storage-mongo/src/main/resources/META-INF/oap-module.oap b/oap-storage/oap-storage-mongo/src/main/resources/META-INF/oap-module.oap index 384a075f42..806b9c6abe 100644 --- a/oap-storage/oap-storage-mongo/src/main/resources/META-INF/oap-module.oap +++ b/oap-storage/oap-storage-mongo/src/main/resources/META-INF/oap-module.oap @@ -5,7 +5,7 @@ services { parameters { connectionString = "mongodb://:/" throwIfMigrationFailed = true -// migrationPackage = "my,migrations" +// migrationPackage = ["my.migrations"] // port = ... // host = ... // database = ... From c7897f835e977eba37cb7c9b803dd5a12b295813 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Fri, 23 Jan 2026 09:26:54 +0200 Subject: [PATCH 24/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/storage/mongo/MongoFixture.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java b/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java index 2ee96a7d05..b2ca3b893b 100644 --- a/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java +++ b/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java @@ -29,9 +29,11 @@ import de.bwaldvogel.mongo.backend.memory.MemoryBackend; import lombok.extern.slf4j.Slf4j; import oap.testng.AbstractFixture; +import oap.util.Lists; import org.bson.Document; import org.jetbrains.annotations.NotNull; +import java.util.List; import java.util.Map; import static oap.testng.Asserts.contentOfTestResource; @@ -81,8 +83,8 @@ public MongoClient createMongoClient() { } @NotNull - public MongoClient createMongoClient( String migrationPackage ) { - return new MongoClient( getConnectionString(), migrationPackage ); + public MongoClient createMongoClient( String migrationPackage, String... migrationPackages ) { + return new MongoClient( getConnectionString(), Lists.concat( List.of( migrationPackage ), List.of( migrationPackages ) ) ); } @NotNull From 904f8799d6b318a74f1a37aba7fb5ef5431cc926 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Fri, 23 Jan 2026 20:24:22 +0200 Subject: [PATCH 25/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/http/test/HttpAsserts.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 9843ae301b..3ba39e0ffd 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -54,10 +54,10 @@ import org.assertj.core.api.AbstractIntegerAssert; import org.assertj.core.api.Assertions; import org.joda.time.DateTime; -import org.jspecify.annotations.NonNull; -import org.jspecify.annotations.Nullable; import org.testng.internal.collections.Ints; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -230,7 +230,7 @@ public static HttpAssertion assertPost( String uri, String content, String conte return assertPost( uri, content, contentType, Maps.of() ); } - private static @NonNull HttpAssertion getResponseAsHttpAssertion( Request request ) throws IOException { + private static @Nonnull HttpAssertion getResponseAsHttpAssertion( Request request ) throws IOException { try( Response response = OK_HTTP_CLIENT.newCall( request ).execute(); ResponseBody body = response.body() ) { From 617f9b18388d4e80868fe9ba5cc6f8256846026b Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Fri, 23 Jan 2026 20:29:28 +0200 Subject: [PATCH 26/36] CE-132 oap-sso: user: replace PK: email -> id --- .../oap-http-test/src/main/java/oap/http/test/HttpAsserts.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 3ba39e0ffd..3c5fe3407e 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -237,7 +237,7 @@ public static HttpAssertion assertPost( String uri, String content, String conte Headers responseHeaders = response.headers(); ArrayList> headers = new ArrayList<>(); responseHeaders.toMultimap().forEach( ( k, vs ) -> vs.forEach( v -> headers.add( Pair.__( k, v ) ) ) ); - byte[] bytes = body.bytes(); + byte[] bytes = body.source().readByteArray(); MediaType mediaType = body.contentType(); return new HttpAssertion( new Client.Response( response.request().url().toString(), From 7b42c2a14b96451da807f75d45adfbe4b2ee44fd Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Sun, 25 Jan 2026 12:57:29 +0200 Subject: [PATCH 27/36] CE-132 oap-sso: user: replace PK: email -> id --- .../oap-http-test/src/main/java/oap/http/test/HttpAsserts.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java index 3c5fe3407e..3ba39e0ffd 100644 --- a/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java +++ b/oap-http/oap-http-test/src/main/java/oap/http/test/HttpAsserts.java @@ -237,7 +237,7 @@ public static HttpAssertion assertPost( String uri, String content, String conte Headers responseHeaders = response.headers(); ArrayList> headers = new ArrayList<>(); responseHeaders.toMultimap().forEach( ( k, vs ) -> vs.forEach( v -> headers.add( Pair.__( k, v ) ) ) ); - byte[] bytes = body.source().readByteArray(); + byte[] bytes = body.bytes(); MediaType mediaType = body.contentType(); return new HttpAssertion( new Client.Response( response.request().url().toString(), From 9e61243b320ff683b993217bcb7a632ae8f27bce Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Sun, 25 Jan 2026 13:37:16 +0200 Subject: [PATCH 28/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/http/pniov3/PnioResponseBuffer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oap-http/oap-pnio-v3/src/main/java/oap/http/pniov3/PnioResponseBuffer.java b/oap-http/oap-pnio-v3/src/main/java/oap/http/pniov3/PnioResponseBuffer.java index a3fff4745e..70fcce931a 100644 --- a/oap-http/oap-pnio-v3/src/main/java/oap/http/pniov3/PnioResponseBuffer.java +++ b/oap-http/oap-pnio-v3/src/main/java/oap/http/pniov3/PnioResponseBuffer.java @@ -34,7 +34,7 @@ @NotThreadSafe public class PnioResponseBuffer { public int length; - byte[] buffer; + public byte[] buffer; public PnioResponseBuffer( int capacity ) { this.buffer = new byte[capacity]; @@ -42,7 +42,7 @@ public PnioResponseBuffer( int capacity ) { } public String string() { - return new String( buffer, 0, length ); + return new String( buffer, 0, length, UTF_8 ); } public boolean isEmpty() { From 4781094ecd76d679751dc02bbb418cb8aa9c7854 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Sun, 25 Jan 2026 13:38:35 +0200 Subject: [PATCH 29/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/http/pniov3/PnioResponseBuffer.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/oap-http/oap-pnio-v3/src/main/java/oap/http/pniov3/PnioResponseBuffer.java b/oap-http/oap-pnio-v3/src/main/java/oap/http/pniov3/PnioResponseBuffer.java index 70fcce931a..c7aa99907d 100644 --- a/oap-http/oap-pnio-v3/src/main/java/oap/http/pniov3/PnioResponseBuffer.java +++ b/oap-http/oap-pnio-v3/src/main/java/oap/http/pniov3/PnioResponseBuffer.java @@ -28,6 +28,7 @@ import javax.annotation.concurrent.NotThreadSafe; import java.io.OutputStream; +import java.nio.ByteBuffer; import static java.nio.charset.StandardCharsets.UTF_8; @@ -45,6 +46,10 @@ public String string() { return new String( buffer, 0, length, UTF_8 ); } + public ByteBuffer byteBuffer() { + return ByteBuffer.wrap( buffer, 0, length ); + } + public boolean isEmpty() { return length == 0; } From 9f54075219c82529b5a9ddc198d69c546f344713 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Mon, 26 Jan 2026 15:54:41 +0200 Subject: [PATCH 30/36] CE-132 oap-sso: user: replace PK: email -> id --- oap-storage/oap-storage-mongo/pom.xml | 7 +++++ .../oap/storage/mongo/MigrationUtils.java | 27 ++++++++++++++++ .../oap/storage/mongo/MigrationUtilsTest.java | 31 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MigrationUtils.java create mode 100644 oap-storage/oap-storage-mongo/src/test/java/oap/storage/mongo/MigrationUtilsTest.java diff --git a/oap-storage/oap-storage-mongo/pom.xml b/oap-storage/oap-storage-mongo/pom.xml index d5dacf58bc..ec688c0e97 100644 --- a/oap-storage/oap-storage-mongo/pom.xml +++ b/oap-storage/oap-storage-mongo/pom.xml @@ -77,6 +77,13 @@ ${oap.deps.mongock.version} + + oap + oap-stdlib-test + ${project.version} + test + + org.projectlombok lombok diff --git a/oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MigrationUtils.java b/oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MigrationUtils.java new file mode 100644 index 0000000000..2596ff9b6b --- /dev/null +++ b/oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MigrationUtils.java @@ -0,0 +1,27 @@ +package oap.storage.mongo; + +import org.apache.commons.lang3.StringUtils; +import org.bson.Document; + +public class MigrationUtils { + public static String getString( Document document, String key ) { + String[] keys = StringUtils.split( key, "." ); + + Document current = document; + Object lastValue = null; + + for( String field : keys ) { + if( lastValue != null ) { + if( lastValue instanceof Document doc ) { + current = doc; + } else { + return null; + } + } + + lastValue = current.get( field ); + } + + return ( String ) lastValue; + } +} diff --git a/oap-storage/oap-storage-mongo/src/test/java/oap/storage/mongo/MigrationUtilsTest.java b/oap-storage/oap-storage-mongo/src/test/java/oap/storage/mongo/MigrationUtilsTest.java new file mode 100644 index 0000000000..64e23815ee --- /dev/null +++ b/oap-storage/oap-storage-mongo/src/test/java/oap/storage/mongo/MigrationUtilsTest.java @@ -0,0 +1,31 @@ +package oap.storage.mongo; + +import org.bson.Document; +import org.testng.annotations.Test; + +import static oap.testng.Asserts.assertString; + +public class MigrationUtilsTest { + @Test + public void testGetString() { + Document document = Document.parse( """ + { + a: "123", + b: { + ba: "12", + bb: { + bbv: "123+" + } + } + } + """ ); + + + assertString( MigrationUtils.getString( document, "a" ) ).isEqualTo( "123" ); + assertString( MigrationUtils.getString( document, "unknown" ) ).isNull(); + assertString( MigrationUtils.getString( document, "a.b.c" ) ).isNull(); + assertString( MigrationUtils.getString( document, "b.bb.bbv" ) ).isEqualTo( "123+" ); + assertString( MigrationUtils.getString( document, "b.bb.unk" ) ).isNull(); + assertString( MigrationUtils.getString( document, "b.unk.unk" ) ).isNull(); + } +} From cae2de7843dc47ec759cf65cdcbd427781946472 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Thu, 29 Jan 2026 14:25:01 +0200 Subject: [PATCH 31/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/storage/mongo/MongoFixture.java | 2 +- .../src/main/java/oap/storage/mongo/MongoClient.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java b/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java index b2ca3b893b..a737690f66 100644 --- a/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java +++ b/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java @@ -99,7 +99,7 @@ public String getConnectionString( String database ) { @NotNull protected MongoServer createMongoServer() { - return new MongoServer( new MemoryBackend().version( ServerVersion.MONGO_4_0 ) ); + return new MongoServer( new MemoryBackend().version( ServerVersion.MONGO_5_0 ) ); } @Override diff --git a/oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MongoClient.java b/oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MongoClient.java index 96a0c75517..b18e127286 100644 --- a/oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MongoClient.java +++ b/oap-storage/oap-storage-mongo/src/main/java/oap/storage/mongo/MongoClient.java @@ -71,8 +71,7 @@ public MongoClient( String connectionString, @Nonnull List migrationPack .applyConnectionString( this.connectionString ); this.mongoClient = MongoClients.create( settingsBuilder.build() ); this.database = mongoClient.getDatabase( this.connectionString.getDatabase() ); - log.debug( "creating connectionString {} migrationPackage {}", - this.connectionString, migrationPackage ); + log.debug( "creating connectionString {} migrationPackage {}", this.connectionString, migrationPackage ); } private MongoClientSettings.Builder defaultBuilder() { From 63391db4282df1a19ec547dccfce55eedf071e61 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Thu, 29 Jan 2026 14:26:35 +0200 Subject: [PATCH 32/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/storage/mongo/MongoFixture.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java b/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java index a737690f66..b7f2b2a60c 100644 --- a/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java +++ b/oap-storage/oap-storage-mongo-test/src/main/java/oap/storage/mongo/MongoFixture.java @@ -33,6 +33,7 @@ import org.bson.Document; import org.jetbrains.annotations.NotNull; +import java.net.InetSocketAddress; import java.util.List; import java.util.Map; @@ -73,7 +74,7 @@ protected void before() { this.server = createMongoServer(); log.info( "mongo port = {}", port ); - this.server.bind( HOST, port ); + this.server.bind( new InetSocketAddress( port ) ); this.mongoClient = createMongoClient(); } From f16ccdaa56299f725448c8edbe8084f02dbeffaa Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Thu, 29 Jan 2026 15:10:39 +0200 Subject: [PATCH 33/36] CE-132 oap-sso: user: replace PK: email -> id --- oap-storage/oap-storage-mongo/pom.xml | 5 +++++ oap-storage/pom.xml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/oap-storage/oap-storage-mongo/pom.xml b/oap-storage/oap-storage-mongo/pom.xml index ec688c0e97..6effa36cfb 100644 --- a/oap-storage/oap-storage-mongo/pom.xml +++ b/oap-storage/oap-storage-mongo/pom.xml @@ -61,6 +61,11 @@ netty-common ${oap.deps.netty.version} + + io.netty + netty-transport + ${oap.deps.netty.version} + io.netty netty-buffer diff --git a/oap-storage/pom.xml b/oap-storage/pom.xml index 14590617a2..f300e1e05f 100644 --- a/oap-storage/pom.xml +++ b/oap-storage/pom.xml @@ -13,7 +13,7 @@ 5.4.0 - 4.2.4.Final + 4.2.9.Final 5.5.1 2.23.17 From 6d813c4bae98303f9553405e72d72dfd0bb41a16 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Thu, 29 Jan 2026 16:13:58 +0200 Subject: [PATCH 34/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/application/ModuleHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/oap-application/oap-application/src/main/java/oap/application/ModuleHelper.java b/oap-application/oap-application/src/main/java/oap/application/ModuleHelper.java index 0a955e4674..00bd5c200d 100644 --- a/oap-application/oap-application/src/main/java/oap/application/ModuleHelper.java +++ b/oap-application/oap-application/src/main/java/oap/application/ModuleHelper.java @@ -286,6 +286,7 @@ private static void loadOnlyMainModuleAndDependsOn( ModuleItemTree modules, modules.remove( module ); + log.debug( "[loadOnlyMainModuleAndDependsOn] module {} -> dependsOn {}", moduleItem.getName(), moduleItem.module.dependsOn ); loadOnlyMainModuleAndDependsOn( modules, moduleItem.module.dependsOn, loaded ); } } From c1763334e19288b3da2fe9699334dce39b7701f5 Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Thu, 29 Jan 2026 16:35:15 +0200 Subject: [PATCH 35/36] CE-132 oap-sso: user: replace PK: email -> id --- .../src/main/java/oap/application/ModuleHelper.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/oap-application/oap-application/src/main/java/oap/application/ModuleHelper.java b/oap-application/oap-application/src/main/java/oap/application/ModuleHelper.java index 00bd5c200d..3463018f78 100644 --- a/oap-application/oap-application/src/main/java/oap/application/ModuleHelper.java +++ b/oap-application/oap-application/src/main/java/oap/application/ModuleHelper.java @@ -286,8 +286,10 @@ private static void loadOnlyMainModuleAndDependsOn( ModuleItemTree modules, modules.remove( module ); - log.debug( "[loadOnlyMainModuleAndDependsOn] module {} -> dependsOn {}", moduleItem.getName(), moduleItem.module.dependsOn ); - loadOnlyMainModuleAndDependsOn( modules, moduleItem.module.dependsOn, loaded ); + if( !moduleItem.module.dependsOn.isEmpty() ) { + log.debug( "[loadOnlyMainModuleAndDependsOn] module {} -> dependsOn {}", moduleItem.getName(), moduleItem.module.dependsOn ); + loadOnlyMainModuleAndDependsOn( modules, moduleItem.module.dependsOn, loaded ); + } } } } From 0e8d1ff434642c5a157f39849018b5327118de6c Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Thu, 29 Jan 2026 20:00:15 +0200 Subject: [PATCH 36/36] CE-132 oap-sso: user: replace PK: email -> id --- oap-stdlib/pom.xml | 21 +++++++++++++++++++++ oap-storage/oap-storage-mongo/pom.xml | 15 --------------- oap-storage/pom.xml | 1 - pom.xml | 2 ++ 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/oap-stdlib/pom.xml b/oap-stdlib/pom.xml index bd56aee4ea..833d605823 100644 --- a/oap-stdlib/pom.xml +++ b/oap-stdlib/pom.xml @@ -305,5 +305,26 @@ spotbugs-annotations ${oap.deps.spotbugs} + + + io.netty + netty-common + ${oap.deps.netty.version} + + + io.netty + netty-transport + ${oap.deps.netty.version} + + + io.netty + netty-buffer + ${oap.deps.netty.version} + + + io.netty + netty-handler + ${oap.deps.netty.version} + diff --git a/oap-storage/oap-storage-mongo/pom.xml b/oap-storage/oap-storage-mongo/pom.xml index 6effa36cfb..d6ddb34e46 100644 --- a/oap-storage/oap-storage-mongo/pom.xml +++ b/oap-storage/oap-storage-mongo/pom.xml @@ -56,21 +56,6 @@ org.apache.commons commons-exec - - io.netty - netty-common - ${oap.deps.netty.version} - - - io.netty - netty-transport - ${oap.deps.netty.version} - - - io.netty - netty-buffer - ${oap.deps.netty.version} - io.mongock mongock-standalone diff --git a/oap-storage/pom.xml b/oap-storage/pom.xml index f300e1e05f..0775a2896c 100644 --- a/oap-storage/pom.xml +++ b/oap-storage/pom.xml @@ -13,7 +13,6 @@ 5.4.0 - 4.2.9.Final 5.5.1 2.23.17 diff --git a/pom.xml b/pom.xml index c52bbb0561..3423477e0b 100644 --- a/pom.xml +++ b/pom.xml @@ -124,5 +124,7 @@ 4.9.8 + + 4.2.9.Final