Skip to content

Commit 66b3242

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 66b3242

File tree

5 files changed

+26
-149
lines changed

5 files changed

+26
-149
lines changed

docs/configuring-the-connector.md

Lines changed: 6 additions & 3 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

@@ -61,7 +61,8 @@ Both digest and basic authentication require the following properties to be conf
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
6667
- `ml.connection.cloudApiKey` = the API key for authenticating with your MarkLogic Cloud instance
6768

@@ -71,13 +72,15 @@ You should also set `ml.connection.port` to 443 for connecting to MarkLogic Clou
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: 1 addition & 1 deletion
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

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)