Skip to content

Commit 43dcf4b

Browse files
committed
MLE-24829 Fixing cloud auth
Kafka validator for securityContextType values needs to accept "cloud". Deleted a couple unused test classes too.
1 parent a4d0ae9 commit 43dcf4b

File tree

6 files changed

+31
-154
lines changed

6 files changed

+31
-154
lines changed

docs/configuring-the-connector.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Regardless of the required authentication strategy, you must configure the follo
4747
- `ml.connection.port` = the port of the MarkLogic app server you wish to connect to
4848
- `ml.connection.securityContextType` = the authentication strategy required by the MarkLogic app server; defaults to DIGEST
4949

50-
The choices for `ml.connection.securityContextType` are DIGEST, BASIC, CERTIFICATE, KERBEROS, and NONE. The additional
51-
properties required for each are described in the following sections.
50+
The choices for `ml.connection.securityContextType` are `DIGEST`, `BASIC`, `CERTIFICATE`, `KERBEROS`, `CLOUD`, and
51+
`NONE`. The additional properties required for each are described in the following sections.
5252

5353
### Configuring digest and basic authentication
5454

@@ -57,27 +57,30 @@ Both digest and basic authentication require the following properties to be conf
5757
- `ml.connection.username` = the name of the MarkLogic user to authenticate as
5858
- `ml.connection.password` = the password of the MarkLogic user
5959

60-
### Configuring MarkLogic Cloud authentication
60+
### Configuring Progress Data Cloud authentication
6161

6262
Cloud authentication requires the following properties to be configured:
6363

64-
- `ml.connection.basePath` = the base path in your MarkLogic Cloud instance that points to the REST API server you
64+
- `ml.connection.securityContextType=CLOUD`
65+
- `ml.connection.basePath` = the base path in your Progress Data Cloud instance that points to the REST API server you
6566
wish to connect to
66-
- `ml.connection.cloudApiKey` = the API key for authenticating with your MarkLogic Cloud instance
67+
- `ml.connection.cloudApiKey` = the API key for authenticating with your Progress Data Cloud instance
6768

68-
You should also set `ml.connection.port` to 443 for connecting to MarkLogic Cloud.
69+
You should also set `ml.connection.port` to 443 for connecting to Progress Data Cloud.
6970

7071
### Configuring certificate authentication
7172

7273
Certificate authentication requires the following properties to be configured:
7374

75+
- `ml.connection.securityContextType=CERTIFICATE`
7476
- `ml.connection.certFile` = path to a PKCS12 certificate file
7577
- `ml.connection.certPassword` = password for the PKCS12 certificate file
7678

7779
### Configuring Kerberos authentication
7880

7981
Kerberos authentication requires the following property to be configured:
8082

83+
- `ml.connection.securityContextType=KERBEROS`
8184
- `ml.connection.externalName` = the name of the principal to be used in Kerberos authentication
8285

8386
### Configuring no authentication

src/main/java/com/marklogic/kafka/connect/MarkLogicConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class MarkLogicConfig extends AbstractConfig {
3535
public static final String SSL_HOST_VERIFIER = "ml.connection.customSsl.hostNameVerifier";
3636
public static final String SSL_MUTUAL_AUTH = "ml.connection.customSsl.mutualAuth";
3737

38-
private static final CustomRecommenderAndValidator CONNECTION_SECURITY_CONTEXT_TYPE_RV = new CustomRecommenderAndValidator("DIGEST", "BASIC", "CERTIFICATE", "KERBEROS", "NONE");
38+
private static final CustomRecommenderAndValidator CONNECTION_SECURITY_CONTEXT_TYPE_RV = new CustomRecommenderAndValidator("DIGEST", "BASIC", "CERTIFICATE", "KERBEROS", "CLOUD", "NONE");
3939
private static final CustomRecommenderAndValidator CONNECTION_TYPE_RV = new CustomRecommenderAndValidator("DIRECT", "GATEWAY", "");
4040
private static final CustomRecommenderAndValidator SSL_HOST_VERIFIER_RV = new CustomRecommenderAndValidator("ANY", "COMMON", "STRICT");
4141

@@ -73,7 +73,7 @@ public static void addDefinitions(ConfigDef configDef) {
7373
"External name for 'KERBEROS' authentication",
7474
GROUP, -1, ConfigDef.Width.MEDIUM, "Kerberos External Name")
7575
.define(CONNECTION_CLOUD_API_KEY, Type.STRING, null, Importance.MEDIUM,
76-
"API key for connecting to MarkLogic Cloud. Should set port to 443 when connecting to MarkLogic Cloud.",
76+
"API key for connecting to Progress Data Cloud. Should set port to 443 when connecting to Progress Data Cloud.",
7777
GROUP, -1, ConfigDef.Width.MEDIUM, "Cloud API Key")
7878
.define(CONNECTION_TYPE, Type.STRING, "", CONNECTION_TYPE_RV, Importance.MEDIUM,
7979
"Set to 'GATEWAY' when the host identified by ml.connection.host is a load balancer. See https://docs.marklogic.com/guide/java/data-movement#id_26583 for more information.",

src/test/java/com/marklogic/kafka/connect/BuildDatabaseClientConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void testInvalidAuthentication() {
182182
securityContextConfig.put(MarkLogicSinkConfig.CONNECTION_SECURITY_CONTEXT_TYPE, "IncorrectValue");
183183
ConfigException ex = assertThrows(ConfigException.class, () -> MarkLogicSinkConfig.CONFIG_DEF.parse(securityContextConfig),
184184
"Should throw ConfigException when an invalid authentication type is provided.");
185-
assertEquals("Invalid value: IncorrectValue; must be one of: [DIGEST, BASIC, CERTIFICATE, KERBEROS, NONE]", ex.getMessage());
185+
assertEquals("Invalid value: IncorrectValue; must be one of: [DIGEST, BASIC, CERTIFICATE, KERBEROS, CLOUD, NONE]", ex.getMessage());
186186
}
187187

188188
@Test

src/test/java/com/marklogic/kafka/connect/sink/MarkLogicSinkConnectorConfigBuilder.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/test/java/com/marklogic/kafka/connect/source/MarkLogicSourceConnectorConfigBuilder.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/test/java/com/marklogic/kafka/connect/source/ReadRowsViaOpticDslTest.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
package com.marklogic.kafka.connect.source;
55

6+
import com.marklogic.client.ProgressDataCloudException;
67
import org.apache.kafka.connect.source.SourceRecord;
78
import org.junit.jupiter.api.Test;
89

@@ -11,9 +12,7 @@
1112
import java.util.List;
1213
import java.util.Map;
1314

14-
import static org.junit.jupiter.api.Assertions.assertEquals;
15-
import static org.junit.jupiter.api.Assertions.assertNull;
16-
import static org.junit.jupiter.api.Assertions.assertTrue;
15+
import static org.junit.jupiter.api.Assertions.*;
1716

1817
class ReadRowsViaOpticDslTest extends AbstractIntegrationSourceTest {
1918

@@ -46,6 +45,23 @@ void readFifteenAuthorsAsJson() throws InterruptedException {
4645
verifyRecordKeysAreSetToIDColumn(records);
4746
}
4847

48+
@Test
49+
void cloudAuth() {
50+
ProgressDataCloudException ex = assertThrows(ProgressDataCloudException.class, () -> startSourceTask(
51+
MarkLogicSourceConfig.CONNECTION_SECURITY_CONTEXT_TYPE, "cloud",
52+
MarkLogicSourceConfig.CONNECTION_CLOUD_API_KEY, "abc123",
53+
MarkLogicSourceConfig.DSL_QUERY, AUTHORS_ORDERED_BY_ID_OPTIC_DSL,
54+
MarkLogicSourceConfig.TOPIC, AUTHORS_TOPIC,
55+
MarkLogicSourceConfig.KEY_COLUMN, "Medical.Authors.ID"
56+
));
57+
58+
String message = ex.getMessage();
59+
assertTrue(message.contains("Unable to call token endpoint"),
60+
"We expect this test to fail because it can't talk to PDC, and that's fine. What this verifies " +
61+
"is that the user can configure the connector to talk to PDC - i.e. 'cloud' is accepted as a " +
62+
"security context type. Actual error: " + message);
63+
}
64+
4965
@Test
5066
void includeColumnTypes() throws InterruptedException {
5167
loadFifteenAuthorsIntoMarkLogic();

0 commit comments

Comments
 (0)