diff --git a/build.yaml b/build.yaml index ff44517c4..d26855e5d 100644 --- a/build.yaml +++ b/build.yaml @@ -1,12 +1,18 @@ projectType: extension -mavenTool: "3.9.5" +mavenTool: "3.9.9" mavenAdditionalArgs: -pl .,mule-http-connector additionalTestConfigs: - functionalTests: + functionalTestsGrizzly: jdkTool: OPEN-JDK17 mavenAdditionalArgs: -pl functional-tests,functional-tests/http,functional-tests/cors -Drevapi.skip -DexportedPackagesValidator.skip -Dmaven.javadoc.skip=true -Dmule.jvm.version.extension.enforcement=LOOSE -Dmule.module.tweaking.validation.skip=true - munitTests: + munitTestsGrizzly: testJdkTool: OPEN-JDK17 mavenAdditionalArgs: -pl mule-http-connector -DmunitMinMuleVersion=4.6.0 -Drevapi.skip -DexportedPackagesValidator.skip -Dmaven.javadoc.skip=true -Dmule.jvm.version.extension.enforcement=LOOSE -Dmule.module.tweaking.validation.skip=true + functionalTestsNetty: + jdkTool: OPEN-JDK17 + mavenAdditionalArgs: -pl functional-tests,functional-tests/http,functional-tests/cors -Drevapi.skip -DexportedPackagesValidator.skip -Dmaven.javadoc.skip=true -Dmule.jvm.version.extension.enforcement=LOOSE -Dmule.module.tweaking.validation.skip=true -Dmule.http.service.implementation=NETTY + munitTestsNetty: + testJdkTool: OPEN-JDK17 + mavenAdditionalArgs: -pl mule-http-connector -DmunitMinMuleVersion=4.10.0-SNAPSHOT -Drevapi.skip -DexportedPackagesValidator.skip -Dmaven.javadoc.skip=true -Dmule.jvm.version.extension.enforcement=LOOSE -Dmule.module.tweaking.validation.skip=true -Dmule.http.service.implementation=NETTY diff --git a/functional-tests/cors/pom.xml b/functional-tests/cors/pom.xml index c0c5d4322..8e5705212 100644 --- a/functional-tests/cors/pom.xml +++ b/functional-tests/cors/pom.xml @@ -106,7 +106,7 @@ org.mule.runtime mule-dwb-api - 2.9.0-20241028 + 2.10.0-SNAPSHOT provided @@ -126,4 +126,4 @@ - \ No newline at end of file + diff --git a/functional-tests/http/pom.xml b/functional-tests/http/pom.xml index 1f478050f..dbdbdf45c 100644 --- a/functional-tests/http/pom.xml +++ b/functional-tests/http/pom.xml @@ -249,12 +249,6 @@ ${mule.version} provided - - org.mule.runtime - mule-module-javaee - ${mule.version} - provided - @@ -273,7 +267,7 @@ org.mule.runtime mule-dwb-api - 2.9.0-20241028 + 2.10.0-SNAPSHOT provided diff --git a/functional-tests/http/src/test/java/org/mule/test/http/functional/AbstractHttpTestCase.java b/functional-tests/http/src/test/java/org/mule/test/http/functional/AbstractHttpTestCase.java index 2500189f6..76dcaf0c6 100644 --- a/functional-tests/http/src/test/java/org/mule/test/http/functional/AbstractHttpTestCase.java +++ b/functional-tests/http/src/test/java/org/mule/test/http/functional/AbstractHttpTestCase.java @@ -52,8 +52,11 @@ public abstract class AbstractHttpTestCase extends MuleArtifactFunctionalTestCas protected static final String J17_SSL_ERROR_RESPONSE = "PKIX path validation failed"; // Expected validation messages for certificates when testing fips. public static final String BOUNCY_CASTLE_CERTIFICATE_UNKNOWN_ERROR_MESSAGE = "certificate_unknown"; + // Expected validation error message when using Netty. + protected static final String NETTY_SSL_ERROR_RESPONSE = "Received fatal alert: handshake_failure"; protected static final String APPROPRIATE_PROTOCOL_ERROR = "No appropriate protocol (protocol is disabled or cipher suites are inappropriate)"; + protected static final String NETTY_APPROPRIATE_PROTOCOL_ERROR = "Received fatal alert: protocol_version"; @Rule public TestHttpClient httpClient = new TestHttpClient.Builder(getService(HttpService.class)).build(); @@ -83,6 +86,8 @@ protected Matcher sslValidationError() { containsString(J8_275_SSL_ERROR_RESPONSE), containsString(J11_SSL_ERROR_RESPONSE), containsString(J17_SSL_ERROR_RESPONSE), - containsString(APPROPRIATE_PROTOCOL_ERROR))); + containsString(NETTY_SSL_ERROR_RESPONSE), + containsString(APPROPRIATE_PROTOCOL_ERROR), + containsString(NETTY_APPROPRIATE_PROTOCOL_ERROR))); } } diff --git a/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerConfigFunctionalTestCase.java b/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerConfigFunctionalTestCase.java index cf2ab31c4..97c761b08 100644 --- a/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerConfigFunctionalTestCase.java +++ b/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerConfigFunctionalTestCase.java @@ -23,6 +23,7 @@ import org.mule.runtime.http.api.HttpConstants.HttpStatus; import org.mule.runtime.http.api.domain.entity.ByteArrayHttpEntity; import org.mule.runtime.http.api.domain.message.request.HttpRequest; +import org.mule.service.http.netty.impl.provider.NettyHttpServiceProvider; import org.mule.tck.junit4.rule.DynamicPort; import org.mule.tck.junit4.rule.SystemProperty; import org.mule.test.http.functional.AbstractHttpTestCase; @@ -113,8 +114,18 @@ public void noListenerConfigWithSpecialCharacters() throws Exception { SocketRequester socketRequester = new SocketRequester("localhost", noListenerConfigPort.getNumber()); socketRequester.initialize(); socketRequester.doRequest("GET " + invalidPathWithSpecialCharacters + " HTTP/1.1"); - assertThat(socketRequester.getResponse(), - containsString(format(NO_LISTENER_ENTITY_FORMAT, escapeHtml4(invalidPathWithSpecialCharacters)))); + + String errorMessage; + if (System.getProperty("mule.http.service.implementation", "GRIZZLY").equals("GRIZZLY")) { + errorMessage = format(NO_LISTENER_ENTITY_FORMAT, escapeHtml4(invalidPathWithSpecialCharacters)); + } else { + String url = format("http://127.0.0.1:%d%s", noListenerConfigPort.getNumber(), invalidPathWithSpecialCharacters); + int indexOfLT = url.indexOf('<'); + errorMessage = + format("HTTP request parsing failed with error: \"Illegal character in path at index %d: %s\"", indexOfLT, url); + } + + assertThat(socketRequester.getResponse(), containsString(errorMessage)); socketRequester.finalizeGracefully(); } diff --git a/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerPersistentConnectionsTestCase.java b/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerPersistentConnectionsTestCase.java index 3d6ab595f..b09956bf2 100644 --- a/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerPersistentConnectionsTestCase.java +++ b/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerPersistentConnectionsTestCase.java @@ -6,10 +6,14 @@ */ package org.mule.test.http.functional.listener; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.mule.runtime.http.api.HttpHeaders.Names.CONNECTION; import static org.mule.runtime.http.api.HttpHeaders.Values.KEEP_ALIVE; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.emptyOrNullString; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + import org.mule.runtime.core.api.util.StringUtils; import org.mule.tck.junit4.rule.DynamicPort; import org.mule.test.http.functional.AbstractHttpTestCase; @@ -122,7 +126,11 @@ private HttpResponse doPerformRequest(int port, HttpVersion httpVersion, boolean } private void assertResponse(String response, boolean shouldBeValid) { - assertThat(StringUtils.isEmpty(response), is(!shouldBeValid)); + if (shouldBeValid) { + assertThat(response, not(emptyOrNullString())); + } else { + assertThat(response, emptyOrNullString()); + } } private void sendRequest(Socket socket, HttpVersion httpVersion) throws IOException { diff --git a/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerResponseBuildersTestCase.java b/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerResponseBuildersTestCase.java index 8e4b89669..dc18261b5 100644 --- a/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerResponseBuildersTestCase.java +++ b/functional-tests/http/src/test/java/org/mule/test/http/functional/listener/HttpListenerResponseBuildersTestCase.java @@ -206,7 +206,6 @@ private HttpResponse statusLineResponseBuilderTest(String url, int expectedStatu throws IOException { final Response response = Request.Get(url).connectTimeout(DEFAULT_TIMEOUT).execute(); final HttpResponse httpResponse = response.returnResponse(); - assertThat(httpResponse.getAllHeaders().length, is(greaterThanOrEqualTo((2)))); assertThat(httpResponse.getStatusLine().getStatusCode(), is(expectedStatus)); assertThat(httpResponse.getStatusLine().getReasonPhrase(), is(expectedReasonPhrase)); return httpResponse; diff --git a/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestErrorHandlingTestCase.java b/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestErrorHandlingTestCase.java index bc0aac662..346a7c8c9 100644 --- a/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestErrorHandlingTestCase.java +++ b/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestErrorHandlingTestCase.java @@ -32,9 +32,10 @@ import static java.lang.String.format; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import org.mule.extension.http.api.HttpResponseAttributes; import org.mule.extension.http.api.error.HttpError; @@ -53,7 +54,6 @@ import io.qameta.allure.Issue; import io.qameta.allure.Stories; import io.qameta.allure.Story; -import org.apache.commons.lang3.SystemUtils; import org.junit.Rule; import org.junit.Test; @@ -157,17 +157,10 @@ public void timeout() throws Exception { @Test public void connectivity() throws Exception { - - String customMessage = ": Connection refused"; - if (SystemUtils.IS_OS_WINDOWS) { - customMessage = customMessage.concat(": no further information"); - } - CoreEvent result = getFlowRunner("handled", unusedPort.getNumber()).run(); - assertThat(result.getMessage(), - hasPayload(equalTo(getErrorMessage(customMessage, unusedPort) - + " connectivity"))); + // The exact message depends on the OS and the underlying framework, but all contain "Connection refused". + assertThat(result.getMessage(), hasPayload(containsString("Connection refused"))); } @Test diff --git a/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestExceptionMessagesTestCase.java b/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestExceptionMessagesTestCase.java index ab4f27d6d..c48253cc3 100644 --- a/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestExceptionMessagesTestCase.java +++ b/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestExceptionMessagesTestCase.java @@ -37,10 +37,13 @@ public void errorMessageIsLoadedFromCauseIfNull() throws Exception { String msg = exception.getMessage(); assertThat(msg, containsString("HTTP GET on resource 'http://notarealsite.mulesoft:124/fakeresource'")); - // Using runtime version 4.1.1, the message contains the name of the exception: "UnresolvedAddressException" - // Using latest, the message is "Couldn't resolve address" + // Using latest grizzly, the message is "Couldn't resolve address" + // Using latest Netty, the message is "nodename nor servname provided, or not known" + // Using Reactor Netty, the message is "Failed to resolve..." assertThat(msg, anyOf(containsString("UnresolvedAddressException"), - containsString("Couldn't resolve address"))); + containsString("Couldn't resolve address"), + containsString("nodename nor servname provided, or not known"), + containsString("Failed to resolve"))); } } diff --git a/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestExpectHeaderFailTestCase.java b/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestExpectHeaderFailTestCase.java index 6631ae4d9..ee2f6cf5e 100644 --- a/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestExpectHeaderFailTestCase.java +++ b/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/HttpRequestExpectHeaderFailTestCase.java @@ -8,7 +8,11 @@ import static org.mule.runtime.http.api.HttpConstants.HttpStatus.EXPECTATION_FAILED; -import static org.junit.Assert.assertThat; +import static java.lang.System.getProperty; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.junit.Assume.assumeThat; import org.mule.extension.http.api.HttpResponseAttributes; import org.mule.runtime.core.api.event.CoreEvent; @@ -31,6 +35,9 @@ protected String getConfigFile() { @Test public void handlesExpectationFailedResponse() throws Exception { + // TODO (W-15666548): Enable this for NETTY too. + assumeThat(getProperty("mule.http.service.implementation", "GRIZZLY"), is("GRIZZLY")); + startExpectFailedServer(); // Set a payload that will fail when consumed. As the server rejects the request after processing @@ -48,5 +55,4 @@ public int read() throws IOException { stopServer(); } - } diff --git a/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/ntlm/NtlmProxyTestAuthorizer.java b/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/ntlm/NtlmProxyTestAuthorizer.java index 484376128..081e5f7b7 100644 --- a/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/ntlm/NtlmProxyTestAuthorizer.java +++ b/functional-tests/http/src/test/java/org/mule/test/http/functional/requester/ntlm/NtlmProxyTestAuthorizer.java @@ -13,11 +13,10 @@ * LICENSE.txt file. */ -import static org.mule.runtime.core.api.util.NetworkUtils.getLocalHost; - import static javax.servlet.http.HttpServletResponse.SC_OK; import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED; +import org.mule.runtime.core.api.util.Base64; import org.mule.test.http.functional.requester.TestAuthorizer; import java.io.IOException; @@ -25,13 +24,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.ning.http.client.ntlm.NTLMEngine; - public class NtlmProxyTestAuthorizer implements TestAuthorizer { private static final String TYPE_2_MESSAGE_CHALLENGE = "TlRMTVNTUAACAAAAAAAAACgAAAABggAAU3J2Tm9uY2UAAAAAAAAAAA=="; private static final String TYPE_2_MESSAGE = "NTLM " + TYPE_2_MESSAGE_CHALLENGE; - private static final String TYPE_1_MESSAGE = "NTLM TlRMTVNTUAABAAAAAYIIogAAAAAoAAAAAAAAACgAAAAFASgKAAAADw=="; private static final String AUTHORIZED = "Authorized"; private String clientAuthHeader; @@ -42,8 +38,6 @@ public class NtlmProxyTestAuthorizer implements TestAuthorizer { private String domain; private String workstation; - private String type3Message; - public NtlmProxyTestAuthorizer(String clientAuthHeader, String serverAuthHeader, int unauthorizedHeader, String user, String password, String domain, String workstation) { @@ -56,12 +50,6 @@ public NtlmProxyTestAuthorizer(String clientAuthHeader, String serverAuthHeader, this.workstation = workstation; } - public void setUp() throws Exception { - String ntlmHost = workstation != null ? workstation : getLocalHost().getHostName(); - String type3Challenge = NTLMEngine.INSTANCE.generateType3Msg(user, password, domain, ntlmHost, TYPE_2_MESSAGE_CHALLENGE); - type3Message = "NTLM " + type3Challenge; - } - @Override public boolean authorizeRequest(String address, HttpServletRequest request, HttpServletResponse response, boolean addAuthorizeMessageInProxy) @@ -72,11 +60,11 @@ public boolean authorizeRequest(String address, HttpServletRequest request, Http response.addHeader(serverAuthHeader, "NTLM"); return false; } - if (TYPE_1_MESSAGE.equals(auth)) { + if (isNtlmTypeN(auth, 1)) { response.setStatus(unauthorizedHeader); response.setHeader(serverAuthHeader, TYPE_2_MESSAGE); return false; - } else if (type3Message.equals(auth)) { + } else if (isNtlmTypeN(auth, 3)) { response.setStatus(SC_OK); if (addAuthorizeMessageInProxy) { response.getWriter().print(AUTHORIZED); @@ -88,6 +76,17 @@ public boolean authorizeRequest(String address, HttpServletRequest request, Http } } + private static boolean isNtlmTypeN(String header, int n) { + if (!header.startsWith("NTLM ")) { + return false; + } + + String base64 = header.substring(5); + byte[] asByteArray = Base64.decode(base64); + byte type = asByteArray[8]; + return type == n; + } + public static class Builder { private String clientAuthHeader; @@ -134,11 +133,8 @@ public Builder setWorkstation(String workstation) { } public NtlmProxyTestAuthorizer build() throws Exception { - NtlmProxyTestAuthorizer testAuthorizer = new NtlmProxyTestAuthorizer(clientAuthHeader, serverAuthHeader, unauthorizedHeader, - user, password, domain, workstation); - testAuthorizer.setUp(); - - return testAuthorizer; + return new NtlmProxyTestAuthorizer(clientAuthHeader, serverAuthHeader, unauthorizedHeader, user, password, domain, + workstation); } } } diff --git a/functional-tests/http/src/test/java/org/mule/test/http/functional/tls/HttpTlsContextClient12ToServer13TestCase.java b/functional-tests/http/src/test/java/org/mule/test/http/functional/tls/HttpTlsContextClient12ToServer13TestCase.java index eac39c02b..7a35460d9 100644 --- a/functional-tests/http/src/test/java/org/mule/test/http/functional/tls/HttpTlsContextClient12ToServer13TestCase.java +++ b/functional-tests/http/src/test/java/org/mule/test/http/functional/tls/HttpTlsContextClient12ToServer13TestCase.java @@ -12,6 +12,7 @@ import static java.lang.System.getProperty; import static org.apache.commons.lang3.SystemUtils.isJavaVersionAtLeast; +import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assume.assumeTrue; @@ -80,7 +81,9 @@ public static void assumeJdkIsCompatible() { @Test public void testClient12ToServer13() throws Exception { expectedError.expectErrorType("HTTP", "CONNECTIVITY"); - expectedError.expectMessage(containsString(ERROR_RESPONSE)); + expectedError.expectMessage(anyOf( + containsString(ERROR_RESPONSE), + containsString("Received fatal alert: protocol_version"))); flowRunner(client12).run(); } diff --git a/functional-tests/http/src/test/resources/log4j2.xml b/functional-tests/http/src/test/resources/log4j2-test.xml similarity index 91% rename from functional-tests/http/src/test/resources/log4j2.xml rename to functional-tests/http/src/test/resources/log4j2-test.xml index f76a34117..04060218c 100644 --- a/functional-tests/http/src/test/resources/log4j2.xml +++ b/functional-tests/http/src/test/resources/log4j2-test.xml @@ -11,7 +11,8 @@ - + + diff --git a/functional-tests/pom.xml b/functional-tests/pom.xml index a8f1e32f6..7ca271ae1 100644 --- a/functional-tests/pom.xml +++ b/functional-tests/pom.xml @@ -61,9 +61,9 @@ 3.5.2 1.x-SNAPSHOT - 4.9.0-SNAPSHOT + 4.10.0-SNAPSHOT ${mule.version} - 1.9.0-SNAPSHOT + 1.10.0-SNAPSHOT ${project.version} @@ -96,7 +96,7 @@ org.mule.runtime mule-dwb-api - 2.9.0-20241028 + 2.10.0-SNAPSHOT diff --git a/mule-http-connector/pom.xml b/mule-http-connector/pom.xml index 94526a8f1..9405c6762 100644 --- a/mule-http-connector/pom.xml +++ b/mule-http-connector/pom.xml @@ -228,7 +228,7 @@ pom import - + org.springframework @@ -415,6 +415,12 @@ ${bctls-fips.version} test + + com.google.guava + failureaccess + 1.0.2 + test +