Skip to content

Commit e19ff3c

Browse files
committed
Delete all secrets with the matching name/id.
This introduces two changes: (1) If there are many matches, we delete all matching secrets. Due to a previous issue, we may have many ... (2) We extract the UUID from the id string and pass it to delete_secret(). This is a workaround to something that looks like a bug in the SDK to me. Signed-off-by: Kurt Garloff <[email protected]>
1 parent 2267a49 commit e19ff3c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Tests/iaas/key-manager/check-for-key-manager.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ def _find_secret(conn: openstack.connection.Connection, secret_name_or_id: str):
6565
exception due to an unexpected microversion parameter.
6666
"""
6767
secrets = conn.key_manager.secrets()
68-
for s in secrets:
69-
if s.name == secret_name_or_id or s.id == secret_name_or_id:
70-
return s
71-
68+
return [ s for s in secrets if s.name == secret_name_or_id or s.id == secret_name_or_id ]
7269

7370
def check_key_manager_permissions(conn: openstack.connection.Connection) -> None:
7471
"""
@@ -78,9 +75,9 @@ def check_key_manager_permissions(conn: openstack.connection.Connection) -> None
7875
"""
7976
secret_name = "scs-member-role-test-secret"
8077
try:
81-
existing_secret = _find_secret(conn, secret_name)
82-
if existing_secret:
83-
conn.key_manager.delete_secret(existing_secret)
78+
existing_secrets = _find_secret(conn, secret_name)
79+
for secret in existing_secrets:
80+
conn.key_manager.delete_secret(secret.id[secret.id.rfind('/')+1:])
8481

8582
conn.key_manager.create_secret(
8683
name=secret_name,

0 commit comments

Comments
 (0)