Skip to content

Commit

Permalink
Merge pull request #1051 from dan1elt0m/fix-old-token-deletion
Browse files Browse the repository at this point in the history
Fix old token not deleted after update
  • Loading branch information
dan1elt0m authored Oct 17, 2023
2 parents ccdc3e8 + cfa72b3 commit 4737bc4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aws-lambda/src/databricks_cdk/resources/tokens/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ def create_or_update_token(properties: TokenProperties, physical_resource_id: Op
if update_token or existing_token is None:
logger.info("Creating new token")
new_token = _create_token(url, properties.comment, properties.lifetime_seconds)
# delete old token if it exists
if existing_token:
_delete_token(token_url=url, token_id=token_id)

token_id = new_token["token_info"]["token_id"]
token_value = new_token["token_value"]
Expand Down
2 changes: 2 additions & 0 deletions aws-lambda/tests/resources/tokens/test_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def test_create_token_not_exist(
)


@patch("src.databricks_cdk.resources.tokens.token._delete_token")
@patch("src.databricks_cdk.resources.tokens.token._create_token")
@patch("src.databricks_cdk.resources.tokens.token.get_existing_tokens")
@patch("src.databricks_cdk.resources.tokens.token.update_token_in_secrets_manager")
Expand All @@ -64,6 +65,7 @@ def test_create_token_already_exist(
patched_update_token_to_secrets_manager,
patched_get_existing_tokens,
patched__create_token,
patched__delete_token,
):
token_properties = TokenProperties(
token_name="test",
Expand Down

0 comments on commit 4737bc4

Please sign in to comment.