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

Fix old token not deleted after update #1051

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading