Skip to content

Commit

Permalink
feat(destination-mssql-v2,bulk-cdk): add ssl restriction (#52147)
Browse files Browse the repository at this point in the history
Co-authored-by: Octavia Squidington III <[email protected]>
  • Loading branch information
gosusnp and octavia-squidington-iii authored Jan 30, 2025
1 parent 2858945 commit 926f13d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package io.airbyte.cdk.load.command

import io.airbyte.cdk.ConfigErrorException
import io.airbyte.cdk.ConnectorErrorException
import io.airbyte.cdk.command.ConfigurationSpecification

interface DestinationConfigurationFactory<
Expand All @@ -15,6 +16,8 @@ interface DestinationConfigurationFactory<
fun make(spec: I): O =
try {
makeWithoutExceptionHandling(spec)
} catch (e: ConnectorErrorException) {
throw e
} catch (e: Exception) {
// Wrap NPEs (mostly) in ConfigErrorException.
throw ConfigErrorException("Failed to build ConnectorConfiguration.", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package io.airbyte.integrations.destination.mssql.v2.config

import io.airbyte.cdk.ConfigErrorException
import io.airbyte.cdk.command.FeatureFlag
import io.airbyte.cdk.load.command.DestinationConfiguration
import io.airbyte.cdk.load.command.DestinationConfigurationFactory
import io.micronaut.context.annotation.Factory
Expand All @@ -24,9 +26,18 @@ data class MSSQLConfiguration(
}

@Singleton
class MSSQLConfigurationFactory :
class MSSQLConfigurationFactory(private val featureFlags: Set<FeatureFlag>) :
DestinationConfigurationFactory<MSSQLSpecification, MSSQLConfiguration> {

constructor() : this(emptySet())

override fun makeWithoutExceptionHandling(pojo: MSSQLSpecification): MSSQLConfiguration {
if (
pojo.sslMethod is Unencrypted &&
featureFlags.contains(FeatureFlag.AIRBYTE_CLOUD_DEPLOYMENT)
) {
throw ConfigErrorException("Connection from Airbyte Cloud requires SSL encryption")
}
return makeWithOverrides(spec = pojo)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.airbyte.integrations.destination.mssql.v2

import io.airbyte.cdk.command.FeatureFlag
import io.airbyte.cdk.load.check.CheckIntegrationTest
import io.airbyte.cdk.load.check.CheckTestConfig
import io.airbyte.integrations.destination.mssql.v2.config.MSSQLSpecification
Expand All @@ -15,9 +16,17 @@ internal class MSSQLCheckTest :
listOf(
CheckTestConfig(MSSQLTestConfigUtil.getConfigPath("check/valid.json")),
CheckTestConfig(MSSQLTestConfigUtil.getConfigPath("check/valid-ssl-trust.json")),
CheckTestConfig(
MSSQLTestConfigUtil.getConfigPath("check/valid-ssl-trust.json"),
setOf(FeatureFlag.AIRBYTE_CLOUD_DEPLOYMENT),
),
),
failConfigFilenamesAndFailureReasons =
mapOf(
CheckTestConfig(
MSSQLTestConfigUtil.getConfigPath("check/valid.json"),
setOf(FeatureFlag.AIRBYTE_CLOUD_DEPLOYMENT),
) to "Airbyte Cloud requires SSL encryption".toPattern(),
CheckTestConfig(
MSSQLTestConfigUtil.getConfigPath("check/fail-internal-schema-invalid.json")
) to "\"iamnotthere\" either does not exist".toPattern(),
Expand Down

0 comments on commit 926f13d

Please sign in to comment.