Skip to content

Commit 3ef6c8b

Browse files
rjrudinMarkLogic Builder
authored andcommitted
DHFPROD-3162: Added command line option to not use SSL
Can include --disableSsl=true Also modifying CopyQueryOptionsCommand to not fail if a particular URI is not found
1 parent d914c5c commit 3ef6c8b

File tree

5 files changed

+82
-35
lines changed

5 files changed

+82
-35
lines changed

marklogic-data-hub/src/main/java/com/marklogic/hub/cli/Options.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ public class Options {
3838
)
3939
private String password;
4040

41+
@Parameter(
42+
names = {"--disableSsl"},
43+
description = "Set to true to disable SSL usage when connecting to MarkLogic"
44+
)
45+
private boolean disableSsl;
46+
4147
@DynamicParameter(
4248
names = "-P",
4349
description = "Use this argument to include any property supported by DHF; e.g. -PmlHost=somehost"
@@ -83,4 +89,12 @@ public String getPassword() {
8389
public void setPassword(String password) {
8490
this.password = password;
8591
}
92+
93+
public boolean isDisableSsl() {
94+
return disableSsl;
95+
}
96+
97+
public void setDisableSsl(boolean disableSsl) {
98+
this.disableSsl = disableSsl;
99+
}
86100
}

marklogic-data-hub/src/main/java/com/marklogic/hub/cli/command/InstallIntoDhsCommand.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class InstallIntoDhsCommand extends AbstractInstallerCommand {
1919

2020
@Override
2121
public void run(ApplicationContext context, Options options) {
22-
initializeProject(context, options, buildDefaultProjectProperties());
22+
initializeProject(context, options, buildDefaultProjectProperties(options));
2323

2424
logger.info("Installing DHF version " + hubConfig.getJarVersion());
2525

@@ -84,25 +84,31 @@ protected void modifyHubConfigForDhs(String groupName) {
8484
* Builds a default set of project properties based on assumptions of how DHS works. These can then be overridden
8585
* via "-P" arguments on the command line.
8686
*
87+
* @param options
8788
* @return
8889
*/
89-
protected Properties buildDefaultProjectProperties() {
90+
protected Properties buildDefaultProjectProperties(Options options) {
9091
// Include System properties so that a client can override e.g. mlHost/mlUsername/mlPassword via JVM props
9192
Properties props = new Properties();
9293
for (String key : System.getProperties().stringPropertyNames()) {
9394
props.put(key, System.getProperties().getProperty(key));
9495
}
9596

96-
applyDhsSpecificProperties(props);
97+
applyDhsSpecificProperties(props, options.isDisableSsl());
9798
return props;
9899
}
99100

100101
/**
101-
* Public so that it can be reused by DHF Gradle plugin.
102+
* Public so that it can be reused by DHF Gradle plugin. Assumes that SSL should be used for connecting to
103+
* MarkLogic.
102104
*
103105
* @param props
104106
*/
105107
public void applyDhsSpecificProperties(Properties props) {
108+
applyDhsSpecificProperties(props, false);
109+
}
110+
111+
public void applyDhsSpecificProperties(Properties props, boolean disableSsl) {
106112
props.setProperty("mlIsHostLoadBalancer", "true");
107113
props.setProperty("mlIsProvisionedEnvironment", "true");
108114
props.setProperty("mlAppServicesPort", "8010");
@@ -114,7 +120,16 @@ public void applyDhsSpecificProperties(Properties props) {
114120
props.setProperty("mlModulePermissions",
115121
"flowDeveloper,read,flowDeveloper,execute,flowDeveloper,insert,flowOperator,read,flowOperator,execute,flowOperator,insert");
116122

117-
setDefaultPropertiesForSecureConnections(props);
123+
props.setProperty("mlAppServicesAuthentication", "basic");
124+
props.setProperty("mlFinalAuth", "basic");
125+
props.setProperty("mlJobAuth", "basic");
126+
props.setProperty("mlStagingAuth", "basic");
127+
128+
if (!disableSsl) {
129+
setDefaultPropertiesForSecureConnections(props);
130+
} else {
131+
logger.info("Not setting default property values for secure connections to MarkLogic");
132+
}
118133
}
119134

120135
/**
@@ -131,16 +146,9 @@ protected void setDefaultPropertiesForSecureConnections(Properties props) {
131146
props.setProperty("mlManageScheme", "https");
132147
props.setProperty("mlManageSimpleSsl", "true");
133148

134-
props.setProperty("mlAppServicesAuthentication", "basic");
135149
props.setProperty("mlAppServicesSimpleSsl", "true");
136-
137-
props.setProperty("mlFinalAuth", "basic");
138150
props.setProperty("mlFinalSimpleSsl", "true");
139-
140-
props.setProperty("mlJobAuth", "basic");
141151
props.setProperty("mlJobSimpleSsl", "true");
142-
143-
props.setProperty("mlStagingAuth", "basic");
144152
props.setProperty("mlStagingSimpleSsl", "true");
145153
}
146154
}

marklogic-data-hub/src/main/java/com/marklogic/hub/cli/command/VerifyDhfInDhsCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class VerifyDhfInDhsCommand extends AbstractVerifyCommand {
2424
@Override
2525
public void run(ApplicationContext context, Options options) {
2626
// TODO This is hacky, need a better mechanism for building these properties post 5.0.2
27-
Properties props = new InstallIntoDhsCommand().buildDefaultProjectProperties();
27+
Properties props = new InstallIntoDhsCommand().buildDefaultProjectProperties(options);
2828
initializeProject(context, options, props);
2929

3030
long start = System.currentTimeMillis();

marklogic-data-hub/src/main/java/com/marklogic/hub/cli/deploy/CopyQueryOptionsCommand.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public void execute(CommandContext context) {
2626
" '/Evaluator/data-hub-STAGING/rest-api/options/default.xml',\n" +
2727
" '/Evaluator/data-hub-FINAL/rest-api/options/default.xml'\n" +
2828
"].forEach(uri => {\n" +
29-
" xdmp.documentInsert(uri.replace('Evaluator', 'Curator'), cts.doc(uri), \n" +
30-
" xdmp.documentGetPermissions(uri), xdmp.documentGetCollections(uri));\n" +
29+
" if (fn.docAvailable(uri)) { xdmp.documentInsert(uri.replace('Evaluator', 'Curator'), cts.doc(uri), \n" +
30+
" xdmp.documentGetPermissions(uri), xdmp.documentGetCollections(uri));}\n" +
3131
"});\n" +
3232
"\n" +
3333
"const finalUri = '/Evaluator/data-hub-FINAL/rest-api/options/default.xml';\n" +
@@ -39,8 +39,8 @@ public void execute(CommandContext context) {
3939
" '/Evaluator/data-hub-ANALYTICS/rest-api/options/default.xml',\n" +
4040
" '/Evaluator/data-hub-OPERATION/rest-api/options/default.xml'\n" +
4141
"].forEach(uri => {\n" +
42-
" xdmp.documentInsert(uri, cts.doc(finalUri), xdmp.documentGetPermissions(finalUri), \n" +
43-
" xdmp.documentGetCollections(finalUri));\n" +
42+
" if (fn.docAvailable(finalUri)) {xdmp.documentInsert(uri, cts.doc(finalUri), xdmp.documentGetPermissions(finalUri), \n" +
43+
" xdmp.documentGetCollections(finalUri));}\n" +
4444
"})";
4545

4646
DatabaseClient client = hubConfig.newModulesDbClient();

marklogic-data-hub/src/test/java/com/marklogic/hub/cli/command/InstallIntoDhsCommandTest.java

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.marklogic.appdeployer.command.triggers.DeployTriggersCommand;
99
import com.marklogic.hub.ApplicationConfig;
1010
import com.marklogic.hub.HubTestBase;
11+
import com.marklogic.hub.cli.Options;
1112
import com.marklogic.hub.cli.deploy.CopyQueryOptionsCommand;
1213
import com.marklogic.hub.cli.deploy.DhsDeployServersCommand;
1314
import com.marklogic.hub.deploy.commands.*;
@@ -29,36 +30,38 @@ public class InstallIntoDhsCommandTest extends HubTestBase {
2930

3031
@Test
3132
public void buildDefaultProjectProperties() {
32-
Properties props = new InstallIntoDhsCommand().buildDefaultProjectProperties();
33-
assertEquals("true", props.getProperty("mlIsHostLoadBalancer"), "This is needed to support running legacy flows");
34-
assertEquals("true", props.getProperty("mlIsProvisionedEnvironment"));
35-
36-
// Verify role mappings
37-
assertEquals("flowDeveloper", props.getProperty("mlFlowDeveloperRole"));
38-
assertEquals("flowOperator", props.getProperty("mlFlowOperatorRole"));
39-
assertEquals("flowDeveloper", props.getProperty("mlDataHubAdminRole"),
40-
"As of 5.0.2, mlDataHubAdminRole is only used for setting permissions on triggers, so it's fine to map it to the flowDeveloper role");
41-
42-
assertEquals("flowDeveloper,read,flowDeveloper,execute,flowDeveloper,insert,flowOperator,read,flowOperator,execute,flowOperator,insert",
43-
props.getProperty("mlModulePermissions"));
33+
Properties props = new InstallIntoDhsCommand().buildDefaultProjectProperties(new Options());
4434

45-
assertEquals("8010", props.getProperty("mlAppServicesPort"), "8000 is not available in DHS, so the staging port is used instead for " +
46-
"loading non-REST modules");
35+
verifyDefaultProperties(props);
4736

4837
assertEquals("https", props.getProperty("mlAdminScheme"));
4938
assertEquals("true", props.getProperty("mlAdminSimpleSsl"));
5039
assertEquals("https", props.getProperty("mlManageScheme"));
5140
assertEquals("true", props.getProperty("mlManageSimpleSsl"));
52-
assertEquals("basic", props.getProperty("mlAppServicesAuthentication"));
5341
assertEquals("true", props.getProperty("mlAppServicesSimpleSsl"));
54-
assertEquals("basic", props.getProperty("mlFinalAuth"));
5542
assertEquals("true", props.getProperty("mlFinalSimpleSsl"));
56-
assertEquals("basic", props.getProperty("mlJobAuth"));
5743
assertEquals("true", props.getProperty("mlJobSimpleSsl"));
58-
assertEquals("basic", props.getProperty("mlStagingAuth"));
5944
assertEquals("true", props.getProperty("mlStagingSimpleSsl"));
6045
}
6146

47+
@Test
48+
public void buildDefaultProjectPropertiesWithoutSslEnabled() {
49+
Options options = new Options();
50+
options.setDisableSsl(true);
51+
52+
Properties props = new InstallIntoDhsCommand().buildDefaultProjectProperties(options);
53+
verifyDefaultProperties(props);
54+
55+
assertNull(props.getProperty("mlAdminScheme"));
56+
assertNull(props.getProperty("mlAdminSimpleSsl"));
57+
assertNull(props.getProperty("mlManageScheme"));
58+
assertNull(props.getProperty("mlManageSimpleSsl"));
59+
assertNull(props.getProperty("mlAppServicesSimpleSsl"));
60+
assertNull(props.getProperty("mlFinalSimpleSsl"));
61+
assertNull(props.getProperty("mlJobSimpleSsl"));
62+
assertNull(props.getProperty("mlStagingSimpleSsl"));
63+
}
64+
6265
@Test
6366
public void modifyHubConfig() {
6467
HubConfigImpl config = new HubConfigImpl();
@@ -93,4 +96,26 @@ public void buildCommandList() {
9396
assertTrue(commands.get(9) instanceof DeployHubTriggersCommand);
9497
assertTrue(commands.get(10) instanceof LoadHubArtifactsCommand);
9598
}
99+
100+
private void verifyDefaultProperties(Properties props) {
101+
assertEquals("true", props.getProperty("mlIsHostLoadBalancer"), "This is needed to support running legacy flows");
102+
assertEquals("true", props.getProperty("mlIsProvisionedEnvironment"));
103+
104+
// Verify role mappings
105+
assertEquals("flowDeveloper", props.getProperty("mlFlowDeveloperRole"));
106+
assertEquals("flowOperator", props.getProperty("mlFlowOperatorRole"));
107+
assertEquals("flowDeveloper", props.getProperty("mlDataHubAdminRole"),
108+
"As of 5.0.2, mlDataHubAdminRole is only used for setting permissions on triggers, so it's fine to map it to the flowDeveloper role");
109+
110+
assertEquals("flowDeveloper,read,flowDeveloper,execute,flowDeveloper,insert,flowOperator,read,flowOperator,execute,flowOperator,insert",
111+
props.getProperty("mlModulePermissions"));
112+
113+
assertEquals("8010", props.getProperty("mlAppServicesPort"), "8000 is not available in DHS, so the staging port is used instead for " +
114+
"loading non-REST modules");
115+
116+
assertEquals("basic", props.getProperty("mlAppServicesAuthentication"));
117+
assertEquals("basic", props.getProperty("mlFinalAuth"));
118+
assertEquals("basic", props.getProperty("mlJobAuth"));
119+
assertEquals("basic", props.getProperty("mlStagingAuth"));
120+
}
96121
}

0 commit comments

Comments
 (0)