Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source TikTok Marketing : Access token is null #14299 #14461

Merged
merged 9 commits into from
Jul 13, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public static List<String> getSortedSecretPaths(final JsonNode spec) {
.anyMatch(field -> field.getKey().equals(JsonSecretsProcessor.AIRBYTE_SECRET_FIELD)))
.stream()
.map(JsonPaths::mapJsonSchemaPathToJsonPath)
.distinct()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a unit test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added unit tests. will attach screenshots with failed tests without this change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add in the javadoc comment that it will not return duplicates?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added javadoc

.sorted()
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class JsonSecretsProcessorTest {
private static final String ARRAY_OF_ONEOF = "array_of_oneof";
private static final String NESTED_OBJECT = "nested_object";
private static final String NESTED_ONEOF = "nested_oneof";
private static final String ONE_OF_SECRET = "oneof_secret";
private static final String ONE_OF = "oneof";
private static final String OPTIONAL_PASSWORD = "optional_password";
private static final String POSTGRES_SSH_KEY = "postgres_ssh_key";
Expand Down Expand Up @@ -334,6 +335,8 @@ private static Stream<Arguments> scenarioProvider() {
Arguments.of(NESTED_ONEOF, false),
Arguments.of(ONE_OF, true),
Arguments.of(ONE_OF, false),
Arguments.of(ONE_OF_SECRET, true),
Arguments.of(ONE_OF_SECRET, false),
Arguments.of(OPTIONAL_PASSWORD, true),
Arguments.of(OPTIONAL_PASSWORD, false),
Arguments.of(POSTGRES_SSH_KEY, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.airbyte.config.persistence.split_secrets.test_cases.ArrayTestCase;
import io.airbyte.config.persistence.split_secrets.test_cases.NestedObjectTestCase;
import io.airbyte.config.persistence.split_secrets.test_cases.NestedOneOfTestCase;
import io.airbyte.config.persistence.split_secrets.test_cases.OneOfSecretTestCase;
import io.airbyte.config.persistence.split_secrets.test_cases.OneOfTestCase;
import io.airbyte.config.persistence.split_secrets.test_cases.OptionalPasswordTestCase;
import io.airbyte.config.persistence.split_secrets.test_cases.PostgresSshKeyTestCase;
Expand Down Expand Up @@ -61,6 +62,7 @@ private static Stream<Arguments> provideTestCases() {
new SimpleTestCase(),
new NestedObjectTestCase(),
new OneOfTestCase(),
new OneOfSecretTestCase(),
new ArrayTestCase(),
new ArrayOneOfTestCase(),
new NestedOneOfTestCase(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.config.persistence.split_secrets.test_cases;

import io.airbyte.config.persistence.split_secrets.SecretCoordinate;
import io.airbyte.config.persistence.split_secrets.SecretPersistence;
import io.airbyte.config.persistence.split_secrets.SecretsHelpersTest;
import io.airbyte.config.persistence.split_secrets.SecretsTestCase;
import java.util.Map;
import java.util.function.Consumer;

public class OneOfSecretTestCase implements SecretsTestCase {

@Override
public String getName() {
return "oneof_secret";
}

@Override
public Map<SecretCoordinate, String> getFirstSecretMap() {
return Map.of(
new SecretCoordinate(PREFIX + SecretsHelpersTest.WORKSPACE_ID + SECRET + SecretsHelpersTest.UUIDS.get(0), 1), "access_token_1",
new SecretCoordinate(PREFIX + SecretsHelpersTest.WORKSPACE_ID + SECRET + SecretsHelpersTest.UUIDS.get(1), 1), "clientId_1",
new SecretCoordinate(PREFIX + SecretsHelpersTest.WORKSPACE_ID + SECRET + SecretsHelpersTest.UUIDS.get(2), 1), "client_secret_1",
new SecretCoordinate(PREFIX + SecretsHelpersTest.WORKSPACE_ID + SECRET + SecretsHelpersTest.UUIDS.get(3), 1), "refresh_token_1");
}

@Override
public Map<SecretCoordinate, String> getSecondSecretMap() {
return Map.of(
new SecretCoordinate(PREFIX + SecretsHelpersTest.WORKSPACE_ID + SECRET + SecretsHelpersTest.UUIDS.get(0), 2), "access_token_2");
}

@Override
public Consumer<SecretPersistence> getPersistenceUpdater() {
return secretPersistence -> {
secretPersistence.write(
new SecretCoordinate(PREFIX + SecretsHelpersTest.WORKSPACE_ID + SECRET + SecretsHelpersTest.UUIDS.get(0), 1),
"access_token_1");
secretPersistence.write(
new SecretCoordinate(PREFIX + SecretsHelpersTest.WORKSPACE_ID + SECRET + SecretsHelpersTest.UUIDS.get(1), 1),
"clientId_1");
secretPersistence.write(
new SecretCoordinate(PREFIX + SecretsHelpersTest.WORKSPACE_ID + SECRET + SecretsHelpersTest.UUIDS.get(2), 1),
"client_secret_1");
secretPersistence.write(
new SecretCoordinate(PREFIX + SecretsHelpersTest.WORKSPACE_ID + SECRET + SecretsHelpersTest.UUIDS.get(3), 1),
"refresh_token_1");
};
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"credentials": {
"auth_method": "oauth2.0",
"client_id" : "**********",
"client_secret": "**********",
"access_token": "**********",
"refresh_token": "**********"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$.credentials.access_token;$.credentials.client_id;$.credentials.client_secret;$.credentials.refresh_token;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"credentials": {
"auth_method": "oauth2.0",
"client_id" : "clientId_1",
"client_secret": "client_secret_1",
"access_token": "access_token_1",
"refresh_token": "refresh_token_1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"credentials": {
"auth_method": "oauth2.0",
"client_id": {
"_secret": "airbyte_workspace_e0eb0554-ffe0-4e9c-9dc0-ed7f52023eb2_secret_2c2ef2b3-259a-4e73-96d1-f56dacee2e5e_v1"
},
"client_secret": {
"_secret": "airbyte_workspace_e0eb0554-ffe0-4e9c-9dc0-ed7f52023eb2_secret_1206db5b-b968-4df1-9a76-f3fcdae7e307_v1"
},
"access_token": {
"_secret": "airbyte_workspace_e0eb0554-ffe0-4e9c-9dc0-ed7f52023eb2_secret_9eba44d8-51e7-48f1-bde2-619af0e42c22_v1"
},
"refresh_token": {
"_secret": "airbyte_workspace_e0eb0554-ffe0-4e9c-9dc0-ed7f52023eb2_secret_c03ef566-79a7-4e77-b6f3-d23d2528f25a_v1"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"type": "object",
"properties": {
"credentials": {
"title": "Authorization Method",
"type": "object",
"oneOf": [
{
"type": "object",
"title": "OAuth2.0",
"required": [
"client_id",
"client_secret",
"access_token",
"refresh_token"
],
"properties": {
"auth_method": {
"type": "string",
"const": "oauth2.0",
"enum": ["oauth2.0"],
"default": "oauth2.0",
"order": 0
},
"client_id": {
"type": "string",
"title": "Client ID",
"description": "The Client ID of your application.",
"airbyte_secret": true
},
"client_secret": {
"type": "string",
"title": "Client Secret",
"description": "The Client Secret of your application.",
"airbyte_secret": true
},
"access_token": {
"type": "string",
"title": "Access Token",
"description": "Access Token for making authenticated requests.",
"airbyte_secret": true
},
"refresh_token": {
"type": "string",
"title": "Refresh Token",
"description": "Refresh Token to renew the expired Access Token.",
"default": "",
"airbyte_secret": true
}
}
},
{
"title": "Access Token",
"type": "object",
"required": ["access_token"],
"properties": {
"auth_method": {
"type": "string",
"const": "access_token",
"enum": ["access_token"],
"default": "access_token",
"order": 0
},
"access_token": {
"type": "string",
"title": "Access Token",
"airbyte_secret": true
}
}
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"credentials": {
"auth_method": "access_token",
"access_token": "access_token_2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"credentials": {
"auth_method": "access_token",
"access_token": {
"_secret": "airbyte_workspace_e0eb0554-ffe0-4e9c-9dc0-ed7f52023eb2_secret_9eba44d8-51e7-48f1-bde2-619af0e42c22_v2"
}
}
}