-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Replaced List with Set in order to avoid credentials loosing for case when we have multiple options with the same key on spec * returned back List to save the order of fields, added distinct() to have a unique path values * clean up * [14299] Source TikTok Marketing : Access token is null added unit tests * [14299] Source TikTok Marketing : Access token is null updated javadoc * Format Co-authored-by: Tuhai Maksym <[email protected]> Co-authored-by: Benoit Moriceau <[email protected]>
- Loading branch information
1 parent
f412716
commit c308c2f
Showing
11 changed files
with
186 additions
and
2 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
54 changes: 54 additions & 0 deletions
54
...test/java/io/airbyte/config/persistence/split_secrets/test_cases/OneOfSecretTestCase.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,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"); | ||
}; | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
airbyte-config/config-persistence/src/test/resources/oneof_secret/expected.json
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,9 @@ | ||
{ | ||
"credentials": { | ||
"auth_method": "oauth2.0", | ||
"client_id": "**********", | ||
"client_secret": "**********", | ||
"access_token": "**********", | ||
"refresh_token": "**********" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
airbyte-config/config-persistence/src/test/resources/oneof_secret/expectedPaths
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 @@ | ||
$.credentials.access_token;$.credentials.client_id;$.credentials.client_secret;$.credentials.refresh_token; |
9 changes: 9 additions & 0 deletions
9
airbyte-config/config-persistence/src/test/resources/oneof_secret/full_config.json
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,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" | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
airbyte-config/config-persistence/src/test/resources/oneof_secret/partial_config.json
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,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" | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
airbyte-config/config-persistence/src/test/resources/oneof_secret/spec.json
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,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 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
airbyte-config/config-persistence/src/test/resources/oneof_secret/update_config.json
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,6 @@ | ||
{ | ||
"credentials": { | ||
"auth_method": "access_token", | ||
"access_token": "access_token_2" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...yte-config/config-persistence/src/test/resources/oneof_secret/updated_partial_config.json
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,8 @@ | ||
{ | ||
"credentials": { | ||
"auth_method": "access_token", | ||
"access_token": { | ||
"_secret": "airbyte_workspace_e0eb0554-ffe0-4e9c-9dc0-ed7f52023eb2_secret_9eba44d8-51e7-48f1-bde2-619af0e42c22_v2" | ||
} | ||
} | ||
} |