-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Bmoric/add fetch source schema in oauth"" (#19513)
* Revert "Revert "Bmoric/add fetch source schema in oauth (#19392)" (#19512)" This reverts commit f08b84f. * Fix complete OAuth * Use var
- Loading branch information
1 parent
373771e
commit 414518f
Showing
8 changed files
with
339 additions
and
51 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
215 changes: 166 additions & 49 deletions
215
airbyte-server/src/main/java/io/airbyte/server/handlers/OAuthHandler.java
Large diffs are not rendered by default.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
airbyte-server/src/main/java/io/airbyte/server/handlers/helpers/OAuthPathExtractor.java
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.handlers.helpers; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class OAuthPathExtractor { | ||
|
||
private static final String PROPERTIES = "properties"; | ||
private static final String PATH_IN_CONNECTOR_CONFIG = "path_in_connector_config"; | ||
|
||
public static Map<String, List<String>> extractOauthConfigurationPaths(final JsonNode configuration) { | ||
|
||
if (configuration.has(PROPERTIES) && configuration.get(PROPERTIES).isObject()) { | ||
final Map<String, List<String>> result = new HashMap<>(); | ||
|
||
configuration.get(PROPERTIES).fields().forEachRemaining(entry -> { | ||
final JsonNode value = entry.getValue(); | ||
if (value.isObject() && value.has(PATH_IN_CONNECTOR_CONFIG) && value.get(PATH_IN_CONNECTOR_CONFIG).isArray()) { | ||
final List<String> path = new ArrayList<>(); | ||
for (final JsonNode pathPart : value.get(PATH_IN_CONNECTOR_CONFIG)) { | ||
path.add(pathPart.textValue()); | ||
} | ||
result.put(entry.getKey(), path); | ||
} | ||
}); | ||
|
||
return result; | ||
} else { | ||
return new HashMap<>(); | ||
} | ||
} | ||
|
||
} |
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
44 changes: 44 additions & 0 deletions
44
airbyte-server/src/test/java/io/airbyte/server/handlers/helper/OAuthPathExtractorTest.java
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.handlers.helper; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.server.handlers.helpers.OAuthPathExtractor; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class OAuthPathExtractorTest { | ||
|
||
@Test | ||
void testExtract() { | ||
final JsonNode input = Jsons.deserialize(""" | ||
{ | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"tenant_id": { | ||
"type": "string", | ||
"path_in_connector_config": ["tenant_id"] | ||
}, | ||
"another_property": { | ||
"type": "string", | ||
"path_in_connector_config": ["another", "property"] | ||
} | ||
} | ||
} | ||
"""); | ||
|
||
final Map<String, List<String>> expected = Map.ofEntries( | ||
Map.entry("tenant_id", List.of("tenant_id")), | ||
Map.entry("another_property", List.of("another", "property"))); | ||
|
||
Assertions.assertThat(OAuthPathExtractor.extractOauthConfigurationPaths(input)) | ||
.containsExactlyInAnyOrderEntriesOf(expected); | ||
} | ||
|
||
} |
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