Skip to content

Commit

Permalink
add test for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
yurii-bidiuk committed Apr 22, 2022
1 parent 2df0c1f commit 5d58623
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ protected StandardCheckConnectionOutput runCheck() throws Exception {
.run(new StandardCheckConnectionInput().withConnectionConfiguration(getConfig()), jobRoot);
}

protected String runCheckAndGetStatusAsString(JsonNode config) throws Exception {
return new DefaultCheckConnectionWorker(
workerConfigs,
new AirbyteIntegrationLauncher(JOB_ID, JOB_ATTEMPT, getImageName(), processFactory, workerConfigs.getResourceRequirements()))
.run(new StandardCheckConnectionInput().withConnectionConfiguration(config), jobRoot).getStatus().toString();
}

protected AirbyteCatalog runDiscover() throws Exception {
return new DefaultDiscoverCatalogWorker(
workerConfigs,
Expand Down
3 changes: 2 additions & 1 deletion airbyte-integrations/connectors/source-snowflake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"database": "AIRBYTE_DATABASE",
"schema": "AIRBYTE_SCHEMA",
"credentails" {
"auth_type": "username/password",
"username": "AIRBYTE_USER",
"password": "SOMEPASSWORD"
}
Expand All @@ -28,7 +29,7 @@
"database": "AIRBYTE_DATABASE",
"schema": "AIRBYTE_SCHEMA",
"credentails" {
"auth_type": "Client",
"auth_type": "OAuth",
"client_id": "client_id",
"client_secret": "client_secret",
"refresh_token": "refresh_token"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

package io.airbyte.integrations.io.airbyte.integration_tests.sources;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Lists;
import io.airbyte.commons.io.IOs;
import io.airbyte.commons.json.Jsons;
Expand All @@ -26,6 +29,7 @@
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Test;

public class SnowflakeSourceAcceptanceTest extends SourceAcceptanceTest {

Expand Down Expand Up @@ -133,4 +137,15 @@ protected JdbcDatabase setupDataBase() {
"database", config.get("database").asText()));
}

@Test
public void testBackwardCompatibilityAfterAddingOauth() throws Exception {
final JsonNode deprecatedStyleConfig = Jsons.clone(config);
final JsonNode password = deprecatedStyleConfig.get("credentials").get("password");

((ObjectNode) deprecatedStyleConfig).remove("credentials");
((ObjectNode) deprecatedStyleConfig).set("password", password);

assertEquals("SUCCEEDED", runCheckAndGetStatusAsString(deprecatedStyleConfig).toUpperCase());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ protected Database setupDatabase() throws Exception {

private Database getDatabase() {
return Databases.createDatabase(
config.get("username").asText(),
config.get("password").asText(),
config.get("credentials").get("username").asText(),
config.get("credentials").get("password").asText(),
String.format("jdbc:snowflake://%s/",
config.get("host").asText()),
SnowflakeSource.DRIVER_CLASS,
Expand Down

0 comments on commit 5d58623

Please sign in to comment.