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,23 @@
/*
* Copyright © 2024 MarkLogic Corporation. All Rights Reserved.
*/
package com.marklogic.client.test.junit5;

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

/**
* Some tests can't run when using the reverse proxy server; for example, TLS/SSL messages don't yet work with our
* reverse proxy server.
*/
public class DisabledWhenUsingReverseProxyServer implements ExecutionCondition {

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext extensionContext) {
return Common.USE_REVERSE_PROXY_SERVER ?
ConditionEvaluationResult.disabled("This test is disabled when the tests are run against a reverse proxy server.") :
ConditionEvaluationResult.enabled("This test is enabled since the reverse proxy server is not being used.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.marklogic.client.row.RowManager.RowStructure;
import com.marklogic.client.row.RowRecord.ColumnKind;
import com.marklogic.client.test.Common;
import com.marklogic.client.test.junit5.DisabledWhenUsingReverseProxyServer;
import com.marklogic.client.test.junit5.RequiresML11;
import com.marklogic.client.type.*;
import com.marklogic.client.util.EditableNamespaceContext;
Expand Down Expand Up @@ -511,13 +512,9 @@ public void testSQLNoResults() {
}

@Test
@ExtendWith(RequiresML11.class)
// A different kind of error is thrown when using the reverse proxy.
@ExtendWith({DisabledWhenUsingReverseProxyServer.class, RequiresML11.class})
public void testErrorWhileStreamingRows() {
if (Common.USE_REVERSE_PROXY_SERVER) {
// Different kind of error is thrown when using reverse proxy.
return;
}

final String validQueryThatEventuallyThrowsAnError = "select case " +
"when lastName = 'Byron' then fn_error(fn_qname('', 'SQL-TABLENOTFOUND'), 'Internal Server Error') end, " +
"opticUnitTest.musician.* from (select * from opticUnitTest.musician order by lastName)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.marklogic.client.ForbiddenUserException;
import com.marklogic.client.MarkLogicIOException;
import com.marklogic.client.test.Common;
import com.marklogic.client.test.junit5.DisabledWhenUsingReverseProxyServer;
import com.marklogic.client.test.junit5.RequireSSLExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -21,7 +22,10 @@
* certificate. See TwoWaySSLTest for scenarios where the client presents its own certificate which the server must
* trust.
*/
@ExtendWith(RequireSSLExtension.class)
@ExtendWith({
DisabledWhenUsingReverseProxyServer.class,
RequireSSLExtension.class
})
class OneWaySSLTest {

/**
Expand All @@ -34,14 +38,6 @@ class OneWaySSLTest {
*/
@Test
void trustAllManager() throws Exception {
if (Common.USE_REVERSE_PROXY_SERVER) {
/**
* Have not been able to get this to work yet, see the ReverseProxyServer class in test-app for more info.
* We know SSL works fine when hitting MarkLogic Cloud though, which is the important part.
*/
return;
}

SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, new TrustManager[]{Common.TRUST_ALL_MANAGER}, null);

Expand All @@ -63,10 +59,6 @@ void trustAllManager() throws Exception {
*/
@Test
void trustManagerThatOnlyTrustsTheCertificateFromTheCertificateTemplate() {
if (Common.USE_REVERSE_PROXY_SERVER) {
return;
}

DatabaseClient client = Common.newClientBuilder()
.withSSLProtocol("TLSv1.2")
.withTrustManager(RequireSSLExtension.newSecureTrustManager())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.marklogic.client.io.StringHandle;
import com.marklogic.client.test.Common;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnJre;
import org.junit.jupiter.api.condition.JRE;

import javax.net.ssl.*;
import javax.security.auth.x500.X500Principal;
Expand Down Expand Up @@ -78,6 +80,8 @@ public void testSSLAuth() throws NoSuchAlgorithmException, KeyManagementExceptio
}

@Test
// Not able to mock the X509Certificate class on Java 21.
@EnabledOnJre({JRE.JAVA_8, JRE.JAVA_11, JRE.JAVA_17})
public void testHostnameVerifier() throws SSLException, CertificateParsingException {
// three things our SSLHostnameVerifier will capture
AtomicReference<String> capturedHost = new AtomicReference<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.marklogic.client.eval.EvalResultIterator;
import com.marklogic.client.io.StringHandle;
import com.marklogic.client.test.Common;
import com.marklogic.client.test.junit5.DisabledWhenUsingReverseProxyServer;
import com.marklogic.client.test.junit5.RequireSSLExtension;
import com.marklogic.mgmt.ManageClient;
import com.marklogic.mgmt.resource.appservers.ServerManager;
Expand All @@ -35,7 +36,10 @@

import static org.junit.jupiter.api.Assertions.*;

@ExtendWith(RequireSSLExtension.class)
@ExtendWith({
DisabledWhenUsingReverseProxyServer.class,
RequireSSLExtension.class
})
public class TwoWaySSLTest {

private final static String TEST_DOCUMENT_URI = "/optic/test/musician1.json";
Expand All @@ -54,9 +58,6 @@ public class TwoWaySSLTest {

@BeforeAll
public static void setup() throws Exception {
if (Common.USE_REVERSE_PROXY_SERVER) {
return;
}
// Create a client using the java-unittest app server - which requires SSL via RequiresSSLExtension - and that
// talks to the Security database.
securityClient = Common.newClientBuilder()
Expand All @@ -82,9 +83,6 @@ public static void setup() throws Exception {

@AfterAll
public static void teardown() {
if (Common.USE_REVERSE_PROXY_SERVER) {
return;
}
removeTwoWaySSLConfig();
deleteCertificateAuthority();
}
Expand All @@ -101,10 +99,6 @@ public static void teardown() {
*/
@Test
void digestAuthentication() {
if (Common.USE_REVERSE_PROXY_SERVER) {
return;
}

// This client uses our Java KeyStore file with a client certificate in it, so it should work.
DatabaseClient clientWithCert = Common.newClientBuilder()
.withKeyStorePath(keyStoreFile.getAbsolutePath())
Expand Down Expand Up @@ -199,10 +193,6 @@ void invalidKeyStoreAlgorithm() {
*/
@Test
void certificateAuthenticationWithSSLContext() throws Exception {
if (Common.USE_REVERSE_PROXY_SERVER) {
return;
}

setAuthenticationToCertificate();
try {
SSLContext sslContext = createSSLContextWithClientCertificate(keyStoreFile);
Expand All @@ -223,10 +213,6 @@ void certificateAuthenticationWithSSLContext() throws Exception {
*/
@Test
void certificateAuthenticationWithCertificateFileAndPassword() {
if (Common.USE_REVERSE_PROXY_SERVER) {
return;
}

setAuthenticationToCertificate();
try {
DatabaseClient client = Common.newClientBuilder()
Expand Down