-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝 Destination bigquery: mark service account as required for cloud (#…
…12768) * Update spec * Update doc * Bump version and update changelog * Modify wording * Add sample service account key json * Add screenshots and common permission issues * Refactor service account helper method * Update log message * Update version date in changelog * auto-bump connector version * auto-bump connector version Co-authored-by: Octavia Squidington III <[email protected]>
- Loading branch information
Showing
10 changed files
with
172 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,18 @@ | |
package io.airbyte.integrations.destination.bigquery; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.google.common.collect.ImmutableMap; | ||
import io.airbyte.commons.json.Jsons; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
@@ -29,30 +34,51 @@ public void init() { | |
|
||
@ParameterizedTest | ||
@MethodSource("validBigQueryIdProvider") | ||
public void testGetDatasetIdSuccess(String projectId, String datasetId, String expected) throws Exception { | ||
JsonNode config = Jsons.jsonNode(configMapBuilder | ||
public void testGetDatasetIdSuccess(final String projectId, final String datasetId, final String expected) { | ||
final JsonNode config = Jsons.jsonNode(configMapBuilder | ||
.put(BigQueryConsts.CONFIG_PROJECT_ID, projectId) | ||
.put(BigQueryConsts.CONFIG_DATASET_ID, datasetId) | ||
.build()); | ||
|
||
String actual = BigQueryUtils.getDatasetId(config); | ||
final String actual = BigQueryUtils.getDatasetId(config); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("invalidBigQueryIdProvider") | ||
public void testGetDatasetIdFail(String projectId, String datasetId, String expected) throws Exception { | ||
JsonNode config = Jsons.jsonNode(configMapBuilder | ||
public void testGetDatasetIdFail(final String projectId, final String datasetId, final String expected) { | ||
final JsonNode config = Jsons.jsonNode(configMapBuilder | ||
.put(BigQueryConsts.CONFIG_PROJECT_ID, projectId) | ||
.put(BigQueryConsts.CONFIG_DATASET_ID, datasetId) | ||
.build()); | ||
|
||
Exception exception = assertThrows(IllegalArgumentException.class, () -> BigQueryUtils.getDatasetId(config)); | ||
final Exception exception = assertThrows(IllegalArgumentException.class, () -> BigQueryUtils.getDatasetId(config)); | ||
|
||
assertEquals(expected, exception.getMessage()); | ||
} | ||
|
||
@Test | ||
public void testIsUsingJsonCredentials() { | ||
// empty | ||
final JsonNode emptyConfig = Jsons.jsonNode(Collections.emptyMap()); | ||
assertFalse(BigQueryUtils.isUsingJsonCredentials(emptyConfig)); | ||
|
||
// empty text | ||
final JsonNode emptyTextConfig = Jsons.jsonNode(Map.of(BigQueryConsts.CONFIG_CREDS, "")); | ||
assertFalse(BigQueryUtils.isUsingJsonCredentials(emptyTextConfig)); | ||
|
||
// non-empty text | ||
final JsonNode nonEmptyTextConfig = Jsons.jsonNode( | ||
Map.of(BigQueryConsts.CONFIG_CREDS, "{ \"service_account\": \"[email protected]\" }")); | ||
assertTrue(BigQueryUtils.isUsingJsonCredentials(nonEmptyTextConfig)); | ||
|
||
// object | ||
final JsonNode objectConfig = Jsons.jsonNode(Map.of( | ||
BigQueryConsts.CONFIG_CREDS, Jsons.jsonNode(Map.of("service_account", "[email protected]")))); | ||
assertTrue(BigQueryUtils.isUsingJsonCredentials(objectConfig)); | ||
} | ||
|
||
private static Stream<Arguments> validBigQueryIdProvider() { | ||
return Stream.of( | ||
Arguments.arguments("my-project", "my_dataset", "my_dataset"), | ||
|
Oops, something went wrong.