Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
*/
package com.marklogic.client.test.junit5;

import com.marklogic.client.test.Common;
import com.marklogic.client.test.MarkLogicVersion;
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExecutionCondition;
import org.junit.jupiter.api.extension.ExtensionContext;

public class RequiresML12Dot0 implements ExecutionCondition {

private static MarkLogicVersion markLogicVersion;

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
if (markLogicVersion == null) {
markLogicVersion = Common.getMarkLogicVersion();
}
boolean supported =
markLogicVersion.getMajor() == 12 && markLogicVersion.getMinor() != null && markLogicVersion.getMinor() == 0;
return supported ?
ConditionEvaluationResult.enabled("MarkLogic is version 12.0.x") :
ConditionEvaluationResult.disabled("MarkLogic is not version 12.0.x");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.marklogic.client.test.junit5.DisabledWhenUsingReverseProxyServer;
import com.marklogic.client.test.junit5.RequireSSLExtension;
import com.marklogic.client.test.junit5.RequiresML11OrLower;
import com.marklogic.client.test.junit5.RequiresML12Dot0;
import com.marklogic.client.test.junit5.RequiresML12Dot1;
import com.marklogic.client.test.junit5.RequiresML12;
import com.marklogic.mgmt.ManageClient;
import com.marklogic.mgmt.resource.appservers.ServerManager;
Expand Down Expand Up @@ -122,14 +124,12 @@ void defaultSslContext() throws Exception {

@ExtendWith(RequiresML11OrLower.class)
@Test
void noSslContext() {
void noSslContextWithMarkLogic11OrLower() {
DatabaseClient client = newSslClient(Map.of());

DatabaseClient.ConnectionResult result = client.checkConnection();
assertEquals("Forbidden", result.getErrorMessage(), "MarkLogic is expected to return a 403 Forbidden when the " +
"user tries to access an HTTPS app server using HTTP. This behavior changes in MarkLogic 12, and it may " +
"be considered a bit surprising with MarkLogic 11 and earlier - that is, the user probably shouldn't get " +
"any response back since a connection cannot be made without using SSL.");
assertEquals("Forbidden", result.getErrorMessage(), "MarkLogic 11 or lower is expected to return a 403 Forbidden when the " +
"user tries to access an HTTPS app server using HTTP.");
assertEquals(403, result.getStatusCode());

ForbiddenUserException ex = assertThrows(ForbiddenUserException.class,
Expand All @@ -143,15 +143,37 @@ void noSslContext() {
);
}

@ExtendWith(RequiresML12.class)
@ExtendWith(RequiresML12Dot0.class)
@Test
void noSslContextWithMarkLogic12() {
void noSslContextWithMarkLogic12Dot0() {
DatabaseClient client = newSslClient(Map.of());

MarkLogicIOException ex = assertThrows(MarkLogicIOException.class, () -> client.checkConnection());
assertTrue(ex.getMessage().contains("unexpected end of stream"), "Per MLE-17505, a change in the openssl " +
"library used by the server results in an IO exception when the client tries to connect to an " +
"app server that requires SSL, but the client does not use SSL. Actual message: " + ex.getMessage());
"app server that requires SSL, but the client does not use SSL. This impacts all ML 12.0.x versions as of 12.0.3. " +
"Actual message: " + ex.getMessage());
}

@ExtendWith(RequiresML12Dot1.class)
@Test
void noSslContextWithMarkLogic12Dot1OrHigher() {
DatabaseClient client = newSslClient(Map.of());

DatabaseClient.ConnectionResult result = client.checkConnection();
assertEquals("Forbidden", result.getErrorMessage(), "MarkLogic 12.1 or higher is expected to return a 403 Forbidden when the " +
"user tries to access an HTTPS app server using HTTP.");
assertEquals(403, result.getStatusCode());

ForbiddenUserException ex = assertThrows(ForbiddenUserException.class,
() -> client.newServerEval().javascript("fn.currentDate()").evalAs(String.class));

assertEquals(
"Local message: User is not allowed to apply resource at eval. Server Message: You have attempted to access an HTTPS server using HTTP.",
ex.getMessage(),
"The user should get a clear message on why the connection failed as opposed to the previous error " +
"message of 'Server (not a REST instance?)'."
);
}

@Test
Expand Down
Loading