-
-
Notifications
You must be signed in to change notification settings - Fork 89
Azure Key Vault: Don't load disabled secret #578
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
Azure Key Vault: Don't load disabled secret #578
Conversation
Thanks @AndreuCodina for the PR. Could you please add a test for |
If I don't mock |
You are mocking expected_secrets = [
type('', (), {'name': 'SqlServerUser', 'enabled': True}),
type('', (), {'name': 'SqlServer--Password', 'enabled': True}),
] You can add a new test and change the |
I tried that, but I get this: {'SqlServerPassword': 'SecretValue', 'DisabledSqlServerPassword': 'SecretValue'} This is the test: def test_do_not_load_disabled_secrets(self, mocker: MockerFixture) -> None:
class AzureKeyVaultSettings(BaseSettings):
"""AzureKeyVault settings."""
SqlServerPassword: str
DisabledSqlServerPassword: str
expected_secrets = [
type('', (), {'name': 'SqlServerPassword', 'enabled': True}),
type('', (), {'name': 'DisabledSqlServerPassword', 'enabled': False}),
]
mocker.patch(
f'{AzureKeyVaultSettingsSource.__module__}.{SecretClient.list_properties_of_secrets.__qualname__}',
return_value=expected_secrets,
)
mocker.patch(
f'{AzureKeyVaultSettingsSource.__module__}.{SecretClient.get_secret.__qualname__}',
return_value=KeyVaultSecret(SecretProperties(), 'SecretValue'),
)
obj = AzureKeyVaultSettingsSource(
AzureKeyVaultSettings, 'https://my-resource.vault.azure.net/', DefaultAzureCredential()
)
settings = obj()
assert 'SqlServerPassword' in settings
assert 'DisabledSqlServerPassword' not in settings |
You need to change
to |
Thanks @AndreuCodina |
No description provided.