Skip to content

Commit 6d602dd

Browse files
author
Charles Greer
authored
Merge pull request #1515 from srinathgit/develop
Fix for Support Ticket 20961
2 parents aa4dacc + 230076f commit 6d602dd

File tree

8 files changed

+167
-82
lines changed

8 files changed

+167
-82
lines changed

marklogic-data-hub/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ task teardown(type: JavaExec) {
269269
test {
270270
minHeapSize = "128m"
271271
maxHeapSize = "256m"
272+
exclude 'com/marklogic/bootstrap/**'
272273
classpath = project.sourceSets.test.runtimeClasspath
273274
}
274275

@@ -289,7 +290,7 @@ task testIntegration(type: Test) {
289290

290291
task testBootstrap(type: Test) {
291292
useJUnit {
292-
exclude 'com/marklogic/bootstrap/**'
293+
include 'com/marklogic/bootstrap/**'
293294
}
294295
}
295296

marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,14 +874,15 @@ public void loadConfigurationFromProperties(Properties environmentProperties) {
874874
finalPort = getEnvPropInteger(environmentProperties, "mlFinalPort", finalPort);
875875
finalAuthMethod = getEnvPropString(environmentProperties, "mlFinalAuth", finalAuthMethod);
876876
finalScheme = getEnvPropString(environmentProperties, "mlFinalScheme", finalScheme);
877+
finalSimpleSsl = getEnvPropBoolean(environmentProperties, "mlFinalSimpleSsl", false);
877878
if (finalSimpleSsl) {
878879
finalSslContext = SimpleX509TrustManager.newSSLContext();
879880
finalSslHostnameVerifier = DatabaseClientFactory.SSLHostnameVerifier.ANY;
880881
finalTrustManager = new SimpleX509TrustManager();
881882
}
882-
finalCertFile = getEnvPropString(environmentProperties, "mlfinalCertFile", finalCertFile);
883-
finalCertPassword = getEnvPropString(environmentProperties, "mlfinalCertPassword", finalCertPassword);
884-
finalExternalName = getEnvPropString(environmentProperties, "mlfinalExternalName", finalExternalName);
883+
finalCertFile = getEnvPropString(environmentProperties, "mlFinalCertFile", finalCertFile);
884+
finalCertPassword = getEnvPropString(environmentProperties, "mlFinalCertPassword", finalCertPassword);
885+
finalExternalName = getEnvPropString(environmentProperties, "mlFinalExternalName", finalExternalName);
885886

886887

887888
jobDbName = getEnvPropString(environmentProperties, "mlJobDbName", jobDbName);

marklogic-data-hub/src/test/java/com/marklogic/bootstrap/DataHubInstallTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
import com.marklogic.client.io.DOMHandle;
2323
import com.marklogic.hub.DataHub;
2424
import com.marklogic.hub.HubConfig;
25+
import com.marklogic.hub.HubConfigBuilder;
2526
import com.marklogic.hub.HubProject;
2627
import com.marklogic.hub.HubTestBase;
2728
import com.marklogic.hub.deploy.commands.DeployHubAmpsCommand;
2829
import com.marklogic.hub.deploy.commands.LoadHubModulesCommand;
2930
import com.marklogic.hub.util.Versions;
3031
import org.apache.commons.io.FileUtils;
3132
import org.custommonkey.xmlunit.XMLUnit;
33+
import org.junit.jupiter.api.AfterAll;
3234
import org.junit.jupiter.api.BeforeEach;
3335
import org.junit.jupiter.api.Disabled;
3436
import org.junit.jupiter.api.Test;
@@ -57,7 +59,7 @@ public class DataHubInstallTest extends HubTestBase {
5759
private static int afterTelemetryInstallCount = 0;
5860

5961
static boolean setupDone=false;
60-
62+
static String projectDir = PROJECT_PATH;
6163
@BeforeEach
6264
public void setup() {
6365
// special case do-one setup.
@@ -102,16 +104,22 @@ public void setup() {
102104
}
103105
afterTelemetryInstallCount = getTelemetryInstallCount();
104106
}
107+
108+
@AfterAll
109+
public static void cleanUp() {
110+
HubConfigBuilder builder = HubConfigBuilder.newHubConfigBuilder(projectDir)
111+
.withPropertiesFromEnvironment();
112+
DataHub.create(builder.build()).uninstall();
113+
setupDone = false;
114+
}
105115

106116

107117
@Test
108-
@Disabled
109118
public void testTelemetryInstallCount() throws IOException {
110119
assertTrue(afterTelemetryInstallCount > 0, "Telemetry install count was not incremented during install. Value now is " + afterTelemetryInstallCount);
111120
}
112121

113122
@Test
114-
@Disabled
115123
public void testProjectScaffolding() throws IOException {
116124
DatabaseClient stagingTriggersClient = null;
117125
DatabaseClient finalTriggersClient = null;
@@ -144,7 +152,6 @@ public void testProjectScaffolding() throws IOException {
144152
}
145153

146154
@Test
147-
@Disabled
148155
public void testInstallHubModules() throws IOException {
149156
assertTrue(getDataHub().isInstalled().isInstalled());
150157

@@ -157,14 +164,12 @@ public void testInstallHubModules() throws IOException {
157164
}
158165

159166
@Test
160-
@Disabled
161167
public void getHubModulesVersion() throws IOException {
162168
String version = getHubFlowRunnerConfig().getJarVersion();
163169
assertEquals(version, new Versions(getHubFlowRunnerConfig()).getHubVersion());
164170
}
165171

166172
@Test
167-
@Disabled
168173
public void testInstallUserModules() throws IOException, ParserConfigurationException, SAXException, URISyntaxException {
169174
URL url = DataHubInstallTest.class.getClassLoader().getResource("data-hub-test");
170175
String path = Paths.get(url.toURI()).toFile().getAbsolutePath();
@@ -291,7 +296,6 @@ public void testInstallUserModules() throws IOException, ParserConfigurationExce
291296
}
292297

293298
@Test
294-
@Disabled
295299
public void testClearUserModules() throws URISyntaxException {
296300
URL url = DataHubInstallTest.class.getClassLoader().getResource("data-hub-test");
297301
String path = Paths.get(url.toURI()).toFile().getAbsolutePath();
@@ -311,7 +315,6 @@ public void testClearUserModules() throws URISyntaxException {
311315
}
312316

313317
@Test
314-
@Disabled
315318
public void testAmpLoading() {
316319
HubConfig config = getHubAdminConfig();
317320
LoadHubModulesCommand loadHubModulesCommand = new LoadHubModulesCommand(config);

ml-data-hub-plugin/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ test {
7474
classpath = project.sourceSets.main.runtimeClasspath + project.sourceSets.test.runtimeClasspath
7575
}
7676

77+
task testFullCycle(type: Test) {
78+
useJUnit {
79+
include 'com/marklogic/gradle/fullcycle/**'
80+
}
81+
}
82+
7783
task sourcesJar(type: Jar, dependsOn: classes) {
7884
classifier 'sources'
7985
from sourceSets.main.allJava

ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/fullcycle/BasicAuthTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class BasicAuthTest extends BaseTest {
3232
}
3333

3434
def cleanupSpec() {
35-
//runTask('mlUndeploy', '-Pconfirm=true')
35+
runTask('mlUndeploy', '-Pconfirm=true')
3636
}
3737

3838
void createProperties() {

ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/fullcycle/SslTest.groovy

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@
1717

1818
package com.marklogic.gradle.fullcycle
1919

20+
import com.fasterxml.jackson.databind.node.ObjectNode
2021
import com.marklogic.client.DatabaseClientFactory
2122
import com.marklogic.client.ext.modulesloader.ssl.SimpleX509TrustManager
2223
import com.marklogic.client.io.DOMHandle
2324
import com.marklogic.client.io.DocumentMetadataHandle
2425
import com.marklogic.gradle.task.BaseTest
26+
import com.marklogic.hub.DatabaseKind
2527
import com.marklogic.hub.HubConfig
28+
import com.marklogic.rest.util.JsonNodeUtil
29+
30+
import org.apache.commons.io.FileUtils
2631
import org.gradle.testkit.runner.UnexpectedBuildFailure
2732
import spock.lang.Ignore
2833

@@ -32,32 +37,20 @@ import javax.net.ssl.TrustManager
3237
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual
3338
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
3439

40+
import java.nio.file.Files
41+
import java.nio.file.Path
3542

36-
/* this particular test requires bootstrap to run on a clean
37-
and ssl-enabled database.
38-
Note this test is diabled until we fix the blocking bug in ml-app-deployer
39-
that inststalls amps via CMA
40-
*/
4143
class SslTest extends BaseTest {
4244

43-
@Ignore
44-
def setupSpecSKIPTHIS() {
45+
46+
def setupSpec() {
4547
createFullPropertiesFile()
4648
BaseTest.buildFile = BaseTest.testProjectDir.newFile('build.gradle')
4749
BaseTest.buildFile << '''
4850
plugins {
4951
id 'com.marklogic.ml-data-hub'
5052
}
5153
52-
ext {
53-
def command = new com.marklogic.appdeployer.command.security.GenerateTemporaryCertificateCommand()
54-
command.setTemplateIdOrName("dhf-cert")
55-
command.setCommonName("localhost")
56-
command.setValidFor(365)
57-
mlAppDeployer.commands.add(command)
58-
}
59-
60-
6154
task enableSSL(type: com.marklogic.gradle.task.MarkLogicTask) {
6255
doFirst {
6356
def manageConfig = getProject().property("mlManageConfig")
@@ -73,12 +66,19 @@ class SslTest extends BaseTest {
7366
7467
def certManager = new com.marklogic.mgmt.resource.security.CertificateTemplateManager(manageClient)
7568
certManager.save(adminCert())
69+
certManager.save(dhfCert())
7670
7771
def gtcc = new com.marklogic.appdeployer.command.security.GenerateTemporaryCertificateCommand();
7872
gtcc.setTemplateIdOrName("admin-cert");
7973
gtcc.setCommonName("localhost");
80-
gtcc.execute(new com.marklogic.appdeployer.command.CommandContext(getStagingAppConfig(), manageClient, adminManager));
81-
74+
gtcc.execute(new com.marklogic.appdeployer.command.CommandContext(getAppConfig(), manageClient, adminManager));
75+
76+
def command = new com.marklogic.appdeployer.command.security.GenerateTemporaryCertificateCommand()
77+
command.setTemplateIdOrName("dhf-cert")
78+
command.setCommonName("localhost")
79+
command.setValidFor(365)
80+
command.execute(new com.marklogic.appdeployer.command.CommandContext(getAppConfig(), manageClient, adminManager));
81+
8282
adminConfig = getProject().property("mlAdminConfig")
8383
adminConfig.setScheme("https")
8484
adminConfig.setConfigureSimpleSsl(true)
@@ -113,6 +113,7 @@ class SslTest extends BaseTest {
113113
114114
def certManager = new com.marklogic.mgmt.resource.security.CertificateTemplateManager(mgClient)
115115
certManager.delete(adminCert())
116+
certManager.delete(dhfCert())
116117
}
117118
}
118119
@@ -133,14 +134,43 @@ class SslTest extends BaseTest {
133134
"""
134135
}
135136
137+
def dhfCert() {
138+
return """
139+
<certificate-template-properties xmlns="http://marklogic.com/manage">
140+
<template-name>dhf-cert</template-name>
141+
<template-description>Sample description</template-description>
142+
<key-type>rsa</key-type>
143+
<key-options />
144+
<req>
145+
<version>0</version>
146+
<subject>
147+
<countryName>US</countryName>
148+
<stateOrProvinceName>VA</stateOrProvinceName>
149+
<localityName>McLean</localityName>
150+
<organizationName>MarkLogic</organizationName>
151+
<organizationalUnitName>Consulting</organizationalUnitName>
152+
<emailAddress>[email protected]</emailAddress>
153+
</subject>
154+
</req>
155+
</certificate-template-properties>
156+
"""
157+
}
158+
136159
'''
137160

138161
runTask("hubInit")
139162
runTask("mlDeploySecurity")
140-
copyResourceToFile("ssl-test/my-template.xml", new File(BaseTest.testProjectDir.root, "user-config/security/certificate-templates/my-template.xml"))
141-
copyResourceToFile("ssl-test/ssl-server.json", new File(BaseTest.testProjectDir.root, "user-config/servers/final-server.json"))
142-
copyResourceToFile("ssl-test/ssl-server.json", new File(BaseTest.testProjectDir.root, "user-config/servers/job-server.json"))
143-
copyResourceToFile("ssl-test/ssl-server.json", new File(BaseTest.testProjectDir.root, "user-config/servers/staging-server.json"))
163+
164+
writeSSLFiles(new File(BaseTest.testProjectDir.root, "src/main/ml-config/servers/final-server.json"),
165+
new File("src/test/resources/ssl-test/ssl-server.json"))
166+
writeSSLFiles(new File(BaseTest.testProjectDir.root, "src/main/hub-internal-config/servers/job-server.json"),
167+
new File("src/test/resources/ssl-test/ssl-server.json"))
168+
writeSSLFiles(new File(BaseTest.testProjectDir.root, "src/main/hub-internal-config/servers/staging-server.json"),
169+
new File("src/test/resources/ssl-test/ssl-server.json"))
170+
/*copyResourceToFile("ssl-test/my-template.xml", new File(BaseTest.testProjectDir.root, "src/main/ml-config/security/certificate-templates/my-template.xml"))
171+
copyResourceToFile("ssl-test/ssl-server.json", new File(BaseTest.testProjectDir.root, "src/main/ml-config/servers/final-server.json"))
172+
copyResourceToFile("ssl-test/ssl-server.json", new File(BaseTest.testProjectDir.root, "src/main/hub-internal-config/servers/job-server.json"))
173+
copyResourceToFile("ssl-test/ssl-server.json", new File(BaseTest.testProjectDir.root, "src/main/hub-internal-config/servers/staging-server.json"))*/
144174
createProperties()
145175
try {
146176
clearDatabases(hubConfig().DEFAULT_MODULES_DB_NAME)
@@ -150,8 +180,7 @@ class SslTest extends BaseTest {
150180
runTask("enableSSL")
151181
}
152182

153-
@Ignore
154-
def cleanupSpecSKIPTHIS() {
183+
def cleanupSpec() {
155184
runTask("mlUndeploy", "-Pconfirm=true")
156185
runTask("mlDeploySecurity")
157186
runTask("disableSSL", "--stacktrace")
@@ -174,7 +203,7 @@ class SslTest extends BaseTest {
174203
"""
175204
}
176205

177-
@Ignore
206+
178207
def "bootstrap a project with ssl out the wazoo"() {
179208
when:
180209
def result = runTask('mlDeploy')
@@ -191,7 +220,7 @@ class SslTest extends BaseTest {
191220
result.task(":mlDeploy").outcome == SUCCESS
192221
}
193222

194-
@Ignore
223+
195224
def "runHarmonizeFlow with default src and dest"() {
196225
given:
197226
println(runTask('hubCreateHarmonizeFlow', '-PentityName=my-new-entity', '-PflowName=my-new-harmonize-flow', '-PdataFormat=xml', '-PpluginFormat=xqy', '-PuseES=false').getOutput())
@@ -227,7 +256,7 @@ class SslTest extends BaseTest {
227256
assertXMLEqual(getXmlFromResource("run-flow-test/harmonized2.xml"), hubConfig().newFinalClient().newDocumentManager().read("/employee2.xml").next().getContent(new DOMHandle()).get())
228257
}
229258

230-
@Ignore
259+
231260
def "runHarmonizeFlow with swapped src and dest"() {
232261
given:
233262
println(runTask('hubCreateHarmonizeFlow', '-PentityName=my-new-entity', '-PflowName=my-new-harmonize-flow', '-PdataFormat=xml', '-PpluginFormat=xqy', '-PuseES=false').getOutput())
@@ -253,13 +282,13 @@ class SslTest extends BaseTest {
253282

254283
when:
255284
println(runTask(
256-
'hubRunFlow',
257-
'-PentityName=my-new-entity',
258-
'-PflowName=my-new-harmonize-flow',
259-
'-PsourceDB=data-hub-FINAL',
260-
'-PdestDB=data-hub-STAGING',
261-
'-i'
262-
).getOutput())
285+
'hubRunFlow',
286+
'-PentityName=my-new-entity',
287+
'-PflowName=my-new-harmonize-flow',
288+
'-PsourceDB=data-hub-FINAL',
289+
'-PdestDB=data-hub-STAGING',
290+
'-i'
291+
).getOutput())
263292

264293
then:
265294
notThrown(UnexpectedBuildFailure)

0 commit comments

Comments
 (0)