Skip to content

Commit

Permalink
don't use MsSQLConfigBuilder.withSsl with strings, but instead proper…
Browse files Browse the repository at this point in the history
…ly named and typed methods (airbytehq#33261)
  • Loading branch information
stephane-airbyte authored and jatinyadav-cc committed Feb 26, 2024
1 parent 47651a5 commit 8565b88
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io.airbyte.cdk.integrations.standardtest.source.TestDestinationEnv;
import io.airbyte.commons.features.FeatureFlags;
import io.airbyte.commons.features.FeatureFlagsWrapper;
import java.util.Map;

public class CloudDeploymentSslEnabledMssqlSourceAcceptanceTest extends MssqlSourceAcceptanceTest {

Expand Down Expand Up @@ -38,7 +37,7 @@ protected FeatureFlags featureFlags() {
@Override
protected JsonNode getConfig() {
return testdb.integrationTestConfigBuilder()
.withSsl(Map.of("ssl_method", "encrypted_trust_server_certificate"))
.withEncrytedTrustServerCertificate()
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

import com.fasterxml.jackson.databind.JsonNode;
import io.airbyte.cdk.integrations.standardtest.source.TestDestinationEnv;
import java.util.Map;

public class SslEnabledMssqlSourceAcceptanceTest extends MssqlSourceAcceptanceTest {

@Override
protected JsonNode getConfig() {
return testdb.integrationTestConfigBuilder()
.withSsl(Map.of("ssl_method", "encrypted_trust_server_certificate"))
.withEncrytedTrustServerCertificate()
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import io.airbyte.commons.features.EnvVariableFeatureFlags;
import io.airbyte.commons.features.FeatureFlagsWrapper;
import io.airbyte.protocol.models.v0.AirbyteConnectionStatus;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
Expand Down Expand Up @@ -61,7 +60,7 @@ void testStrictSSLUnsecuredNoTunnel() throws Exception {
void testStrictSSLSecuredNoTunnel() throws Exception {
try (final var testdb = createTestDatabase()) {
final var config = testdb.testConfigBuilder()
.withSsl(Map.of("ssl_method", "encrypted_trust_server_certificate"))
.withEncrytedTrustServerCertificate()
.with("tunnel_method", ImmutableMap.builder().put("tunnel_method", "NO_TUNNEL").build())
.build();
final AirbyteConnectionStatus actual = source().check(config);
Expand All @@ -77,7 +76,7 @@ void testStrictSSLSecuredWithTunnel() throws Exception {
.withDatabase()
.with(JdbcUtils.USERNAME_KEY, testdb.getUserName())
.with(JdbcUtils.PASSWORD_KEY, "fake")
.withSsl(Map.of("ssl_method", "encrypted_trust_server_certificate"))
.withEncrytedTrustServerCertificate()
.with("tunnel_method", ImmutableMap.builder().put("tunnel_method", "SSH_KEY_AUTH").build())
.build();
final AirbyteConnectionStatus actual = source().check(config);
Expand All @@ -94,7 +93,7 @@ void testStrictSSLUnsecuredWithTunnel() throws Exception {
.withDatabase()
.with(JdbcUtils.USERNAME_KEY, testdb.getUserName())
.with(JdbcUtils.PASSWORD_KEY, "fake")
.withSsl(Map.of("ssl_method", "encrypted_trust_server_certificate"))
.withEncrytedTrustServerCertificate()
.with("tunnel_method", ImmutableMap.builder().put("tunnel_method", "SSH_KEY_AUTH").build())
.build();
final AirbyteConnectionStatus actual = source().check(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,26 @@ public MsSQLConfigBuilder withoutSsl() {
return withSsl(Map.of("ssl_method", "unencrypted"));
}

@Override
@Deprecated
public MsSQLConfigBuilder withSsl(Map<Object, Object> sslMode) {
return with("ssl_method", sslMode);
}

public MsSQLConfigBuilder withEncrytedTrustServerCertificate() {
return withSsl(Map.of("ssl_method", "encrypted_trust_server_certificate"));
}

public MsSQLConfigBuilder withEncrytedVerifyServerCertificate(String certificate, String hostnameInCertificate) {
if (hostnameInCertificate != null) {
return withSsl(Map.of("ssl_method", "encrypted_verify_certificate",
"certificate", certificate,
"hostNameInCertificate", hostnameInCertificate));
} else {
return withSsl(Map.of("ssl_method", "encrypted_verify_certificate",
"certificate", certificate));
}
}

}

}

0 comments on commit 8565b88

Please sign in to comment.