-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update renewed Jira refresh token back to the secrets store (#5324)
* Introduced PluginConfigVariable interaface to provide ability for the plugins to get access to their underlying aws secrets store member to be able to update if needed Signed-off-by: Santhosh Gandhe <[email protected]> * renewed access token and refresh tokens are now updated back in the secrets store Signed-off-by: Santhosh Gandhe <[email protected]> * better naming Signed-off-by: Santhosh Gandhe <[email protected]> * fixing the test cases based on the new PluginConfigVariable attribute used for refreshToken Signed-off-by: Santhosh Gandhe <[email protected]> * improving the coverage Signed-off-by: Santhosh Gandhe <[email protected]> * Keeping the existing values in the secret. Just updating an existing key Signed-off-by: Santhosh Gandhe <[email protected]> * Allowing secrets manager update without a key and also some additional test coverage Signed-off-by: Santhosh Gandhe <[email protected]> * isUpdatable boolean is introduced and its corresponding tests Signed-off-by: Santhosh Gandhe <[email protected]> * additional coverage Signed-off-by: Santhosh Gandhe <[email protected]> * implementing newly added method Signed-off-by: Santhosh Gandhe <[email protected]> * switching PluginConfigVariable from refreshToken to accessToken Signed-off-by: Santhosh Gandhe <[email protected]> * Only the master node is responsible for Token refresh Signed-off-by: Santhosh Gandhe <[email protected]> * Added addition parameter in the API to accept the secrets version to set that helps with enforcing idempotency while updating the secret store multiple times Signed-off-by: Santhosh Gandhe <[email protected]> * better naming Signed-off-by: Santhosh Gandhe <[email protected]> * removing setting a versionId for idempotency Signed-off-by: Santhosh Gandhe <[email protected]> * removed constructor argument to PluginConfigVariable Signed-off-by: Santhosh Gandhe <[email protected]> --------- Signed-off-by: Santhosh Gandhe <[email protected]>
- Loading branch information
Showing
28 changed files
with
753 additions
and
73 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...ava/org/opensearch/dataprepper/model/plugin/FailedToUpdatePluginConfigValueException.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,26 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
package org.opensearch.dataprepper.model.plugin; | ||
|
||
/** | ||
* Exception thrown when a secret could not be updated. | ||
* | ||
* @since 2.11 | ||
*/ | ||
public class FailedToUpdatePluginConfigValueException extends RuntimeException { | ||
|
||
public FailedToUpdatePluginConfigValueException(final String message) { | ||
super(message); | ||
} | ||
|
||
public FailedToUpdatePluginConfigValueException(final String message, Throwable e) { | ||
super(message, e); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...pi/src/main/java/org/opensearch/dataprepper/model/plugin/PluginConfigValueTranslator.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 |
---|---|---|
@@ -1,7 +1,48 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
package org.opensearch.dataprepper.model.plugin; | ||
|
||
/** | ||
* Interface for a Plugin configuration value translator. | ||
* It translates a string expression that is describing a secret store Id and secret Key in to a secretValue | ||
* extracted from corresponding secret store. | ||
* | ||
* @since 2.0 | ||
*/ | ||
|
||
public interface PluginConfigValueTranslator { | ||
/** | ||
* Translates a string expression that is describing a secret store Id and secret Key in to a secretValue | ||
* extracted from corresponding secret store. | ||
* Example expression: ${{aws_secrets:secretId:secretKey}} | ||
* | ||
* @param value the string value to translate | ||
* @return the translated object | ||
*/ | ||
Object translate(final String value); | ||
|
||
/** | ||
* Returns the prefix for this translator. | ||
* | ||
* @return the prefix for this translator | ||
*/ | ||
String getPrefix(); | ||
|
||
/** | ||
* Translates a string expression that is describing a secret store Id and secret Key in to an instance | ||
* of PluginConfigVariable with secretValue extracted from corresponding secret store. Additionally, | ||
* this PluginConfigVariable helps with updating the secret value in the secret store, if required. | ||
* Example expression: ${{aws_secrets:secretId:secretKey}} | ||
* | ||
* @param value the string value to translate | ||
* @return the translated object | ||
*/ | ||
PluginConfigVariable translateToPluginConfigVariable(final String value); | ||
} |
40 changes: 40 additions & 0 deletions
40
...epper-api/src/main/java/org/opensearch/dataprepper/model/plugin/PluginConfigVariable.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 OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
package org.opensearch.dataprepper.model.plugin; | ||
|
||
/** | ||
* Interface for a Extension Plugin configuration variable. | ||
* It gives access to the details of a defined extension variable. | ||
* | ||
* @since 2.11 | ||
*/ | ||
public interface PluginConfigVariable { | ||
|
||
/** | ||
* Returns the value of this variable. | ||
* | ||
* @return the value of this variable | ||
*/ | ||
Object getValue(); | ||
|
||
/** | ||
* If this variable is updatable, this method helps to set a new value for this variable | ||
* | ||
* @param updatedValue the new value to set | ||
*/ | ||
void setValue(Object updatedValue); | ||
|
||
/** | ||
* Returns if the variable is updatable. | ||
* | ||
* @return true if this variable is updatable, false otherwise | ||
*/ | ||
boolean isUpdatable(); | ||
} |
43 changes: 43 additions & 0 deletions
43
...org/opensearch/dataprepper/model/plugin/FailedToUpdatePluginConfigValueExceptionTest.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,43 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
package org.opensearch.dataprepper.model.plugin; | ||
|
||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.UUID; | ||
|
||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class FailedToUpdatePluginConfigValueExceptionTest extends RuntimeException { | ||
private String message; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
message = UUID.randomUUID().toString(); | ||
} | ||
|
||
@Test | ||
void testGetMessage_should_return_correct_message() { | ||
FailedToUpdatePluginConfigValueException failedToUpdateSecretException = new FailedToUpdatePluginConfigValueException(message); | ||
assertThat(failedToUpdateSecretException.getMessage(), equalTo(message)); | ||
} | ||
|
||
@Test | ||
void testGetMessage_should_return_correct_message_with_throwable() { | ||
RuntimeException cause = new RuntimeException("testException"); | ||
FailedToUpdatePluginConfigValueException failedToUpdateSecretException = new FailedToUpdatePluginConfigValueException(message, cause); | ||
assertThat(failedToUpdateSecretException.getMessage(), equalTo(message)); | ||
assertThat(failedToUpdateSecretException.getCause(), equalTo(cause)); | ||
} | ||
|
||
} |
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
Oops, something went wrong.