Ensure credential updates properly merge values.
Previously updating the credentials would delete values from the existing crednetials if they weren't also present in the update. This adds a method for merging credentials to the KeyVaultCredentials model and adds tests to both the cloud provider and model.
This commit is contained in:
@@ -100,6 +100,26 @@ def test_KeyVaultCredentials_enforce_root_creds():
|
||||
)
|
||||
|
||||
|
||||
def test_KeyVaultCredentials_merge_credentials():
|
||||
old_secret = KeyVaultCredentials(
|
||||
tenant_id="foo",
|
||||
tenant_admin_username="bar",
|
||||
tenant_admin_password="baz", # pragma: allowlist secret
|
||||
)
|
||||
new_secret = KeyVaultCredentials(
|
||||
tenant_id="foo", tenant_sp_client_id="bip", tenant_sp_key="bop"
|
||||
)
|
||||
|
||||
expected_update = KeyVaultCredentials(
|
||||
tenant_id="foo",
|
||||
tenant_admin_username="bar",
|
||||
tenant_admin_password="baz", # pragma: allowlist secret
|
||||
tenant_sp_client_id="bip",
|
||||
tenant_sp_key="bop",
|
||||
)
|
||||
assert old_secret.merge_credentials(new_secret) == expected_update
|
||||
|
||||
|
||||
user_payload = {
|
||||
"tenant_id": "123",
|
||||
"display_name": "Han Solo",
|
||||
|
Reference in New Issue
Block a user