Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #498 from marklogic/dev
Browse files Browse the repository at this point in the history
Merging dev into master for 4.6.1
  • Loading branch information
rjrudin authored Jan 11, 2024
2 parents 6273b76 + 54c098a commit 9e32edd
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "com.marklogic"
version = "4.6.0"
version = "4.6.1"

java {
sourceCompatibility = 1.8
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ It is not intended to be used to build this project.
<modelVersion>4.0.0</modelVersion>
<groupId>com.marklogic</groupId>
<artifactId>ml-app-deployer</artifactId>
<version>4.6.0</version>
<version>4.6.1</version>
<name>com.marklogic:ml-app-deployer</name>
<description>Java client for the MarkLogic REST Management API and for deploying applications to MarkLogic</description>
<url>https://github.com/marklogic/ml-app-deployer</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,19 @@ public DeployCustomForestsCommand() {

@Override
public void execute(CommandContext context) {
Configuration configuration = null;
if (context.getAppConfig().getCmaConfig().isDeployForests()) {
configuration = new Configuration();
}

for (ConfigDir configDir : context.getAppConfig().getConfigDirs()) {
File dir = new File(configDir.getBaseDir(), customForestsPath);
if (dir != null && dir.exists()) {
payloadParser = new PayloadParser();
for (File f : dir.listFiles()) {
if (f.isDirectory()) {
processDirectory(f, context, configuration);
processDirectory(f, context);
}
}
} else {
logResourceDirectoryNotFound(dir);
}
}

if (configuration != null) {
deployConfiguration(context, configuration);
}
}

/**
Expand All @@ -79,7 +70,7 @@ public void execute(CommandContext context) {
* @param dir
* @param context
*/
protected void processDirectory(File dir, CommandContext context, Configuration configuration) {
protected void processDirectory(File dir, CommandContext context) {
if (logger.isInfoEnabled()) {
logger.info("Processing custom forest files in directory: " + dir.getAbsolutePath());
}
Expand All @@ -91,6 +82,11 @@ protected void processDirectory(File dir, CommandContext context, Configuration
}
String payload = readResourceFromFile(context, f);

// As of 4.6.1, create a CMA request per file so that the user has control over how many forests are
// submitted in a single request, thus avoiding potential timeouts.
Configuration configuration = context.getAppConfig().getCmaConfig().isDeployForests() ?
new Configuration() : null;

if (payloadParser.isJsonPayload(payload)) {
if (configuration != null) {
addForestsToCmaConfiguration(context, payload, configuration);
Expand All @@ -104,6 +100,10 @@ protected void processDirectory(File dir, CommandContext context, Configuration
mgr.save(payload);
}
}

if (configuration != null) {
deployConfiguration(context, configuration);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/marklogic/rest/util/RestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.marklogic.client.DatabaseClientBuilder;
import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.client.DatabaseClientFactory.SSLHostnameVerifier;
import com.marklogic.client.ext.modulesloader.ssl.SimpleX509TrustManager;
import com.marklogic.client.ext.ssl.SslConfig;
import com.marklogic.client.ext.ssl.SslUtil;
Expand Down Expand Up @@ -114,7 +115,8 @@ public DatabaseClientBuilder newDatabaseClientBuilder() {
.withSSLContext(StringUtils.hasText(sslProtocol) ?
SimpleX509TrustManager.newSSLContext(sslProtocol) :
SimpleX509TrustManager.newSSLContext())
.withTrustManager(new SimpleX509TrustManager());
.withTrustManager(new SimpleX509TrustManager())
.withSSLHostnameVerifier(SSLHostnameVerifier.ANY);
} else {
builder.withSSLProtocol(sslProtocol);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ public void test() {
assertTrue(mgr.exists("sample-app-content-custom-3"));
}

/**
* Can examine logging to verify that one request is made per forest.
*/
@Test
public void deployWithCma() {
appConfig.getCmaConfig().enableAll();
public void deployWithoutCMA() {
appConfig.getCmaConfig().setDeployForests(false);
test();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.marklogic.mgmt;

import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.client.DatabaseClientFactory.SSLHostnameVerifier;
import com.marklogic.mgmt.util.SimplePropertySource;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -104,6 +105,19 @@ public void sslProperties() {
assertEquals("PKIX", config.getTrustManagementAlgorithm());
}

@Test
void simpleSsl() {
ManageConfig config = configure(
"mlManageSimpleSsl", "true",
"mlUsername", "admin",
"mlPassword", "admin"
);

DatabaseClientFactory.Bean bean = config.newDatabaseClientBuilder().buildBean();
SSLHostnameVerifier verifier = bean.getSecurityContext().getSSLHostnameVerifier();
assertEquals(SSLHostnameVerifier.ANY, verifier, "simpleSsl should default to using the ANY hostname verifier");
}

@Test
public void mlHost() {
ManageConfig config = configure("mlHost", "host1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
*/
package com.marklogic.mgmt.admin;

import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.mgmt.util.SimplePropertySource;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.client.DatabaseClientFactory.SSLHostnameVerifier;
import com.marklogic.mgmt.util.SimplePropertySource;

public class DefaultAdminConfigFactoryTest {

@Test
Expand Down Expand Up @@ -75,6 +76,19 @@ public void sslProperties() {
assertEquals("PKIX", config.getTrustManagementAlgorithm());
}

@Test
void simpleSsl() {
AdminConfig config = configure(
"mlAdminSimpleSsl", "true",
"mlUsername", "admin",
"mlPassword", "admin"
);

DatabaseClientFactory.Bean bean = config.newDatabaseClientBuilder().buildBean();
SSLHostnameVerifier verifier = bean.getSecurityContext().getSSLHostnameVerifier();
assertEquals(SSLHostnameVerifier.ANY, verifier, "simpleSsl should default to using the ANY hostname verifier");
}

@Test
void cloudApiKeyAndBasePath() {
AdminConfig config = configure(
Expand Down

0 comments on commit 9e32edd

Please sign in to comment.