From 0b71864d4c7116fe908fd6bb36f5db1b31c6bbb8 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 11:47:58 -0700 Subject: [PATCH 001/129] Adding azure-appconfiguration-provider --- sdk/appconfiguration/azure-appconfiguration-provider | 1 + 1 file changed, 1 insertion(+) create mode 160000 sdk/appconfiguration/azure-appconfiguration-provider diff --git a/sdk/appconfiguration/azure-appconfiguration-provider b/sdk/appconfiguration/azure-appconfiguration-provider new file mode 160000 index 000000000000..ff1e84bacc32 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider @@ -0,0 +1 @@ +Subproject commit ff1e84bacc3284af077d6935beda70b9509a9e7f From 95e8f80c0293f55ae51de19baf53358de2192018 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 11:51:31 -0700 Subject: [PATCH 002/129] Fixing repo issue --- .../appconfiguration-provider/CHANGELOG.md | 20 ++++ .../appconfiguration-provider/LICENSE | 21 ++++ .../appconfiguration-provider/MANIFEST.in | 7 ++ .../appconfiguration-provider/README.md | 91 +++++++++++++++ .../azure/__init__.py | 1 + .../appconfigurationprovider/__init__.py | 22 ++++ .../_azureappconfigurationkeyvaultoptions.py | 14 +++ .../_azureappconfigurationprovider.py | 107 ++++++++++++++++++ .../_settingselector.py | 10 ++ .../appconfigurationprovider/_user_agent.py | 11 ++ .../appconfigurationprovider/_version.py | 6 + .../dev_requirements.txt | 6 + .../appconfiguration-provider/mypy.ini | 12 ++ .../sdk_packaging.toml | 9 ++ .../appconfiguration-provider/setup.py | 78 +++++++++++++ .../azure-appconfiguration-provider | 1 - 16 files changed, 415 insertions(+), 1 deletion(-) create mode 100644 sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md create mode 100644 sdk/appconfiguration/appconfiguration-provider/LICENSE create mode 100644 sdk/appconfiguration/appconfiguration-provider/MANIFEST.in create mode 100644 sdk/appconfiguration/appconfiguration-provider/README.md create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/__init__.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt create mode 100644 sdk/appconfiguration/appconfiguration-provider/mypy.ini create mode 100644 sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml create mode 100644 sdk/appconfiguration/appconfiguration-provider/setup.py delete mode 160000 sdk/appconfiguration/azure-appconfiguration-provider diff --git a/sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md b/sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md new file mode 100644 index 000000000000..1683e32f84f2 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md @@ -0,0 +1,20 @@ +# Release History + +## 1.0.0b1 (Unreleased) + +New Azure App Configuration Provider + +Provides additional support above the Azure App Configuration SDK. Enables: +* Connecting to an Azure App Configuration store +* Selecting multiple keys using Setting Selector +* Resove Key Vault References when supplied AzureAppConfigurationKeyVaultOptions + +The Azure App Configuration Provider once loaded returns a dictionary of key/value pairs to use in configuration. + +```python +endpoint = "https://.azconfig.io" +default_credential = DefaultAzureCredential() +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=default_credential) +print(config["message"]) +``` \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/LICENSE b/sdk/appconfiguration/appconfiguration-provider/LICENSE new file mode 100644 index 000000000000..63447fd8bbbf --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/MANIFEST.in b/sdk/appconfiguration/appconfiguration-provider/MANIFEST.in new file mode 100644 index 000000000000..731abed60dd1 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/MANIFEST.in @@ -0,0 +1,7 @@ +recursive-include tests *.py +include *.md +include LICENSE +include azure/__init__.py +recursive-include samples *.py *.md +recursive-include doc *.rst +include azure/appconfiguration/py.typed \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/README.md b/sdk/appconfiguration/appconfiguration-provider/README.md new file mode 100644 index 000000000000..7620d7478d0f --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/README.md @@ -0,0 +1,91 @@ +# Azure App Configuration Python Provider + +Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. This provider adds additional functionality above the azure-sdk-for-pyton. + +Using the provider enables loading sets of configurations from a Azure App Configuration store in a managed way. + +## Getting started + +### Get credentials + +Use the [Azure CLI][azure_cli] snippet below to get the connection string from the Configuration Store. + +```Powershell +az appconfig credential list --name +``` + +Alternatively, get the connection string from the Azure Portal. + +### Creating a provider + +You can create a client with a connection string: + +```python +config = AzureAppConfigurationProvider.load(connection_string="your-connection-string") +``` + +or with AAD: + +```python +config = AzureAppConfigurationProvider.load(endpoint="your-endpoint", credential=DefaultAzureCredential()) +``` + +these providers will by default load all configurations with `(No Label)` from your configuration store. + +### Selecting configurations + +You can refine or expand the configurations loaded from your store by using `SettingSelector`s. Setting selectors provide a way to pass a key filter and label filter into the provider. + +```python +selects = {SettingSelector(key_filter="*", label_filter="\0"), SettingSelector(key_filter="*", label_filter="dev")} +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=default_credential, selects=selects) +``` +In this example all configuration with empty label and the dev label are loaded. Because the dev selector is listed last, any configurations from dev take priority over those with `(No Label)` when duplicates are found. + +### Trimming Keys + +You can trim the prefix off of keys by providing a list of trimmed key prefixes to the provider. + +```python +trimmed_key_prefixes={"/application/"} +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=default_credential, trimmed_key_prefixes=trimmed_key_prefixes) +``` + +### Resolving Key Vault References + +Key Vault References can be resolved by providing credentials to your key vault to the provider using `AzureAppConfigurationKeyVaultOptions`. + +#### With Credentials + +You can provide `AzureAppConfigurationKeyVaultOptions` with a credential and all key vault references will be resolved with it. The provider will attempt to connect to any key vault referenced with the credential provided. + +```python +key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=default_credential) +config = AzureAppConfigurationProvider.load(endpoint=endpoint, credential=default_credential, key_vault_options=key_vault_options) +``` +### With Clients + +You can provide `AzureAppConfigurationKeyVaultOptions` with a list of `SecretClients`. + +```python +key_vault_options = AzureAppConfigurationKeyVaultOptions( + secret_clients={SecretClient( + vault_url=key_vault_uri, credential=default_credential)}) +config = AzureAppConfigurationProvider.load(endpoint=endpoint, credential=default_credential, key_vault_options=key_vault_options) +``` + +### Secret Resolver + +If no Credentials or Clients are provided a secret resolver can be used. Secret resolver provides a way to return any value you want to a key vault reference. + +```python +def secret_resolver(uri): + return "From Secret Resolver" + +key_vault_options = AzureAppConfigurationKeyVaultOptions( + secret_resolver=secret_resolver) +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=default_credential, key_vault_options=key_vault_options) +``` \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/__init__.py b/sdk/appconfiguration/appconfiguration-provider/azure/__init__.py new file mode 100644 index 000000000000..d19ce0e399ec --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py new file mode 100644 index 000000000000..5691dba68be6 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from ._azureappconfigurationprovider import AzureAppConfigurationProvider +from ._azureappconfigurationkeyvaultoptions import AzureAppConfigurationKeyVaultOptions +from ._settingselector import SettingSelector + +from ._version import VERSION + +__version__ = VERSION +__all__ = [ + "AzureAppConfigurationProvider", + "AzureAppConfigurationKeyVaultOptions", + "SettingSelector" +] diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py new file mode 100644 index 000000000000..40fd4814704b --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -0,0 +1,14 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +class AzureAppConfigurationKeyVaultOptions: + + def __init__(self, credential=None, secret_clients=None, secret_resolver=None): + """ + credential, secret_clients (clients for connecting to multiple key vaults with different credentials), secret_resolver + """ + self.credential = credential + self.secret_clients = secret_clients + self.secret_resolver = secret_resolver diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py new file mode 100644 index 000000000000..5ec32d0d3e5a --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -0,0 +1,107 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +from azure.appconfiguration import AzureAppConfigurationClient +from azure.keyvault.secrets import SecretClient +from ._settingselector import SettingSelector +from urllib.parse import urlparse +import json + + +class AzureAppConfigurationProvider: + + @classmethod + def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): + """ + Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration settings into itself for usage. + Optional parameters: + selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not specified, all key-values with the empty label will be loaded. + trimmed_key_prefixes (remove prefixes in key name, list of what to trim), + key_vault_options (Configurations for connecting to Key Vault(s)) test + """ + provider = AzureAppConfigurationProvider() + + if (connection_string is not None): + provider.client = AzureAppConfigurationClient.from_connection_string( + connection_string) + else: + provider.client = AzureAppConfigurationClient(endpoint, credential) + + selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) + provider.trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) + key_vault_options = kwargs.pop("key_vault_options", None) + pipeline = kwargs.pop("pipeline") + + provider.dict = {} + + for select in selects: + configurations = provider.client.list_configuration_settings( + key_filter=select.key_filter, label_filter=select.label_filter) + for config in configurations: + if (config.content_type is None): + # Deals with possible null value via Rest API + provider.dict[provider.trim(config.key)] = config.value + elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": + jObject = json.loads(config.value) + uriValue = jObject['uri'] + + uri = urlparse(uriValue) + + key_vault_uri = "https://" + uri.hostname + key_vault_secret_prefix = "/secrets/" + key_vault_secret_name = uri.path[len( + key_vault_secret_prefix):] + if (key_vault_options.credential is not None): + secret_client = SecretClient( + vault_url=key_vault_uri, credential=key_vault_options.credential) + secret = secret_client.get_secret( + key_vault_secret_name) + provider.dict[provider.trim(config.key)] = secret.value + continue + if (key_vault_options.secret_clients is not None): + for secret_client in key_vault_options.secret_clients: + if (secret_client._vault_url == key_vault_uri): + secret = secret_client.get_secret( + key_vault_secret_name) + provider.dict[provider.trim( + config.key)] = secret.value + break + continue + if (key_vault_options.secret_resolver is not None): + provider.dict[provider.trim( + config.key)] = key_vault_options.secret_resolver(uri) + elif "application/json" in config.content_type: + jObject = json.loads(config.value) + provider.dict[provider.trim(config.key)] = jObject + else: + provider.dict[provider.trim(config.key)] = config.value + return provider + + def trim(self, key): + for trim in self.trim_prefixes: + if key.startswith(trim): + return key[len(trim):] + return key + + def __getitem__(self, key): + return self.dict[key] + + def __repr__(self): + return repr(self.dict) + + def __len__(self): + return len(self.dict) + + def copy(self): + return self.dict.copy() + + def has_key(self, k): + return k in self.dict + + def keys(self): + return self.dict.keys() + + def values(self): + return self.dict.values() diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py new file mode 100644 index 000000000000..fa87c4531384 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py @@ -0,0 +1,10 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +class SettingSelector: + + def __init__(self, key_filter, label_filter): + self.key_filter = key_filter + self.label_filter = label_filter \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py new file mode 100644 index 000000000000..7f4dc03a8fdc --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py @@ -0,0 +1,11 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +import platform +from ._version import VERSION +from azure.appconfiguration._version import VERSION as SDK_VERSION + +USER_AGENT = "python-appconfigurationprovider/{} azsdk-python-appconfiguration/{} Python/{} ({})".format( + VERSION, SDK_VERSION, platform.python_version(), platform.platform() +) diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py new file mode 100644 index 000000000000..ac9f392f513e --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py @@ -0,0 +1,6 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +VERSION = "1.0.0b1" diff --git a/sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt new file mode 100644 index 000000000000..b0d3f64b6dbd --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt @@ -0,0 +1,6 @@ +-e ../../../tools/azure-devtools +../../core/azure-core +-e ../../identity/azure-identity +aiohttp>=3.0 +-e ../../../tools/azure-sdk-tools +-e ../../../tools/azure-devtools \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/mypy.ini b/sdk/appconfiguration/appconfiguration-provider/mypy.ini new file mode 100644 index 000000000000..a90acaba8d0e --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/mypy.ini @@ -0,0 +1,12 @@ +[mypy] +python_version = 3.6 +warn_unused_configs = True +ignore_missing_imports = True + +# Per-module options: + +[mypy-azure.appconfiguration._generated.*] +ignore_errors = True + +[mypy-azure.core.*] +ignore_errors = True \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml new file mode 100644 index 000000000000..1f3da94f6908 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-app-configuration-provider" +package_nspkg = "azure-data-nspkg" +package_pprint_name = "App Configuration Provider" +package_doc_id = "" +is_stable = false +is_arm = false +need_msrestazure = false +auto_update = false \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/setup.py b/sdk/appconfiguration/appconfiguration-provider/setup.py new file mode 100644 index 000000000000..25fd47fd9d69 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/setup.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +import sys +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-appconfigurationprovider" +PACKAGE_PPRINT_NAME = "App Configuration Provider" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace("-", ".") + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: + version = re.search( + r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE + ).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + +with open("README.md", encoding="utf-8") as f: + readme = f.read() +with open("CHANGELOG.md", encoding="utf-8") as f: + changelog = f.read() + +exclude_packages = [ + "tests", + "tests.*", + "samples", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", +] +if sys.version_info < (3, 5, 3): + exclude_packages.extend(["*.aio", "*.aio.*"]) + +setup( + name=PACKAGE_NAME, + version=version, + include_package_data=True, + description="Microsoft {} Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration-provider", + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages(exclude=exclude_packages), + python_requires=">=3.6", + install_requires=[ + "msrest>=0.6.10", + "azure-core<2.0.0,>=1.2.2", + ], +) \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider b/sdk/appconfiguration/azure-appconfiguration-provider deleted file mode 160000 index ff1e84bacc32..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration-provider +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ff1e84bacc3284af077d6935beda70b9509a9e7f From 7085b9340dd2aa93d2b77fa9849a94fa2ca19d4e Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 11:52:10 -0700 Subject: [PATCH 003/129] Fixing repo issue --- .../CHANGELOG.md | 0 .../LICENSE | 0 .../MANIFEST.in | 0 .../README.md | 0 .../azure/__init__.py | 0 .../azure/appconfigurationprovider/__init__.py | 0 .../_azureappconfigurationkeyvaultoptions.py | 0 .../appconfigurationprovider/_azureappconfigurationprovider.py | 2 +- .../azure/appconfigurationprovider/_settingselector.py | 0 .../azure/appconfigurationprovider/_user_agent.py | 0 .../azure/appconfigurationprovider/_version.py | 0 .../dev_requirements.txt | 0 .../mypy.ini | 0 .../sdk_packaging.toml | 0 .../setup.py | 0 15 files changed, 1 insertion(+), 1 deletion(-) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/CHANGELOG.md (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/LICENSE (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/MANIFEST.in (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/README.md (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/__init__.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/__init__.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/_azureappconfigurationprovider.py (99%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/_settingselector.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/_user_agent.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/_version.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/dev_requirements.txt (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/mypy.ini (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/sdk_packaging.toml (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/setup.py (100%) diff --git a/sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md rename to sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md diff --git a/sdk/appconfiguration/appconfiguration-provider/LICENSE b/sdk/appconfiguration/azure-appconfiguration-provider/LICENSE similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/LICENSE rename to sdk/appconfiguration/azure-appconfiguration-provider/LICENSE diff --git a/sdk/appconfiguration/appconfiguration-provider/MANIFEST.in b/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/MANIFEST.in rename to sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in diff --git a/sdk/appconfiguration/appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/README.md rename to sdk/appconfiguration/azure-appconfiguration-provider/README.md diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py similarity index 99% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 5ec32d0d3e5a..fa251c6b66f2 100644 --- a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -19,7 +19,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): Optional parameters: selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not specified, all key-values with the empty label will be loaded. trimmed_key_prefixes (remove prefixes in key name, list of what to trim), - key_vault_options (Configurations for connecting to Key Vault(s)) test + key_vault_options (Configurations for connecting to Key Vault(s)) """ provider = AzureAppConfigurationProvider() diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py diff --git a/sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt rename to sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt diff --git a/sdk/appconfiguration/appconfiguration-provider/mypy.ini b/sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/mypy.ini rename to sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini diff --git a/sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml rename to sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml diff --git a/sdk/appconfiguration/appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/setup.py rename to sdk/appconfiguration/azure-appconfiguration-provider/setup.py From 2c49e9d199b81725263eb8af5559ade2d662f888 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 13:49:28 -0700 Subject: [PATCH 004/129] Updated to setup user agent and header info --- .../_azureappconfigurationprovider.py | 45 ++++++++++++++----- .../appconfigurationprovider/_user_agent.py | 4 +- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index fa251c6b66f2..a689f017a46e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -6,6 +6,7 @@ from azure.appconfiguration import AzureAppConfigurationClient from azure.keyvault.secrets import SecretClient from ._settingselector import SettingSelector +from ._user_agent import USER_AGENT from urllib.parse import urlparse import json @@ -14,25 +15,23 @@ class AzureAppConfigurationProvider: @classmethod def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): - """ - Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration settings into itself for usage. - Optional parameters: - selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not specified, all key-values with the empty label will be loaded. - trimmed_key_prefixes (remove prefixes in key name, list of what to trim), + """ + Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration settings into itself for usage. + Optional parameters: + selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not specified, all key-values with the empty label will be loaded. + trimmed_key_prefixes (remove prefixes in key name, list of what to trim), key_vault_options (Configurations for connecting to Key Vault(s)) """ + provider = AzureAppConfigurationProvider() - if (connection_string is not None): - provider.client = AzureAppConfigurationClient.from_connection_string( - connection_string) - else: - provider.client = AzureAppConfigurationClient(endpoint, credential) + key_vault_options = kwargs.pop("key_vault_options", None) + + provider.client = cls.buildprovider( + connection_string, endpoint, credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) provider.trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) - key_vault_options = kwargs.pop("key_vault_options", None) - pipeline = kwargs.pop("pipeline") provider.dict = {} @@ -79,6 +78,28 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider.dict[provider.trim(config.key)] = config.value return provider + def buildprovider(connection_string, endpoint, credential, key_vault_options): + usesKeyVault = False + + if (key_vault_options is not None and (key_vault_options.credential is not None or key_vault_options.secret_clients is not None or key_vault_options.secret_resolver is not None)): + usesKeyVault = True + + headers = {} + correlationcontext = "RequestType=Startup" + + if (usesKeyVault): + correlationcontext += ",UsesKeyVault" + + headers["Correlation-Context"] = correlationcontext + useragent = USER_AGENT + + if (connection_string is not None): + return AzureAppConfigurationClient.from_connection_string( + connection_string, user_agent=useragent, headers=headers) + else: + return AzureAppConfigurationClient( + endpoint, credential, user_agent=useragent, headers=headers) + def trim(self, key): for trim in self.trim_prefixes: if key.startswith(trim): diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py index 7f4dc03a8fdc..66023530ce56 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py @@ -6,6 +6,6 @@ from ._version import VERSION from azure.appconfiguration._version import VERSION as SDK_VERSION -USER_AGENT = "python-appconfigurationprovider/{} azsdk-python-appconfiguration/{} Python/{} ({})".format( - VERSION, SDK_VERSION, platform.python_version(), platform.platform() +USER_AGENT = "python-appconfigurationprovider/{}".format( + VERSION ) From c6895e947cf47e9e42cb641e86c61e828aae551f Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 14:04:19 -0700 Subject: [PATCH 005/129] Updating to cache secret_clients --- .../_azureappconfigurationprovider.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index a689f017a46e..66d062f335fb 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -22,7 +22,6 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): trimmed_key_prefixes (remove prefixes in key name, list of what to trim), key_vault_options (Configurations for connecting to Key Vault(s)) """ - provider = AzureAppConfigurationProvider() key_vault_options = kwargs.pop("key_vault_options", None) @@ -34,6 +33,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider.trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) provider.dict = {} + secret_clients = {} for select in selects: configurations = provider.client.list_configuration_settings( @@ -53,8 +53,17 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_secret_name = uri.path[len( key_vault_secret_prefix):] if (key_vault_options.credential is not None): - secret_client = SecretClient( - vault_url=key_vault_uri, credential=key_vault_options.credential) + secret_client = None + + # Clients only should be made once, will reuse if client already made + for client_uri in secret_clients: + if client_uri == key_vault_uri: + secret_client = secret_clients[client_uri] + break + if (secret_client is None): + secret_client = SecretClient( + vault_url=key_vault_uri, credential=key_vault_options.credential) + secret_clients[key_vault_uri] = secret_client secret = secret_client.get_secret( key_vault_secret_name) provider.dict[provider.trim(config.key)] = secret.value From 9f1cc57e14d5bb595bcf81802b0303bbd04582f4 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 14:05:47 -0700 Subject: [PATCH 006/129] Fixed Naming --- .../_azureappconfigurationprovider.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 66d062f335fb..580ce3cf4e62 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -43,10 +43,10 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): # Deals with possible null value via Rest API provider.dict[provider.trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": - jObject = json.loads(config.value) - uriValue = jObject['uri'] + j_object = json.loads(config.value) + uri_value = j_object['uri'] - uri = urlparse(uriValue) + uri = urlparse(uri_value) key_vault_uri = "https://" + uri.hostname key_vault_secret_prefix = "/secrets/" @@ -81,8 +81,8 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider.dict[provider.trim( config.key)] = key_vault_options.secret_resolver(uri) elif "application/json" in config.content_type: - jObject = json.loads(config.value) - provider.dict[provider.trim(config.key)] = jObject + j_object = json.loads(config.value) + provider.dict[provider.trim(config.key)] = j_object else: provider.dict[provider.trim(config.key)] = config.value return provider @@ -94,12 +94,12 @@ def buildprovider(connection_string, endpoint, credential, key_vault_options): usesKeyVault = True headers = {} - correlationcontext = "RequestType=Startup" + correlation_context = "RequestType=Startup" if (usesKeyVault): - correlationcontext += ",UsesKeyVault" + correlation_context += ",UsesKeyVault" - headers["Correlation-Context"] = correlationcontext + headers["Correlation-Context"] = correlation_context useragent = USER_AGENT if (connection_string is not None): From 9a86e7bb30368fd572b845506290af3354dc6142 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 14:19:27 -0700 Subject: [PATCH 007/129] Fixed Typo --- sdk/appconfiguration/azure-appconfiguration-provider/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index 7620d7478d0f..7e69f0e95f8a 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -1,6 +1,6 @@ # Azure App Configuration Python Provider -Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. This provider adds additional functionality above the azure-sdk-for-pyton. +Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. This provider adds additional functionality above the azure-sdk-for-python. Using the provider enables loading sets of configurations from a Azure App Configuration store in a managed way. From 5e3d40990a607a6f301d2c6012be52213539b140 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 1 Sep 2022 12:14:50 -0700 Subject: [PATCH 008/129] Added Samples, Fixed issue with Key Vault Options not set when secret is in store. --- .../_azureappconfigurationprovider.py | 5 ++ .../samples/README.md | 56 +++++++++++++++++++ .../samples/aad_sample.py | 30 ++++++++++ .../samples/connection_string_sample.py | 28 ++++++++++ .../samples/key_vault_reference_sample.py | 17 ++++++ 5 files changed, 136 insertions(+) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 580ce3cf4e62..cba7499bfab2 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -9,6 +9,7 @@ from ._user_agent import USER_AGENT from urllib.parse import urlparse import json +import warnings class AzureAppConfigurationProvider: @@ -43,6 +44,10 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): # Deals with possible null value via Rest API provider.dict[provider.trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": + if (key_vault_options is None): + warnings.warn( + "Key Vault Reference found, but no Key Vault Options were provided") + continue j_object = json.loads(config.value) uri_value = j_object['uri'] diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md new file mode 100644 index 000000000000..868bfaa7f3b7 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md @@ -0,0 +1,56 @@ +--- +page_type: sample +languages: + - python +products: + - azure + - azure-app-configuration +--- + +# Azure App Configuration Provider Library Python Samples + +## Prerequisites + +You must have an [Azure subscription][azure_sub], and a [Configuration Store][configuration_store] to use this package. + +To create a Configuration Store, you can either use [Azure Portal](https://ms.portal.azure.com/#create/Microsoft.Azconfig) or if you are using [Azure CLI][azure_cli] you can simply run the following snippet in your console: + +```Powershell +az appconfig create --name --resource-group --location eastus +``` + +### Create Keys + +```Powershell +az appconfig kv set --name --key message --value "hi" +az appconfig kv set --name --key test.message --value "Hi with test Prefix" +``` + +### Create Key Vault Reference + +Requires Key Vault with Secret already created. + +```Powershell +az appconfig kv set-keyvault --name --key secret --secret-identifier +``` + +## Setup + +Install the Azure App Configuration Provider client library for Python with pip: + +```commandline +pip install azure-appconfiguration-provider +``` + +## Contents + +| File | Description | +|-------------|-------------| +| aad_sample.py | demos connecting to app configuration with Azure Active Directory | +| connection_string_sample.py | demos connecting to app configuration with a Connection String | +| key_vault_reference_sample.py | demos resovling key vault references with App Configuration | + + +[azure_sub]: https://azure.microsoft.com/free/ +[azure_cli]: https://docs.microsoft.com/cli/azure +[configuration_store]: https://azure.microsoft.com/services/app-configuration/ \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py new file mode 100644 index 000000000000..ccafa1db1622 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -0,0 +1,30 @@ +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + SettingSelector +) +from azure.identity import DefaultAzureCredential +import os + +endpoint = os.environ.get("AZURE_APPCONFIG_ENDPOINT") +credential = DefaultAzureCredential() + +# Connecting to Azure App Configuration using AAD +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=credential) + +print(config["message"]) + +# Connecting to Azure App Configuration using AAD and trimmed key prefixes +trimmed = {"test."} +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=credential, trimmed_key_prefixes=trimmed) + +print(config["message"]) + +# Connection to Azure App Configuration using SettingSelector +selects = {SettingSelector("message*", "\0")} +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=credential, selects=selects) + +print("message found: " + str(config.has_key("message"))) +print("test.message found: " + str(config.has_key("config.message"))) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py new file mode 100644 index 000000000000..6d6aa21d3441 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -0,0 +1,28 @@ +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + SettingSelector +) +import os + +connection_string = os.environ.get("AZURE_APPCONFIG_CONNECTION_STRING") + +# Connecting to Azure App Configuration using connection string +config = AzureAppConfigurationProvider.load( + connection_string=connection_string) + +print(config["message"]) + +# Connecting to Azure App Configuration using connection string and trimmed key prefixes +trimmed = {"test."} +config = AzureAppConfigurationProvider.load( + connection_string=connection_string, trimmed_key_prefixes=trimmed) + +print(config["message"]) + +# Connection to Azure App Configuration using SettingSelector +selects = {SettingSelector("message*", "\0")} +config = AzureAppConfigurationProvider.load( + connection_string=connection_string, selects=selects) + +print("message found: " + str(config.has_key("message"))) +print("test.message found: " + str(config.has_key("config.message"))) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py new file mode 100644 index 000000000000..0f516de7dff3 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -0,0 +1,17 @@ +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + AzureAppConfigurationKeyVaultOptions, + SettingSelector +) +from azure.identity import DefaultAzureCredential +import os + +endpoint = os.environ.get("AZURE_APPCONFIG_ENDPOINT") +credential = DefaultAzureCredential() + +# Connection to Azure App Configuration using AAD and Resolving Key Vault References +key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=credential) +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=credential, key_vault_options=key_vault_options) + +print(config["secret"]) From 6ac7714fa9499f581c984a16e401e6ad9af018bd Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 2 Sep 2022 11:22:20 -0700 Subject: [PATCH 009/129] Fixed SP, Dependency, and Pylint issues --- .../CHANGELOG.md | 2 +- .../azure/__init__.py | 3 +- .../_azureappconfigurationkeyvaultoptions.py | 4 +- .../_azureappconfigurationprovider.py | 38 ++++++++++--------- .../_settingselector.py | 2 +- .../appconfigurationprovider/_user_agent.py | 2 - .../samples/README.md | 2 +- .../azure-appconfiguration-provider/setup.py | 4 +- 8 files changed, 29 insertions(+), 28 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md index 1683e32f84f2..c3f16119c9f4 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md @@ -7,7 +7,7 @@ New Azure App Configuration Provider Provides additional support above the Azure App Configuration SDK. Enables: * Connecting to an Azure App Configuration store * Selecting multiple keys using Setting Selector -* Resove Key Vault References when supplied AzureAppConfigurationKeyVaultOptions +* Resolve Key Vault References when supplied AzureAppConfigurationKeyVaultOptions The Azure App Configuration Provider once loaded returns a dictionary of key/value pairs to use in configuration. diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py index d19ce0e399ec..229d1b3c8804 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py @@ -1 +1,2 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore \ No newline at end of file +__path__ = __import__("pkgutil").extend_path( + __path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 40fd4814704b..bb4a75da8fae 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -6,8 +6,8 @@ class AzureAppConfigurationKeyVaultOptions: def __init__(self, credential=None, secret_clients=None, secret_resolver=None): - """ - credential, secret_clients (clients for connecting to multiple key vaults with different credentials), secret_resolver + """ + credential, secret_clients (clients for connecting to multiple key vaults with different credentials), secret_resolver """ self.credential = credential self.secret_clients = secret_clients diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index cba7499bfab2..1966c0480e0a 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -3,13 +3,13 @@ # Licensed under the MIT License. # ------------------------------------ +from urllib.parse import urlparse +import json +import warnings from azure.appconfiguration import AzureAppConfigurationClient from azure.keyvault.secrets import SecretClient from ._settingselector import SettingSelector from ._user_agent import USER_AGENT -from urllib.parse import urlparse -import json -import warnings class AzureAppConfigurationProvider: @@ -17,9 +17,11 @@ class AzureAppConfigurationProvider: @classmethod def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): """ - Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration settings into itself for usage. + Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration + settings into itself for usage. Optional parameters: - selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not specified, all key-values with the empty label will be loaded. + selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not + specified, all key-values with the empty label will be loaded. trimmed_key_prefixes (remove prefixes in key name, list of what to trim), key_vault_options (Configurations for connecting to Key Vault(s)) """ @@ -40,11 +42,11 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): configurations = provider.client.list_configuration_settings( key_filter=select.key_filter, label_filter=select.label_filter) for config in configurations: - if (config.content_type is None): + if config.content_type is None: # Deals with possible null value via Rest API provider.dict[provider.trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": - if (key_vault_options is None): + if key_vault_options is None: warnings.warn( "Key Vault Reference found, but no Key Vault Options were provided") continue @@ -57,7 +59,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_secret_prefix = "/secrets/" key_vault_secret_name = uri.path[len( key_vault_secret_prefix):] - if (key_vault_options.credential is not None): + if key_vault_options.credential is not None: secret_client = None # Clients only should be made once, will reuse if client already made @@ -65,7 +67,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): if client_uri == key_vault_uri: secret_client = secret_clients[client_uri] break - if (secret_client is None): + if secret_client is None: secret_client = SecretClient( vault_url=key_vault_uri, credential=key_vault_options.credential) secret_clients[key_vault_uri] = secret_client @@ -73,7 +75,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_secret_name) provider.dict[provider.trim(config.key)] = secret.value continue - if (key_vault_options.secret_clients is not None): + if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: if (secret_client._vault_url == key_vault_uri): secret = secret_client.get_secret( @@ -82,7 +84,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): config.key)] = secret.value break continue - if (key_vault_options.secret_resolver is not None): + if key_vault_options.secret_resolver is not None: provider.dict[provider.trim( config.key)] = key_vault_options.secret_resolver(uri) elif "application/json" in config.content_type: @@ -92,27 +94,27 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider.dict[provider.trim(config.key)] = config.value return provider - def buildprovider(connection_string, endpoint, credential, key_vault_options): + def buildprovider(self, connection_string, endpoint, credential, key_vault_options): usesKeyVault = False - if (key_vault_options is not None and (key_vault_options.credential is not None or key_vault_options.secret_clients is not None or key_vault_options.secret_resolver is not None)): + if (key_vault_options is not None and + (key_vault_options.credential is not None or key_vault_options.secret_clients is not None or + key_vault_options.secret_resolver is not None)): usesKeyVault = True headers = {} correlation_context = "RequestType=Startup" - if (usesKeyVault): + if usesKeyVault: correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context useragent = USER_AGENT - if (connection_string is not None): + if connection_string is not None: return AzureAppConfigurationClient.from_connection_string( connection_string, user_agent=useragent, headers=headers) - else: - return AzureAppConfigurationClient( - endpoint, credential, user_agent=useragent, headers=headers) + return AzureAppConfigurationClient(endpoint, credential, user_agent=useragent, headers=headers) def trim(self, key): for trim in self.trim_prefixes: diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py index fa87c4531384..d9b94fedd914 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py @@ -7,4 +7,4 @@ class SettingSelector: def __init__(self, key_filter, label_filter): self.key_filter = key_filter - self.label_filter = label_filter \ No newline at end of file + self.label_filter = label_filter diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py index 66023530ce56..43eedb9b9551 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py @@ -2,9 +2,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ -import platform from ._version import VERSION -from azure.appconfiguration._version import VERSION as SDK_VERSION USER_AGENT = "python-appconfigurationprovider/{}".format( VERSION diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md index 868bfaa7f3b7..881144ea7209 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md @@ -48,7 +48,7 @@ pip install azure-appconfiguration-provider |-------------|-------------| | aad_sample.py | demos connecting to app configuration with Azure Active Directory | | connection_string_sample.py | demos connecting to app configuration with a Connection String | -| key_vault_reference_sample.py | demos resovling key vault references with App Configuration | +| key_vault_reference_sample.py | demos resolving key vault references with App Configuration | [azure_sub]: https://azure.microsoft.com/free/ diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 25fd47fd9d69..69b8c100699f 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -72,7 +72,7 @@ packages=find_packages(exclude=exclude_packages), python_requires=">=3.6", install_requires=[ - "msrest>=0.6.10", + "msrest>=0.6.21", "azure-core<2.0.0,>=1.2.2", ], -) \ No newline at end of file +) From 649e6fd8da7225987ee0e21886d0597778c2cbee Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 2 Sep 2022 12:03:12 -0700 Subject: [PATCH 010/129] Fixed more lint issues, moved key vault references to be a method --- .../azure-appconfiguration-provider/README.md | 34 ++++- .../_azureappconfigurationkeyvaultoptions.py | 3 +- .../_azureappconfigurationprovider.py | 129 ++++++++++-------- 3 files changed, 103 insertions(+), 63 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index 7e69f0e95f8a..ecf48ea1c197 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -1,4 +1,4 @@ -# Azure App Configuration Python Provider +# Azure App Configuration Python Provider client library for Python Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. This provider adds additional functionality above the azure-sdk-for-python. @@ -32,6 +32,8 @@ config = AzureAppConfigurationProvider.load(endpoint="your-endpoint", credential these providers will by default load all configurations with `(No Label)` from your configuration store. +## Examples + ### Selecting configurations You can refine or expand the configurations loaded from your store by using `SettingSelector`s. Setting selectors provide a way to pass a key filter and label filter into the provider. @@ -88,4 +90,32 @@ key_vault_options = AzureAppConfigurationKeyVaultOptions( secret_resolver=secret_resolver) config = AzureAppConfigurationProvider.load( endpoint=endpoint, credential=default_credential, key_vault_options=key_vault_options) -``` \ No newline at end of file +``` + +## Key concepts + +## Troubleshooting + +## Next steps + +## Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, +see the Code of Conduct FAQ or contact opencode@microsoft.com with any +additional questions or comments. + +[cla]: https://cla.microsoft.com +[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ +[coc_contact]: mailto:opencode@microsoft.com \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index bb4a75da8fae..2abc44a7bfd1 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -7,7 +7,8 @@ class AzureAppConfigurationKeyVaultOptions: def __init__(self, credential=None, secret_clients=None, secret_resolver=None): """ - credential, secret_clients (clients for connecting to multiple key vaults with different credentials), secret_resolver + credential, secret_clients (clients for connecting to multiple key vaults with different credentials), + secret_resolver """ self.credential = credential self.secret_clients = secret_clients diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 1966c0480e0a..1f6d2bfba9fb 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -14,14 +14,19 @@ class AzureAppConfigurationProvider: + def __init__(self): + self._dict = {} + self._trim_prefixes = [] + self.client = None + @classmethod def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): """ - Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration - settings into itself for usage. + Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration + settings into itself for usage. Optional parameters: - selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not - specified, all key-values with the empty label will be loaded. + selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not + specified, all key-values with the empty label will be loaded. trimmed_key_prefixes (remove prefixes in key name, list of what to trim), key_vault_options (Configurations for connecting to Key Vault(s)) """ @@ -29,69 +34,30 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_options = kwargs.pop("key_vault_options", None) - provider.client = cls.buildprovider( + provider._client = provider.buildprovider( connection_string, endpoint, credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) - provider.trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) + provider._trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) - provider.dict = {} + provider._dict = {} secret_clients = {} for select in selects: - configurations = provider.client.list_configuration_settings( + configurations = provider._client.list_configuration_settings( key_filter=select.key_filter, label_filter=select.label_filter) for config in configurations: if config.content_type is None: # Deals with possible null value via Rest API - provider.dict[provider.trim(config.key)] = config.value + provider._dict[provider.trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": - if key_vault_options is None: - warnings.warn( - "Key Vault Reference found, but no Key Vault Options were provided") - continue - j_object = json.loads(config.value) - uri_value = j_object['uri'] - - uri = urlparse(uri_value) - - key_vault_uri = "https://" + uri.hostname - key_vault_secret_prefix = "/secrets/" - key_vault_secret_name = uri.path[len( - key_vault_secret_prefix):] - if key_vault_options.credential is not None: - secret_client = None - - # Clients only should be made once, will reuse if client already made - for client_uri in secret_clients: - if client_uri == key_vault_uri: - secret_client = secret_clients[client_uri] - break - if secret_client is None: - secret_client = SecretClient( - vault_url=key_vault_uri, credential=key_vault_options.credential) - secret_clients[key_vault_uri] = secret_client - secret = secret_client.get_secret( - key_vault_secret_name) - provider.dict[provider.trim(config.key)] = secret.value - continue - if key_vault_options.secret_clients is not None: - for secret_client in key_vault_options.secret_clients: - if (secret_client._vault_url == key_vault_uri): - secret = secret_client.get_secret( - key_vault_secret_name) - provider.dict[provider.trim( - config.key)] = secret.value - break - continue - if key_vault_options.secret_resolver is not None: - provider.dict[provider.trim( - config.key)] = key_vault_options.secret_resolver(uri) + provider.resolve_keyvault_references( + config, key_vault_options, secret_clients) elif "application/json" in config.content_type: j_object = json.loads(config.value) - provider.dict[provider.trim(config.key)] = j_object + provider._dict[provider.trim(config.key)] = j_object else: - provider.dict[provider.trim(config.key)] = config.value + provider._dict[provider.trim(config.key)] = config.value return provider def buildprovider(self, connection_string, endpoint, credential, key_vault_options): @@ -116,29 +82,72 @@ def buildprovider(self, connection_string, endpoint, credential, key_vault_optio connection_string, user_agent=useragent, headers=headers) return AzureAppConfigurationClient(endpoint, credential, user_agent=useragent, headers=headers) + def resolve_keyvault_references(self, config, key_vault_options, secret_clients): + if key_vault_options is None: + warnings.warn( + "Key Vault Reference found, but no Key Vault Options were provided") + return + j_object = json.loads(config.value) + uri_value = j_object['uri'] + + uri = urlparse(uri_value) + + key_vault_uri = "https://" + uri.hostname + key_vault_secret_prefix = "/secrets/" + key_vault_secret_name = uri.path[len( + key_vault_secret_prefix):] + if key_vault_options.credential is not None: + secret_client = None + + # Clients only should be made once, will reuse if client already made + for client_uri in secret_clients: + if client_uri == key_vault_uri: + secret_client = secret_clients[client_uri] + break + if secret_client is None: + secret_client = SecretClient( + vault_url=key_vault_uri, credential=key_vault_options.credential) + secret_clients[key_vault_uri] = secret_client + secret = secret_client.get_secret( + key_vault_secret_name) + self._dict[self.trim(config.key)] = secret.value + return + if key_vault_options.secret_clients is not None: + for secret_client in key_vault_options.secret_clients: + if secret_client._vault_url == key_vault_uri: + secret = secret_client.get_secret( + key_vault_secret_name) + self._dict[self.trim( + config.key)] = secret.value + break + return + if key_vault_options.secret_resolver is not None: + self._dict[self.trim( + config.key)] = key_vault_options.secret_resolver(uri) + def trim(self, key): - for trim in self.trim_prefixes: + for trim in self._trim_prefixes: if key.startswith(trim): return key[len(trim):] return key def __getitem__(self, key): - return self.dict[key] + return self._dict[key] def __repr__(self): - return repr(self.dict) + return repr(self._dict) def __len__(self): - return len(self.dict) + return len(self._dict) def copy(self): - return self.dict.copy() + return self._dict.copy() def has_key(self, k): - return k in self.dict + return k in self._dict def keys(self): - return self.dict.keys() + return self._dict.keys() def values(self): - return self.dict.values() + return self._dict.values() From ffd2d62b64e553f283e81b52f99b7e9e3914da2b Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 2 Sep 2022 12:38:37 -0700 Subject: [PATCH 011/129] More Linting fixes --- .../_azureappconfigurationkeyvaultoptions.py | 4 ++-- .../_azureappconfigurationprovider.py | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 2abc44a7bfd1..ea1349260759 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -7,8 +7,8 @@ class AzureAppConfigurationKeyVaultOptions: def __init__(self, credential=None, secret_clients=None, secret_resolver=None): """ - credential, secret_clients (clients for connecting to multiple key vaults with different credentials), - secret_resolver + credential, secret_clients (clients for connecting to multiple key vaults with different credentials), + secret_resolver """ self.credential = credential self.secret_clients = secret_clients diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 1f6d2bfba9fb..65cc1e427699 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -17,7 +17,7 @@ class AzureAppConfigurationProvider: def __init__(self): self._dict = {} self._trim_prefixes = [] - self.client = None + self._client = None @classmethod def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): @@ -34,8 +34,8 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_options = kwargs.pop("key_vault_options", None) - provider._client = provider.buildprovider( - connection_string, endpoint, credential, key_vault_options) + provider.buildprovider(connection_string, endpoint, + credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) provider._trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) @@ -78,9 +78,11 @@ def buildprovider(self, connection_string, endpoint, credential, key_vault_optio useragent = USER_AGENT if connection_string is not None: - return AzureAppConfigurationClient.from_connection_string( + self._client = AzureAppConfigurationClient.from_connection_string( connection_string, user_agent=useragent, headers=headers) - return AzureAppConfigurationClient(endpoint, credential, user_agent=useragent, headers=headers) + return + self._client = AzureAppConfigurationClient( + endpoint, credential, user_agent=useragent, headers=headers) def resolve_keyvault_references(self, config, key_vault_options, secret_clients): if key_vault_options is None: From 84dd7703a73fc992cdfc3f584c7ec64d5d44d98b Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 2 Sep 2022 12:57:27 -0700 Subject: [PATCH 012/129] Fixing dependency issues with build --- .../azure-appconfiguration-provider/dev_requirements.txt | 1 + sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt index b0d3f64b6dbd..adab992bf639 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt +++ b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt @@ -1,5 +1,6 @@ -e ../../../tools/azure-devtools ../../core/azure-core +-e ../azure-appconfiguration -e ../../identity/azure-identity aiohttp>=3.0 -e ../../../tools/azure-sdk-tools diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 69b8c100699f..e6826bfacd68 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -74,5 +74,8 @@ install_requires=[ "msrest>=0.6.21", "azure-core<2.0.0,>=1.2.2", + "azure-appconfiguration<2.0.0,>=1.1.1", + "azure-identity<2.0.0,>=1.4.0", + "azure-keyvault-secrets<5.0.0,>=4.0.0", ], ) From 31d2318a5ef4ca3c9c99db6d0827beba535ca75b Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 9 Sep 2022 13:45:18 -0700 Subject: [PATCH 013/129] Updated Docs. Fixed extra code for Key Vault Usage. Updated Readme to include a list of features and future features. Added Clients sample for Key Vault. --- .../azure-appconfiguration-provider/README.md | 20 +++++ .../appconfigurationprovider/__init__.py | 10 +-- .../_azureappconfigurationkeyvaultoptions.py | 23 ++++-- .../_azureappconfigurationprovider.py | 79 ++++++++++++------- .../_settingselector.py | 17 +++- .../appconfigurationprovider/_user_agent.py | 10 ++- .../appconfigurationprovider/_version.py | 9 ++- .../samples/aad_sample.py | 6 ++ .../samples/connection_string_sample.py | 6 ++ ...vault_reference_provided_clients_sample.py | 26 ++++++ .../samples/key_vault_reference_sample.py | 9 ++- 11 files changed, 159 insertions(+), 56 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index ecf48ea1c197..f9f0229d33c5 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -32,6 +32,26 @@ config = AzureAppConfigurationProvider.load(endpoint="your-endpoint", credential these providers will by default load all configurations with `(No Label)` from your configuration store. +### Features + +Currently the Azure App Configuration Provider enables: + +* Connecting to an App Configuration Store using a connection string or Azure Active Directory. +* Selecting multiple sets of configurations using `SettingSelector`. +* Trim prefixes off key names. +* Resolving Key Vault References, requires AAD. +* Secret Resolver, resolve Key Vault References locally without connecting to Key Vault. +* Json Content Type + +#### Future Features + +List of features we are going to add to the Python Provider in the future. + +* Geo-Replication support +* Feature Management +* Dynamic Refresh +* Configuration Placeholders + ## Examples ### Selecting configurations diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py index 5691dba68be6..1ef7efc3de32 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py @@ -1,13 +1,9 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- +# ------------------------------------------------------------------------ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- +# ------------------------------------------------------------------------- + from ._azureappconfigurationprovider import AzureAppConfigurationProvider from ._azureappconfigurationkeyvaultoptions import AzureAppConfigurationKeyVaultOptions from ._settingselector import SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index ea1349260759..976eafeaea98 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -1,15 +1,22 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- class AzureAppConfigurationKeyVaultOptions: + """ + Options for connecting to Key Vault. + :param credential: A credential for authenticating with the key vault. This is optional if secret_clients is provided. + :type credential: ~azure.core.credentials.TokenCredential + :param secret_clients: A list of SecretClient from azure-keyvault-secrets. This is optional if credential is provided. + :type secret_clients: list[~azure.keyvault.secrets.SecretClient] + :param secret_resolver: A function that takes a URI and returns a value. + :type secret_resolver: callable + """ def __init__(self, credential=None, secret_clients=None, secret_resolver=None): - """ - credential, secret_clients (clients for connecting to multiple key vaults with different credentials), - secret_resolver - """ + # type: (TokenCredential, List[SecretClient], Callable) -> None self.credential = credential self.secret_clients = secret_clients self.secret_resolver = secret_resolver diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 65cc1e427699..f9101f791746 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- from urllib.parse import urlparse import json @@ -13,8 +14,14 @@ class AzureAppConfigurationProvider: + """ + Provides a dictionary-like interface to Azure App Configuration settings. Enables loading of sets of configuration + settings from Azure App Configuration into a Python application. Enables trimming of prefixes from configuration + keys. Enables resolution of Key Vault references in configuration settings. + """ def __init__(self): + # type: () -> None self._dict = {} self._trim_prefixes = [] self._client = None @@ -22,20 +29,26 @@ def __init__(self): @classmethod def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): """ - Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration - settings into itself for usage. - Optional parameters: - selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not - specified, all key-values with the empty label will be loaded. - trimmed_key_prefixes (remove prefixes in key name, list of what to trim), - key_vault_options (Configurations for connecting to Key Vault(s)) + Loads configuration settings from Azure App Configuration into a Python application. + :param connection_string: Connection string (one of connection_string or endpoint and credential must be set) + :type connection_string: str + :param endpoint: Endpoint (one of connection_string or endpoint and credential must be set) + :type endpoint: str + :param credential: Credential (one of connection_string or endpoint and credential must be set) + :type credential: Union[AppConfigConnectionStringCredential, TokenCredential] + :keyword selectors: List of setting selectors to filter configuration settings + :type selectors: list[~azure.appconfigurationprovider.SettingSelector] + :keyword trim_prefixes: List of prefixes to trim from configuration keys + :type trim_prefixes: list[str] + :keyword key_vault_options: Options for resolving Key Vault references + :type key_vault_options: ~azure.appconfigurationprovider.KeyVaultOptions """ provider = AzureAppConfigurationProvider() key_vault_options = kwargs.pop("key_vault_options", None) - provider.buildprovider(connection_string, endpoint, - credential, key_vault_options) + provider.__buildprovider(connection_string, endpoint, + credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) provider._trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) @@ -51,7 +64,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): # Deals with possible null value via Rest API provider._dict[provider.trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": - provider.resolve_keyvault_references( + provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) elif "application/json" in config.content_type: j_object = json.loads(config.value) @@ -60,18 +73,13 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider._dict[provider.trim(config.key)] = config.value return provider - def buildprovider(self, connection_string, endpoint, credential, key_vault_options): - usesKeyVault = False + def __buildprovider(self, connection_string, endpoint, credential, key_vault_options): + headers = {} + correlation_context = "RequestType=Startup" if (key_vault_options is not None and (key_vault_options.credential is not None or key_vault_options.secret_clients is not None or key_vault_options.secret_resolver is not None)): - usesKeyVault = True - - headers = {} - correlation_context = "RequestType=Startup" - - if usesKeyVault: correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context @@ -84,7 +92,7 @@ def buildprovider(self, connection_string, endpoint, credential, key_vault_optio self._client = AzureAppConfigurationClient( endpoint, credential, user_agent=useragent, headers=headers) - def resolve_keyvault_references(self, config, key_vault_options, secret_clients): + def __resolve_keyvault_references(self, config, key_vault_options, secret_clients): if key_vault_options is None: warnings.warn( "Key Vault Reference found, but no Key Vault Options were provided") @@ -112,22 +120,22 @@ def resolve_keyvault_references(self, config, key_vault_options, secret_clients) secret_clients[key_vault_uri] = secret_client secret = secret_client.get_secret( key_vault_secret_name) - self._dict[self.trim(config.key)] = secret.value + self._dict[self.__trim(config.key)] = secret.value return if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: if secret_client._vault_url == key_vault_uri: secret = secret_client.get_secret( key_vault_secret_name) - self._dict[self.trim( + self._dict[self.__trim( config.key)] = secret.value break return if key_vault_options.secret_resolver is not None: - self._dict[self.trim( + self._dict[self.__trim( config.key)] = key_vault_options.secret_resolver(uri) - def trim(self, key): + def __trim(self, key): for trim in self._trim_prefixes: if key.startswith(trim): return key[len(trim):] @@ -143,13 +151,30 @@ def __len__(self): return len(self._dict) def copy(self): + """ + Returns a copy of the configuration settings + type: () -> dict + """ return self._dict.copy() def has_key(self, k): + """ + Returns True if the configuration settings has been loaded from Azure App Configuration. + type: (str) -> bool + """ return k in self._dict def keys(self): + """ + Returns a list of keys loaded from Azure App Configuration. + type: () -> list + """ return self._dict.keys() def values(self): + """ + Returns a list of values loaded from Azure App Configuration. Any values that are Key Vault references will be + resolved. + type: () -> list + """ return self._dict.values() diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py index d9b94fedd914..3dbb41231db5 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py @@ -1,10 +1,19 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- class SettingSelector: + """ + Selects a set of configuration settings from Azure App Configuration. + :param key_filter: A filter to select configuration settings based on their keys. + :type key_filter: str + :param label_filter: A filter to select configuration settings based on their labels. + :type label_filter: str + """ def __init__(self, key_filter, label_filter): + # type: (str, str) -> None self.key_filter = key_filter self.label_filter = label_filter diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py index 43eedb9b9551..b75e8a607e9f 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py @@ -1,7 +1,9 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + from ._version import VERSION USER_AGENT = "python-appconfigurationprovider/{}".format( diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py index ac9f392f513e..839ee5fc6576 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py @@ -1,6 +1,7 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- VERSION = "1.0.0b1" diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index ccafa1db1622..52ad33fe735b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -1,3 +1,9 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index 6d6aa21d3441..a9ff30c9ca21 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -1,3 +1,9 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py new file mode 100644 index 000000000000..387f42775c07 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -0,0 +1,26 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + AzureAppConfigurationKeyVaultOptions +) +from azure.keyvault.secrets import SecretClient +from azure.identity import DefaultAzureCredential +import os + +endpoint = os.environ.get("AZURE_APPCONFIG_ENDPOINT") +key_vault_uri = os.environ.get("AZURE_KEYVAULT_URI") +credential = DefaultAzureCredential() + +# Connection to Azure App Configuration using AAD with Provided Client +secret_client = SecretClient(vault_url=key_vault_uri, credential=credential) +key_vault_options = AzureAppConfigurationKeyVaultOptions(secret_clients=[ + secret_client]) +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=credential, key_vault_options=key_vault_options) + +print(config["secret"]) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index 0f516de7dff3..6fa55b7f0297 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -1,7 +1,12 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, - AzureAppConfigurationKeyVaultOptions, - SettingSelector + AzureAppConfigurationKeyVaultOptions ) from azure.identity import DefaultAzureCredential import os From 0aa7e99bc90b41e2b07b800cb0886d99d6d6b882 Mon Sep 17 00:00:00 2001 From: Matthew Metcalf Date: Fri, 9 Sep 2022 13:54:02 -0700 Subject: [PATCH 014/129] Adding Test Case, currently doesn't work --- .../tests/conftest.py | 7 +++++ .../tests/test_provider.py | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py new file mode 100644 index 000000000000..9fd3224d9530 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py @@ -0,0 +1,7 @@ +from devtools_testutils import test_proxy +import pytest + +# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method +@pytest.fixture(scope="session", autouse=True) +def start_proxy(test_proxy): + return \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py new file mode 100644 index 000000000000..aa860cdca7f4 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -0,0 +1,30 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import functools +from azure.appconfiguration import AzureAppConfigurationClient +from azure.identity import DefaultAzureCredential + +from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy + +AppConfigProviderPreparer = functools.partial( + EnvironmentVariableLoader, + "appconfiguration", + appconfiguration_connection_string="Endpoint=https://fake_app_config.azconfig-test.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=", + appconfiguration_endpoint_string="https://fake_app_config.azconfig-test.io" +) + +class TestAppConfigurationProvider(AzureRecordedTestCase): + + def buildClient(self, endpoint): + return AzureAppConfigurationClient(base_url=endpoint, credential=DefaultAzureCredential()) + + # method: provider_creation + @AppConfigProviderPreparer() + @recorded_by_proxy + def test_provider_creation(self, appconfiguration_endpoint_string): + client = self.buildClient(appconfiguration_endpoint_string) + + assert client.get_configuration_setting("message","\0") == "hi" \ No newline at end of file From 0aa91a5a11bfae76f524a9e657f79bc4e0c3b636 Mon Sep 17 00:00:00 2001 From: Matthew Metcalf Date: Mon, 19 Sep 2022 11:49:09 -0700 Subject: [PATCH 015/129] Fixing Tests --- ...urationProvidertest_provider_creation.json | 267 ++++++++++++++++++ .../tests/test_provider.py | 3 +- 2 files changed, 268 insertions(+), 2 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json new file mode 100644 index 000000000000..0dff5970b68d --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -0,0 +1,267 @@ +{ + "Entries": [ + { + "RequestUri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1753", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Ath0zAFi31FNvKANFWwF1y8; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", + "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrfWar8zX8BblDnJAKRl2Hz_-7zEPqvGMEvPEm4jaimQqfTO66wTmt9q7V3kIc3ezFdZRu3vXykHx7Bl4PfmIfQhjCk4yEqgLFhix1WaTIZlQzYXp7mkOhrDjZJ368eQ0QRAdKtduf_g3kwVBi50QHgTmWYgslpizT-dWmZ65Q39MgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13622.7 - NCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=Ath0zAFi31FNvKANFWwF1y8; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Ath0zAFi31FNvKANFWwF1y8; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13562.12 - SCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "client-request-id": "72b30cb2-f149-4eeb-a2c8-f318375aa74c", + "Connection": "keep-alive", + "Content-Length": "392", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": "fpc=Ath0zAFi31FNvKANFWwF1y8; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", + "x-client-cpu": "x64", + "x-client-current-telemetry": "4|730,0|", + "x-client-last-telemetry": "4|0|||", + "x-client-os": "win32", + "x-client-sku": "MSAL.Python", + "x-client-ver": "1.18.0", + "x-ms-lib-capability": "retry-after, h429" + }, + "RequestBody": "client_id=5b99b3ef-331b-47b1-b984-a967ab4c2623\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=Endpoint=https://fake_app_config.azconfig-test.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fpython-provider.azconfig.io%2F.default", + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-store, no-cache", + "client-request-id": "72b30cb2-f149-4eeb-a2c8-f318375aa74c", + "Content-Length": "111", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "Expires": "-1", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Pragma": "no-cache", + "Set-Cookie": [ + "fpc=Ath0zAFi31FNvKANFWwF1y8W9qlXAQAAAICzrdoOAAAA; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-clitelem": "1,0,0,,", + "x-ms-ests-server": "2.1.13622.7 - NCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_type": "Bearer", + "expires_in": 86399, + "ext_expires_in": 86399, + "refresh_in": 43199, + "access_token": "Sanitized" + } + }, + { + "RequestUri": "https://fake_app_config.azconfig-test.io/kv/message?label=%00\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kv\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kv\u002Bjson; charset=utf-8", + "Date": "Fri, 09 Sep 2022 22:21:53 GMT", + "ETag": "\u0022RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk\u0022", + "Last-Modified": "Thu, 01 Sep 2022 17:53:26 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NjoxNyMxNjY5NTQ1Mg==;sn=16695452", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "cb587955-b687-4421-8aed-c29479a5b118" + }, + "ResponseBody": { + "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", + "key": "message", + "label": null, + "content_type": "", + "value": "hi", + "tags": {}, + "locked": false, + "last_modified": "2022-09-01T17:53:26\u002B00:00" + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index aa860cdca7f4..18a64e59bbe5 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -26,5 +26,4 @@ def buildClient(self, endpoint): @recorded_by_proxy def test_provider_creation(self, appconfiguration_endpoint_string): client = self.buildClient(appconfiguration_endpoint_string) - - assert client.get_configuration_setting("message","\0") == "hi" \ No newline at end of file + assert client.get_configuration_setting(key="message",label="\0").value == "hi" \ No newline at end of file From 68e20d7f4a39cca4691ec1aa32594b3c584a65dd Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 19 Sep 2022 13:35:47 -0700 Subject: [PATCH 016/129] Fixing Trim. Fixing Typo in readme. --- .../azure-appconfiguration-provider/README.md | 2 +- .../_azureappconfigurationprovider.py | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index f9f0229d33c5..1c78189eb099 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -2,7 +2,7 @@ Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. This provider adds additional functionality above the azure-sdk-for-python. -Using the provider enables loading sets of configurations from a Azure App Configuration store in a managed way. +Using the provider enables loading sets of configurations from an Azure App Configuration store in a managed way. ## Getting started diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index f9101f791746..f668bd6bbd20 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -62,15 +62,15 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): for config in configurations: if config.content_type is None: # Deals with possible null value via Rest API - provider._dict[provider.trim(config.key)] = config.value + provider._dict[provider.__trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) elif "application/json" in config.content_type: j_object = json.loads(config.value) - provider._dict[provider.trim(config.key)] = j_object + provider._dict[provider.__trim(config.key)] = j_object else: - provider._dict[provider.trim(config.key)] = config.value + provider._dict[provider.__trim(config.key)] = config.value return provider def __buildprovider(self, connection_string, endpoint, credential, key_vault_options): @@ -94,9 +94,8 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt def __resolve_keyvault_references(self, config, key_vault_options, secret_clients): if key_vault_options is None: - warnings.warn( - "Key Vault Reference found, but no Key Vault Options were provided") - return + raise AttributeError( + "Key Vault options must be set to resolve Key Vault references.") j_object = json.loads(config.value) uri_value = j_object['uri'] @@ -118,10 +117,12 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client secret_client = SecretClient( vault_url=key_vault_uri, credential=key_vault_options.credential) secret_clients[key_vault_uri] = secret_client - secret = secret_client.get_secret( - key_vault_secret_name) - self._dict[self.__trim(config.key)] = secret.value - return + secret = secret_client.get_secret( + key_vault_secret_name) + self._dict[self.__trim(config.key)] = secret.value + return + raise AttributeError( + "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: if secret_client._vault_url == key_vault_uri: @@ -129,11 +130,13 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client key_vault_secret_name) self._dict[self.__trim( config.key)] = secret.value - break - return + return if key_vault_options.secret_resolver is not None: self._dict[self.__trim( config.key)] = key_vault_options.secret_resolver(uri) + return + raise AttributeError( + "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) def __trim(self, key): for trim in self._trim_prefixes: @@ -152,7 +155,7 @@ def __len__(self): def copy(self): """ - Returns a copy of the configuration settings + Returns a copy of the configuration settings type: () -> dict """ return self._dict.copy() From 7ca6cd309713e26ab8900fc974c6d9141de32b57 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 19 Sep 2022 13:46:56 -0700 Subject: [PATCH 017/129] Fixing Length and vault_url issues. --- .../_azureappconfigurationkeyvaultoptions.py | 6 ++++-- .../_azureappconfigurationprovider.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 976eafeaea98..9657b766143f 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -7,9 +7,11 @@ class AzureAppConfigurationKeyVaultOptions: """ Options for connecting to Key Vault. - :param credential: A credential for authenticating with the key vault. This is optional if secret_clients is provided. + :param credential: A credential for authenticating with the key vault. This is optional if secret_clients is + provided. :type credential: ~azure.core.credentials.TokenCredential - :param secret_clients: A list of SecretClient from azure-keyvault-secrets. This is optional if credential is provided. + :param secret_clients: A list of SecretClient from azure-keyvault-secrets. This is optional if credential is + provided. :type secret_clients: list[~azure.keyvault.secrets.SecretClient] :param secret_resolver: A function that takes a URI and returns a value. :type secret_resolver: callable diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index f668bd6bbd20..6222849b26fb 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -125,7 +125,7 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: - if secret_client._vault_url == key_vault_uri: + if secret_client.vault_url == key_vault_uri: secret = secret_client.get_secret( key_vault_secret_name) self._dict[self.__trim( From 2c8bb78f71fb95c35077723d005a780e26b1153a Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 11:05:36 -0700 Subject: [PATCH 018/129] Updating from code review comments --- .../azure-appconfiguration-provider/README.md | 3 +- .../_azureappconfigurationprovider.py | 96 ++++++++++++++----- .../appconfigurationprovider/_constants.py | 7 ++ .../_settingselector.py | 4 +- ...vault_reference_provided_clients_sample.py | 6 +- .../samples/key_vault_reference_sample.py | 7 +- 6 files changed, 91 insertions(+), 32 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index 1c78189eb099..f382de19a032 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -67,12 +67,13 @@ In this example all configuration with empty label and the dev label are loaded. ### Trimming Keys -You can trim the prefix off of keys by providing a list of trimmed key prefixes to the provider. +You can trim the prefix off of keys by providing a list of trimmed key prefixes to the provider. For example, if you have the key(s) like `/applicaiton/message` in your configuration store, you could trim `/application/` from them. ```python trimmed_key_prefixes={"/application/"} config = AzureAppConfigurationProvider.load( endpoint=endpoint, credential=default_credential, trimmed_key_prefixes=trimmed_key_prefixes) +print(config["message"]) ``` ### Resolving Key Vault References diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 6222849b26fb..fad3f06807c2 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -6,10 +6,14 @@ from urllib.parse import urlparse import json -import warnings from azure.appconfiguration import AzureAppConfigurationClient from azure.keyvault.secrets import SecretClient +from azure.core.exceptions import ( + HttpResponseError, + ResourceNotFoundError +) from ._settingselector import SettingSelector +from ._constants import KEY_VAULT_REFERNCE_CONTENT_TYPE from ._user_agent import USER_AGENT @@ -51,22 +55,24 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) - provider._trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) + + provider._trim_prefixes = sorted(kwargs.pop( + "trimmed_key_prefixes", []), key=len, reverse=True) provider._dict = {} secret_clients = {} for select in selects: - configurations = provider._client.list_configuration_settings( - key_filter=select.key_filter, label_filter=select.label_filter) + try: + configurations = provider._client.list_configuration_settings( + key_filter=select.key_filter, label_filter=select.label_filter) + except HttpResponseError as e: + raise e for config in configurations: - if config.content_type is None: - # Deals with possible null value via Rest API - provider._dict[provider.__trim(config.key)] = config.value - elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": + if config.content_type == KEY_VAULT_REFERNCE_CONTENT_TYPE: provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) - elif "application/json" in config.content_type: + elif (provider.__is_json_content_type(config.content_type)): j_object = json.loads(config.value) provider._dict[provider.__trim(config.key)] = j_object else: @@ -77,15 +83,18 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt headers = {} correlation_context = "RequestType=Startup" - if (key_vault_options is not None and - (key_vault_options.credential is not None or key_vault_options.secret_clients is not None or - key_vault_options.secret_resolver is not None)): + if (key_vault_options and + (key_vault_options.credential or key_vault_options or key_vault_options.secret_resolver)): correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context useragent = USER_AGENT - if connection_string is not None: + if (connection_string and endpoint): + raise AttributeError( + "Both connection_string and endpoint are set. Only one of these should be set.") + + if connection_string: self._client = AzureAppConfigurationClient.from_connection_string( connection_string, user_agent=useragent, headers=headers) return @@ -97,14 +106,17 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client raise AttributeError( "Key Vault options must be set to resolve Key Vault references.") j_object = json.loads(config.value) - uri_value = j_object['uri'] + uri_value = j_object.get("uri", None) + + if uri_value is None: + raise AttributeError( + "Key Vault reference must have a uri value.") uri = urlparse(uri_value) key_vault_uri = "https://" + uri.hostname key_vault_secret_prefix = "/secrets/" - key_vault_secret_name = uri.path[len( - key_vault_secret_prefix):] + key_vault_secret_name = uri.path[len(key_vault_secret_prefix):] if key_vault_options.credential is not None: secret_client = None @@ -117,20 +129,33 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client secret_client = SecretClient( vault_url=key_vault_uri, credential=key_vault_options.credential) secret_clients[key_vault_uri] = secret_client - secret = secret_client.get_secret( - key_vault_secret_name) - self._dict[self.__trim(config.key)] = secret.value - return + try: + secret = secret_client.get_secret( + key_vault_secret_name) + + self._dict[self.__trim(config.key)] = secret.value + return + except ResourceNotFoundError as e: + raise ValueError("Key Vault %s does not contain secret %s" % ( + key_vault_uri, key_vault_secret_name)) + except HttpResponseError as e: + raise e raise AttributeError( "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: if secret_client.vault_url == key_vault_uri: - secret = secret_client.get_secret( - key_vault_secret_name) - self._dict[self.__trim( - config.key)] = secret.value - return + try: + secret = secret_client.get_secret( + key_vault_secret_name) + self._dict[self.__trim( + config.key)] = secret.value + return + except ResourceNotFoundError as e: + raise ValueError("Key Vault %s does not contain secret %s" % ( + key_vault_uri, key_vault_secret_name)) + except HttpResponseError as e: + raise e if key_vault_options.secret_resolver is not None: self._dict[self.__trim( config.key)] = key_vault_options.secret_resolver(uri) @@ -138,6 +163,27 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client raise AttributeError( "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) + def __is_json_content_type(self, content_type): + if not content_type: + return False + + content_type = content_type.strip().lower() + mime_type = content_type.split(';')[0].strip() + + type_parts = mime_type.split('/') + if len(type_parts) != 2: + return False + + (main_type, sub_type) = type_parts + if main_type != "application": + return False + + sub_types = sub_type.split('+') + if "json" in sub_types: + return True + + return False + def __trim(self, key): for trim in self._trim_prefixes: if key.startswith(trim): diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py new file mode 100644 index 000000000000..99978e2c0ced --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py @@ -0,0 +1,7 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + +KEY_VAULT_REFERNCE_CONTENT_TYPE = u"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py index 3dbb41231db5..a82699284710 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py @@ -9,11 +9,11 @@ class SettingSelector: Selects a set of configuration settings from Azure App Configuration. :param key_filter: A filter to select configuration settings based on their keys. :type key_filter: str - :param label_filter: A filter to select configuration settings based on their labels. + :param label_filter: A filter to select configuration settings based on their labels. Default is value is '\0' :type label_filter: str """ - def __init__(self, key_filter, label_filter): + def __init__(self, key_filter, label_filter="\0"): # type: (str, str) -> None self.key_filter = key_filter self.label_filter = label_filter diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 387f42775c07..9151f1a699ef 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -6,7 +6,8 @@ from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, - AzureAppConfigurationKeyVaultOptions + AzureAppConfigurationKeyVaultOptions, + SettingSelector ) from azure.keyvault.secrets import SecretClient from azure.identity import DefaultAzureCredential @@ -18,9 +19,10 @@ # Connection to Azure App Configuration using AAD with Provided Client secret_client = SecretClient(vault_url=key_vault_uri, credential=credential) +selects = {SettingSelector("*", "prod")} key_vault_options = AzureAppConfigurationKeyVaultOptions(secret_clients=[ secret_client]) config = AzureAppConfigurationProvider.load( - endpoint=endpoint, credential=credential, key_vault_options=key_vault_options) + endpoint=endpoint, credential=credential, key_vault_options=key_vault_options, selects=selects) print(config["secret"]) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index 6fa55b7f0297..a66664f34bcf 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -6,7 +6,8 @@ from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, - AzureAppConfigurationKeyVaultOptions + AzureAppConfigurationKeyVaultOptions, + SettingSelector ) from azure.identity import DefaultAzureCredential import os @@ -16,7 +17,9 @@ # Connection to Azure App Configuration using AAD and Resolving Key Vault References key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=credential) +selects = {SettingSelector("*", "prod")} + config = AzureAppConfigurationProvider.load( - endpoint=endpoint, credential=credential, key_vault_options=key_vault_options) + endpoint=endpoint, credential=credential, key_vault_options=key_vault_options, selects=selects) print(config["secret"]) From f7e39290c56d18bb6043b01a2ea095d91122b033 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 11:59:36 -0700 Subject: [PATCH 019/129] Added more error checking. Made Key_VAULT_SECRET_PREFIX a constant. --- .../_azureappconfigurationprovider.py | 28 +++++++++++++++---- .../appconfigurationprovider/_constants.py | 2 ++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index fad3f06807c2..cc40c27409ac 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -13,7 +13,10 @@ ResourceNotFoundError ) from ._settingselector import SettingSelector -from ._constants import KEY_VAULT_REFERNCE_CONTENT_TYPE +from ._constants import ( + KEY_VAULT_REFERNCE_CONTENT_TYPE, + Key_VAULT_SECRET_PREFIX +) from ._user_agent import USER_AGENT @@ -73,8 +76,12 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) elif (provider.__is_json_content_type(config.content_type)): - j_object = json.loads(config.value) - provider._dict[provider.__trim(config.key)] = j_object + try: + j_object = json.loads(config.value) + provider._dict[provider.__trim(config.key)] = j_object + except json.JSONDecodeError as e: + raise ValueError( + "Invalid JSON value for key: " + config.key) else: provider._dict[provider.__trim(config.key)] = config.value return provider @@ -105,7 +112,12 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client if key_vault_options is None: raise AttributeError( "Key Vault options must be set to resolve Key Vault references.") - j_object = json.loads(config.value) + try: + j_object = json.loads(config.value) + except json.JSONDecodeError as e: + raise ValueError( + "Invalid JSON value for key vault reference: " + config.key) + uri_value = j_object.get("uri", None) if uri_value is None: @@ -115,8 +127,12 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client uri = urlparse(uri_value) key_vault_uri = "https://" + uri.hostname - key_vault_secret_prefix = "/secrets/" - key_vault_secret_name = uri.path[len(key_vault_secret_prefix):] + + if Key_VAULT_SECRET_PREFIX not in uri.path: + raise AttributeError( + "Key Vault reference must have a secret identifier.") + + key_vault_secret_name = uri.path[len(Key_VAULT_SECRET_PREFIX):] if key_vault_options.credential is not None: secret_client = None diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py index 99978e2c0ced..de6be50d218a 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py @@ -5,3 +5,5 @@ # ------------------------------------------------------------------------- KEY_VAULT_REFERNCE_CONTENT_TYPE = u"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" + +Key_VAULT_SECRET_PREFIX = u"/secrets/" From ef7a7f56a74b995db99810c3b0d02401f8c67b5d Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 12:14:55 -0700 Subject: [PATCH 020/129] Updated to use Key Vault Identifier. --- .../_azureappconfigurationprovider.py | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index cc40c27409ac..00b19e26f24b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -8,6 +8,7 @@ import json from azure.appconfiguration import AzureAppConfigurationClient from azure.keyvault.secrets import SecretClient +from azure.keyvault.secrets import KeyVaultSecretIdentifier from azure.core.exceptions import ( HttpResponseError, ResourceNotFoundError @@ -124,60 +125,53 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client raise AttributeError( "Key Vault reference must have a uri value.") - uri = urlparse(uri_value) + key_vault_idenfier = KeyVaultSecretIdentifier(uri_value) - key_vault_uri = "https://" + uri.hostname - - if Key_VAULT_SECRET_PREFIX not in uri.path: - raise AttributeError( - "Key Vault reference must have a secret identifier.") - - key_vault_secret_name = uri.path[len(Key_VAULT_SECRET_PREFIX):] if key_vault_options.credential is not None: secret_client = None # Clients only should be made once, will reuse if client already made for client_uri in secret_clients: - if client_uri == key_vault_uri: + if client_uri == key_vault_idenfier.vault_url: secret_client = secret_clients[client_uri] break if secret_client is None: secret_client = SecretClient( - vault_url=key_vault_uri, credential=key_vault_options.credential) - secret_clients[key_vault_uri] = secret_client + vault_url=key_vault_idenfier.vault_url, credential=key_vault_options.credential) + secret_clients[key_vault_idenfier.vault_url] = secret_client try: secret = secret_client.get_secret( - key_vault_secret_name) + key_vault_idenfier.name, version=key_vault_idenfier.version) self._dict[self.__trim(config.key)] = secret.value return except ResourceNotFoundError as e: raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_uri, key_vault_secret_name)) + key_vault_idenfier.vault_url, key_vault_idenfier.name)) except HttpResponseError as e: raise e raise AttributeError( - "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) + "No Secret Client found for Key Vault reference %s" % (key_vault_idenfier.vault_url)) if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: - if secret_client.vault_url == key_vault_uri: + if secret_client.vault_url == key_vault_idenfier.vault_url: try: secret = secret_client.get_secret( - key_vault_secret_name) + key_vault_idenfier.name, version=key_vault_idenfier.version) self._dict[self.__trim( config.key)] = secret.value return except ResourceNotFoundError as e: raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_uri, key_vault_secret_name)) + key_vault_idenfier.vault_url, key_vault_idenfier.name)) except HttpResponseError as e: raise e if key_vault_options.secret_resolver is not None: self._dict[self.__trim( - config.key)] = key_vault_options.secret_resolver(uri) + config.key)] = key_vault_options.secret_resolver(key_vault_idenfier.vault_url) return raise AttributeError( - "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) + "No Secret Client found for Key Vault reference %s" % (key_vault_idenfier.vault_url)) def __is_json_content_type(self, content_type): if not content_type: From cbf2acb122e78c983dea946703b428e91427b9bd Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 12:33:03 -0700 Subject: [PATCH 021/129] Fixed Spelling --- .../azure-appconfiguration-provider/README.md | 2 +- .../_azureappconfigurationprovider.py | 29 +++++++++---------- .../appconfigurationprovider/_constants.py | 4 +-- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index f382de19a032..1a762bfbefd8 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -67,7 +67,7 @@ In this example all configuration with empty label and the dev label are loaded. ### Trimming Keys -You can trim the prefix off of keys by providing a list of trimmed key prefixes to the provider. For example, if you have the key(s) like `/applicaiton/message` in your configuration store, you could trim `/application/` from them. +You can trim the prefix off of keys by providing a list of trimmed key prefixes to the provider. For example, if you have the key(s) like `/application/message` in your configuration store, you could trim `/application/` from them. ```python trimmed_key_prefixes={"/application/"} diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 00b19e26f24b..95594ec118dd 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -15,8 +15,7 @@ ) from ._settingselector import SettingSelector from ._constants import ( - KEY_VAULT_REFERNCE_CONTENT_TYPE, - Key_VAULT_SECRET_PREFIX + KEY_VAULT_REFERENCE_CONTENT_TYPE ) from ._user_agent import USER_AGENT @@ -73,7 +72,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): except HttpResponseError as e: raise e for config in configurations: - if config.content_type == KEY_VAULT_REFERNCE_CONTENT_TYPE: + if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) elif (provider.__is_json_content_type(config.content_type)): @@ -125,53 +124,53 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client raise AttributeError( "Key Vault reference must have a uri value.") - key_vault_idenfier = KeyVaultSecretIdentifier(uri_value) + key_vault_identifier = KeyVaultSecretIdentifier(uri_value) if key_vault_options.credential is not None: secret_client = None # Clients only should be made once, will reuse if client already made for client_uri in secret_clients: - if client_uri == key_vault_idenfier.vault_url: + if client_uri == key_vault_identifier.vault_url: secret_client = secret_clients[client_uri] break if secret_client is None: secret_client = SecretClient( - vault_url=key_vault_idenfier.vault_url, credential=key_vault_options.credential) - secret_clients[key_vault_idenfier.vault_url] = secret_client + vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) + secret_clients[key_vault_identifier.vault_url] = secret_client try: secret = secret_client.get_secret( - key_vault_idenfier.name, version=key_vault_idenfier.version) + key_vault_identifier.name, version=key_vault_identifier.version) self._dict[self.__trim(config.key)] = secret.value return except ResourceNotFoundError as e: raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_idenfier.vault_url, key_vault_idenfier.name)) + key_vault_identifier.vault_url, key_vault_identifier.name)) except HttpResponseError as e: raise e raise AttributeError( - "No Secret Client found for Key Vault reference %s" % (key_vault_idenfier.vault_url)) + "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: - if secret_client.vault_url == key_vault_idenfier.vault_url: + if secret_client.vault_url == key_vault_identifier.vault_url: try: secret = secret_client.get_secret( - key_vault_idenfier.name, version=key_vault_idenfier.version) + key_vault_identifier.name, version=key_vault_identifier.version) self._dict[self.__trim( config.key)] = secret.value return except ResourceNotFoundError as e: raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_idenfier.vault_url, key_vault_idenfier.name)) + key_vault_identifier.vault_url, key_vault_identifier.name)) except HttpResponseError as e: raise e if key_vault_options.secret_resolver is not None: self._dict[self.__trim( - config.key)] = key_vault_options.secret_resolver(key_vault_idenfier.vault_url) + config.key)] = key_vault_options.secret_resolver(key_vault_identifier.vault_url) return raise AttributeError( - "No Secret Client found for Key Vault reference %s" % (key_vault_idenfier.vault_url)) + "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) def __is_json_content_type(self, content_type): if not content_type: diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py index de6be50d218a..913b7e142627 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py @@ -4,6 +4,4 @@ # license information. # ------------------------------------------------------------------------- -KEY_VAULT_REFERNCE_CONTENT_TYPE = u"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" - -Key_VAULT_SECRET_PREFIX = u"/secrets/" +KEY_VAULT_REFERENCE_CONTENT_TYPE = u"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" From 047d526b416cdbcc8baa031a1f9eff37aacf45ca Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 13:39:16 -0700 Subject: [PATCH 022/129] Updated Test --- ...urationProvidertest_provider_creation.json | 47 ++++++++++++------- .../tests/test_provider.py | 12 ++--- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index 0dff5970b68d..d2d6fe23a4db 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -183,7 +183,7 @@ "Accept-Encoding": "gzip, deflate", "client-request-id": "72b30cb2-f149-4eeb-a2c8-f318375aa74c", "Connection": "keep-alive", - "Content-Length": "392", + "Content-Length": "296", "Content-Type": "application/x-www-form-urlencoded", "Cookie": "fpc=Ath0zAFi31FNvKANFWwF1y8; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", @@ -195,7 +195,7 @@ "x-client-ver": "1.18.0", "x-ms-lib-capability": "retry-after, h429" }, - "RequestBody": "client_id=5b99b3ef-331b-47b1-b984-a967ab4c2623\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=Endpoint=https://fake_app_config.azconfig-test.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fpython-provider.azconfig.io%2F.default", + "RequestBody": "client_id=5b99b3ef-331b-47b1-b984-a967ab4c2623\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=SomeFakeClientSecretToxCM3YWvEqxHXaBa\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Ffake_app_config.azconfig.io%2F.default", "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-store, no-cache", @@ -226,13 +226,14 @@ } }, { - "RequestUri": "https://fake_app_config.azconfig-test.io/kv/message?label=%00\u0026api-version=1.0", + "RequestUri": "https://fake_app_config.azconfig-test.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", "RequestMethod": "GET", "RequestHeaders": { - "Accept": "application/vnd.microsoft.appconfig.kv\u002Bjson, application/json, application/problem\u002Bjson", + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -241,10 +242,8 @@ "Access-Control-Allow-Origin": "*", "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", - "Content-Type": "application/vnd.microsoft.appconfig.kv\u002Bjson; charset=utf-8", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", "Date": "Fri, 09 Sep 2022 22:21:53 GMT", - "ETag": "\u0022RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk\u0022", - "Last-Modified": "Thu, 01 Sep 2022 17:53:26 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", "Sync-Token": "zAJw6V16=NjoxNyMxNjY5NTQ1Mg==;sn=16695452", @@ -252,16 +251,30 @@ "x-ms-correlation-request-id": "cb587955-b687-4421-8aed-c29479a5b118" }, "ResponseBody": { - "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", - "key": "message", - "label": null, - "content_type": "", - "value": "hi", - "tags": {}, - "locked": false, - "last_modified": "2022-09-01T17:53:26\u002B00:00" + "items": [ + { + "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", + "key": "message", + "label": null, + "content_type": "", + "value": "hi", + "tags": {}, + "locked": false, + "last_modified": "2022-09-01T17:53:26\u002B00:00" + }, + { + "etag": "MUD4TSfiMxgwTqVTAlI_rNyXQz9bAPZ3VXDO-Hk_ejI", + "key": "test.message", + "label": null, + "content_type": "", + "value": "Hi with test Prefix", + "tags": {}, + "locked": false, + "last_modified": "2022-09-01T17:53:46\u002B00:00" + } + ] } } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index 18a64e59bbe5..ccb8ae27497d 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -4,9 +4,8 @@ # license information. # -------------------------------------------------------------------------- import functools -from azure.appconfiguration import AzureAppConfigurationClient +from azure.appconfigurationprovider import AzureAppConfigurationProvider from azure.identity import DefaultAzureCredential - from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy AppConfigProviderPreparer = functools.partial( @@ -16,14 +15,15 @@ appconfiguration_endpoint_string="https://fake_app_config.azconfig-test.io" ) + class TestAppConfigurationProvider(AzureRecordedTestCase): - def buildClient(self, endpoint): - return AzureAppConfigurationClient(base_url=endpoint, credential=DefaultAzureCredential()) + def buildProvider(self, endpoint): + return AzureAppConfigurationProvider.load(endpoint=endpoint, credential=DefaultAzureCredential()) # method: provider_creation @AppConfigProviderPreparer() @recorded_by_proxy def test_provider_creation(self, appconfiguration_endpoint_string): - client = self.buildClient(appconfiguration_endpoint_string) - assert client.get_configuration_setting(key="message",label="\0").value == "hi" \ No newline at end of file + client = self.buildProvider(appconfiguration_endpoint_string) + assert client["message"] == "hi" From f379833b1e65c2ea888564f180db71b7b91976bd Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 14:33:52 -0700 Subject: [PATCH 023/129] Reworked key vault reference resolution. Fixed lint issues. --- .../_azureappconfigurationkeyvaultoptions.py | 2 +- .../_azureappconfigurationprovider.py | 71 ++++++++----------- .../samples/connection_string_sample.py | 1 + 3 files changed, 30 insertions(+), 44 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 9657b766143f..cbaef50e53d4 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -17,7 +17,7 @@ class AzureAppConfigurationKeyVaultOptions: :type secret_resolver: callable """ - def __init__(self, credential=None, secret_clients=None, secret_resolver=None): + def __init__(self, credential=None, secret_clients={}, secret_resolver=None): # type: (TokenCredential, List[SecretClient], Callable) -> None self.credential = credential self.secret_clients = secret_clients diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 95594ec118dd..c1f0c4b30c47 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -4,7 +4,6 @@ # license information. # ------------------------------------------------------------------------- -from urllib.parse import urlparse import json from azure.appconfiguration import AzureAppConfigurationClient from azure.keyvault.secrets import SecretClient @@ -63,7 +62,8 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): "trimmed_key_prefixes", []), key=len, reverse=True) provider._dict = {} - secret_clients = {} + + secret_clients = key_vault_options.secret_clients if key_vault_options else {} for select in selects: try: @@ -75,7 +75,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) - elif (provider.__is_json_content_type(config.content_type)): + elif provider.__is_json_content_type(config.content_type): try: j_object = json.loads(config.value) provider._dict[provider.__trim(config.key)] = j_object @@ -126,45 +126,29 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client key_vault_identifier = KeyVaultSecretIdentifier(uri_value) - if key_vault_options.credential is not None: - secret_client = None - - # Clients only should be made once, will reuse if client already made - for client_uri in secret_clients: - if client_uri == key_vault_identifier.vault_url: - secret_client = secret_clients[client_uri] - break - if secret_client is None: - secret_client = SecretClient( - vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) - secret_clients[key_vault_identifier.vault_url] = secret_client - try: - secret = secret_client.get_secret( - key_vault_identifier.name, version=key_vault_identifier.version) - - self._dict[self.__trim(config.key)] = secret.value - return - except ResourceNotFoundError as e: - raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_identifier.vault_url, key_vault_identifier.name)) - except HttpResponseError as e: - raise e - raise AttributeError( - "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) - if key_vault_options.secret_clients is not None: - for secret_client in key_vault_options.secret_clients: - if secret_client.vault_url == key_vault_identifier.vault_url: - try: - secret = secret_client.get_secret( - key_vault_identifier.name, version=key_vault_identifier.version) - self._dict[self.__trim( - config.key)] = secret.value - return - except ResourceNotFoundError as e: - raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_identifier.vault_url, key_vault_identifier.name)) - except HttpResponseError as e: - raise e + referenced_client = None + + for secret_client in secret_clients: + if secret_client.vault_url == key_vault_identifier.vault_url: + referenced_client = secret_client + break + if referenced_client is None and key_vault_options.credential is not None: + referenced_client = SecretClient( + vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) + secret_clients[key_vault_identifier.vault_url] = referenced_client + + if referenced_client: + try: + secret = referenced_client.get_secret( + key_vault_identifier.name, version=key_vault_identifier.version) + self._dict[self.__trim(config.key)] = secret.value + return + except ResourceNotFoundError as e: + raise ValueError("Key Vault %s does not contain secret %s" % ( + key_vault_identifier.vault_url, key_vault_identifier.name)) + except HttpResponseError as e: + raise e + if key_vault_options.secret_resolver is not None: self._dict[self.__trim( config.key)] = key_vault_options.secret_resolver(key_vault_identifier.vault_url) @@ -172,7 +156,8 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client raise AttributeError( "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) - def __is_json_content_type(self, content_type): + @staticmethod + def __is_json_content_type(content_type): if not content_type: return False diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index a9ff30c9ca21..974313a9977e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -17,6 +17,7 @@ connection_string=connection_string) print(config["message"]) +print(config["myjson"]["key"]) # Connecting to Azure App Configuration using connection string and trimmed key prefixes trimmed = {"test."} From dcb6cf790ffedc03129e5826d3d9bfe9c2687356 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 10:47:06 -0700 Subject: [PATCH 024/129] Fixing Lint Issue. Updating Test Running --- .../_azureappconfigurationkeyvaultoptions.py | 2 +- .../samples/connection_string_sample.py | 2 +- .../tests/conftest.py | 26 ++++++- ...urationProvidertest_provider_creation.json | 68 +++++++++++-------- 4 files changed, 65 insertions(+), 33 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index cbaef50e53d4..534c621dd7c9 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -17,7 +17,7 @@ class AzureAppConfigurationKeyVaultOptions: :type secret_resolver: callable """ - def __init__(self, credential=None, secret_clients={}, secret_resolver=None): + def __init__(self, credential=None, secret_clients=dict(), secret_resolver=None): # type: (TokenCredential, List[SecretClient], Callable) -> None self.credential = credential self.secret_clients = secret_clients diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index 974313a9977e..7550e77039db 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -17,7 +17,7 @@ connection_string=connection_string) print(config["message"]) -print(config["myjson"]["key"]) +print(config["my_json"]["key"]) # Connecting to Azure App Configuration using connection string and trimmed key prefixes trimmed = {"test."} diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py index 9fd3224d9530..5fdf89985f4a 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py @@ -1,7 +1,29 @@ -from devtools_testutils import test_proxy +import os +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer +) import pytest # autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method + + @pytest.fixture(scope="session", autouse=True) def start_proxy(test_proxy): - return \ No newline at end of file + return + +# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method + + +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + add_general_regex_sanitizer(value="fake-endpoint.azconfig.io", + regex=os.environ.get('APPCONFIGURATION_ENDPOINT_STRING')) + add_general_regex_sanitizer(value="fake-connection-string", + regex=os.environ.get('APPCONFIGURATION_CONNECTION_STRING')) + add_general_regex_sanitizer( + value="fake-client-id", regex=os.environ.get('APPCONFIGURATION_CLIENT_ID')) + add_general_regex_sanitizer( + value="fake-client-secret", regex=os.environ.get('APPCONFIGURATION_CLIENT_SECRET')) + add_general_regex_sanitizer( + value="fake-tenant-id", regex=os.environ.get('APPCONFIGURATION_TENANT_ID')) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index d2d6fe23a4db..78579324c398 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0/.well-known/openid-configuration", + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", "RequestMethod": "GET", "RequestHeaders": { "Accept": "*/*", @@ -15,29 +15,29 @@ "Access-Control-Allow-Methods": "GET, OPTIONS", "Access-Control-Allow-Origin": "*", "Cache-Control": "max-age=86400, private", - "Content-Length": "1753", + "Content-Length": "1599", "Content-Type": "application/json; charset=utf-8", - "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "Date": "Wed, 21 Sep 2022 17:42:06 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=Ath0zAFi31FNvKANFWwF1y8; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", - "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrfWar8zX8BblDnJAKRl2Hz_-7zEPqvGMEvPEm4jaimQqfTO66wTmt9q7V3kIc3ezFdZRu3vXykHx7Bl4PfmIfQhjCk4yEqgLFhix1WaTIZlQzYXp7mkOhrDjZJ368eQ0QRAdKtduf_g3kwVBi50QHgTmWYgslpizT-dWmZ65Q39MgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", + "fpc=AtHW-D0oI7BCs5w8PtmWt0M; expires=Fri, 21-Oct-2022 17:42:07 GMT; path=/; secure; HttpOnly; SameSite=None", + "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7Wevrw4PHrGRl95uoBDVdJ6fbkrvGZccTxlEqPtQBJpCoPGW95rWFbbHMqCVjuUHS6707n_jIrHLhtYgeurc1PaEFvYnsAWfWKM-kDnd8q1fmelLXOyur7ddTBsZT-qwYKw4xI-pJWMlOLKh4_4Z7BwuCwIFKl00wt1_JZ1YwZne7wYMMuDk56dBUmH_cx5EP0kCOPqaU37Xwbg7OvtuLpQauiLD4tMlA05hASJpjaO3Bk24gAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13622.7 - NCUS ProdSlices", + "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { - "token_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token", + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": [ "client_secret_post", "private_key_jwt", "client_secret_basic" ], - "jwks_uri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/discovery/v2.0/keys", + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", "response_modes_supported": [ "query", "fragment", @@ -61,14 +61,14 @@ "email", "offline_access" ], - "issuer": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0", + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", - "authorization_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/authorize", - "device_authorization_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/devicecode", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, - "end_session_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/logout", + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", "claims_supported": [ "sub", "iss", @@ -90,7 +90,7 @@ "c_hash", "email" ], - "kerberos_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/kerberos", + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", "tenant_region_scope": "WW", "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", @@ -105,7 +105,7 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "Cookie": "fpc=Ath0zAFi31FNvKANFWwF1y8; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "Cookie": "fpc=AtHW-D0oI7BCs5w8PtmWt0M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" }, "RequestBody": null, @@ -116,16 +116,16 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "945", "Content-Type": "application/json; charset=utf-8", - "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "Date": "Wed, 21 Sep 2022 17:42:07 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=Ath0zAFi31FNvKANFWwF1y8; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", + "fpc=AtHW-D0oI7BCs5w8PtmWt0M; expires=Fri, 21-Oct-2022 17:42:07 GMT; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13562.12 - SCUS ProdSlices", + "x-ms-ests-server": "2.1.13622.7 - WUS2 ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -176,16 +176,16 @@ } }, { - "RequestUri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token", + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", - "client-request-id": "72b30cb2-f149-4eeb-a2c8-f318375aa74c", + "client-request-id": "2a07081c-66f6-4d46-8077-b893dc513f19", "Connection": "keep-alive", - "Content-Length": "296", + "Content-Length": "255", "Content-Type": "application/x-www-form-urlencoded", - "Cookie": "fpc=Ath0zAFi31FNvKANFWwF1y8; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "Cookie": "fpc=AtHW-D0oI7BCs5w8PtmWt0M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", "x-client-cpu": "x64", "x-client-current-telemetry": "4|730,0|", @@ -195,26 +195,26 @@ "x-client-ver": "1.18.0", "x-ms-lib-capability": "retry-after, h429" }, - "RequestBody": "client_id=5b99b3ef-331b-47b1-b984-a967ab4c2623\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=SomeFakeClientSecretToxCM3YWvEqxHXaBa\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Ffake_app_config.azconfig.io%2F.default", + "RequestBody": "client_id=fake-client-id\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=fake-client-secret\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Ffake-endpoint.azconfig.io%2F.default", "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-store, no-cache", - "client-request-id": "72b30cb2-f149-4eeb-a2c8-f318375aa74c", + "client-request-id": "2a07081c-66f6-4d46-8077-b893dc513f19", "Content-Length": "111", "Content-Type": "application/json; charset=utf-8", - "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "Date": "Wed, 21 Sep 2022 17:42:07 GMT", "Expires": "-1", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Pragma": "no-cache", "Set-Cookie": [ - "fpc=Ath0zAFi31FNvKANFWwF1y8W9qlXAQAAAICzrdoOAAAA; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", + "fpc=AtHW-D0oI7BCs5w8PtmWt0MW9qlXAQAAAO9DvdoOAAAA; expires=Fri, 21-Oct-2022 17:42:08 GMT; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.13622.7 - NCUS ProdSlices", + "x-ms-ests-server": "2.1.13777.4 - EUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -243,12 +243,12 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Fri, 09 Sep 2022 22:21:53 GMT", + "Date": "Wed, 21 Sep 2022 17:42:08 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjY5NTQ1Mg==;sn=16695452", + "Sync-Token": "zAJw6V16=NjoxNyMxNjg2MzM1Nw==;sn=16863357", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "cb587955-b687-4421-8aed-c29479a5b118" + "x-ms-correlation-request-id": "9478e864-7c4e-4c4d-8659-cfa8da3e7b64" }, "ResponseBody": { "items": [ @@ -262,6 +262,16 @@ "locked": false, "last_modified": "2022-09-01T17:53:26\u002B00:00" }, + { + "etag": "jf2AWA7sfhfRYx0rPoBxqdCf1Lfzpos0v4emLvuYP-4", + "key": "my_json", + "label": null, + "content_type": "application/json", + "value": "{\u0022key\u0022:\u0022value\u0022}", + "tags": {}, + "locked": false, + "last_modified": "2022-09-20T23:10:44\u002B00:00" + }, { "etag": "MUD4TSfiMxgwTqVTAlI_rNyXQz9bAPZ3VXDO-Hk_ejI", "key": "test.message", From a0c6cb8eee769843e3e83abd6731926cf7a17f4f Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 11:34:04 -0700 Subject: [PATCH 025/129] Fixing Tests --- .../tests/conftest.py | 2 +- ...urationProvidertest_provider_creation.json | 237 +------------- ...ionProvidertest_provider_creation_aad.json | 291 ++++++++++++++++++ .../tests/test_provider.py | 76 ++++- 4 files changed, 367 insertions(+), 239 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py index 5fdf89985f4a..aa499fb92527 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py @@ -17,7 +17,7 @@ def start_proxy(test_proxy): @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): - add_general_regex_sanitizer(value="fake-endpoint.azconfig.io", + add_general_regex_sanitizer(value="https://fake-endpoint.azconfig.io", regex=os.environ.get('APPCONFIGURATION_ENDPOINT_STRING')) add_general_regex_sanitizer(value="fake-connection-string", regex=os.environ.get('APPCONFIGURATION_CONNECTION_STRING')) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index 78579324c398..63e748faf842 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -1,239 +1,16 @@ { "Entries": [ { - "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Access-Control-Allow-Methods": "GET, OPTIONS", - "Access-Control-Allow-Origin": "*", - "Cache-Control": "max-age=86400, private", - "Content-Length": "1599", - "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 17:42:06 GMT", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Set-Cookie": [ - "fpc=AtHW-D0oI7BCs5w8PtmWt0M; expires=Fri, 21-Oct-2022 17:42:07 GMT; path=/; secure; HttpOnly; SameSite=None", - "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7Wevrw4PHrGRl95uoBDVdJ6fbkrvGZccTxlEqPtQBJpCoPGW95rWFbbHMqCVjuUHS6707n_jIrHLhtYgeurc1PaEFvYnsAWfWKM-kDnd8q1fmelLXOyur7ddTBsZT-qwYKw4xI-pJWMlOLKh4_4Z7BwuCwIFKl00wt1_JZ1YwZne7wYMMuDk56dBUmH_cx5EP0kCOPqaU37Xwbg7OvtuLpQauiLD4tMlA05hASJpjaO3Bk24gAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", - "token_endpoint_auth_methods_supported": [ - "client_secret_post", - "private_key_jwt", - "client_secret_basic" - ], - "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", - "response_modes_supported": [ - "query", - "fragment", - "form_post" - ], - "subject_types_supported": [ - "pairwise" - ], - "id_token_signing_alg_values_supported": [ - "RS256" - ], - "response_types_supported": [ - "code", - "id_token", - "code id_token", - "id_token token" - ], - "scopes_supported": [ - "openid", - "profile", - "email", - "offline_access" - ], - "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", - "request_uri_parameter_supported": false, - "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", - "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", - "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", - "http_logout_supported": true, - "frontchannel_logout_supported": true, - "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", - "claims_supported": [ - "sub", - "iss", - "cloud_instance_name", - "cloud_instance_host_name", - "cloud_graph_host_name", - "msgraph_host", - "aud", - "exp", - "iat", - "auth_time", - "acr", - "nonce", - "preferred_username", - "name", - "tid", - "ver", - "at_hash", - "c_hash", - "email" - ], - "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", - "tenant_region_scope": "WW", - "cloud_instance_name": "microsoftonline.com", - "cloud_graph_host_name": "graph.windows.net", - "msgraph_host": "graph.microsoft.com", - "rbac_url": "https://pas.windows.net" - } - }, - { - "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "Connection": "keep-alive", - "Cookie": "fpc=AtHW-D0oI7BCs5w8PtmWt0M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Access-Control-Allow-Methods": "GET, OPTIONS", - "Access-Control-Allow-Origin": "*", - "Cache-Control": "max-age=86400, private", - "Content-Length": "945", - "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 17:42:07 GMT", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Set-Cookie": [ - "fpc=AtHW-D0oI7BCs5w8PtmWt0M; expires=Fri, 21-Oct-2022 17:42:07 GMT; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13622.7 - WUS2 ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", - "api-version": "1.1", - "metadata": [ - { - "preferred_network": "login.microsoftonline.com", - "preferred_cache": "login.windows.net", - "aliases": [ - "login.microsoftonline.com", - "login.windows.net", - "login.microsoft.com", - "sts.windows.net" - ] - }, - { - "preferred_network": "login.partner.microsoftonline.cn", - "preferred_cache": "login.partner.microsoftonline.cn", - "aliases": [ - "login.partner.microsoftonline.cn", - "login.chinacloudapi.cn" - ] - }, - { - "preferred_network": "login.microsoftonline.de", - "preferred_cache": "login.microsoftonline.de", - "aliases": [ - "login.microsoftonline.de" - ] - }, - { - "preferred_network": "login.microsoftonline.us", - "preferred_cache": "login.microsoftonline.us", - "aliases": [ - "login.microsoftonline.us", - "login.usgovcloudapi.net" - ] - }, - { - "preferred_network": "login-us.microsoftonline.com", - "preferred_cache": "login-us.microsoftonline.com", - "aliases": [ - "login-us.microsoftonline.com" - ] - } - ] - } - }, - { - "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "client-request-id": "2a07081c-66f6-4d46-8077-b893dc513f19", - "Connection": "keep-alive", - "Content-Length": "255", - "Content-Type": "application/x-www-form-urlencoded", - "Cookie": "fpc=AtHW-D0oI7BCs5w8PtmWt0M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", - "x-client-cpu": "x64", - "x-client-current-telemetry": "4|730,0|", - "x-client-last-telemetry": "4|0|||", - "x-client-os": "win32", - "x-client-sku": "MSAL.Python", - "x-client-ver": "1.18.0", - "x-ms-lib-capability": "retry-after, h429" - }, - "RequestBody": "client_id=fake-client-id\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=fake-client-secret\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Ffake-endpoint.azconfig.io%2F.default", - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-store, no-cache", - "client-request-id": "2a07081c-66f6-4d46-8077-b893dc513f19", - "Content-Length": "111", - "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 17:42:07 GMT", - "Expires": "-1", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Pragma": "no-cache", - "Set-Cookie": [ - "fpc=AtHW-D0oI7BCs5w8PtmWt0MW9qlXAQAAAO9DvdoOAAAA; expires=Fri, 21-Oct-2022 17:42:08 GMT; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.13777.4 - EUS ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "token_type": "Bearer", - "expires_in": 86399, - "ext_expires_in": 86399, - "refresh_in": 43199, - "access_token": "Sanitized" - } - }, - { - "RequestUri": "https://fake_app_config.azconfig-test.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestUri": "fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", "RequestMethod": "GET", "RequestHeaders": { "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.6 (Windows-10-10.0.22000-SP0)", + "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", + "x-ms-date": "Sep, 21 2022 18:22:11.213870 GMT" }, "RequestBody": null, "StatusCode": 200, @@ -243,12 +20,12 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Wed, 21 Sep 2022 17:42:08 GMT", + "Date": "Wed, 21 Sep 2022 18:22:11 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjg2MzM1Nw==;sn=16863357", + "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDMyMQ==;sn=16864321", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "9478e864-7c4e-4c4d-8659-cfa8da3e7b64" + "x-ms-correlation-request-id": "d109bdd2-2e35-4748-8dff-b548c55a99e6" }, "ResponseBody": { "items": [ diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json new file mode 100644 index 000000000000..b9005e1077cb --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json @@ -0,0 +1,291 @@ +{ + "Entries": [ + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1599", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=AhyWxyAqvHlIgeVTxU0ZntE; expires=Fri, 21-Oct-2022 18:22:13 GMT; path=/; secure; HttpOnly; SameSite=None", + "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevruzHA3uNG6YmCUn8KDqEbZhkAJIcrqMGz9qDpTSknEwDCtG0wPNEgOrlOiBwApukfwQx_3YJczFMXMGxa1z7c_SimB-PV2g1wuQwEENhCz18MKm3OZ2BanW9AYbk3ocCLWeEFArzoVXfWbIDIVa1fWrWiT477_18wfP3ZBHoNIgbC97_umYvTkWwpMs7pklZ6SfRKTIP6vkMVEhkoNKCgML5uGG5jyrJeGP-h7UjX4jUgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=AhyWxyAqvHlIgeVTxU0ZntE; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=AhyWxyAqvHlIgeVTxU0ZntE; expires=Fri, 21-Oct-2022 18:22:13 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.7 - SCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "client-request-id": "13b2341d-c273-44c9-9927-80fb0dcbdaa6", + "Connection": "keep-alive", + "Content-Length": "255", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": "fpc=AhyWxyAqvHlIgeVTxU0ZntE; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)", + "x-client-cpu": "x64", + "x-client-current-telemetry": "4|730,0|", + "x-client-last-telemetry": "4|0|||", + "x-client-os": "win32", + "x-client-sku": "MSAL.Python", + "x-client-ver": "1.18.0", + "x-ms-lib-capability": "retry-after, h429" + }, + "RequestBody": "client_id=fake-client-id\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=fake-client-secret\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fpython-provider.azconfig.io%2F.default", + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-store, no-cache", + "client-request-id": "13b2341d-c273-44c9-9927-80fb0dcbdaa6", + "Content-Length": "111", + "Content-Security-Policy-Report-Only": "script-src \u0027self\u0027 \u0027nonce-hMw6CXt6AY9vBIalIpW2cg\u0027 \u0027unsafe-eval\u0027 \u0027unsafe-inline\u0027; object-src \u0027none\u0027; base-uri \u0027none\u0027; report-uri https://csp.microsoft.com/report/ESTS-UX-All", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "Expires": "-1", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Pragma": "no-cache", + "Set-Cookie": [ + "fpc=AhyWxyAqvHlIgeVTxU0ZntEW9qlXAQAAAFVNvdoOAAAA; expires=Fri, 21-Oct-2022 18:22:14 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-clitelem": "1,0,0,,", + "x-ms-ests-server": "2.1.13777.4 - WUS2 ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_type": "Bearer", + "expires_in": 86399, + "ext_expires_in": 86399, + "refresh_in": 43199, + "access_token": "Sanitized" + } + }, + { + "RequestUri": "fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Wed, 21 Sep 2022 18:22:14 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDMyMQ==;sn=16864321", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "2d929cdd-7f97-4e20-a757-94498bebb049" + }, + "ResponseBody": { + "items": [ + { + "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", + "key": "message", + "label": null, + "content_type": "", + "value": "hi", + "tags": {}, + "locked": false, + "last_modified": "2022-09-01T17:53:26\u002B00:00" + }, + { + "etag": "jf2AWA7sfhfRYx0rPoBxqdCf1Lfzpos0v4emLvuYP-4", + "key": "my_json", + "label": null, + "content_type": "application/json", + "value": "{\u0022key\u0022:\u0022value\u0022}", + "tags": {}, + "locked": false, + "last_modified": "2022-09-20T23:10:44\u002B00:00" + }, + { + "etag": "MUD4TSfiMxgwTqVTAlI_rNyXQz9bAPZ3VXDO-Hk_ejI", + "key": "test.message", + "label": null, + "content_type": "", + "value": "Hi with test Prefix", + "tags": {}, + "locked": false, + "last_modified": "2022-09-01T17:53:46\u002B00:00" + } + ] + } + } + ], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index ccb8ae27497d..fb656449fc8e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -5,25 +5,85 @@ # -------------------------------------------------------------------------- import functools from azure.appconfigurationprovider import AzureAppConfigurationProvider -from azure.identity import DefaultAzureCredential from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy +from azure.appconfiguration import AzureAppConfigurationClient +import inspect AppConfigProviderPreparer = functools.partial( EnvironmentVariableLoader, "appconfiguration", - appconfiguration_connection_string="Endpoint=https://fake_app_config.azconfig-test.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=", - appconfiguration_endpoint_string="https://fake_app_config.azconfig-test.io" + appconfiguration_connection_string="Endpoint=https://fake-endpoint.azconfig.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=", + appconfiguration_endpoint_string="https://fake-endpoint.azconfig.io", + appconfiguration_client_id="fake-client-id", + appconfiguration_client_secret="fake-client-secret", + appconfiguration_tenant_id="fake-tenant-id", ) +def app_config_decorator(func, **kwargs): + @AppConfigProviderPreparer() + def wrapper(*args, **kwargs): + appconfiguration_connection_string = kwargs.pop( + "appconfiguration_connection_string") + kwargs['appconfiguration_connection_string'] = appconfiguration_connection_string + + trimmed_kwargs = {k: v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + func(*args, **trimmed_kwargs) + return wrapper + + +def app_config_decorator_aad(func, **kwargs): + @AppConfigProviderPreparer() + def wrapper(*args, **kwargs): + appconfiguration_endpoint_string = kwargs.pop( + "appconfiguration_endpoint_string") + kwargs['appconfiguration_endpoint_string'] = appconfiguration_endpoint_string + + trimmed_kwargs = {k: v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + func(*args, **trimmed_kwargs) + return wrapper + + +def trim_kwargs_from_test_function(fn, kwargs): + # the next function is the actual test function. the kwargs need to be trimmed so + # that parameters which are not required will not be passed to it. + if not getattr(fn, '__is_preparer', False): + try: + args, _, kw, _, _, _, _ = inspect.getfullargspec(fn) + except AttributeError: + args, _, kw, _ = inspect.getargspec( + fn) # pylint: disable=deprecated-method + if kw is None: + args = set(args) + for key in [k for k in kwargs if k not in args]: + del kwargs[key] + + class TestAppConfigurationProvider(AzureRecordedTestCase): - def buildProvider(self, endpoint): - return AzureAppConfigurationProvider.load(endpoint=endpoint, credential=DefaultAzureCredential()) + def build_provider_aad(self, endpoint): + cred = self.get_credential(AzureAppConfigurationClient) + return AzureAppConfigurationProvider.load(endpoint=endpoint, credential=cred) + + def build_provider(self, connection_string): + return AzureAppConfigurationProvider.load(connection_string=connection_string) # method: provider_creation - @AppConfigProviderPreparer() @recorded_by_proxy - def test_provider_creation(self, appconfiguration_endpoint_string): - client = self.buildProvider(appconfiguration_endpoint_string) + @app_config_decorator + def test_provider_creation(self, appconfiguration_connection_string): + + client = self.build_provider(appconfiguration_connection_string) + assert client["message"] == "hi" + + # method: provider_creation_aad + @recorded_by_proxy + @app_config_decorator_aad + def test_provider_creation_aad(self, appconfiguration_endpoint_string): + + client = self.build_provider_aad(appconfiguration_endpoint_string) assert client["message"] == "hi" From 4dd0831e38dead6807c5871781b4d31275c9f2a8 Mon Sep 17 00:00:00 2001 From: Matthew Metcalf Date: Wed, 21 Sep 2022 11:39:26 -0700 Subject: [PATCH 026/129] Fixed Tests? --- ...urationProvidertest_provider_creation.json | 14 +++--- ...ionProvidertest_provider_creation_aad.json | 45 +++++++++---------- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index 63e748faf842..00cd18ebcfe0 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -1,16 +1,16 @@ { "Entries": [ { - "RequestUri": "fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", "RequestMethod": "GET", "RequestHeaders": { "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.6 (Windows-10-10.0.22000-SP0)", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Sep, 21 2022 18:22:11.213870 GMT" + "x-ms-date": "Sep, 21 2022 18:39:00.013800 GMT" }, "RequestBody": null, "StatusCode": 200, @@ -20,12 +20,12 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:22:11 GMT", + "Date": "Wed, 21 Sep 2022 18:39:00 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDMyMQ==;sn=16864321", + "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDQyNw==;sn=16864427", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "d109bdd2-2e35-4748-8dff-b548c55a99e6" + "x-ms-correlation-request-id": "e49e00e4-8005-4e38-a362-ec7253675842" }, "ResponseBody": { "items": [ @@ -64,4 +64,4 @@ } ], "Variables": {} -} \ No newline at end of file +} diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json index b9005e1077cb..274ab1b8ac7e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json @@ -7,7 +7,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -17,11 +17,11 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "1599", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "Date": "Wed, 21 Sep 2022 18:39:00 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=AhyWxyAqvHlIgeVTxU0ZntE; expires=Fri, 21-Oct-2022 18:22:13 GMT; path=/; secure; HttpOnly; SameSite=None", - "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevruzHA3uNG6YmCUn8KDqEbZhkAJIcrqMGz9qDpTSknEwDCtG0wPNEgOrlOiBwApukfwQx_3YJczFMXMGxa1z7c_SimB-PV2g1wuQwEENhCz18MKm3OZ2BanW9AYbk3ocCLWeEFArzoVXfWbIDIVa1fWrWiT477_18wfP3ZBHoNIgbC97_umYvTkWwpMs7pklZ6SfRKTIP6vkMVEhkoNKCgML5uGG5jyrJeGP-h7UjX4jUgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", + "fpc=AuaI0l5Thi1Ph8qKgY3w55M; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", + "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrXUK8WCbx7_3eLM8Xf9iPBqq-GaEFnitho0XCJynEDnSTZtNHQ0IlZZ2H5Uh-oD7-OLVsDF-fTKQ1-MzOkg6rll2XLpIL0pCqCNbmGhPq_7QQJLyU3I4yOASYKSJvcQR2RFUji-c971-vuLC_yEQHTyrso57pHLqPC0pA2gWYR0DqeuTMgGf7cV3PXCbwlRUUPFquNO44Yfeo3D9Hyog-mTMb_xzZSzrEINr5PfIbMz0gAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], @@ -105,8 +105,8 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "Cookie": "fpc=AhyWxyAqvHlIgeVTxU0ZntE; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + "Cookie": "fpc=AuaI0l5Thi1Ph8qKgY3w55M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -116,16 +116,16 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "945", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "Date": "Wed, 21 Sep 2022 18:39:01 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=AhyWxyAqvHlIgeVTxU0ZntE; expires=Fri, 21-Oct-2022 18:22:13 GMT; path=/; secure; HttpOnly; SameSite=None", + "fpc=AuaI0l5Thi1Ph8qKgY3w55M; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13672.7 - SCUS ProdSlices", + "x-ms-ests-server": "2.1.13622.7 - SCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -181,12 +181,12 @@ "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", - "client-request-id": "13b2341d-c273-44c9-9927-80fb0dcbdaa6", + "client-request-id": "3a839a03-715b-4fc0-b093-fa24c0cfeeef", "Connection": "keep-alive", "Content-Length": "255", "Content-Type": "application/x-www-form-urlencoded", - "Cookie": "fpc=AhyWxyAqvHlIgeVTxU0ZntE; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)", + "Cookie": "fpc=AuaI0l5Thi1Ph8qKgY3w55M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", "x-client-cpu": "x64", "x-client-current-telemetry": "4|730,0|", "x-client-last-telemetry": "4|0|||", @@ -199,23 +199,22 @@ "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-store, no-cache", - "client-request-id": "13b2341d-c273-44c9-9927-80fb0dcbdaa6", + "client-request-id": "3a839a03-715b-4fc0-b093-fa24c0cfeeef", "Content-Length": "111", - "Content-Security-Policy-Report-Only": "script-src \u0027self\u0027 \u0027nonce-hMw6CXt6AY9vBIalIpW2cg\u0027 \u0027unsafe-eval\u0027 \u0027unsafe-inline\u0027; object-src \u0027none\u0027; base-uri \u0027none\u0027; report-uri https://csp.microsoft.com/report/ESTS-UX-All", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "Date": "Wed, 21 Sep 2022 18:39:01 GMT", "Expires": "-1", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Pragma": "no-cache", "Set-Cookie": [ - "fpc=AhyWxyAqvHlIgeVTxU0ZntEW9qlXAQAAAFVNvdoOAAAA; expires=Fri, 21-Oct-2022 18:22:14 GMT; path=/; secure; HttpOnly; SameSite=None", + "fpc=AuaI0l5Thi1Ph8qKgY3w55MW9qlXAQAAAEVRvdoOAAAA; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.13777.4 - WUS2 ProdSlices", + "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -227,14 +226,14 @@ } }, { - "RequestUri": "fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", "RequestMethod": "GET", "RequestHeaders": { "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -244,12 +243,12 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:22:14 GMT", + "Date": "Wed, 21 Sep 2022 18:39:02 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDMyMQ==;sn=16864321", + "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDQyNw==;sn=16864427", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "2d929cdd-7f97-4e20-a757-94498bebb049" + "x-ms-correlation-request-id": "d1f48db0-be79-4eca-a13c-7c1caf29edb5" }, "ResponseBody": { "items": [ @@ -288,4 +287,4 @@ } ], "Variables": {} -} \ No newline at end of file +} From d7ae7dd7f1d18e4b1b30ed079c06439160635ec6 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 13:47:25 -0700 Subject: [PATCH 027/129] Setting secret clients to {} if none. Adding override to shared_requirements --- .../_azureappconfigurationkeyvaultoptions.py | 5 ++++- shared_requirements.txt | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 534c621dd7c9..8d2c646ce084 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -17,8 +17,11 @@ class AzureAppConfigurationKeyVaultOptions: :type secret_resolver: callable """ - def __init__(self, credential=None, secret_clients=dict(), secret_resolver=None): + def __init__(self, credential=None, secret_clients=None, secret_resolver=None): # type: (TokenCredential, List[SecretClient], Callable) -> None self.credential = credential self.secret_clients = secret_clients self.secret_resolver = secret_resolver + + if self.secret_clients is None: + self.secret_clients = {} diff --git a/shared_requirements.txt b/shared_requirements.txt index 3d93b1e4172f..41ac1ef86bbd 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -183,6 +183,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-eventhub-checkpointstoretable azure-core<2.0.0,>=1.14.0 #override azure-eventhub uamqp>=1.6.0,<2.0.0 #override azure-appconfiguration msrest>=0.6.10 +#override azure-appconfiguration azure-keyvault-secrets<5.0.0,>=4.0.0 #override azure-servicebus uamqp>=1.5.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 #override azure-servicebus azure-core<2.0.0,>=1.14.0 From 3dcb5d4868df6e5c81e989ea55381e912a446bc7 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 15:07:43 -0700 Subject: [PATCH 028/129] Updating shared requirements --- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 3 +-- shared_requirements.txt | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index e6826bfacd68..59005df4782e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -74,8 +74,7 @@ install_requires=[ "msrest>=0.6.21", "azure-core<2.0.0,>=1.2.2", - "azure-appconfiguration<2.0.0,>=1.1.1", - "azure-identity<2.0.0,>=1.4.0", + "azure-appconfiguration<2.0.0,>=1.2.0", "azure-keyvault-secrets<5.0.0,>=4.0.0", ], ) diff --git a/shared_requirements.txt b/shared_requirements.txt index 37812a211b1b..35f0da9ff921 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -3,6 +3,7 @@ azure-ai-translation-nspkg azure-ai-language-nspkg azure-iot-nspkg azure-monitor-nspkg +azure-appconfiguration<2.0.0,>=1.2.0 azure-applicationinsights~=0.1.0 azure-batch~=4.1 azure-cognitiveservices-nspkg From 821cd095c6e365b0d8259f56686b1d677fd6c87a Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 15:28:03 -0700 Subject: [PATCH 029/129] Fixed override. Switched to SecretReferenceConfigurationSetting --- .../_azureappconfigurationprovider.py | 11 ++--------- shared_requirements.txt | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index c1f0c4b30c47..bf1c5044b410 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -112,19 +112,12 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client if key_vault_options is None: raise AttributeError( "Key Vault options must be set to resolve Key Vault references.") - try: - j_object = json.loads(config.value) - except json.JSONDecodeError as e: - raise ValueError( - "Invalid JSON value for key vault reference: " + config.key) - uri_value = j_object.get("uri", None) - - if uri_value is None: + if config.secret_id is None: raise AttributeError( "Key Vault reference must have a uri value.") - key_vault_identifier = KeyVaultSecretIdentifier(uri_value) + key_vault_identifier = KeyVaultSecretIdentifier(config.secret_id) referenced_client = None diff --git a/shared_requirements.txt b/shared_requirements.txt index 35f0da9ff921..1a4d42afa2fa 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -186,7 +186,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-eventhub-checkpointstoretable azure-core<2.0.0,>=1.14.0 #override azure-eventhub uamqp>=1.6.0,<2.0.0 #override azure-appconfiguration msrest>=0.6.10 -#override azure-appconfiguration azure-keyvault-secrets<5.0.0,>=4.0.0 +#override azure-appconfiguration-provider azure-keyvault-secrets<5.0.0,>=4.0.0 #override azure-servicebus uamqp>=1.5.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 #override azure-servicebus azure-core<2.0.0,>=1.14.0 From 22a77165f566b1683a8177fdabc5a3c7fbf6f844 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 15:52:54 -0700 Subject: [PATCH 030/129] Updated Requirement KeyVaultSecretIdentifier is needed. --- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 2 +- shared_requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 59005df4782e..596121e98136 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -75,6 +75,6 @@ "msrest>=0.6.21", "azure-core<2.0.0,>=1.2.2", "azure-appconfiguration<2.0.0,>=1.2.0", - "azure-keyvault-secrets<5.0.0,>=4.0.0", + "azure-keyvault-secrets<5.0.0,>=4.3.0", ], ) diff --git a/shared_requirements.txt b/shared_requirements.txt index 1a4d42afa2fa..4a69c595148e 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -186,7 +186,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-eventhub-checkpointstoretable azure-core<2.0.0,>=1.14.0 #override azure-eventhub uamqp>=1.6.0,<2.0.0 #override azure-appconfiguration msrest>=0.6.10 -#override azure-appconfiguration-provider azure-keyvault-secrets<5.0.0,>=4.0.0 +#override azure-appconfiguration-provider azure-keyvault-secrets<5.0.0,>=4.3.0 #override azure-servicebus uamqp>=1.5.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 #override azure-servicebus azure-core<2.0.0,>=1.14.0 From f67503c6f21404b154db791a14fd9d4bce0c5b4d Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 16:52:05 -0700 Subject: [PATCH 031/129] Update ci.yml --- sdk/appconfiguration/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index 0243a961ba45..bef1907c22b2 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -34,5 +34,7 @@ extends: Artifacts: - name: azure-appconfiguration safeName: azureappconfiguration + - name: azure-appconfiguration-provider + safeName: azureappconfigurationprovider - name: azure-mgmt-appconfiguration safeName: azuremgmtappconfiguration \ No newline at end of file From 34f274d7b7e361aaaabe6cd95d168ab995751d15 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 16:53:04 -0700 Subject: [PATCH 032/129] Update ci.yml --- sdk/appconfiguration/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index bef1907c22b2..1542a66a49f5 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -31,6 +31,7 @@ extends: ServiceDirectory: appconfiguration VerifyAutorest: false ValidateFormatting: false + TestProxy: true Artifacts: - name: azure-appconfiguration safeName: azureappconfiguration From ceab535c45c32d359f6bbbb0b5337d3d9cf8f17b Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 08:43:17 -0700 Subject: [PATCH 033/129] Fixed structure --- .../azure/appconfiguration/__init__.py | 2 ++ .../provider}/__init__.py | 0 .../provider}/_azureappconfigurationkeyvaultoptions.py | 0 .../provider}/_azureappconfigurationprovider.py | 0 .../provider}/_constants.py | 0 .../provider}/_settingselector.py | 0 .../provider}/_user_agent.py | 0 .../provider}/_version.py | 0 .../azure-appconfiguration-provider/samples/aad_sample.py | 2 +- .../samples/connection_string_sample.py | 2 +- .../samples/key_vault_reference_provided_clients_sample.py | 2 +- .../samples/key_vault_reference_sample.py | 2 +- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 2 +- .../azure-appconfiguration-provider/tests/test_provider.py | 2 +- 14 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/__init__.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_azureappconfigurationprovider.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_constants.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_settingselector.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_user_agent.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_version.py (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py new file mode 100644 index 000000000000..229d1b3c8804 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py @@ -0,0 +1,2 @@ +__path__ = __import__("pkgutil").extend_path( + __path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index 52ad33fe735b..122daa6ad70c 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index 7550e77039db..bd4f1b1dbc34 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 9151f1a699ef..8d67f617c34c 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index a66664f34bcf..4e02cb434197 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 596121e98136..8da1268eb78b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -13,7 +13,7 @@ from setuptools import find_packages, setup # Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-appconfigurationprovider" +PACKAGE_NAME = "azure-appconfiguration-provider" PACKAGE_PPRINT_NAME = "App Configuration Provider" # a-b-c => a/b/c diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index fb656449fc8e..2b3f5023406b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- import functools -from azure.appconfigurationprovider import AzureAppConfigurationProvider +from azure.appconfiguration.provider import AzureAppConfigurationProvider from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy from azure.appconfiguration import AzureAppConfigurationClient import inspect From d9e75a6f037aeb7b053875180ad7960614ec27a7 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 09:51:51 -0700 Subject: [PATCH 034/129] Update dev_requirements.txt --- .../azure-appconfiguration-provider/dev_requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt index adab992bf639..c811a688cdf7 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt +++ b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt @@ -2,6 +2,7 @@ ../../core/azure-core -e ../azure-appconfiguration -e ../../identity/azure-identity +-e ../../keyvault/azure-keyvault-secrets aiohttp>=3.0 -e ../../../tools/azure-sdk-tools -e ../../../tools/azure-devtools \ No newline at end of file From 8407fbcbabacfd7681dee35a1a5b446e49d5190c Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 10:32:54 -0700 Subject: [PATCH 035/129] Update sdk_packaging.toml --- .../azure-appconfiguration-provider/sdk_packaging.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml index 1f3da94f6908..7d93f77a90ba 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml +++ b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml @@ -1,5 +1,5 @@ [packaging] -package_name = "azure-app-configuration-provider" +package_name = "azure-appconfiguration-provider" package_nspkg = "azure-data-nspkg" package_pprint_name = "App Configuration Provider" package_doc_id = "" From 6ce62f57742166d4fb038c847af727aee3bfc160 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 15:15:06 -0700 Subject: [PATCH 036/129] Revert working state --- .../azure/appconfiguration/__init__.py | 2 -- .../provider => appconfigurationprovider}/__init__.py | 0 .../_azureappconfigurationkeyvaultoptions.py | 0 .../_azureappconfigurationprovider.py | 6 ++++-- .../provider => appconfigurationprovider}/_constants.py | 0 .../_settingselector.py | 0 .../provider => appconfigurationprovider}/_user_agent.py | 0 .../provider => appconfigurationprovider}/_version.py | 0 .../azure-appconfiguration-provider/samples/aad_sample.py | 2 +- .../samples/key_vault_reference_provided_clients_sample.py | 2 +- .../samples/key_vault_reference_sample.py | 2 +- .../azure-appconfiguration-provider/sdk_packaging.toml | 2 +- .../azure-appconfiguration-provider/setup.py | 2 +- .../azure-appconfiguration-provider/tests/test_provider.py | 2 +- sdk/appconfiguration/ci.yml | 2 +- 15 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/__init__.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_azureappconfigurationprovider.py (98%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_constants.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_settingselector.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_user_agent.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_version.py (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py deleted file mode 100644 index 229d1b3c8804..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__path__ = __import__("pkgutil").extend_path( - __path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py similarity index 98% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index bf1c5044b410..53a517c5db1d 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -6,8 +6,10 @@ import json from azure.appconfiguration import AzureAppConfigurationClient -from azure.keyvault.secrets import SecretClient -from azure.keyvault.secrets import KeyVaultSecretIdentifier +from azure.keyvault.secrets import ( + SecretClient, + KeyVaultSecretIdentifier +) from azure.core.exceptions import ( HttpResponseError, ResourceNotFoundError diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index 122daa6ad70c..52ad33fe735b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 8d67f617c34c..9151f1a699ef 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index 4e02cb434197..a66664f34bcf 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml index 7d93f77a90ba..32efea5975a9 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml +++ b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml @@ -1,5 +1,5 @@ [packaging] -package_name = "azure-appconfiguration-provider" +package_name = "azure-appconfigurationprovider" package_nspkg = "azure-data-nspkg" package_pprint_name = "App Configuration Provider" package_doc_id = "" diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 8da1268eb78b..596121e98136 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -13,7 +13,7 @@ from setuptools import find_packages, setup # Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-appconfiguration-provider" +PACKAGE_NAME = "azure-appconfigurationprovider" PACKAGE_PPRINT_NAME = "App Configuration Provider" # a-b-c => a/b/c diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index 2b3f5023406b..fb656449fc8e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- import functools -from azure.appconfiguration.provider import AzureAppConfigurationProvider +from azure.appconfigurationprovider import AzureAppConfigurationProvider from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy from azure.appconfiguration import AzureAppConfigurationClient import inspect diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index 1542a66a49f5..ab40932bd913 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -35,7 +35,7 @@ extends: Artifacts: - name: azure-appconfiguration safeName: azureappconfiguration - - name: azure-appconfiguration-provider + - name: azure-appconfigurationprovider safeName: azureappconfigurationprovider - name: azure-mgmt-appconfiguration safeName: azuremgmtappconfiguration \ No newline at end of file From 95e5d30a9e34b53419e476d3d27842b7e9506a7e Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 15:23:18 -0700 Subject: [PATCH 037/129] Renamed correctly --- .../azure/appconfiguration/__init__.py | 2 ++ .../provider}/__init__.py | 0 .../provider}/_azureappconfigurationkeyvaultoptions.py | 0 .../provider}/_azureappconfigurationprovider.py | 0 .../provider}/_constants.py | 0 .../provider}/_settingselector.py | 0 .../provider}/_user_agent.py | 0 .../provider}/_version.py | 0 .../azure-appconfiguration-provider/samples/aad_sample.py | 2 +- .../samples/key_vault_reference_provided_clients_sample.py | 2 +- .../samples/key_vault_reference_sample.py | 2 +- .../azure-appconfiguration-provider/sdk_packaging.toml | 2 +- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 2 +- .../azure-appconfiguration-provider/tests/test_provider.py | 2 +- sdk/appconfiguration/ci.yml | 2 +- 15 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/__init__.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_azureappconfigurationprovider.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_constants.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_settingselector.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_user_agent.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_version.py (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py new file mode 100644 index 000000000000..229d1b3c8804 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py @@ -0,0 +1,2 @@ +__path__ = __import__("pkgutil").extend_path( + __path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index 52ad33fe735b..122daa6ad70c 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 9151f1a699ef..8d67f617c34c 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index a66664f34bcf..4e02cb434197 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml index 32efea5975a9..7d93f77a90ba 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml +++ b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml @@ -1,5 +1,5 @@ [packaging] -package_name = "azure-appconfigurationprovider" +package_name = "azure-appconfiguration-provider" package_nspkg = "azure-data-nspkg" package_pprint_name = "App Configuration Provider" package_doc_id = "" diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 596121e98136..8da1268eb78b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -13,7 +13,7 @@ from setuptools import find_packages, setup # Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-appconfigurationprovider" +PACKAGE_NAME = "azure-appconfiguration-provider" PACKAGE_PPRINT_NAME = "App Configuration Provider" # a-b-c => a/b/c diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index fb656449fc8e..2b3f5023406b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- import functools -from azure.appconfigurationprovider import AzureAppConfigurationProvider +from azure.appconfiguration.provider import AzureAppConfigurationProvider from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy from azure.appconfiguration import AzureAppConfigurationClient import inspect diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index ab40932bd913..1542a66a49f5 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -35,7 +35,7 @@ extends: Artifacts: - name: azure-appconfiguration safeName: azureappconfiguration - - name: azure-appconfigurationprovider + - name: azure-appconfiguration-provider safeName: azureappconfigurationprovider - name: azure-mgmt-appconfiguration safeName: azuremgmtappconfiguration \ No newline at end of file From fdc6e98e3ce488f77a7e41c4506ea7a39ed65d9a Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 16:08:17 -0700 Subject: [PATCH 038/129] Using azure-appconfigurationprovider --- .../azure/appconfiguration/__init__.py | 2 -- .../provider => appconfigurationprovider}/__init__.py | 0 .../_azureappconfigurationkeyvaultoptions.py | 0 .../_azureappconfigurationprovider.py | 0 .../provider => appconfigurationprovider}/_constants.py | 0 .../provider => appconfigurationprovider}/_settingselector.py | 0 .../provider => appconfigurationprovider}/_user_agent.py | 0 .../provider => appconfigurationprovider}/_version.py | 0 .../azure-appconfiguration-provider/samples/README.md | 2 +- .../azure-appconfiguration-provider/samples/aad_sample.py | 2 +- .../samples/connection_string_sample.py | 2 +- .../samples/key_vault_reference_provided_clients_sample.py | 2 +- .../samples/key_vault_reference_sample.py | 2 +- .../azure-appconfiguration-provider/sdk_packaging.toml | 2 +- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 2 +- .../azure-appconfiguration-provider/tests/test_provider.py | 2 +- sdk/appconfiguration/ci.yml | 2 +- 17 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/__init__.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_azureappconfigurationprovider.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_constants.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_settingselector.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_user_agent.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_version.py (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py deleted file mode 100644 index 229d1b3c8804..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__path__ = __import__("pkgutil").extend_path( - __path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md index 881144ea7209..166e5da217f5 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md @@ -39,7 +39,7 @@ az appconfig kv set-keyvault --name --key secret --secret-id Install the Azure App Configuration Provider client library for Python with pip: ```commandline -pip install azure-appconfiguration-provider +pip install provider ``` ## Contents diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index 122daa6ad70c..52ad33fe735b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index bd4f1b1dbc34..7550e77039db 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 8d67f617c34c..9151f1a699ef 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index 4e02cb434197..a66664f34bcf 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml index 7d93f77a90ba..32efea5975a9 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml +++ b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml @@ -1,5 +1,5 @@ [packaging] -package_name = "azure-appconfiguration-provider" +package_name = "azure-appconfigurationprovider" package_nspkg = "azure-data-nspkg" package_pprint_name = "App Configuration Provider" package_doc_id = "" diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 8da1268eb78b..596121e98136 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -13,7 +13,7 @@ from setuptools import find_packages, setup # Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-appconfiguration-provider" +PACKAGE_NAME = "azure-appconfigurationprovider" PACKAGE_PPRINT_NAME = "App Configuration Provider" # a-b-c => a/b/c diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index 2b3f5023406b..fb656449fc8e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- import functools -from azure.appconfiguration.provider import AzureAppConfigurationProvider +from azure.appconfigurationprovider import AzureAppConfigurationProvider from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy from azure.appconfiguration import AzureAppConfigurationClient import inspect diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index 1542a66a49f5..ab40932bd913 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -35,7 +35,7 @@ extends: Artifacts: - name: azure-appconfiguration safeName: azureappconfiguration - - name: azure-appconfiguration-provider + - name: azure-appconfigurationprovider safeName: azureappconfigurationprovider - name: azure-mgmt-appconfiguration safeName: azuremgmtappconfiguration \ No newline at end of file From e6d65fb94e63ec829e46da83f0cf00c4f9406d10 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 16:26:09 -0700 Subject: [PATCH 039/129] Fixing shared Requirements merge issue --- shared_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared_requirements.txt b/shared_requirements.txt index e4f47bf8c745..bdb2d3d70f47 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -187,7 +187,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-eventhub uamqp>=1.6.0,<2.0.0 #override azure-appconfiguration msrest>=0.6.10 #override azure-appconfiguration azure-core<2.0.0,>=1.24.0 -#override azure-appconfiguration-provider azure-keyvault-secrets<5.0.0,>=4.3.0 +#override azure-appconfigurationprovider azure-keyvault-secrets<5.0.0,>=4.3.0 #override azure-servicebus uamqp>=1.5.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 #override azure-servicebus azure-core<2.0.0,>=1.14.0 From 4a6b17c26492a9da598f1626062f405dd72fc3c1 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 11:10:03 -0700 Subject: [PATCH 040/129] Updated from review comments --- .../_azure_appconfiguration_provider_error.py | 12 +++++++ .../_azureappconfigurationprovider.py | 31 ++++++++----------- 2 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py new file mode 100644 index 000000000000..8b7e2f3dacfa --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py @@ -0,0 +1,12 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + +class KeyVaultReferenceError(ValueError): + """Raised when a Key Vault reference is invalid.""" + + def __init__(self, message, *args): + # type: (str, Any) -> None + super(KeyVaultReferenceError, self).__init__(message, *args) \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 53a517c5db1d..91b5a6c99cd4 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -15,9 +15,9 @@ ResourceNotFoundError ) from ._settingselector import SettingSelector -from ._constants import ( - KEY_VAULT_REFERENCE_CONTENT_TYPE -) +from ._azure_appconfiguration_provider_error import KeyVaultReferenceError +from ._constants import KEY_VAULT_REFERENCE_CONTENT_TYPE + from ._user_agent import USER_AGENT @@ -75,15 +75,15 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): raise e for config in configurations: if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: - provider.__resolve_keyvault_references( - config, key_vault_options, secret_clients) + secret = provider.__resolve_keyvault_reference(config, key_vault_options, secret_clients) + provider._dict[provider.__trim(config.key)] = secret elif provider.__is_json_content_type(config.content_type): try: j_object = json.loads(config.value) provider._dict[provider.__trim(config.key)] = j_object except json.JSONDecodeError as e: - raise ValueError( - "Invalid JSON value for key: " + config.key) + # If the value is not a valid JSON, treat it like regular string value + provider._dict[provider.__trim(config.key)] = config.value else: provider._dict[provider.__trim(config.key)] = config.value return provider @@ -93,7 +93,7 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt correlation_context = "RequestType=Startup" if (key_vault_options and - (key_vault_options.credential or key_vault_options or key_vault_options.secret_resolver)): + (key_vault_options.credential or key_vault_options.secret_clients or key_vault_options.secret_resolver)): correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context @@ -110,7 +110,7 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt self._client = AzureAppConfigurationClient( endpoint, credential, user_agent=useragent, headers=headers) - def __resolve_keyvault_references(self, config, key_vault_options, secret_clients): + def __resolve_keyvault_reference(self, config, key_vault_options, secret_clients): if key_vault_options is None: raise AttributeError( "Key Vault options must be set to resolve Key Vault references.") @@ -134,21 +134,16 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client if referenced_client: try: - secret = referenced_client.get_secret( - key_vault_identifier.name, version=key_vault_identifier.version) - self._dict[self.__trim(config.key)] = secret.value - return + return referenced_client.get_secret(key_vault_identifier.name, version=key_vault_identifier.version) except ResourceNotFoundError as e: - raise ValueError("Key Vault %s does not contain secret %s" % ( + raise KeyVaultReferenceError("Key Vault %s does not contain secret %s" % ( key_vault_identifier.vault_url, key_vault_identifier.name)) except HttpResponseError as e: raise e if key_vault_options.secret_resolver is not None: - self._dict[self.__trim( - config.key)] = key_vault_options.secret_resolver(key_vault_identifier.vault_url) - return - raise AttributeError( + return key_vault_options.secret_resolver(config.secret_id) + raise KeyVaultReferenceError( "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) @staticmethod From 76c4fb9b7aab4618b5aa0ae7fa6795866eb7c009 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 12:13:35 -0700 Subject: [PATCH 041/129] Fixing package folder --- .../CHANGELOG.md | 0 .../LICENSE | 0 .../MANIFEST.in | 0 .../README.md | 0 .../azure/__init__.py | 0 .../azure/appconfigurationprovider/__init__.py | 0 .../_azure_appconfiguration_provider_error.py | 0 .../_azureappconfigurationkeyvaultoptions.py | 0 .../_azureappconfigurationprovider.py | 8 ++------ .../azure/appconfigurationprovider/_constants.py | 0 .../azure/appconfigurationprovider/_settingselector.py | 0 .../azure/appconfigurationprovider/_user_agent.py | 0 .../azure/appconfigurationprovider/_version.py | 0 .../dev_requirements.txt | 0 .../mypy.ini | 0 .../samples/README.md | 0 .../samples/aad_sample.py | 0 .../samples/connection_string_sample.py | 0 .../key_vault_reference_provided_clients_sample.py | 0 .../samples/key_vault_reference_sample.py | 0 .../sdk_packaging.toml | 0 .../setup.py | 2 +- .../tests/conftest.py | 0 ...estAppConfigurationProvidertest_provider_creation.json | 0 ...ppConfigurationProvidertest_provider_creation_aad.json | 0 .../tests/test_provider.py | 0 26 files changed, 3 insertions(+), 7 deletions(-) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/CHANGELOG.md (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/LICENSE (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/MANIFEST.in (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/README.md (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/__init__.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/__init__.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_azureappconfigurationprovider.py (97%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_constants.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_settingselector.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_user_agent.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_version.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/dev_requirements.txt (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/mypy.ini (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/samples/README.md (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/samples/aad_sample.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/samples/connection_string_sample.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/samples/key_vault_reference_provided_clients_sample.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/samples/key_vault_reference_sample.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/sdk_packaging.toml (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/setup.py (97%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/tests/conftest.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/tests/test_provider.py (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md b/sdk/appconfiguration/azure-appconfigurationprovider/CHANGELOG.md similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md rename to sdk/appconfiguration/azure-appconfigurationprovider/CHANGELOG.md diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/LICENSE b/sdk/appconfiguration/azure-appconfigurationprovider/LICENSE similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/LICENSE rename to sdk/appconfiguration/azure-appconfigurationprovider/LICENSE diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in b/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in rename to sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfigurationprovider/README.md similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/README.md rename to sdk/appconfiguration/azure-appconfigurationprovider/README.md diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py similarity index 97% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 91b5a6c99cd4..66de236e7936 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -121,12 +121,8 @@ def __resolve_keyvault_reference(self, config, key_vault_options, secret_clients key_vault_identifier = KeyVaultSecretIdentifier(config.secret_id) - referenced_client = None - - for secret_client in secret_clients: - if secret_client.vault_url == key_vault_identifier.vault_url: - referenced_client = secret_client - break + referenced_client = next((client for client in secret_clients if client.vault_url == key_vault_identifier.vault_url), None) + if referenced_client is None and key_vault_options.credential is not None: referenced_client = SecretClient( vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_version.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfigurationprovider/dev_requirements.txt similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt rename to sdk/appconfiguration/azure-appconfigurationprovider/dev_requirements.txt diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini b/sdk/appconfiguration/azure-appconfigurationprovider/mypy.ini similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini rename to sdk/appconfiguration/azure-appconfigurationprovider/mypy.ini diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md b/sdk/appconfiguration/azure-appconfigurationprovider/samples/README.md similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md rename to sdk/appconfiguration/azure-appconfigurationprovider/samples/README.md diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py rename to sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py rename to sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_provided_clients_sample.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py rename to sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_provided_clients_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_sample.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py rename to sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfigurationprovider/sdk_packaging.toml similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml rename to sdk/appconfiguration/azure-appconfigurationprovider/sdk_packaging.toml diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfigurationprovider/setup.py similarity index 97% rename from sdk/appconfiguration/azure-appconfiguration-provider/setup.py rename to sdk/appconfiguration/azure-appconfigurationprovider/setup.py index 596121e98136..7d82158a004a 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/setup.py @@ -55,7 +55,7 @@ license="MIT License", author="Microsoft Corporation", author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration-provider", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfigurationprovider", classifiers=[ "Development Status :: 5 - Production/Stable", "Programming Language :: Python", diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py rename to sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json rename to sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json rename to sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py rename to sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py From 5c2d30e957f1775fc6142f32df02400ae3e68872 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 12:34:18 -0700 Subject: [PATCH 042/129] Fix lint, removed extra fixture --- .../_azure_appconfiguration_provider_error.py | 4 ---- .../_azureappconfigurationprovider.py | 6 ++++-- .../azure-appconfigurationprovider/tests/conftest.py | 7 ------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py index 8b7e2f3dacfa..0bc4fdb0c0b3 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py @@ -6,7 +6,3 @@ class KeyVaultReferenceError(ValueError): """Raised when a Key Vault reference is invalid.""" - - def __init__(self, message, *args): - # type: (str, Any) -> None - super(KeyVaultReferenceError, self).__init__(message, *args) \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 66de236e7936..655ea05383b2 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -93,7 +93,8 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt correlation_context = "RequestType=Startup" if (key_vault_options and - (key_vault_options.credential or key_vault_options.secret_clients or key_vault_options.secret_resolver)): + (key_vault_options.credential or + key_vault_options.secret_clients or key_vault_options.secret_resolver)): correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context @@ -110,7 +111,8 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt self._client = AzureAppConfigurationClient( endpoint, credential, user_agent=useragent, headers=headers) - def __resolve_keyvault_reference(self, config, key_vault_options, secret_clients): + @staticmethod + def __resolve_keyvault_reference(config, key_vault_options, secret_clients): if key_vault_options is None: raise AttributeError( "Key Vault options must be set to resolve Key Vault references.") diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py index aa499fb92527..cb502f715c0f 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py @@ -8,13 +8,6 @@ # autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method -@pytest.fixture(scope="session", autouse=True) -def start_proxy(test_proxy): - return - -# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method - - @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): add_general_regex_sanitizer(value="https://fake-endpoint.azconfig.io", From 9171668e811327a9d2d1fb8c03adee1062430d75 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 16:10:22 -0700 Subject: [PATCH 043/129] Create py.typed --- .../azure/appconfigurationprovider/py.typed | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/py.typed diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/py.typed b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/py.typed new file mode 100644 index 000000000000..e69de29bb2d1 From f81281cf77d39964f3ab9e2a6e11ae6c838d2111 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 16:12:45 -0700 Subject: [PATCH 044/129] Updated Manifest to use right py.typed file --- sdk/appconfiguration/azure-appconfiguration/MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in b/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in index c33cc70f3bd4..79397d225f59 100644 --- a/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in +++ b/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in @@ -4,4 +4,4 @@ include LICENSE include azure/__init__.py recursive-include samples *.py *.md recursive-include doc *.rst -include azure/appconfiguration/py.typed +include azure/appconfigurationprovider/py.typed From 740ba6577a9b0544462fa6b0077d8dddc1398970 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 16:21:17 -0700 Subject: [PATCH 045/129] Switched Files --- sdk/appconfiguration/azure-appconfiguration/MANIFEST.in | 2 +- sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in b/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in index 79397d225f59..c33cc70f3bd4 100644 --- a/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in +++ b/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in @@ -4,4 +4,4 @@ include LICENSE include azure/__init__.py recursive-include samples *.py *.md recursive-include doc *.rst -include azure/appconfigurationprovider/py.typed +include azure/appconfiguration/py.typed diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in b/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in index 731abed60dd1..4bb4e84cc2d6 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in +++ b/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in @@ -4,4 +4,4 @@ include LICENSE include azure/__init__.py recursive-include samples *.py *.md recursive-include doc *.rst -include azure/appconfiguration/py.typed \ No newline at end of file +include azure/provider/py.typed \ No newline at end of file From 7a436aae5747875df76c1961f1836aaa2b11f54a Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 16:45:57 -0700 Subject: [PATCH 046/129] Fixing lint issue --- .../_azureappconfigurationprovider.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 655ea05383b2..e7918a96e5f9 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -93,7 +93,7 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt correlation_context = "RequestType=Startup" if (key_vault_options and - (key_vault_options.credential or + (key_vault_options.credential or key_vault_options.secret_clients or key_vault_options.secret_resolver)): correlation_context += ",UsesKeyVault" @@ -123,8 +123,9 @@ def __resolve_keyvault_reference(config, key_vault_options, secret_clients): key_vault_identifier = KeyVaultSecretIdentifier(config.secret_id) - referenced_client = next((client for client in secret_clients if client.vault_url == key_vault_identifier.vault_url), None) - + referenced_client = next( + (client for client in secret_clients if client.vault_url == key_vault_identifier.vault_url), None) + if referenced_client is None and key_vault_options.credential is not None: referenced_client = SecretClient( vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) From 3d0a7e94ce00263527cb889a6d2c2dea8f6c37c0 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 17:18:14 -0700 Subject: [PATCH 047/129] Setting defaults for test --- .../azure-appconfigurationprovider/tests/conftest.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py index cb502f715c0f..0f9438676749 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py @@ -10,13 +10,13 @@ @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): - add_general_regex_sanitizer(value="https://fake-endpoint.azconfig.io", - regex=os.environ.get('APPCONFIGURATION_ENDPOINT_STRING')) + add_general_regex_sanitizer(value="https://fake-endpoint.azconfig.io", + regex=os.environ.get('APPCONFIGURATION_ENDPOINT_STRING', "https://fake-endpoint.azconfig.io")) add_general_regex_sanitizer(value="fake-connection-string", - regex=os.environ.get('APPCONFIGURATION_CONNECTION_STRING')) + regex=os.environ.get('APPCONFIGURATION_CONNECTION_STRING', "fake-connection-string")) add_general_regex_sanitizer( - value="fake-client-id", regex=os.environ.get('APPCONFIGURATION_CLIENT_ID')) + value="fake-client-id", regex=os.environ.get('APPCONFIGURATION_CLIENT_ID', "fake-client-id")) add_general_regex_sanitizer( - value="fake-client-secret", regex=os.environ.get('APPCONFIGURATION_CLIENT_SECRET')) + value="fake-client-secret", regex=os.environ.get('APPCONFIGURATION_CLIENT_SECRET', "fake-client-secret")) add_general_regex_sanitizer( - value="fake-tenant-id", regex=os.environ.get('APPCONFIGURATION_TENANT_ID')) + value="fake-tenant-id", regex=os.environ.get('APPCONFIGURATION_TENANT_ID', "fake-tenant-id")) From b8faf099d14dcd5983bf8f0c073c7cc23e7c3670 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 26 Sep 2022 10:29:17 -0700 Subject: [PATCH 048/129] Updating Docs --- .../_azureappconfigurationkeyvaultoptions.py | 1 + .../_azureappconfigurationprovider.py | 5 +++++ .../azure/appconfigurationprovider/_settingselector.py | 1 + 3 files changed, 7 insertions(+) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 8d2c646ce084..5032d2812539 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -7,6 +7,7 @@ class AzureAppConfigurationKeyVaultOptions: """ Options for connecting to Key Vault. + :param credential: A credential for authenticating with the key vault. This is optional if secret_clients is provided. :type credential: ~azure.core.credentials.TokenCredential diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index e7918a96e5f9..e1ac17389592 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -38,6 +38,7 @@ def __init__(self): def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): """ Loads configuration settings from Azure App Configuration into a Python application. + :param connection_string: Connection string (one of connection_string or endpoint and credential must be set) :type connection_string: str :param endpoint: Endpoint (one of connection_string or endpoint and credential must be set) @@ -185,6 +186,7 @@ def __len__(self): def copy(self): """ Returns a copy of the configuration settings + type: () -> dict """ return self._dict.copy() @@ -192,6 +194,7 @@ def copy(self): def has_key(self, k): """ Returns True if the configuration settings has been loaded from Azure App Configuration. + type: (str) -> bool """ return k in self._dict @@ -199,6 +202,7 @@ def has_key(self, k): def keys(self): """ Returns a list of keys loaded from Azure App Configuration. + type: () -> list """ return self._dict.keys() @@ -207,6 +211,7 @@ def values(self): """ Returns a list of values loaded from Azure App Configuration. Any values that are Key Vault references will be resolved. + type: () -> list """ return self._dict.values() diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py index a82699284710..15ee4f0baf85 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py @@ -7,6 +7,7 @@ class SettingSelector: """ Selects a set of configuration settings from Azure App Configuration. + :param key_filter: A filter to select configuration settings based on their keys. :type key_filter: str :param label_filter: A filter to select configuration settings based on their labels. Default is value is '\0' From 8efbc43c83001e7d773db039a442f2af85d2c1b1 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 26 Sep 2022 11:01:50 -0700 Subject: [PATCH 049/129] Fixing Whitespace --- .../_azureappconfigurationkeyvaultoptions.py | 2 +- .../appconfigurationprovider/_azureappconfigurationprovider.py | 2 +- .../azure/appconfigurationprovider/_settingselector.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 5032d2812539..d640015c0695 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -7,7 +7,7 @@ class AzureAppConfigurationKeyVaultOptions: """ Options for connecting to Key Vault. - + :param credential: A credential for authenticating with the key vault. This is optional if secret_clients is provided. :type credential: ~azure.core.credentials.TokenCredential diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index e1ac17389592..2560788a9950 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -211,7 +211,7 @@ def values(self): """ Returns a list of values loaded from Azure App Configuration. Any values that are Key Vault references will be resolved. - + type: () -> list """ return self._dict.values() diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py index 15ee4f0baf85..c56d6ca8ae80 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py @@ -7,7 +7,7 @@ class SettingSelector: """ Selects a set of configuration settings from Azure App Configuration. - + :param key_filter: A filter to select configuration settings based on their keys. :type key_filter: str :param label_filter: A filter to select configuration settings based on their labels. Default is value is '\0' From b2cc043f6fab073f12e559658d87f20158048e83 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 26 Sep 2022 15:45:11 -0700 Subject: [PATCH 050/129] Updating to support in operation --- .../_azureappconfigurationprovider.py | 8 ++++---- .../samples/connection_string_sample.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 2560788a9950..988badc96c3d 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -191,13 +191,13 @@ def copy(self): """ return self._dict.copy() - def has_key(self, k): + def __contains__(self, __x: object): """ - Returns True if the configuration settings has been loaded from Azure App Configuration. + Returns True if the configuration settings contains the specified key - type: (str) -> bool + type: (object) -> bool """ - return k in self._dict + return self._dict.__contains__(__x) def keys(self): """ diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py index 7550e77039db..d531643e8c56 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py @@ -31,5 +31,5 @@ config = AzureAppConfigurationProvider.load( connection_string=connection_string, selects=selects) -print("message found: " + str(config.has_key("message"))) -print("test.message found: " + str(config.has_key("config.message"))) +print("message found: " + str("message" in config)) +print("test.message found: " + str("test.message" in config)) From e6619bdcb79f6555a10fda5074a87185ce0d83f6 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 26 Sep 2022 15:47:11 -0700 Subject: [PATCH 051/129] Updated sample with in usage --- .../azure-appconfigurationprovider/samples/aad_sample.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py index 52ad33fe735b..c525bc02f88b 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py @@ -32,5 +32,5 @@ config = AzureAppConfigurationProvider.load( endpoint=endpoint, credential=credential, selects=selects) -print("message found: " + str(config.has_key("message"))) -print("test.message found: " + str(config.has_key("config.message"))) +print("message found: " + str("message" in config)) +print("test.message found: " + str("test.message" in config)) From 176673ad49d063771b78ce8dc6e719d13fb27c4c Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 26 Sep 2022 15:58:02 -0700 Subject: [PATCH 052/129] Cleaned up key trimming usage --- .../_azureappconfigurationprovider.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 988badc96c3d..7902e7de0b21 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -75,18 +75,26 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): except HttpResponseError as e: raise e for config in configurations: + + trimmed_key = config.key + # Trim the key if it starts with one of the prefixes provided + for trim in provider._trim_prefixes: + if config.key.startswith(trim): + trimmed_key = config.key[len(trim):] + break + if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: secret = provider.__resolve_keyvault_reference(config, key_vault_options, secret_clients) - provider._dict[provider.__trim(config.key)] = secret + provider._dict[trimmed_key] = secret elif provider.__is_json_content_type(config.content_type): try: j_object = json.loads(config.value) - provider._dict[provider.__trim(config.key)] = j_object + provider._dict[trimmed_key] = j_object except json.JSONDecodeError as e: # If the value is not a valid JSON, treat it like regular string value - provider._dict[provider.__trim(config.key)] = config.value + provider._dict[trimmed_key] = config.value else: - provider._dict[provider.__trim(config.key)] = config.value + provider._dict[trimmed_key] = config.value return provider def __buildprovider(self, connection_string, endpoint, credential, key_vault_options): @@ -168,12 +176,6 @@ def __is_json_content_type(content_type): return False - def __trim(self, key): - for trim in self._trim_prefixes: - if key.startswith(trim): - return key[len(trim):] - return key - def __getitem__(self, key): return self._dict[key] From dfd6facfa1ac4a5d2778a5d5d4ed82b1ec6170dd Mon Sep 17 00:00:00 2001 From: mrm9084 Date: Tue, 27 Sep 2022 10:22:08 -0700 Subject: [PATCH 053/129] Removed extra catches for now. Cleaned up lint. --- .../_azureappconfigurationprovider.py | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 7902e7de0b21..d82239dfceb8 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -10,10 +10,7 @@ SecretClient, KeyVaultSecretIdentifier ) -from azure.core.exceptions import ( - HttpResponseError, - ResourceNotFoundError -) +from azure.core.exceptions import ResourceNotFoundError from ._settingselector import SettingSelector from ._azure_appconfiguration_provider_error import KeyVaultReferenceError from ._constants import KEY_VAULT_REFERENCE_CONTENT_TYPE @@ -69,11 +66,8 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): secret_clients = key_vault_options.secret_clients if key_vault_options else {} for select in selects: - try: - configurations = provider._client.list_configuration_settings( - key_filter=select.key_filter, label_filter=select.label_filter) - except HttpResponseError as e: - raise e + configurations = provider._client.list_configuration_settings( + key_filter=select.key_filter, label_filter=select.label_filter) for config in configurations: trimmed_key = config.key @@ -82,7 +76,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): if config.key.startswith(trim): trimmed_key = config.key[len(trim):] break - + if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: secret = provider.__resolve_keyvault_reference(config, key_vault_options, secret_clients) provider._dict[trimmed_key] = secret @@ -90,7 +84,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): try: j_object = json.loads(config.value) provider._dict[trimmed_key] = j_object - except json.JSONDecodeError as e: + except json.JSONDecodeError: # If the value is not a valid JSON, treat it like regular string value provider._dict[trimmed_key] = config.value else: @@ -143,11 +137,10 @@ def __resolve_keyvault_reference(config, key_vault_options, secret_clients): if referenced_client: try: return referenced_client.get_secret(key_vault_identifier.name, version=key_vault_identifier.version) - except ResourceNotFoundError as e: + except ResourceNotFoundError: raise KeyVaultReferenceError("Key Vault %s does not contain secret %s" % ( key_vault_identifier.vault_url, key_vault_identifier.name)) - except HttpResponseError as e: - raise e + if key_vault_options.secret_resolver is not None: return key_vault_options.secret_resolver(config.secret_id) From b2bfbff1511f2be6a5930a4b3c2e043842ed0203 Mon Sep 17 00:00:00 2001 From: mrm9084 Date: Tue, 27 Sep 2022 15:44:15 -0700 Subject: [PATCH 054/129] Adding more tests --- .../_azureappconfigurationprovider.py | 2 +- .../tests/conftest.py | 9 +- .../tests/preparers.py | 60 +++ ...urationProvidertest_provider_creation.json | 28 +- ...rationProvidertest_provider_selectors.json | 47 ++ ...dertest_provider_trimmed_key_prefixes.json | 67 +++ ...onProvidertest_provider_creation_aad.json} | 96 +--- ...rationProvidertest_provider_selectors.json | 219 +++++++++ ...dertest_provider_trimmed_key_prefixes.json | 239 +++++++++ ...nProvidertest_provider_with_key_vault.json | 462 ++++++++++++++++++ .../tests/test_provider.py | 99 ++-- .../tests/test_provider_aad.py | 49 ++ .../test_provider_key_vault_reference.py | 30 ++ 13 files changed, 1247 insertions(+), 160 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json rename sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/{test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json => test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json} (65%) create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index d82239dfceb8..7d2bbb4a6cb1 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -136,7 +136,7 @@ def __resolve_keyvault_reference(config, key_vault_options, secret_clients): if referenced_client: try: - return referenced_client.get_secret(key_vault_identifier.name, version=key_vault_identifier.version) + return referenced_client.get_secret(key_vault_identifier.name, version=key_vault_identifier.version).value except ResourceNotFoundError: raise KeyVaultReferenceError("Key Vault %s does not contain secret %s" % ( key_vault_identifier.vault_url, key_vault_identifier.name)) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py index 0f9438676749..244b14a8905c 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py @@ -1,7 +1,9 @@ import os from devtools_testutils import ( test_proxy, - add_general_regex_sanitizer + add_general_regex_sanitizer, + add_body_string_sanitizer, + add_oauth_response_sanitizer ) import pytest @@ -11,7 +13,7 @@ @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): add_general_regex_sanitizer(value="https://fake-endpoint.azconfig.io", - regex=os.environ.get('APPCONFIGURATION_ENDPOINT_STRING', "https://fake-endpoint.azconfig.io")) + regex= os.environ.get('APPCONFIGURATION_ENDPOINT_STRING', "https://fake-endpoint.azconfig.io")) add_general_regex_sanitizer(value="fake-connection-string", regex=os.environ.get('APPCONFIGURATION_CONNECTION_STRING', "fake-connection-string")) add_general_regex_sanitizer( @@ -20,3 +22,6 @@ def add_sanitizers(test_proxy): value="fake-client-secret", regex=os.environ.get('APPCONFIGURATION_CLIENT_SECRET', "fake-client-secret")) add_general_regex_sanitizer( value="fake-tenant-id", regex=os.environ.get('APPCONFIGURATION_TENANT_ID', "fake-tenant-id")) + add_general_regex_sanitizer( + value="https://fake-key-vault.vault.azure.net/", regex="/*" + os.environ.get('APPCONFIGURATION_KEY_VAULT_REFERENCE', "fake-key-vault.vault") + "/*") + add_oauth_response_sanitizer() diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py new file mode 100644 index 000000000000..5febb75fb5f8 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py @@ -0,0 +1,60 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import functools +from devtools_testutils import EnvironmentVariableLoader +import inspect + +AppConfigProviderPreparer = functools.partial( + EnvironmentVariableLoader, + "appconfiguration", + appconfiguration_connection_string="Endpoint=https://fake-endpoint.azconfig.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=", + appconfiguration_endpoint_string="https://fake-endpoint.azconfig.io", + appconfiguration_client_id="fake-client-id", + appconfiguration_client_secret="fake-client-secret", + appconfiguration_tenant_id="fake-tenant-id", +) + + +def app_config_decorator(func, **kwargs): + @AppConfigProviderPreparer() + def wrapper(*args, **kwargs): + appconfiguration_connection_string = kwargs.pop( + "appconfiguration_connection_string") + kwargs['appconfiguration_connection_string'] = appconfiguration_connection_string + + trimmed_kwargs = {k: v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + func(*args, **trimmed_kwargs) + return wrapper + + +def app_config_decorator_aad(func, **kwargs): + @AppConfigProviderPreparer() + def wrapper(*args, **kwargs): + appconfiguration_endpoint_string = kwargs.pop( + "appconfiguration_endpoint_string") + kwargs['appconfiguration_endpoint_string'] = appconfiguration_endpoint_string + + trimmed_kwargs = {k: v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + func(*args, **trimmed_kwargs) + return wrapper + +def trim_kwargs_from_test_function(fn, kwargs): + # the next function is the actual test function. the kwargs need to be trimmed so + # that parameters which are not required will not be passed to it. + if not getattr(fn, '__is_preparer', False): + try: + args, _, kw, _, _, _, _ = inspect.getfullargspec(fn) + except AttributeError: + args, _, kw, _ = inspect.getargspec( + fn) # pylint: disable=deprecated-method + if kw is None: + args = set(args) + for key in [k for k in kwargs if k not in args]: + del kwargs[key] \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index 00cd18ebcfe0..c152eeedd3fa 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -8,9 +8,9 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Sep, 21 2022 18:39:00.013800 GMT" + "x-ms-date": "Sep, 27 2022 22:42:40.104313 GMT" }, "RequestBody": null, "StatusCode": 200, @@ -20,44 +20,44 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:39:00 GMT", + "Date": "Tue, 27 Sep 2022 22:42:40 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDQyNw==;sn=16864427", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "e49e00e4-8005-4e38-a362-ec7253675842" + "x-ms-correlation-request-id": "c7ce670d-847a-4232-93fc-a4efa00562d4" }, "ResponseBody": { "items": [ { - "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", + "etag": "RX6Uzn3YdpSnDk7SX9kzxXwDFdYhR8dGGLEXBZ6i_nM", "key": "message", "label": null, "content_type": "", "value": "hi", "tags": {}, "locked": false, - "last_modified": "2022-09-01T17:53:26\u002B00:00" + "last_modified": "2022-09-27T19:41:40\u002B00:00" }, { - "etag": "jf2AWA7sfhfRYx0rPoBxqdCf1Lfzpos0v4emLvuYP-4", + "etag": "dYgyN_oxYWzXEQN8K8d2q-4rKQJwftuzR75Jagqq_pw", "key": "my_json", "label": null, "content_type": "application/json", "value": "{\u0022key\u0022:\u0022value\u0022}", "tags": {}, "locked": false, - "last_modified": "2022-09-20T23:10:44\u002B00:00" + "last_modified": "2022-09-27T20:35:17\u002B00:00" }, { - "etag": "MUD4TSfiMxgwTqVTAlI_rNyXQz9bAPZ3VXDO-Hk_ejI", - "key": "test.message", + "etag": "7vw5ma2Cc0-eE1cnRaaCv2_VtAS8BQ5jbHP9eNS_MFA", + "key": "test.trimmed", "label": null, - "content_type": "", - "value": "Hi with test Prefix", + "content_type": "key", + "value": "key", "tags": {}, "locked": false, - "last_modified": "2022-09-01T17:53:46\u002B00:00" + "last_modified": "2022-09-27T19:58:41\u002B00:00" } ] } diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json new file mode 100644 index 000000000000..8f48737a4bb7 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json @@ -0,0 +1,47 @@ +{ + "Entries": [ + { + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=message%2A\u0026label=dev\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", + "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", + "x-ms-date": "Sep, 27 2022 22:42:40.650526 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:40 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "06221105-78da-4e5e-8239-20d1d53ea669" + }, + "ResponseBody": { + "items": [ + { + "etag": "yEiVkIl-IHlB26quPXo_Z2GbB5yQm_ENTWI2c1k1J4E", + "key": "message", + "label": "dev", + "content_type": "", + "value": "test", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T20:06:21\u002B00:00" + } + ] + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json new file mode 100644 index 000000000000..cd5910270754 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json @@ -0,0 +1,67 @@ +{ + "Entries": [ + { + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", + "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", + "x-ms-date": "Sep, 27 2022 22:42:40.490235 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:40 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "55e5698f-c69d-4645-81aa-3f25371d56a4" + }, + "ResponseBody": { + "items": [ + { + "etag": "RX6Uzn3YdpSnDk7SX9kzxXwDFdYhR8dGGLEXBZ6i_nM", + "key": "message", + "label": null, + "content_type": "", + "value": "hi", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T19:41:40\u002B00:00" + }, + { + "etag": "dYgyN_oxYWzXEQN8K8d2q-4rKQJwftuzR75Jagqq_pw", + "key": "my_json", + "label": null, + "content_type": "application/json", + "value": "{\u0022key\u0022:\u0022value\u0022}", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T20:35:17\u002B00:00" + }, + { + "etag": "7vw5ma2Cc0-eE1cnRaaCv2_VtAS8BQ5jbHP9eNS_MFA", + "key": "test.trimmed", + "label": null, + "content_type": "key", + "value": "key", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T19:58:41\u002B00:00" + } + ] + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json similarity index 65% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json rename to sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json index 274ab1b8ac7e..b63dadebf96b 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json @@ -7,7 +7,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -17,17 +17,17 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "1599", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:39:00 GMT", + "Date": "Tue, 27 Sep 2022 22:42:40 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=AuaI0l5Thi1Ph8qKgY3w55M; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", - "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrXUK8WCbx7_3eLM8Xf9iPBqq-GaEFnitho0XCJynEDnSTZtNHQ0IlZZ2H5Uh-oD7-OLVsDF-fTKQ1-MzOkg6rll2XLpIL0pCqCNbmGhPq_7QQJLyU3I4yOASYKSJvcQR2RFUji-c971-vuLC_yEQHTyrso57pHLqPC0pA2gWYR0DqeuTMgGf7cV3PXCbwlRUUPFquNO44Yfeo3D9Hyog-mTMb_xzZSzrEINr5PfIbMz0gAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", + "fpc=Aih2w7HdW0RLsLtcNXW6NJo; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", + "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrkYxHw6mf13fuPRCu6v488gBdmaagfm2C8Q8ZiC9pB0nYYkXjS9U5w5mUTT51HcOESfBkGL6zDFmEHCECrlz_k72p8NUOMuj8OHKqWYGUIMnrKLpjfjH0i6lBviGMxCSFlnfEbzZfWev4InHJwQ2u2shZYtE7Y5Hb_K_3kYBp1RkgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", + "x-ms-ests-server": "2.1.13672.11 - NCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -105,8 +105,8 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "Cookie": "fpc=AuaI0l5Thi1Ph8qKgY3w55M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJo; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -116,16 +116,16 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "945", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:39:01 GMT", + "Date": "Tue, 27 Sep 2022 22:42:40 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=AuaI0l5Thi1Ph8qKgY3w55M; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", + "fpc=Aih2w7HdW0RLsLtcNXW6NJo; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13622.7 - SCUS ProdSlices", + "x-ms-ests-server": "2.1.13672.11 - SCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -175,56 +175,6 @@ ] } }, - { - "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "client-request-id": "3a839a03-715b-4fc0-b093-fa24c0cfeeef", - "Connection": "keep-alive", - "Content-Length": "255", - "Content-Type": "application/x-www-form-urlencoded", - "Cookie": "fpc=AuaI0l5Thi1Ph8qKgY3w55M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", - "x-client-cpu": "x64", - "x-client-current-telemetry": "4|730,0|", - "x-client-last-telemetry": "4|0|||", - "x-client-os": "win32", - "x-client-sku": "MSAL.Python", - "x-client-ver": "1.18.0", - "x-ms-lib-capability": "retry-after, h429" - }, - "RequestBody": "client_id=fake-client-id\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=fake-client-secret\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fpython-provider.azconfig.io%2F.default", - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-store, no-cache", - "client-request-id": "3a839a03-715b-4fc0-b093-fa24c0cfeeef", - "Content-Length": "111", - "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:39:01 GMT", - "Expires": "-1", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Pragma": "no-cache", - "Set-Cookie": [ - "fpc=AuaI0l5Thi1Ph8qKgY3w55MW9qlXAQAAAEVRvdoOAAAA; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "token_type": "Bearer", - "expires_in": 86399, - "ext_expires_in": 86399, - "refresh_in": 43199, - "access_token": "Sanitized" - } - }, { "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", "RequestMethod": "GET", @@ -233,7 +183,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -243,44 +193,44 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:39:02 GMT", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDQyNw==;sn=16864427", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "d1f48db0-be79-4eca-a13c-7c1caf29edb5" + "x-ms-correlation-request-id": "30054af8-b684-4033-b1b5-9c071f491287" }, "ResponseBody": { "items": [ { - "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", + "etag": "RX6Uzn3YdpSnDk7SX9kzxXwDFdYhR8dGGLEXBZ6i_nM", "key": "message", "label": null, "content_type": "", "value": "hi", "tags": {}, "locked": false, - "last_modified": "2022-09-01T17:53:26\u002B00:00" + "last_modified": "2022-09-27T19:41:40\u002B00:00" }, { - "etag": "jf2AWA7sfhfRYx0rPoBxqdCf1Lfzpos0v4emLvuYP-4", + "etag": "dYgyN_oxYWzXEQN8K8d2q-4rKQJwftuzR75Jagqq_pw", "key": "my_json", "label": null, "content_type": "application/json", "value": "{\u0022key\u0022:\u0022value\u0022}", "tags": {}, "locked": false, - "last_modified": "2022-09-20T23:10:44\u002B00:00" + "last_modified": "2022-09-27T20:35:17\u002B00:00" }, { - "etag": "MUD4TSfiMxgwTqVTAlI_rNyXQz9bAPZ3VXDO-Hk_ejI", - "key": "test.message", + "etag": "7vw5ma2Cc0-eE1cnRaaCv2_VtAS8BQ5jbHP9eNS_MFA", + "key": "test.trimmed", "label": null, - "content_type": "", - "value": "Hi with test Prefix", + "content_type": "key", + "value": "key", "tags": {}, "locked": false, - "last_modified": "2022-09-01T17:53:46\u002B00:00" + "last_modified": "2022-09-27T19:58:41\u002B00:00" } ] } diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json new file mode 100644 index 000000000000..8daf37f02eef --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json @@ -0,0 +1,219 @@ +{ + "Entries": [ + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1599", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAgAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - EUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAgAAAGBzxdoOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAgAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - SCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=message%2A\u0026label=dev\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "98fc8948-d720-480a-a4f8-837e65f57cd0" + }, + "ResponseBody": { + "items": [ + { + "etag": "yEiVkIl-IHlB26quPXo_Z2GbB5yQm_ENTWI2c1k1J4E", + "key": "message", + "label": "dev", + "content_type": "", + "value": "test", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T20:06:21\u002B00:00" + } + ] + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json new file mode 100644 index 000000000000..78700e7ff862 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json @@ -0,0 +1,239 @@ +{ + "Entries": [ + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1599", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAQAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - NCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAQAAAGBzxdoOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAQAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - EUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "902e6b7c-5cfa-45b1-a567-c8ca2469af77" + }, + "ResponseBody": { + "items": [ + { + "etag": "RX6Uzn3YdpSnDk7SX9kzxXwDFdYhR8dGGLEXBZ6i_nM", + "key": "message", + "label": null, + "content_type": "", + "value": "hi", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T19:41:40\u002B00:00" + }, + { + "etag": "dYgyN_oxYWzXEQN8K8d2q-4rKQJwftuzR75Jagqq_pw", + "key": "my_json", + "label": null, + "content_type": "application/json", + "value": "{\u0022key\u0022:\u0022value\u0022}", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T20:35:17\u002B00:00" + }, + { + "etag": "7vw5ma2Cc0-eE1cnRaaCv2_VtAS8BQ5jbHP9eNS_MFA", + "key": "test.trimmed", + "label": null, + "content_type": "key", + "value": "key", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T19:58:41\u002B00:00" + } + ] + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json new file mode 100644 index 000000000000..a75dbd8379b1 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json @@ -0,0 +1,462 @@ +{ + "Entries": [ + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1599", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAwAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:42 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - SCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAwAAAGBzxdoOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAwAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:42 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - NCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=prod\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup,UsesKeyVault", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "362c7696-90d5-42fc-85b1-a28493c8db0a" + }, + "ResponseBody": { + "items": [ + { + "etag": "cuoTxCSuBxPyk2kTGtNoy7AiY8kwWEvkhEM4hVmSZxA", + "key": "secret", + "label": "prod", + "content_type": "application/vnd.microsoft.appconfig.keyvaultref\u002Bjson;charset=utf-8", + "value": "{\u0022uri\u0022:\u0022https://fake-key-vault.vault.azure.net/secrets/secret\u0022}", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T21:30:56\u002B00:00" + } + ] + } + }, + { + "RequestUri": "https://fake-key-vault.vault.azure.net/secrets/secret/?api-version=7.3", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-keyvault-secrets/4.7.0b1 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 401, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "97", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000;includeSubDomains", + "WWW-Authenticate": "Bearer authorization=\u0022https://login.windows.net/fake-tenant-id\u0022, resource=\u0022https://vault.azure.net\u0022", + "X-Content-Type-Options": "nosniff", + "x-ms-keyvault-network-info": "conn_type=Ipv4;addr=131.107.1.245;act_addr_fam=InterNetwork;", + "x-ms-keyvault-region": "northcentralus", + "x-ms-keyvault-service-version": "1.9.538.1" + }, + "ResponseBody": { + "error": { + "code": "Unauthorized", + "message": "AKV10000: Request is missing a Bearer or PoP token." + } + } + }, + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1599", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNBAAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:43 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - SCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNBAAAAGBzxdoOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:43 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNBAAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:43 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - EUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://fake-key-vault.vault.azure.net/secrets/secret/?api-version=7.3", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-keyvault-secrets/4.7.0b1 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "258", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:43 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000;includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-keyvault-network-info": "conn_type=Ipv4;addr=131.107.1.245;act_addr_fam=InterNetwork;", + "x-ms-keyvault-region": "northcentralus", + "x-ms-keyvault-service-version": "1.9.538.1" + }, + "ResponseBody": { + "value": "my-secret", + "id": "https://fake-key-vault.vault.azure.net/secrets/secret/efa8cdd8eef24d3b8d0ad36d9804af45", + "attributes": { + "enabled": true, + "created": 1664314220, + "updated": 1664314220, + "recoveryLevel": "Recoverable\u002BPurgeable", + "recoverableDays": 90 + }, + "tags": {} + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py index fb656449fc8e..fe1642864cf6 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py @@ -3,87 +3,46 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -import functools -from azure.appconfigurationprovider import AzureAppConfigurationProvider -from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy -from azure.appconfiguration import AzureAppConfigurationClient -import inspect - -AppConfigProviderPreparer = functools.partial( - EnvironmentVariableLoader, - "appconfiguration", - appconfiguration_connection_string="Endpoint=https://fake-endpoint.azconfig.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=", - appconfiguration_endpoint_string="https://fake-endpoint.azconfig.io", - appconfiguration_client_id="fake-client-id", - appconfiguration_client_secret="fake-client-secret", - appconfiguration_tenant_id="fake-tenant-id", +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + SettingSelector ) - - -def app_config_decorator(func, **kwargs): - @AppConfigProviderPreparer() - def wrapper(*args, **kwargs): - appconfiguration_connection_string = kwargs.pop( - "appconfiguration_connection_string") - kwargs['appconfiguration_connection_string'] = appconfiguration_connection_string - - trimmed_kwargs = {k: v for k, v in kwargs.items()} - trim_kwargs_from_test_function(func, trimmed_kwargs) - - func(*args, **trimmed_kwargs) - return wrapper - - -def app_config_decorator_aad(func, **kwargs): - @AppConfigProviderPreparer() - def wrapper(*args, **kwargs): - appconfiguration_endpoint_string = kwargs.pop( - "appconfiguration_endpoint_string") - kwargs['appconfiguration_endpoint_string'] = appconfiguration_endpoint_string - - trimmed_kwargs = {k: v for k, v in kwargs.items()} - trim_kwargs_from_test_function(func, trimmed_kwargs) - - func(*args, **trimmed_kwargs) - return wrapper - - -def trim_kwargs_from_test_function(fn, kwargs): - # the next function is the actual test function. the kwargs need to be trimmed so - # that parameters which are not required will not be passed to it. - if not getattr(fn, '__is_preparer', False): - try: - args, _, kw, _, _, _, _ = inspect.getfullargspec(fn) - except AttributeError: - args, _, kw, _ = inspect.getargspec( - fn) # pylint: disable=deprecated-method - if kw is None: - args = set(args) - for key in [k for k in kwargs if k not in args]: - del kwargs[key] - +from devtools_testutils import ( + AzureRecordedTestCase, + recorded_by_proxy +) +from azure.appconfiguration import AzureAppConfigurationClient +from preparers import app_config_decorator class TestAppConfigurationProvider(AzureRecordedTestCase): - def build_provider_aad(self, endpoint): - cred = self.get_credential(AzureAppConfigurationClient) - return AzureAppConfigurationProvider.load(endpoint=endpoint, credential=cred) - - def build_provider(self, connection_string): - return AzureAppConfigurationProvider.load(connection_string=connection_string) + def build_provider(self, connection_string, trimmed_key_prefixes=[], selects={SettingSelector("*", "\0")}): + return AzureAppConfigurationProvider.load(connection_string=connection_string, trimmed_key_prefixes=trimmed_key_prefixes, selects=selects) # method: provider_creation @recorded_by_proxy @app_config_decorator def test_provider_creation(self, appconfiguration_connection_string): - client = self.build_provider(appconfiguration_connection_string) assert client["message"] == "hi" + assert client["my_json"]["key"] == "value" - # method: provider_creation_aad + # method: provider_trimmed_key_prefixes @recorded_by_proxy - @app_config_decorator_aad - def test_provider_creation_aad(self, appconfiguration_endpoint_string): - - client = self.build_provider_aad(appconfiguration_endpoint_string) + @app_config_decorator + def test_provider_trimmed_key_prefixes(self, appconfiguration_connection_string): + trimmed = {"test."} + client = self.build_provider(appconfiguration_connection_string, trimmed_key_prefixes=trimmed) assert client["message"] == "hi" + assert client["my_json"]["key"] == "value" + assert client["trimmed"] == "key" + assert "test.trimmed" not in client + + # method: provider_selectors + @recorded_by_proxy + @app_config_decorator + def test_provider_selectors(self, appconfiguration_connection_string): + selects = {SettingSelector("message*", "dev")} + client = self.build_provider(appconfiguration_connection_string, selects=selects) + assert client["message"] == "test" + assert "test.trimmed" not in client diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py new file mode 100644 index 000000000000..b5735df3704d --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py @@ -0,0 +1,49 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + SettingSelector +) +from devtools_testutils import ( + AzureRecordedTestCase, + recorded_by_proxy +) +from azure.appconfiguration import AzureAppConfigurationClient +from preparers import app_config_decorator_aad + +class TestAppConfigurationProvider(AzureRecordedTestCase): + + def build_provider_aad(self, endpoint, trimmed_key_prefixes=[], selects={SettingSelector("*", "\0")}): + cred = self.get_credential(AzureAppConfigurationClient) + return AzureAppConfigurationProvider.load(endpoint=endpoint,credential=cred, trimmed_key_prefixes=trimmed_key_prefixes, selects=selects) + + # method: provider_creation_aad + @recorded_by_proxy + @app_config_decorator_aad + def test_provider_creation_aad(self, appconfiguration_endpoint_string): + client = self.build_provider_aad(appconfiguration_endpoint_string) + assert client["message"] == "hi" + assert client["my_json"]["key"] == "value" + + # method: provider_trimmed_key_prefixes + @recorded_by_proxy + @app_config_decorator_aad + def test_provider_trimmed_key_prefixes(self, appconfiguration_endpoint_string): + trimmed = {"test."} + client = self.build_provider_aad(appconfiguration_endpoint_string, trimmed_key_prefixes=trimmed) + assert client["message"] == "hi" + assert client["my_json"]["key"] == "value" + assert client["trimmed"] == "key" + assert "test.trimmed" not in client + + # method: provider_selectors + @recorded_by_proxy + @app_config_decorator_aad + def test_provider_selectors(self, appconfiguration_endpoint_string): + selects = {SettingSelector("message*", "dev")} + client = self.build_provider_aad(appconfiguration_endpoint_string, selects=selects) + assert client["message"] == "test" + assert "test.trimmed" not in client \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py new file mode 100644 index 000000000000..6e42cbc9cbb8 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py @@ -0,0 +1,30 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + SettingSelector, + AzureAppConfigurationKeyVaultOptions +) +from devtools_testutils import ( + AzureRecordedTestCase, + recorded_by_proxy +) +from azure.appconfiguration import AzureAppConfigurationClient +from preparers import app_config_decorator_aad + +class TestAppConfigurationProvider(AzureRecordedTestCase): + + def build_provider_aad(self, endpoint, key_vault_options): + cred = self.get_credential(AzureAppConfigurationClient) + return AzureAppConfigurationProvider.load(endpoint=endpoint,credential=cred, selects=[SettingSelector("*", "prod")], key_vault_options=key_vault_options) + + # method: provider_with_key_vault + @recorded_by_proxy + @app_config_decorator_aad + def test_provider_with_key_vault(self, appconfiguration_endpoint_string): + key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=self.get_credential(AzureAppConfigurationClient)) + client = self.build_provider_aad(appconfiguration_endpoint_string, key_vault_options=key_vault_options) + assert client["secret"] == "my-secret" \ No newline at end of file From 75bc7e2a55ce9a6ba1005e75e0fcc97ae816ed30 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 28 Sep 2022 09:45:23 -0700 Subject: [PATCH 055/129] Fixed Linting --- .../appconfigurationprovider/_azureappconfigurationprovider.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 7d2bbb4a6cb1..391ea465bad7 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -136,7 +136,8 @@ def __resolve_keyvault_reference(config, key_vault_options, secret_clients): if referenced_client: try: - return referenced_client.get_secret(key_vault_identifier.name, version=key_vault_identifier.version).value + return referenced_client.get_secret(key_vault_identifier.name, + version=key_vault_identifier.version).value except ResourceNotFoundError: raise KeyVaultReferenceError("Key Vault %s does not contain secret %s" % ( key_vault_identifier.vault_url, key_vault_identifier.name)) From 9639c96d6db9be63e78add255e4e1c3b56d66438 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 29 Sep 2022 09:09:08 -0700 Subject: [PATCH 056/129] Fixing Auto Format --- .../azure/__init__.py | 3 +- .../appconfigurationprovider/__init__.py | 6 +- .../_azure_appconfiguration_provider_error.py | 1 + .../_azureappconfigurationkeyvaultoptions.py | 1 + .../_azureappconfigurationprovider.py | 66 +++++++++---------- .../appconfigurationprovider/_constants.py | 2 +- .../_settingselector.py | 1 + .../appconfigurationprovider/_user_agent.py | 4 +- 8 files changed, 39 insertions(+), 45 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py index 229d1b3c8804..d55ccad1f573 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py @@ -1,2 +1 @@ -__path__ = __import__("pkgutil").extend_path( - __path__, __name__) # type: ignore +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py index 1ef7efc3de32..a29ac854e457 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py @@ -11,8 +11,4 @@ from ._version import VERSION __version__ = VERSION -__all__ = [ - "AzureAppConfigurationProvider", - "AzureAppConfigurationKeyVaultOptions", - "SettingSelector" -] +__all__ = ["AzureAppConfigurationProvider", "AzureAppConfigurationKeyVaultOptions", "SettingSelector"] diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py index 0bc4fdb0c0b3..3c7021cb71ba 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py @@ -4,5 +4,6 @@ # license information. # ------------------------------------------------------------------------- + class KeyVaultReferenceError(ValueError): """Raised when a Key Vault reference is invalid.""" diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index d640015c0695..7a6519e1b9be 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -4,6 +4,7 @@ # license information. # ------------------------------------------------------------------------- + class AzureAppConfigurationKeyVaultOptions: """ Options for connecting to Key Vault. diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 391ea465bad7..203ebf6165ca 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -6,10 +6,7 @@ import json from azure.appconfiguration import AzureAppConfigurationClient -from azure.keyvault.secrets import ( - SecretClient, - KeyVaultSecretIdentifier -) +from azure.keyvault.secrets import SecretClient, KeyVaultSecretIdentifier from azure.core.exceptions import ResourceNotFoundError from ._settingselector import SettingSelector from ._azure_appconfiguration_provider_error import KeyVaultReferenceError @@ -53,13 +50,11 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_options = kwargs.pop("key_vault_options", None) - provider.__buildprovider(connection_string, endpoint, - credential, key_vault_options) + provider.__buildprovider(connection_string, endpoint, credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) - provider._trim_prefixes = sorted(kwargs.pop( - "trimmed_key_prefixes", []), key=len, reverse=True) + provider._trim_prefixes = sorted(kwargs.pop("trimmed_key_prefixes", []), key=len, reverse=True) provider._dict = {} @@ -67,14 +62,15 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): for select in selects: configurations = provider._client.list_configuration_settings( - key_filter=select.key_filter, label_filter=select.label_filter) + key_filter=select.key_filter, label_filter=select.label_filter + ) for config in configurations: trimmed_key = config.key # Trim the key if it starts with one of the prefixes provided for trim in provider._trim_prefixes: if config.key.startswith(trim): - trimmed_key = config.key[len(trim):] + trimmed_key = config.key[len(trim) :] break if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: @@ -95,58 +91,60 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt headers = {} correlation_context = "RequestType=Startup" - if (key_vault_options and - (key_vault_options.credential or - key_vault_options.secret_clients or key_vault_options.secret_resolver)): + if key_vault_options and ( + key_vault_options.credential or key_vault_options.secret_clients or key_vault_options.secret_resolver + ): correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context useragent = USER_AGENT - if (connection_string and endpoint): - raise AttributeError( - "Both connection_string and endpoint are set. Only one of these should be set.") + if connection_string and endpoint: + raise AttributeError("Both connection_string and endpoint are set. Only one of these should be set.") if connection_string: self._client = AzureAppConfigurationClient.from_connection_string( - connection_string, user_agent=useragent, headers=headers) + connection_string, user_agent=useragent, headers=headers + ) return - self._client = AzureAppConfigurationClient( - endpoint, credential, user_agent=useragent, headers=headers) + self._client = AzureAppConfigurationClient(endpoint, credential, user_agent=useragent, headers=headers) @staticmethod def __resolve_keyvault_reference(config, key_vault_options, secret_clients): if key_vault_options is None: - raise AttributeError( - "Key Vault options must be set to resolve Key Vault references.") + raise AttributeError("Key Vault options must be set to resolve Key Vault references.") if config.secret_id is None: - raise AttributeError( - "Key Vault reference must have a uri value.") + raise AttributeError("Key Vault reference must have a uri value.") key_vault_identifier = KeyVaultSecretIdentifier(config.secret_id) referenced_client = next( - (client for client in secret_clients if client.vault_url == key_vault_identifier.vault_url), None) + (client for client in secret_clients if client.vault_url == key_vault_identifier.vault_url), None + ) if referenced_client is None and key_vault_options.credential is not None: referenced_client = SecretClient( - vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) + vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential + ) secret_clients[key_vault_identifier.vault_url] = referenced_client if referenced_client: try: - return referenced_client.get_secret(key_vault_identifier.name, - version=key_vault_identifier.version).value + return referenced_client.get_secret( + key_vault_identifier.name, version=key_vault_identifier.version + ).value except ResourceNotFoundError: - raise KeyVaultReferenceError("Key Vault %s does not contain secret %s" % ( - key_vault_identifier.vault_url, key_vault_identifier.name)) - + raise KeyVaultReferenceError( + "Key Vault %s does not contain secret %s" + % (key_vault_identifier.vault_url, key_vault_identifier.name) + ) if key_vault_options.secret_resolver is not None: return key_vault_options.secret_resolver(config.secret_id) raise KeyVaultReferenceError( - "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) + "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url) + ) @staticmethod def __is_json_content_type(content_type): @@ -154,9 +152,9 @@ def __is_json_content_type(content_type): return False content_type = content_type.strip().lower() - mime_type = content_type.split(';')[0].strip() + mime_type = content_type.split(";")[0].strip() - type_parts = mime_type.split('/') + type_parts = mime_type.split("/") if len(type_parts) != 2: return False @@ -164,7 +162,7 @@ def __is_json_content_type(content_type): if main_type != "application": return False - sub_types = sub_type.split('+') + sub_types = sub_type.split("+") if "json" in sub_types: return True diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py index 913b7e142627..eb9425333a1d 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py @@ -4,4 +4,4 @@ # license information. # ------------------------------------------------------------------------- -KEY_VAULT_REFERENCE_CONTENT_TYPE = u"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" +KEY_VAULT_REFERENCE_CONTENT_TYPE = "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py index c56d6ca8ae80..bef1b4668a6b 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py @@ -4,6 +4,7 @@ # license information. # ------------------------------------------------------------------------- + class SettingSelector: """ Selects a set of configuration settings from Azure App Configuration. diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py index b75e8a607e9f..429a07c30051 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py @@ -6,6 +6,4 @@ from ._version import VERSION -USER_AGENT = "python-appconfigurationprovider/{}".format( - VERSION -) +USER_AGENT = "python-appconfigurationprovider/{}".format(VERSION) From 2f07a55c219aea0d2db28cc6bb0b06c4e6ed651c Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 6 Oct 2022 10:15:10 -0700 Subject: [PATCH 057/129] Fixing Key Vault Reference Test --- .../tests/test_provider_key_vault_reference.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py index 6e42cbc9cbb8..e77f5adebadb 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py @@ -8,6 +8,7 @@ SettingSelector, AzureAppConfigurationKeyVaultOptions ) +from azure.keyvault.secrets import SecretClient from devtools_testutils import ( AzureRecordedTestCase, recorded_by_proxy @@ -25,6 +26,7 @@ def build_provider_aad(self, endpoint, key_vault_options): @recorded_by_proxy @app_config_decorator_aad def test_provider_with_key_vault(self, appconfiguration_endpoint_string): - key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=self.get_credential(AzureAppConfigurationClient)) + key_vault_cred = self.get_credential(SecretClient) + key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=key_vault_cred) client = self.build_provider_aad(appconfiguration_endpoint_string, key_vault_options=key_vault_options) assert client["secret"] == "my-secret" \ No newline at end of file From 560be04df758ff691b96edaf7eb1e3d12e65355b Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 6 Oct 2022 11:20:42 -0700 Subject: [PATCH 058/129] Trying to update the package name --- .../CHANGELOG.md | 0 .../LICENSE | 0 .../MANIFEST.in | 0 .../README.md | 0 .../azure/__init__.py | 0 .../azure/appconfiguration/__init__.py | 1 + .../appconfiguration/provider}/__init__.py | 0 .../_azure_appconfiguration_provider_error.py | 0 .../_azureappconfigurationkeyvaultoptions.py | 0 .../_azureappconfigurationprovider.py | 0 .../appconfiguration/provider}/_constants.py | 0 .../provider}/_settingselector.py | 0 .../appconfiguration/provider}/_user_agent.py | 2 +- .../appconfiguration/provider}/_version.py | 0 .../azure/appconfiguration/provider}/py.typed | 0 .../dev_requirements.txt | 0 .../mypy.ini | 0 .../samples/README.md | 2 +- .../samples/aad_sample.py | 2 +- .../samples/connection_string_sample.py | 2 +- ...vault_reference_provided_clients_sample.py | 2 +- .../samples/key_vault_reference_sample.py | 2 +- .../sdk_packaging.toml | 2 +- .../setup.py | 4 +- .../tests/conftest.py | 0 .../tests/preparers.py | 0 ...urationProvidertest_provider_creation.json | 4 +- ...rationProvidertest_provider_selectors.json | 4 +- ...dertest_provider_trimmed_key_prefixes.json | 4 +- ...ionProvidertest_provider_creation_aad.json | 4 +- ...rationProvidertest_provider_selectors.json | 4 +- ...dertest_provider_trimmed_key_prefixes.json | 4 +- ...nProvidertest_provider_with_key_vault.json | 4 +- .../tests/test_provider.py | 2 +- .../tests/test_provider_aad.py | 2 +- .../test_provider_key_vault_reference.py | 2 +- sdk/appconfiguration/ci.yml | 38 +++++++++---------- shared_requirements.txt | 2 +- 38 files changed, 47 insertions(+), 46 deletions(-) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/CHANGELOG.md (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/LICENSE (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/MANIFEST.in (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/README.md (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/azure/__init__.py (100%) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/__init__.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_azure_appconfiguration_provider_error.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_azureappconfigurationprovider.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_constants.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_settingselector.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_user_agent.py (83%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_version.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/py.typed (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/dev_requirements.txt (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/mypy.ini (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/samples/README.md (97%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/samples/aad_sample.py (96%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/samples/connection_string_sample.py (96%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/samples/key_vault_reference_provided_clients_sample.py (96%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/samples/key_vault_reference_sample.py (95%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/sdk_packaging.toml (79%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/setup.py (96%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/conftest.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/preparers.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json (95%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json (93%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json (95%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json (98%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json (98%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json (98%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json (99%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/test_provider.py (97%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/test_provider_aad.py (97%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/test_provider_key_vault_reference.py (96%) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/CHANGELOG.md rename to sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/LICENSE b/sdk/appconfiguration/azure-appconfiguration-provider/LICENSE similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/LICENSE rename to sdk/appconfiguration/azure-appconfiguration-provider/LICENSE diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in b/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in rename to sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/README.md rename to sdk/appconfiguration/azure-appconfiguration-provider/README.md diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py new file mode 100644 index 000000000000..d55ccad1f573 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azure_appconfiguration_provider_error.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azure_appconfiguration_provider_error.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py similarity index 83% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py index 429a07c30051..62961551d751 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py @@ -6,4 +6,4 @@ from ._version import VERSION -USER_AGENT = "python-appconfigurationprovider/{}".format(VERSION) +USER_AGENT = "python-appconfiguration-provider/{}".format(VERSION) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/py.typed b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/py.typed similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/py.typed rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/py.typed diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/dev_requirements.txt rename to sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/mypy.ini b/sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/mypy.ini rename to sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md similarity index 97% rename from sdk/appconfiguration/azure-appconfigurationprovider/samples/README.md rename to sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md index 166e5da217f5..6eed2a4059e4 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md @@ -39,7 +39,7 @@ az appconfig kv set-keyvault --name --key secret --secret-id Install the Azure App Configuration Provider client library for Python with pip: ```commandline -pip install provider +pip install azure.appconfiguration.provider ``` ## Contents diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py similarity index 96% rename from sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py rename to sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index c525bc02f88b..4c875ad53b86 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py similarity index 96% rename from sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py rename to sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index d531643e8c56..c18a5f989fbb 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py similarity index 96% rename from sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_provided_clients_sample.py rename to sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 9151f1a699ef..8d67f617c34c 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py similarity index 95% rename from sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_sample.py rename to sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index a66664f34bcf..4e02cb434197 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml similarity index 79% rename from sdk/appconfiguration/azure-appconfigurationprovider/sdk_packaging.toml rename to sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml index 32efea5975a9..7d93f77a90ba 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/sdk_packaging.toml +++ b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml @@ -1,5 +1,5 @@ [packaging] -package_name = "azure-appconfigurationprovider" +package_name = "azure-appconfiguration-provider" package_nspkg = "azure-data-nspkg" package_pprint_name = "App Configuration Provider" package_doc_id = "" diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py similarity index 96% rename from sdk/appconfiguration/azure-appconfigurationprovider/setup.py rename to sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 7d82158a004a..8da1268eb78b 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -13,7 +13,7 @@ from setuptools import find_packages, setup # Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-appconfigurationprovider" +PACKAGE_NAME = "azure-appconfiguration-provider" PACKAGE_PPRINT_NAME = "App Configuration Provider" # a-b-c => a/b/c @@ -55,7 +55,7 @@ license="MIT License", author="Microsoft Corporation", author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfigurationprovider", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration-provider", classifiers=[ "Development Status :: 5 - Production/Stable", "Programming Language :: Python", diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/preparers.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/preparers.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json similarity index 95% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index c152eeedd3fa..fd5b1bf899c6 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -8,7 +8,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", "x-ms-date": "Sep, 27 2022 22:42:40.104313 GMT" }, @@ -64,4 +64,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json similarity index 93% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json index 8f48737a4bb7..525dccf8aaab 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json @@ -8,7 +8,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", "x-ms-date": "Sep, 27 2022 22:42:40.650526 GMT" }, @@ -44,4 +44,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json similarity index 95% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json index cd5910270754..6faf86a93e30 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json @@ -8,7 +8,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", "x-ms-date": "Sep, 27 2022 22:42:40.490235 GMT" }, @@ -64,4 +64,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json similarity index 98% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json index b63dadebf96b..2d4e0036340f 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json @@ -183,7 +183,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -237,4 +237,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json similarity index 98% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json index 8daf37f02eef..692dc3e00582 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json @@ -182,7 +182,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -216,4 +216,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json similarity index 98% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json index 78700e7ff862..ae777e18c7df 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json @@ -182,7 +182,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -236,4 +236,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json similarity index 99% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json index a75dbd8379b1..296e19128463 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json @@ -182,7 +182,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup,UsesKeyVault", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -459,4 +459,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py similarity index 97% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index fe1642864cf6..ec14c4a5bad8 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_aad.py similarity index 97% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_aad.py index b5735df3704d..5ab9351a2828 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_aad.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py similarity index 96% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py index e77f5adebadb..92a8fd49a95d 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector, AzureAppConfigurationKeyVaultOptions diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index ab40932bd913..1d361c8a15be 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -3,27 +3,27 @@ trigger: branches: include: - - main - - hotfix/* - - release/* - - restapi* + - main + - hotfix/* + - release/* + - restapi* paths: include: - - sdk/appconfiguration/ - - sdk/core/ + - sdk/appconfiguration/ + - sdk/core/ pr: branches: include: - - main - - feature/* - - hotfix/* - - release/* - - restapi* + - main + - feature/* + - hotfix/* + - release/* + - restapi* paths: include: - - sdk/appconfiguration/ - - sdk/core/ + - sdk/appconfiguration/ + - sdk/core/ extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -33,9 +33,9 @@ extends: ValidateFormatting: false TestProxy: true Artifacts: - - name: azure-appconfiguration - safeName: azureappconfiguration - - name: azure-appconfigurationprovider - safeName: azureappconfigurationprovider - - name: azure-mgmt-appconfiguration - safeName: azuremgmtappconfiguration \ No newline at end of file + - name: azure-appconfiguration + safeName: azureappconfiguration + - name: azure-appconfiguration-provider + safeName: azureappconfigurationprovider + - name: azure-mgmt-appconfiguration + safeName: azuremgmtappconfiguration diff --git a/shared_requirements.txt b/shared_requirements.txt index bdb2d3d70f47..e4f47bf8c745 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -187,7 +187,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-eventhub uamqp>=1.6.0,<2.0.0 #override azure-appconfiguration msrest>=0.6.10 #override azure-appconfiguration azure-core<2.0.0,>=1.24.0 -#override azure-appconfigurationprovider azure-keyvault-secrets<5.0.0,>=4.3.0 +#override azure-appconfiguration-provider azure-keyvault-secrets<5.0.0,>=4.3.0 #override azure-servicebus uamqp>=1.5.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 #override azure-servicebus azure-core<2.0.0,>=1.14.0 From f340a5e8c8f4c2a548fc23838137e478d9e311c2 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 6 Oct 2022 14:07:49 -0700 Subject: [PATCH 059/129] Fixed formatting? --- sdk/appconfiguration/ci.yml | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index 1d361c8a15be..1542a66a49f5 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -3,27 +3,27 @@ trigger: branches: include: - - main - - hotfix/* - - release/* - - restapi* + - main + - hotfix/* + - release/* + - restapi* paths: include: - - sdk/appconfiguration/ - - sdk/core/ + - sdk/appconfiguration/ + - sdk/core/ pr: branches: include: - - main - - feature/* - - hotfix/* - - release/* - - restapi* + - main + - feature/* + - hotfix/* + - release/* + - restapi* paths: include: - - sdk/appconfiguration/ - - sdk/core/ + - sdk/appconfiguration/ + - sdk/core/ extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -33,9 +33,9 @@ extends: ValidateFormatting: false TestProxy: true Artifacts: - - name: azure-appconfiguration - safeName: azureappconfiguration - - name: azure-appconfiguration-provider - safeName: azureappconfigurationprovider - - name: azure-mgmt-appconfiguration - safeName: azuremgmtappconfiguration + - name: azure-appconfiguration + safeName: azureappconfiguration + - name: azure-appconfiguration-provider + safeName: azureappconfigurationprovider + - name: azure-mgmt-appconfiguration + safeName: azuremgmtappconfiguration \ No newline at end of file From dc943c3e67245a8597ef65259e8cc60ce26f31b2 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 11:47:58 -0700 Subject: [PATCH 060/129] Adding azure-appconfiguration-provider --- sdk/appconfiguration/azure-appconfiguration-provider | 1 + 1 file changed, 1 insertion(+) create mode 160000 sdk/appconfiguration/azure-appconfiguration-provider diff --git a/sdk/appconfiguration/azure-appconfiguration-provider b/sdk/appconfiguration/azure-appconfiguration-provider new file mode 160000 index 000000000000..ff1e84bacc32 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider @@ -0,0 +1 @@ +Subproject commit ff1e84bacc3284af077d6935beda70b9509a9e7f From e8dec63f0dc1b5b457be2d2b1185d8935d9b6b30 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 11:51:31 -0700 Subject: [PATCH 061/129] Fixing repo issue --- .../appconfiguration-provider/CHANGELOG.md | 20 ++++ .../appconfiguration-provider/LICENSE | 21 ++++ .../appconfiguration-provider/MANIFEST.in | 7 ++ .../appconfiguration-provider/README.md | 91 +++++++++++++++ .../azure/__init__.py | 1 + .../appconfigurationprovider/__init__.py | 22 ++++ .../_azureappconfigurationkeyvaultoptions.py | 14 +++ .../_azureappconfigurationprovider.py | 107 ++++++++++++++++++ .../_settingselector.py | 10 ++ .../appconfigurationprovider/_user_agent.py | 11 ++ .../appconfigurationprovider/_version.py | 6 + .../dev_requirements.txt | 6 + .../appconfiguration-provider/mypy.ini | 12 ++ .../sdk_packaging.toml | 9 ++ .../appconfiguration-provider/setup.py | 78 +++++++++++++ .../azure-appconfiguration-provider | 1 - 16 files changed, 415 insertions(+), 1 deletion(-) create mode 100644 sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md create mode 100644 sdk/appconfiguration/appconfiguration-provider/LICENSE create mode 100644 sdk/appconfiguration/appconfiguration-provider/MANIFEST.in create mode 100644 sdk/appconfiguration/appconfiguration-provider/README.md create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/__init__.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py create mode 100644 sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt create mode 100644 sdk/appconfiguration/appconfiguration-provider/mypy.ini create mode 100644 sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml create mode 100644 sdk/appconfiguration/appconfiguration-provider/setup.py delete mode 160000 sdk/appconfiguration/azure-appconfiguration-provider diff --git a/sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md b/sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md new file mode 100644 index 000000000000..1683e32f84f2 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md @@ -0,0 +1,20 @@ +# Release History + +## 1.0.0b1 (Unreleased) + +New Azure App Configuration Provider + +Provides additional support above the Azure App Configuration SDK. Enables: +* Connecting to an Azure App Configuration store +* Selecting multiple keys using Setting Selector +* Resove Key Vault References when supplied AzureAppConfigurationKeyVaultOptions + +The Azure App Configuration Provider once loaded returns a dictionary of key/value pairs to use in configuration. + +```python +endpoint = "https://.azconfig.io" +default_credential = DefaultAzureCredential() +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=default_credential) +print(config["message"]) +``` \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/LICENSE b/sdk/appconfiguration/appconfiguration-provider/LICENSE new file mode 100644 index 000000000000..63447fd8bbbf --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/MANIFEST.in b/sdk/appconfiguration/appconfiguration-provider/MANIFEST.in new file mode 100644 index 000000000000..731abed60dd1 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/MANIFEST.in @@ -0,0 +1,7 @@ +recursive-include tests *.py +include *.md +include LICENSE +include azure/__init__.py +recursive-include samples *.py *.md +recursive-include doc *.rst +include azure/appconfiguration/py.typed \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/README.md b/sdk/appconfiguration/appconfiguration-provider/README.md new file mode 100644 index 000000000000..7620d7478d0f --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/README.md @@ -0,0 +1,91 @@ +# Azure App Configuration Python Provider + +Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. This provider adds additional functionality above the azure-sdk-for-pyton. + +Using the provider enables loading sets of configurations from a Azure App Configuration store in a managed way. + +## Getting started + +### Get credentials + +Use the [Azure CLI][azure_cli] snippet below to get the connection string from the Configuration Store. + +```Powershell +az appconfig credential list --name +``` + +Alternatively, get the connection string from the Azure Portal. + +### Creating a provider + +You can create a client with a connection string: + +```python +config = AzureAppConfigurationProvider.load(connection_string="your-connection-string") +``` + +or with AAD: + +```python +config = AzureAppConfigurationProvider.load(endpoint="your-endpoint", credential=DefaultAzureCredential()) +``` + +these providers will by default load all configurations with `(No Label)` from your configuration store. + +### Selecting configurations + +You can refine or expand the configurations loaded from your store by using `SettingSelector`s. Setting selectors provide a way to pass a key filter and label filter into the provider. + +```python +selects = {SettingSelector(key_filter="*", label_filter="\0"), SettingSelector(key_filter="*", label_filter="dev")} +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=default_credential, selects=selects) +``` +In this example all configuration with empty label and the dev label are loaded. Because the dev selector is listed last, any configurations from dev take priority over those with `(No Label)` when duplicates are found. + +### Trimming Keys + +You can trim the prefix off of keys by providing a list of trimmed key prefixes to the provider. + +```python +trimmed_key_prefixes={"/application/"} +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=default_credential, trimmed_key_prefixes=trimmed_key_prefixes) +``` + +### Resolving Key Vault References + +Key Vault References can be resolved by providing credentials to your key vault to the provider using `AzureAppConfigurationKeyVaultOptions`. + +#### With Credentials + +You can provide `AzureAppConfigurationKeyVaultOptions` with a credential and all key vault references will be resolved with it. The provider will attempt to connect to any key vault referenced with the credential provided. + +```python +key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=default_credential) +config = AzureAppConfigurationProvider.load(endpoint=endpoint, credential=default_credential, key_vault_options=key_vault_options) +``` +### With Clients + +You can provide `AzureAppConfigurationKeyVaultOptions` with a list of `SecretClients`. + +```python +key_vault_options = AzureAppConfigurationKeyVaultOptions( + secret_clients={SecretClient( + vault_url=key_vault_uri, credential=default_credential)}) +config = AzureAppConfigurationProvider.load(endpoint=endpoint, credential=default_credential, key_vault_options=key_vault_options) +``` + +### Secret Resolver + +If no Credentials or Clients are provided a secret resolver can be used. Secret resolver provides a way to return any value you want to a key vault reference. + +```python +def secret_resolver(uri): + return "From Secret Resolver" + +key_vault_options = AzureAppConfigurationKeyVaultOptions( + secret_resolver=secret_resolver) +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=default_credential, key_vault_options=key_vault_options) +``` \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/__init__.py b/sdk/appconfiguration/appconfiguration-provider/azure/__init__.py new file mode 100644 index 000000000000..d19ce0e399ec --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py new file mode 100644 index 000000000000..5691dba68be6 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from ._azureappconfigurationprovider import AzureAppConfigurationProvider +from ._azureappconfigurationkeyvaultoptions import AzureAppConfigurationKeyVaultOptions +from ._settingselector import SettingSelector + +from ._version import VERSION + +__version__ = VERSION +__all__ = [ + "AzureAppConfigurationProvider", + "AzureAppConfigurationKeyVaultOptions", + "SettingSelector" +] diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py new file mode 100644 index 000000000000..40fd4814704b --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -0,0 +1,14 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +class AzureAppConfigurationKeyVaultOptions: + + def __init__(self, credential=None, secret_clients=None, secret_resolver=None): + """ + credential, secret_clients (clients for connecting to multiple key vaults with different credentials), secret_resolver + """ + self.credential = credential + self.secret_clients = secret_clients + self.secret_resolver = secret_resolver diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py new file mode 100644 index 000000000000..5ec32d0d3e5a --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -0,0 +1,107 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +from azure.appconfiguration import AzureAppConfigurationClient +from azure.keyvault.secrets import SecretClient +from ._settingselector import SettingSelector +from urllib.parse import urlparse +import json + + +class AzureAppConfigurationProvider: + + @classmethod + def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): + """ + Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration settings into itself for usage. + Optional parameters: + selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not specified, all key-values with the empty label will be loaded. + trimmed_key_prefixes (remove prefixes in key name, list of what to trim), + key_vault_options (Configurations for connecting to Key Vault(s)) test + """ + provider = AzureAppConfigurationProvider() + + if (connection_string is not None): + provider.client = AzureAppConfigurationClient.from_connection_string( + connection_string) + else: + provider.client = AzureAppConfigurationClient(endpoint, credential) + + selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) + provider.trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) + key_vault_options = kwargs.pop("key_vault_options", None) + pipeline = kwargs.pop("pipeline") + + provider.dict = {} + + for select in selects: + configurations = provider.client.list_configuration_settings( + key_filter=select.key_filter, label_filter=select.label_filter) + for config in configurations: + if (config.content_type is None): + # Deals with possible null value via Rest API + provider.dict[provider.trim(config.key)] = config.value + elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": + jObject = json.loads(config.value) + uriValue = jObject['uri'] + + uri = urlparse(uriValue) + + key_vault_uri = "https://" + uri.hostname + key_vault_secret_prefix = "/secrets/" + key_vault_secret_name = uri.path[len( + key_vault_secret_prefix):] + if (key_vault_options.credential is not None): + secret_client = SecretClient( + vault_url=key_vault_uri, credential=key_vault_options.credential) + secret = secret_client.get_secret( + key_vault_secret_name) + provider.dict[provider.trim(config.key)] = secret.value + continue + if (key_vault_options.secret_clients is not None): + for secret_client in key_vault_options.secret_clients: + if (secret_client._vault_url == key_vault_uri): + secret = secret_client.get_secret( + key_vault_secret_name) + provider.dict[provider.trim( + config.key)] = secret.value + break + continue + if (key_vault_options.secret_resolver is not None): + provider.dict[provider.trim( + config.key)] = key_vault_options.secret_resolver(uri) + elif "application/json" in config.content_type: + jObject = json.loads(config.value) + provider.dict[provider.trim(config.key)] = jObject + else: + provider.dict[provider.trim(config.key)] = config.value + return provider + + def trim(self, key): + for trim in self.trim_prefixes: + if key.startswith(trim): + return key[len(trim):] + return key + + def __getitem__(self, key): + return self.dict[key] + + def __repr__(self): + return repr(self.dict) + + def __len__(self): + return len(self.dict) + + def copy(self): + return self.dict.copy() + + def has_key(self, k): + return k in self.dict + + def keys(self): + return self.dict.keys() + + def values(self): + return self.dict.values() diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py new file mode 100644 index 000000000000..fa87c4531384 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py @@ -0,0 +1,10 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +class SettingSelector: + + def __init__(self, key_filter, label_filter): + self.key_filter = key_filter + self.label_filter = label_filter \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py new file mode 100644 index 000000000000..7f4dc03a8fdc --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py @@ -0,0 +1,11 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +import platform +from ._version import VERSION +from azure.appconfiguration._version import VERSION as SDK_VERSION + +USER_AGENT = "python-appconfigurationprovider/{} azsdk-python-appconfiguration/{} Python/{} ({})".format( + VERSION, SDK_VERSION, platform.python_version(), platform.platform() +) diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py new file mode 100644 index 000000000000..ac9f392f513e --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py @@ -0,0 +1,6 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +VERSION = "1.0.0b1" diff --git a/sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt new file mode 100644 index 000000000000..b0d3f64b6dbd --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt @@ -0,0 +1,6 @@ +-e ../../../tools/azure-devtools +../../core/azure-core +-e ../../identity/azure-identity +aiohttp>=3.0 +-e ../../../tools/azure-sdk-tools +-e ../../../tools/azure-devtools \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/mypy.ini b/sdk/appconfiguration/appconfiguration-provider/mypy.ini new file mode 100644 index 000000000000..a90acaba8d0e --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/mypy.ini @@ -0,0 +1,12 @@ +[mypy] +python_version = 3.6 +warn_unused_configs = True +ignore_missing_imports = True + +# Per-module options: + +[mypy-azure.appconfiguration._generated.*] +ignore_errors = True + +[mypy-azure.core.*] +ignore_errors = True \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml new file mode 100644 index 000000000000..1f3da94f6908 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-app-configuration-provider" +package_nspkg = "azure-data-nspkg" +package_pprint_name = "App Configuration Provider" +package_doc_id = "" +is_stable = false +is_arm = false +need_msrestazure = false +auto_update = false \ No newline at end of file diff --git a/sdk/appconfiguration/appconfiguration-provider/setup.py b/sdk/appconfiguration/appconfiguration-provider/setup.py new file mode 100644 index 000000000000..25fd47fd9d69 --- /dev/null +++ b/sdk/appconfiguration/appconfiguration-provider/setup.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +import sys +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-appconfigurationprovider" +PACKAGE_PPRINT_NAME = "App Configuration Provider" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace("-", ".") + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: + version = re.search( + r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE + ).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + +with open("README.md", encoding="utf-8") as f: + readme = f.read() +with open("CHANGELOG.md", encoding="utf-8") as f: + changelog = f.read() + +exclude_packages = [ + "tests", + "tests.*", + "samples", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", +] +if sys.version_info < (3, 5, 3): + exclude_packages.extend(["*.aio", "*.aio.*"]) + +setup( + name=PACKAGE_NAME, + version=version, + include_package_data=True, + description="Microsoft {} Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration-provider", + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages(exclude=exclude_packages), + python_requires=">=3.6", + install_requires=[ + "msrest>=0.6.10", + "azure-core<2.0.0,>=1.2.2", + ], +) \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider b/sdk/appconfiguration/azure-appconfiguration-provider deleted file mode 160000 index ff1e84bacc32..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration-provider +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ff1e84bacc3284af077d6935beda70b9509a9e7f From 9e889d012f1ceb2f782bfbf9463c916b66fcdc9d Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 11:52:10 -0700 Subject: [PATCH 062/129] Fixing repo issue --- .../CHANGELOG.md | 0 .../LICENSE | 0 .../MANIFEST.in | 0 .../README.md | 0 .../azure/__init__.py | 0 .../azure/appconfigurationprovider/__init__.py | 0 .../_azureappconfigurationkeyvaultoptions.py | 0 .../appconfigurationprovider/_azureappconfigurationprovider.py | 2 +- .../azure/appconfigurationprovider/_settingselector.py | 0 .../azure/appconfigurationprovider/_user_agent.py | 0 .../azure/appconfigurationprovider/_version.py | 0 .../dev_requirements.txt | 0 .../mypy.ini | 0 .../sdk_packaging.toml | 0 .../setup.py | 0 15 files changed, 1 insertion(+), 1 deletion(-) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/CHANGELOG.md (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/LICENSE (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/MANIFEST.in (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/README.md (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/__init__.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/__init__.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/_azureappconfigurationprovider.py (99%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/_settingselector.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/_user_agent.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/azure/appconfigurationprovider/_version.py (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/dev_requirements.txt (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/mypy.ini (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/sdk_packaging.toml (100%) rename sdk/appconfiguration/{appconfiguration-provider => azure-appconfiguration-provider}/setup.py (100%) diff --git a/sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/CHANGELOG.md rename to sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md diff --git a/sdk/appconfiguration/appconfiguration-provider/LICENSE b/sdk/appconfiguration/azure-appconfiguration-provider/LICENSE similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/LICENSE rename to sdk/appconfiguration/azure-appconfiguration-provider/LICENSE diff --git a/sdk/appconfiguration/appconfiguration-provider/MANIFEST.in b/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/MANIFEST.in rename to sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in diff --git a/sdk/appconfiguration/appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/README.md rename to sdk/appconfiguration/azure-appconfiguration-provider/README.md diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py similarity index 99% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 5ec32d0d3e5a..fa251c6b66f2 100644 --- a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -19,7 +19,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): Optional parameters: selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not specified, all key-values with the empty label will be loaded. trimmed_key_prefixes (remove prefixes in key name, list of what to trim), - key_vault_options (Configurations for connecting to Key Vault(s)) test + key_vault_options (Configurations for connecting to Key Vault(s)) """ provider = AzureAppConfigurationProvider() diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py diff --git a/sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/azure/appconfigurationprovider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py diff --git a/sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/dev_requirements.txt rename to sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt diff --git a/sdk/appconfiguration/appconfiguration-provider/mypy.ini b/sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/mypy.ini rename to sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini diff --git a/sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/sdk_packaging.toml rename to sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml diff --git a/sdk/appconfiguration/appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py similarity index 100% rename from sdk/appconfiguration/appconfiguration-provider/setup.py rename to sdk/appconfiguration/azure-appconfiguration-provider/setup.py From c3b56e5569b5970a1f1d7f8e3c42d09697203144 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 13:49:28 -0700 Subject: [PATCH 063/129] Updated to setup user agent and header info --- .../_azureappconfigurationprovider.py | 45 ++++++++++++++----- .../appconfigurationprovider/_user_agent.py | 4 +- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index fa251c6b66f2..a689f017a46e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -6,6 +6,7 @@ from azure.appconfiguration import AzureAppConfigurationClient from azure.keyvault.secrets import SecretClient from ._settingselector import SettingSelector +from ._user_agent import USER_AGENT from urllib.parse import urlparse import json @@ -14,25 +15,23 @@ class AzureAppConfigurationProvider: @classmethod def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): - """ - Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration settings into itself for usage. - Optional parameters: - selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not specified, all key-values with the empty label will be loaded. - trimmed_key_prefixes (remove prefixes in key name, list of what to trim), + """ + Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration settings into itself for usage. + Optional parameters: + selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not specified, all key-values with the empty label will be loaded. + trimmed_key_prefixes (remove prefixes in key name, list of what to trim), key_vault_options (Configurations for connecting to Key Vault(s)) """ + provider = AzureAppConfigurationProvider() - if (connection_string is not None): - provider.client = AzureAppConfigurationClient.from_connection_string( - connection_string) - else: - provider.client = AzureAppConfigurationClient(endpoint, credential) + key_vault_options = kwargs.pop("key_vault_options", None) + + provider.client = cls.buildprovider( + connection_string, endpoint, credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) provider.trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) - key_vault_options = kwargs.pop("key_vault_options", None) - pipeline = kwargs.pop("pipeline") provider.dict = {} @@ -79,6 +78,28 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider.dict[provider.trim(config.key)] = config.value return provider + def buildprovider(connection_string, endpoint, credential, key_vault_options): + usesKeyVault = False + + if (key_vault_options is not None and (key_vault_options.credential is not None or key_vault_options.secret_clients is not None or key_vault_options.secret_resolver is not None)): + usesKeyVault = True + + headers = {} + correlationcontext = "RequestType=Startup" + + if (usesKeyVault): + correlationcontext += ",UsesKeyVault" + + headers["Correlation-Context"] = correlationcontext + useragent = USER_AGENT + + if (connection_string is not None): + return AzureAppConfigurationClient.from_connection_string( + connection_string, user_agent=useragent, headers=headers) + else: + return AzureAppConfigurationClient( + endpoint, credential, user_agent=useragent, headers=headers) + def trim(self, key): for trim in self.trim_prefixes: if key.startswith(trim): diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py index 7f4dc03a8fdc..66023530ce56 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py @@ -6,6 +6,6 @@ from ._version import VERSION from azure.appconfiguration._version import VERSION as SDK_VERSION -USER_AGENT = "python-appconfigurationprovider/{} azsdk-python-appconfiguration/{} Python/{} ({})".format( - VERSION, SDK_VERSION, platform.python_version(), platform.platform() +USER_AGENT = "python-appconfigurationprovider/{}".format( + VERSION ) From 86cd913e56fabd0d80a20c5c2f892156acc789bf Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 14:04:19 -0700 Subject: [PATCH 064/129] Updating to cache secret_clients --- .../_azureappconfigurationprovider.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index a689f017a46e..66d062f335fb 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -22,7 +22,6 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): trimmed_key_prefixes (remove prefixes in key name, list of what to trim), key_vault_options (Configurations for connecting to Key Vault(s)) """ - provider = AzureAppConfigurationProvider() key_vault_options = kwargs.pop("key_vault_options", None) @@ -34,6 +33,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider.trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) provider.dict = {} + secret_clients = {} for select in selects: configurations = provider.client.list_configuration_settings( @@ -53,8 +53,17 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_secret_name = uri.path[len( key_vault_secret_prefix):] if (key_vault_options.credential is not None): - secret_client = SecretClient( - vault_url=key_vault_uri, credential=key_vault_options.credential) + secret_client = None + + # Clients only should be made once, will reuse if client already made + for client_uri in secret_clients: + if client_uri == key_vault_uri: + secret_client = secret_clients[client_uri] + break + if (secret_client is None): + secret_client = SecretClient( + vault_url=key_vault_uri, credential=key_vault_options.credential) + secret_clients[key_vault_uri] = secret_client secret = secret_client.get_secret( key_vault_secret_name) provider.dict[provider.trim(config.key)] = secret.value From 1220f9dcbe8d980fd8fc112279e2a3ec32b71800 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 14:05:47 -0700 Subject: [PATCH 065/129] Fixed Naming --- .../_azureappconfigurationprovider.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 66d062f335fb..580ce3cf4e62 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -43,10 +43,10 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): # Deals with possible null value via Rest API provider.dict[provider.trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": - jObject = json.loads(config.value) - uriValue = jObject['uri'] + j_object = json.loads(config.value) + uri_value = j_object['uri'] - uri = urlparse(uriValue) + uri = urlparse(uri_value) key_vault_uri = "https://" + uri.hostname key_vault_secret_prefix = "/secrets/" @@ -81,8 +81,8 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider.dict[provider.trim( config.key)] = key_vault_options.secret_resolver(uri) elif "application/json" in config.content_type: - jObject = json.loads(config.value) - provider.dict[provider.trim(config.key)] = jObject + j_object = json.loads(config.value) + provider.dict[provider.trim(config.key)] = j_object else: provider.dict[provider.trim(config.key)] = config.value return provider @@ -94,12 +94,12 @@ def buildprovider(connection_string, endpoint, credential, key_vault_options): usesKeyVault = True headers = {} - correlationcontext = "RequestType=Startup" + correlation_context = "RequestType=Startup" if (usesKeyVault): - correlationcontext += ",UsesKeyVault" + correlation_context += ",UsesKeyVault" - headers["Correlation-Context"] = correlationcontext + headers["Correlation-Context"] = correlation_context useragent = USER_AGENT if (connection_string is not None): From 9e4842983d9424da320db8a225f8d3e2916f85d6 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 30 Aug 2022 14:19:27 -0700 Subject: [PATCH 066/129] Fixed Typo --- sdk/appconfiguration/azure-appconfiguration-provider/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index 7620d7478d0f..7e69f0e95f8a 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -1,6 +1,6 @@ # Azure App Configuration Python Provider -Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. This provider adds additional functionality above the azure-sdk-for-pyton. +Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. This provider adds additional functionality above the azure-sdk-for-python. Using the provider enables loading sets of configurations from a Azure App Configuration store in a managed way. From 0b15d1a9c51c67cb1f6a3f8b0daf479fbf9fb880 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 1 Sep 2022 12:14:50 -0700 Subject: [PATCH 067/129] Added Samples, Fixed issue with Key Vault Options not set when secret is in store. --- .../_azureappconfigurationprovider.py | 5 ++ .../samples/README.md | 56 +++++++++++++++++++ .../samples/aad_sample.py | 30 ++++++++++ .../samples/connection_string_sample.py | 28 ++++++++++ .../samples/key_vault_reference_sample.py | 17 ++++++ 5 files changed, 136 insertions(+) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 580ce3cf4e62..cba7499bfab2 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -9,6 +9,7 @@ from ._user_agent import USER_AGENT from urllib.parse import urlparse import json +import warnings class AzureAppConfigurationProvider: @@ -43,6 +44,10 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): # Deals with possible null value via Rest API provider.dict[provider.trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": + if (key_vault_options is None): + warnings.warn( + "Key Vault Reference found, but no Key Vault Options were provided") + continue j_object = json.loads(config.value) uri_value = j_object['uri'] diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md new file mode 100644 index 000000000000..868bfaa7f3b7 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md @@ -0,0 +1,56 @@ +--- +page_type: sample +languages: + - python +products: + - azure + - azure-app-configuration +--- + +# Azure App Configuration Provider Library Python Samples + +## Prerequisites + +You must have an [Azure subscription][azure_sub], and a [Configuration Store][configuration_store] to use this package. + +To create a Configuration Store, you can either use [Azure Portal](https://ms.portal.azure.com/#create/Microsoft.Azconfig) or if you are using [Azure CLI][azure_cli] you can simply run the following snippet in your console: + +```Powershell +az appconfig create --name --resource-group --location eastus +``` + +### Create Keys + +```Powershell +az appconfig kv set --name --key message --value "hi" +az appconfig kv set --name --key test.message --value "Hi with test Prefix" +``` + +### Create Key Vault Reference + +Requires Key Vault with Secret already created. + +```Powershell +az appconfig kv set-keyvault --name --key secret --secret-identifier +``` + +## Setup + +Install the Azure App Configuration Provider client library for Python with pip: + +```commandline +pip install azure-appconfiguration-provider +``` + +## Contents + +| File | Description | +|-------------|-------------| +| aad_sample.py | demos connecting to app configuration with Azure Active Directory | +| connection_string_sample.py | demos connecting to app configuration with a Connection String | +| key_vault_reference_sample.py | demos resovling key vault references with App Configuration | + + +[azure_sub]: https://azure.microsoft.com/free/ +[azure_cli]: https://docs.microsoft.com/cli/azure +[configuration_store]: https://azure.microsoft.com/services/app-configuration/ \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py new file mode 100644 index 000000000000..ccafa1db1622 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -0,0 +1,30 @@ +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + SettingSelector +) +from azure.identity import DefaultAzureCredential +import os + +endpoint = os.environ.get("AZURE_APPCONFIG_ENDPOINT") +credential = DefaultAzureCredential() + +# Connecting to Azure App Configuration using AAD +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=credential) + +print(config["message"]) + +# Connecting to Azure App Configuration using AAD and trimmed key prefixes +trimmed = {"test."} +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=credential, trimmed_key_prefixes=trimmed) + +print(config["message"]) + +# Connection to Azure App Configuration using SettingSelector +selects = {SettingSelector("message*", "\0")} +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=credential, selects=selects) + +print("message found: " + str(config.has_key("message"))) +print("test.message found: " + str(config.has_key("config.message"))) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py new file mode 100644 index 000000000000..6d6aa21d3441 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -0,0 +1,28 @@ +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + SettingSelector +) +import os + +connection_string = os.environ.get("AZURE_APPCONFIG_CONNECTION_STRING") + +# Connecting to Azure App Configuration using connection string +config = AzureAppConfigurationProvider.load( + connection_string=connection_string) + +print(config["message"]) + +# Connecting to Azure App Configuration using connection string and trimmed key prefixes +trimmed = {"test."} +config = AzureAppConfigurationProvider.load( + connection_string=connection_string, trimmed_key_prefixes=trimmed) + +print(config["message"]) + +# Connection to Azure App Configuration using SettingSelector +selects = {SettingSelector("message*", "\0")} +config = AzureAppConfigurationProvider.load( + connection_string=connection_string, selects=selects) + +print("message found: " + str(config.has_key("message"))) +print("test.message found: " + str(config.has_key("config.message"))) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py new file mode 100644 index 000000000000..0f516de7dff3 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -0,0 +1,17 @@ +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + AzureAppConfigurationKeyVaultOptions, + SettingSelector +) +from azure.identity import DefaultAzureCredential +import os + +endpoint = os.environ.get("AZURE_APPCONFIG_ENDPOINT") +credential = DefaultAzureCredential() + +# Connection to Azure App Configuration using AAD and Resolving Key Vault References +key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=credential) +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=credential, key_vault_options=key_vault_options) + +print(config["secret"]) From 8aa4762e4300b7ab892b025e3ea05e06ef8a076c Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 2 Sep 2022 11:22:20 -0700 Subject: [PATCH 068/129] Fixed SP, Dependency, and Pylint issues --- .../CHANGELOG.md | 2 +- .../azure/__init__.py | 3 +- .../_azureappconfigurationkeyvaultoptions.py | 4 +- .../_azureappconfigurationprovider.py | 38 ++++++++++--------- .../_settingselector.py | 2 +- .../appconfigurationprovider/_user_agent.py | 2 - .../samples/README.md | 2 +- .../azure-appconfiguration-provider/setup.py | 4 +- 8 files changed, 29 insertions(+), 28 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md index 1683e32f84f2..c3f16119c9f4 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md @@ -7,7 +7,7 @@ New Azure App Configuration Provider Provides additional support above the Azure App Configuration SDK. Enables: * Connecting to an Azure App Configuration store * Selecting multiple keys using Setting Selector -* Resove Key Vault References when supplied AzureAppConfigurationKeyVaultOptions +* Resolve Key Vault References when supplied AzureAppConfigurationKeyVaultOptions The Azure App Configuration Provider once loaded returns a dictionary of key/value pairs to use in configuration. diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py index d19ce0e399ec..229d1b3c8804 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py @@ -1 +1,2 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore \ No newline at end of file +__path__ = __import__("pkgutil").extend_path( + __path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 40fd4814704b..bb4a75da8fae 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -6,8 +6,8 @@ class AzureAppConfigurationKeyVaultOptions: def __init__(self, credential=None, secret_clients=None, secret_resolver=None): - """ - credential, secret_clients (clients for connecting to multiple key vaults with different credentials), secret_resolver + """ + credential, secret_clients (clients for connecting to multiple key vaults with different credentials), secret_resolver """ self.credential = credential self.secret_clients = secret_clients diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index cba7499bfab2..1966c0480e0a 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -3,13 +3,13 @@ # Licensed under the MIT License. # ------------------------------------ +from urllib.parse import urlparse +import json +import warnings from azure.appconfiguration import AzureAppConfigurationClient from azure.keyvault.secrets import SecretClient from ._settingselector import SettingSelector from ._user_agent import USER_AGENT -from urllib.parse import urlparse -import json -import warnings class AzureAppConfigurationProvider: @@ -17,9 +17,11 @@ class AzureAppConfigurationProvider: @classmethod def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): """ - Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration settings into itself for usage. + Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration + settings into itself for usage. Optional parameters: - selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not specified, all key-values with the empty label will be loaded. + selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not + specified, all key-values with the empty label will be loaded. trimmed_key_prefixes (remove prefixes in key name, list of what to trim), key_vault_options (Configurations for connecting to Key Vault(s)) """ @@ -40,11 +42,11 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): configurations = provider.client.list_configuration_settings( key_filter=select.key_filter, label_filter=select.label_filter) for config in configurations: - if (config.content_type is None): + if config.content_type is None: # Deals with possible null value via Rest API provider.dict[provider.trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": - if (key_vault_options is None): + if key_vault_options is None: warnings.warn( "Key Vault Reference found, but no Key Vault Options were provided") continue @@ -57,7 +59,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_secret_prefix = "/secrets/" key_vault_secret_name = uri.path[len( key_vault_secret_prefix):] - if (key_vault_options.credential is not None): + if key_vault_options.credential is not None: secret_client = None # Clients only should be made once, will reuse if client already made @@ -65,7 +67,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): if client_uri == key_vault_uri: secret_client = secret_clients[client_uri] break - if (secret_client is None): + if secret_client is None: secret_client = SecretClient( vault_url=key_vault_uri, credential=key_vault_options.credential) secret_clients[key_vault_uri] = secret_client @@ -73,7 +75,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_secret_name) provider.dict[provider.trim(config.key)] = secret.value continue - if (key_vault_options.secret_clients is not None): + if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: if (secret_client._vault_url == key_vault_uri): secret = secret_client.get_secret( @@ -82,7 +84,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): config.key)] = secret.value break continue - if (key_vault_options.secret_resolver is not None): + if key_vault_options.secret_resolver is not None: provider.dict[provider.trim( config.key)] = key_vault_options.secret_resolver(uri) elif "application/json" in config.content_type: @@ -92,27 +94,27 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider.dict[provider.trim(config.key)] = config.value return provider - def buildprovider(connection_string, endpoint, credential, key_vault_options): + def buildprovider(self, connection_string, endpoint, credential, key_vault_options): usesKeyVault = False - if (key_vault_options is not None and (key_vault_options.credential is not None or key_vault_options.secret_clients is not None or key_vault_options.secret_resolver is not None)): + if (key_vault_options is not None and + (key_vault_options.credential is not None or key_vault_options.secret_clients is not None or + key_vault_options.secret_resolver is not None)): usesKeyVault = True headers = {} correlation_context = "RequestType=Startup" - if (usesKeyVault): + if usesKeyVault: correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context useragent = USER_AGENT - if (connection_string is not None): + if connection_string is not None: return AzureAppConfigurationClient.from_connection_string( connection_string, user_agent=useragent, headers=headers) - else: - return AzureAppConfigurationClient( - endpoint, credential, user_agent=useragent, headers=headers) + return AzureAppConfigurationClient(endpoint, credential, user_agent=useragent, headers=headers) def trim(self, key): for trim in self.trim_prefixes: diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py index fa87c4531384..d9b94fedd914 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py @@ -7,4 +7,4 @@ class SettingSelector: def __init__(self, key_filter, label_filter): self.key_filter = key_filter - self.label_filter = label_filter \ No newline at end of file + self.label_filter = label_filter diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py index 66023530ce56..43eedb9b9551 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py @@ -2,9 +2,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ -import platform from ._version import VERSION -from azure.appconfiguration._version import VERSION as SDK_VERSION USER_AGENT = "python-appconfigurationprovider/{}".format( VERSION diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md index 868bfaa7f3b7..881144ea7209 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md @@ -48,7 +48,7 @@ pip install azure-appconfiguration-provider |-------------|-------------| | aad_sample.py | demos connecting to app configuration with Azure Active Directory | | connection_string_sample.py | demos connecting to app configuration with a Connection String | -| key_vault_reference_sample.py | demos resovling key vault references with App Configuration | +| key_vault_reference_sample.py | demos resolving key vault references with App Configuration | [azure_sub]: https://azure.microsoft.com/free/ diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 25fd47fd9d69..69b8c100699f 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -72,7 +72,7 @@ packages=find_packages(exclude=exclude_packages), python_requires=">=3.6", install_requires=[ - "msrest>=0.6.10", + "msrest>=0.6.21", "azure-core<2.0.0,>=1.2.2", ], -) \ No newline at end of file +) From 4fdfb56f1ebe1470c5b1aa9a6ebd5920cd4832d4 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 2 Sep 2022 12:03:12 -0700 Subject: [PATCH 069/129] Fixed more lint issues, moved key vault references to be a method --- .../azure-appconfiguration-provider/README.md | 34 ++++- .../_azureappconfigurationkeyvaultoptions.py | 3 +- .../_azureappconfigurationprovider.py | 129 ++++++++++-------- 3 files changed, 103 insertions(+), 63 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index 7e69f0e95f8a..ecf48ea1c197 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -1,4 +1,4 @@ -# Azure App Configuration Python Provider +# Azure App Configuration Python Provider client library for Python Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. This provider adds additional functionality above the azure-sdk-for-python. @@ -32,6 +32,8 @@ config = AzureAppConfigurationProvider.load(endpoint="your-endpoint", credential these providers will by default load all configurations with `(No Label)` from your configuration store. +## Examples + ### Selecting configurations You can refine or expand the configurations loaded from your store by using `SettingSelector`s. Setting selectors provide a way to pass a key filter and label filter into the provider. @@ -88,4 +90,32 @@ key_vault_options = AzureAppConfigurationKeyVaultOptions( secret_resolver=secret_resolver) config = AzureAppConfigurationProvider.load( endpoint=endpoint, credential=default_credential, key_vault_options=key_vault_options) -``` \ No newline at end of file +``` + +## Key concepts + +## Troubleshooting + +## Next steps + +## Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, +see the Code of Conduct FAQ or contact opencode@microsoft.com with any +additional questions or comments. + +[cla]: https://cla.microsoft.com +[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ +[coc_contact]: mailto:opencode@microsoft.com \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index bb4a75da8fae..2abc44a7bfd1 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -7,7 +7,8 @@ class AzureAppConfigurationKeyVaultOptions: def __init__(self, credential=None, secret_clients=None, secret_resolver=None): """ - credential, secret_clients (clients for connecting to multiple key vaults with different credentials), secret_resolver + credential, secret_clients (clients for connecting to multiple key vaults with different credentials), + secret_resolver """ self.credential = credential self.secret_clients = secret_clients diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 1966c0480e0a..1f6d2bfba9fb 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -14,14 +14,19 @@ class AzureAppConfigurationProvider: + def __init__(self): + self._dict = {} + self._trim_prefixes = [] + self.client = None + @classmethod def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): """ - Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration - settings into itself for usage. + Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration + settings into itself for usage. Optional parameters: - selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not - specified, all key-values with the empty label will be loaded. + selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not + specified, all key-values with the empty label will be loaded. trimmed_key_prefixes (remove prefixes in key name, list of what to trim), key_vault_options (Configurations for connecting to Key Vault(s)) """ @@ -29,69 +34,30 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_options = kwargs.pop("key_vault_options", None) - provider.client = cls.buildprovider( + provider._client = provider.buildprovider( connection_string, endpoint, credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) - provider.trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) + provider._trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) - provider.dict = {} + provider._dict = {} secret_clients = {} for select in selects: - configurations = provider.client.list_configuration_settings( + configurations = provider._client.list_configuration_settings( key_filter=select.key_filter, label_filter=select.label_filter) for config in configurations: if config.content_type is None: # Deals with possible null value via Rest API - provider.dict[provider.trim(config.key)] = config.value + provider._dict[provider.trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": - if key_vault_options is None: - warnings.warn( - "Key Vault Reference found, but no Key Vault Options were provided") - continue - j_object = json.loads(config.value) - uri_value = j_object['uri'] - - uri = urlparse(uri_value) - - key_vault_uri = "https://" + uri.hostname - key_vault_secret_prefix = "/secrets/" - key_vault_secret_name = uri.path[len( - key_vault_secret_prefix):] - if key_vault_options.credential is not None: - secret_client = None - - # Clients only should be made once, will reuse if client already made - for client_uri in secret_clients: - if client_uri == key_vault_uri: - secret_client = secret_clients[client_uri] - break - if secret_client is None: - secret_client = SecretClient( - vault_url=key_vault_uri, credential=key_vault_options.credential) - secret_clients[key_vault_uri] = secret_client - secret = secret_client.get_secret( - key_vault_secret_name) - provider.dict[provider.trim(config.key)] = secret.value - continue - if key_vault_options.secret_clients is not None: - for secret_client in key_vault_options.secret_clients: - if (secret_client._vault_url == key_vault_uri): - secret = secret_client.get_secret( - key_vault_secret_name) - provider.dict[provider.trim( - config.key)] = secret.value - break - continue - if key_vault_options.secret_resolver is not None: - provider.dict[provider.trim( - config.key)] = key_vault_options.secret_resolver(uri) + provider.resolve_keyvault_references( + config, key_vault_options, secret_clients) elif "application/json" in config.content_type: j_object = json.loads(config.value) - provider.dict[provider.trim(config.key)] = j_object + provider._dict[provider.trim(config.key)] = j_object else: - provider.dict[provider.trim(config.key)] = config.value + provider._dict[provider.trim(config.key)] = config.value return provider def buildprovider(self, connection_string, endpoint, credential, key_vault_options): @@ -116,29 +82,72 @@ def buildprovider(self, connection_string, endpoint, credential, key_vault_optio connection_string, user_agent=useragent, headers=headers) return AzureAppConfigurationClient(endpoint, credential, user_agent=useragent, headers=headers) + def resolve_keyvault_references(self, config, key_vault_options, secret_clients): + if key_vault_options is None: + warnings.warn( + "Key Vault Reference found, but no Key Vault Options were provided") + return + j_object = json.loads(config.value) + uri_value = j_object['uri'] + + uri = urlparse(uri_value) + + key_vault_uri = "https://" + uri.hostname + key_vault_secret_prefix = "/secrets/" + key_vault_secret_name = uri.path[len( + key_vault_secret_prefix):] + if key_vault_options.credential is not None: + secret_client = None + + # Clients only should be made once, will reuse if client already made + for client_uri in secret_clients: + if client_uri == key_vault_uri: + secret_client = secret_clients[client_uri] + break + if secret_client is None: + secret_client = SecretClient( + vault_url=key_vault_uri, credential=key_vault_options.credential) + secret_clients[key_vault_uri] = secret_client + secret = secret_client.get_secret( + key_vault_secret_name) + self._dict[self.trim(config.key)] = secret.value + return + if key_vault_options.secret_clients is not None: + for secret_client in key_vault_options.secret_clients: + if secret_client._vault_url == key_vault_uri: + secret = secret_client.get_secret( + key_vault_secret_name) + self._dict[self.trim( + config.key)] = secret.value + break + return + if key_vault_options.secret_resolver is not None: + self._dict[self.trim( + config.key)] = key_vault_options.secret_resolver(uri) + def trim(self, key): - for trim in self.trim_prefixes: + for trim in self._trim_prefixes: if key.startswith(trim): return key[len(trim):] return key def __getitem__(self, key): - return self.dict[key] + return self._dict[key] def __repr__(self): - return repr(self.dict) + return repr(self._dict) def __len__(self): - return len(self.dict) + return len(self._dict) def copy(self): - return self.dict.copy() + return self._dict.copy() def has_key(self, k): - return k in self.dict + return k in self._dict def keys(self): - return self.dict.keys() + return self._dict.keys() def values(self): - return self.dict.values() + return self._dict.values() From b87beee85e050d15ad61f0c55bd2e92c8f9e7229 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 2 Sep 2022 12:38:37 -0700 Subject: [PATCH 070/129] More Linting fixes --- .../_azureappconfigurationkeyvaultoptions.py | 4 ++-- .../_azureappconfigurationprovider.py | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 2abc44a7bfd1..ea1349260759 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -7,8 +7,8 @@ class AzureAppConfigurationKeyVaultOptions: def __init__(self, credential=None, secret_clients=None, secret_resolver=None): """ - credential, secret_clients (clients for connecting to multiple key vaults with different credentials), - secret_resolver + credential, secret_clients (clients for connecting to multiple key vaults with different credentials), + secret_resolver """ self.credential = credential self.secret_clients = secret_clients diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 1f6d2bfba9fb..65cc1e427699 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -17,7 +17,7 @@ class AzureAppConfigurationProvider: def __init__(self): self._dict = {} self._trim_prefixes = [] - self.client = None + self._client = None @classmethod def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): @@ -34,8 +34,8 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_options = kwargs.pop("key_vault_options", None) - provider._client = provider.buildprovider( - connection_string, endpoint, credential, key_vault_options) + provider.buildprovider(connection_string, endpoint, + credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) provider._trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) @@ -78,9 +78,11 @@ def buildprovider(self, connection_string, endpoint, credential, key_vault_optio useragent = USER_AGENT if connection_string is not None: - return AzureAppConfigurationClient.from_connection_string( + self._client = AzureAppConfigurationClient.from_connection_string( connection_string, user_agent=useragent, headers=headers) - return AzureAppConfigurationClient(endpoint, credential, user_agent=useragent, headers=headers) + return + self._client = AzureAppConfigurationClient( + endpoint, credential, user_agent=useragent, headers=headers) def resolve_keyvault_references(self, config, key_vault_options, secret_clients): if key_vault_options is None: From b237292404d2c68dc88921ba8b693ddfd24b53c2 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 2 Sep 2022 12:57:27 -0700 Subject: [PATCH 071/129] Fixing dependency issues with build --- .../azure-appconfiguration-provider/dev_requirements.txt | 1 + sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt index b0d3f64b6dbd..adab992bf639 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt +++ b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt @@ -1,5 +1,6 @@ -e ../../../tools/azure-devtools ../../core/azure-core +-e ../azure-appconfiguration -e ../../identity/azure-identity aiohttp>=3.0 -e ../../../tools/azure-sdk-tools diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 69b8c100699f..e6826bfacd68 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -74,5 +74,8 @@ install_requires=[ "msrest>=0.6.21", "azure-core<2.0.0,>=1.2.2", + "azure-appconfiguration<2.0.0,>=1.1.1", + "azure-identity<2.0.0,>=1.4.0", + "azure-keyvault-secrets<5.0.0,>=4.0.0", ], ) From 8335a1a47b0d27c3057d535023498bd52a216a8d Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 9 Sep 2022 13:45:18 -0700 Subject: [PATCH 072/129] Updated Docs. Fixed extra code for Key Vault Usage. Updated Readme to include a list of features and future features. Added Clients sample for Key Vault. --- .../azure-appconfiguration-provider/README.md | 20 +++++ .../appconfigurationprovider/__init__.py | 10 +-- .../_azureappconfigurationkeyvaultoptions.py | 23 ++++-- .../_azureappconfigurationprovider.py | 79 ++++++++++++------- .../_settingselector.py | 17 +++- .../appconfigurationprovider/_user_agent.py | 10 ++- .../appconfigurationprovider/_version.py | 9 ++- .../samples/aad_sample.py | 6 ++ .../samples/connection_string_sample.py | 6 ++ ...vault_reference_provided_clients_sample.py | 26 ++++++ .../samples/key_vault_reference_sample.py | 9 ++- 11 files changed, 159 insertions(+), 56 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index ecf48ea1c197..f9f0229d33c5 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -32,6 +32,26 @@ config = AzureAppConfigurationProvider.load(endpoint="your-endpoint", credential these providers will by default load all configurations with `(No Label)` from your configuration store. +### Features + +Currently the Azure App Configuration Provider enables: + +* Connecting to an App Configuration Store using a connection string or Azure Active Directory. +* Selecting multiple sets of configurations using `SettingSelector`. +* Trim prefixes off key names. +* Resolving Key Vault References, requires AAD. +* Secret Resolver, resolve Key Vault References locally without connecting to Key Vault. +* Json Content Type + +#### Future Features + +List of features we are going to add to the Python Provider in the future. + +* Geo-Replication support +* Feature Management +* Dynamic Refresh +* Configuration Placeholders + ## Examples ### Selecting configurations diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py index 5691dba68be6..1ef7efc3de32 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py @@ -1,13 +1,9 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- +# ------------------------------------------------------------------------ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- +# ------------------------------------------------------------------------- + from ._azureappconfigurationprovider import AzureAppConfigurationProvider from ._azureappconfigurationkeyvaultoptions import AzureAppConfigurationKeyVaultOptions from ._settingselector import SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index ea1349260759..976eafeaea98 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -1,15 +1,22 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- class AzureAppConfigurationKeyVaultOptions: + """ + Options for connecting to Key Vault. + :param credential: A credential for authenticating with the key vault. This is optional if secret_clients is provided. + :type credential: ~azure.core.credentials.TokenCredential + :param secret_clients: A list of SecretClient from azure-keyvault-secrets. This is optional if credential is provided. + :type secret_clients: list[~azure.keyvault.secrets.SecretClient] + :param secret_resolver: A function that takes a URI and returns a value. + :type secret_resolver: callable + """ def __init__(self, credential=None, secret_clients=None, secret_resolver=None): - """ - credential, secret_clients (clients for connecting to multiple key vaults with different credentials), - secret_resolver - """ + # type: (TokenCredential, List[SecretClient], Callable) -> None self.credential = credential self.secret_clients = secret_clients self.secret_resolver = secret_resolver diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 65cc1e427699..f9101f791746 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- from urllib.parse import urlparse import json @@ -13,8 +14,14 @@ class AzureAppConfigurationProvider: + """ + Provides a dictionary-like interface to Azure App Configuration settings. Enables loading of sets of configuration + settings from Azure App Configuration into a Python application. Enables trimming of prefixes from configuration + keys. Enables resolution of Key Vault references in configuration settings. + """ def __init__(self): + # type: () -> None self._dict = {} self._trim_prefixes = [] self._client = None @@ -22,20 +29,26 @@ def __init__(self): @classmethod def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): """ - Requires either a connection-string, or an Endpoint with a Credential. Loads the selected configuration - settings into itself for usage. - Optional parameters: - selectors (List of SettingSelector for selecting which applicationconfiguration settings to load),. If not - specified, all key-values with the empty label will be loaded. - trimmed_key_prefixes (remove prefixes in key name, list of what to trim), - key_vault_options (Configurations for connecting to Key Vault(s)) + Loads configuration settings from Azure App Configuration into a Python application. + :param connection_string: Connection string (one of connection_string or endpoint and credential must be set) + :type connection_string: str + :param endpoint: Endpoint (one of connection_string or endpoint and credential must be set) + :type endpoint: str + :param credential: Credential (one of connection_string or endpoint and credential must be set) + :type credential: Union[AppConfigConnectionStringCredential, TokenCredential] + :keyword selectors: List of setting selectors to filter configuration settings + :type selectors: list[~azure.appconfigurationprovider.SettingSelector] + :keyword trim_prefixes: List of prefixes to trim from configuration keys + :type trim_prefixes: list[str] + :keyword key_vault_options: Options for resolving Key Vault references + :type key_vault_options: ~azure.appconfigurationprovider.KeyVaultOptions """ provider = AzureAppConfigurationProvider() key_vault_options = kwargs.pop("key_vault_options", None) - provider.buildprovider(connection_string, endpoint, - credential, key_vault_options) + provider.__buildprovider(connection_string, endpoint, + credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) provider._trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) @@ -51,7 +64,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): # Deals with possible null value via Rest API provider._dict[provider.trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": - provider.resolve_keyvault_references( + provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) elif "application/json" in config.content_type: j_object = json.loads(config.value) @@ -60,18 +73,13 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider._dict[provider.trim(config.key)] = config.value return provider - def buildprovider(self, connection_string, endpoint, credential, key_vault_options): - usesKeyVault = False + def __buildprovider(self, connection_string, endpoint, credential, key_vault_options): + headers = {} + correlation_context = "RequestType=Startup" if (key_vault_options is not None and (key_vault_options.credential is not None or key_vault_options.secret_clients is not None or key_vault_options.secret_resolver is not None)): - usesKeyVault = True - - headers = {} - correlation_context = "RequestType=Startup" - - if usesKeyVault: correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context @@ -84,7 +92,7 @@ def buildprovider(self, connection_string, endpoint, credential, key_vault_optio self._client = AzureAppConfigurationClient( endpoint, credential, user_agent=useragent, headers=headers) - def resolve_keyvault_references(self, config, key_vault_options, secret_clients): + def __resolve_keyvault_references(self, config, key_vault_options, secret_clients): if key_vault_options is None: warnings.warn( "Key Vault Reference found, but no Key Vault Options were provided") @@ -112,22 +120,22 @@ def resolve_keyvault_references(self, config, key_vault_options, secret_clients) secret_clients[key_vault_uri] = secret_client secret = secret_client.get_secret( key_vault_secret_name) - self._dict[self.trim(config.key)] = secret.value + self._dict[self.__trim(config.key)] = secret.value return if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: if secret_client._vault_url == key_vault_uri: secret = secret_client.get_secret( key_vault_secret_name) - self._dict[self.trim( + self._dict[self.__trim( config.key)] = secret.value break return if key_vault_options.secret_resolver is not None: - self._dict[self.trim( + self._dict[self.__trim( config.key)] = key_vault_options.secret_resolver(uri) - def trim(self, key): + def __trim(self, key): for trim in self._trim_prefixes: if key.startswith(trim): return key[len(trim):] @@ -143,13 +151,30 @@ def __len__(self): return len(self._dict) def copy(self): + """ + Returns a copy of the configuration settings + type: () -> dict + """ return self._dict.copy() def has_key(self, k): + """ + Returns True if the configuration settings has been loaded from Azure App Configuration. + type: (str) -> bool + """ return k in self._dict def keys(self): + """ + Returns a list of keys loaded from Azure App Configuration. + type: () -> list + """ return self._dict.keys() def values(self): + """ + Returns a list of values loaded from Azure App Configuration. Any values that are Key Vault references will be + resolved. + type: () -> list + """ return self._dict.values() diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py index d9b94fedd914..3dbb41231db5 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py @@ -1,10 +1,19 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- class SettingSelector: + """ + Selects a set of configuration settings from Azure App Configuration. + :param key_filter: A filter to select configuration settings based on their keys. + :type key_filter: str + :param label_filter: A filter to select configuration settings based on their labels. + :type label_filter: str + """ def __init__(self, key_filter, label_filter): + # type: (str, str) -> None self.key_filter = key_filter self.label_filter = label_filter diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py index 43eedb9b9551..b75e8a607e9f 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py @@ -1,7 +1,9 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + from ._version import VERSION USER_AGENT = "python-appconfigurationprovider/{}".format( diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py index ac9f392f513e..839ee5fc6576 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py @@ -1,6 +1,7 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- VERSION = "1.0.0b1" diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index ccafa1db1622..52ad33fe735b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -1,3 +1,9 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index 6d6aa21d3441..a9ff30c9ca21 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -1,3 +1,9 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py new file mode 100644 index 000000000000..387f42775c07 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -0,0 +1,26 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + AzureAppConfigurationKeyVaultOptions +) +from azure.keyvault.secrets import SecretClient +from azure.identity import DefaultAzureCredential +import os + +endpoint = os.environ.get("AZURE_APPCONFIG_ENDPOINT") +key_vault_uri = os.environ.get("AZURE_KEYVAULT_URI") +credential = DefaultAzureCredential() + +# Connection to Azure App Configuration using AAD with Provided Client +secret_client = SecretClient(vault_url=key_vault_uri, credential=credential) +key_vault_options = AzureAppConfigurationKeyVaultOptions(secret_clients=[ + secret_client]) +config = AzureAppConfigurationProvider.load( + endpoint=endpoint, credential=credential, key_vault_options=key_vault_options) + +print(config["secret"]) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index 0f516de7dff3..6fa55b7f0297 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -1,7 +1,12 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, - AzureAppConfigurationKeyVaultOptions, - SettingSelector + AzureAppConfigurationKeyVaultOptions ) from azure.identity import DefaultAzureCredential import os From b097b0ff9d0c41b058fdf3964eeb7ac2f4f4bfae Mon Sep 17 00:00:00 2001 From: Matthew Metcalf Date: Fri, 9 Sep 2022 13:54:02 -0700 Subject: [PATCH 073/129] Adding Test Case, currently doesn't work --- .../tests/conftest.py | 7 +++++ .../tests/test_provider.py | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py new file mode 100644 index 000000000000..9fd3224d9530 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py @@ -0,0 +1,7 @@ +from devtools_testutils import test_proxy +import pytest + +# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method +@pytest.fixture(scope="session", autouse=True) +def start_proxy(test_proxy): + return \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py new file mode 100644 index 000000000000..aa860cdca7f4 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -0,0 +1,30 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import functools +from azure.appconfiguration import AzureAppConfigurationClient +from azure.identity import DefaultAzureCredential + +from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy + +AppConfigProviderPreparer = functools.partial( + EnvironmentVariableLoader, + "appconfiguration", + appconfiguration_connection_string="Endpoint=https://fake_app_config.azconfig-test.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=", + appconfiguration_endpoint_string="https://fake_app_config.azconfig-test.io" +) + +class TestAppConfigurationProvider(AzureRecordedTestCase): + + def buildClient(self, endpoint): + return AzureAppConfigurationClient(base_url=endpoint, credential=DefaultAzureCredential()) + + # method: provider_creation + @AppConfigProviderPreparer() + @recorded_by_proxy + def test_provider_creation(self, appconfiguration_endpoint_string): + client = self.buildClient(appconfiguration_endpoint_string) + + assert client.get_configuration_setting("message","\0") == "hi" \ No newline at end of file From 1f57085a2782247ddbf3d4d9a2e6b2151b4e6e83 Mon Sep 17 00:00:00 2001 From: Matthew Metcalf Date: Mon, 19 Sep 2022 11:49:09 -0700 Subject: [PATCH 074/129] Fixing Tests --- ...urationProvidertest_provider_creation.json | 267 ++++++++++++++++++ .../tests/test_provider.py | 3 +- 2 files changed, 268 insertions(+), 2 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json new file mode 100644 index 000000000000..0dff5970b68d --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -0,0 +1,267 @@ +{ + "Entries": [ + { + "RequestUri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1753", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Ath0zAFi31FNvKANFWwF1y8; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", + "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrfWar8zX8BblDnJAKRl2Hz_-7zEPqvGMEvPEm4jaimQqfTO66wTmt9q7V3kIc3ezFdZRu3vXykHx7Bl4PfmIfQhjCk4yEqgLFhix1WaTIZlQzYXp7mkOhrDjZJ368eQ0QRAdKtduf_g3kwVBi50QHgTmWYgslpizT-dWmZ65Q39MgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13622.7 - NCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=Ath0zAFi31FNvKANFWwF1y8; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Ath0zAFi31FNvKANFWwF1y8; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13562.12 - SCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "client-request-id": "72b30cb2-f149-4eeb-a2c8-f318375aa74c", + "Connection": "keep-alive", + "Content-Length": "392", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": "fpc=Ath0zAFi31FNvKANFWwF1y8; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", + "x-client-cpu": "x64", + "x-client-current-telemetry": "4|730,0|", + "x-client-last-telemetry": "4|0|||", + "x-client-os": "win32", + "x-client-sku": "MSAL.Python", + "x-client-ver": "1.18.0", + "x-ms-lib-capability": "retry-after, h429" + }, + "RequestBody": "client_id=5b99b3ef-331b-47b1-b984-a967ab4c2623\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=Endpoint=https://fake_app_config.azconfig-test.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fpython-provider.azconfig.io%2F.default", + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-store, no-cache", + "client-request-id": "72b30cb2-f149-4eeb-a2c8-f318375aa74c", + "Content-Length": "111", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "Expires": "-1", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Pragma": "no-cache", + "Set-Cookie": [ + "fpc=Ath0zAFi31FNvKANFWwF1y8W9qlXAQAAAICzrdoOAAAA; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-clitelem": "1,0,0,,", + "x-ms-ests-server": "2.1.13622.7 - NCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_type": "Bearer", + "expires_in": 86399, + "ext_expires_in": 86399, + "refresh_in": 43199, + "access_token": "Sanitized" + } + }, + { + "RequestUri": "https://fake_app_config.azconfig-test.io/kv/message?label=%00\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kv\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kv\u002Bjson; charset=utf-8", + "Date": "Fri, 09 Sep 2022 22:21:53 GMT", + "ETag": "\u0022RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk\u0022", + "Last-Modified": "Thu, 01 Sep 2022 17:53:26 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NjoxNyMxNjY5NTQ1Mg==;sn=16695452", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "cb587955-b687-4421-8aed-c29479a5b118" + }, + "ResponseBody": { + "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", + "key": "message", + "label": null, + "content_type": "", + "value": "hi", + "tags": {}, + "locked": false, + "last_modified": "2022-09-01T17:53:26\u002B00:00" + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index aa860cdca7f4..18a64e59bbe5 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -26,5 +26,4 @@ def buildClient(self, endpoint): @recorded_by_proxy def test_provider_creation(self, appconfiguration_endpoint_string): client = self.buildClient(appconfiguration_endpoint_string) - - assert client.get_configuration_setting("message","\0") == "hi" \ No newline at end of file + assert client.get_configuration_setting(key="message",label="\0").value == "hi" \ No newline at end of file From 2bd138e7109fe5de351a649055f300c6a8f4e980 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 19 Sep 2022 13:35:47 -0700 Subject: [PATCH 075/129] Fixing Trim. Fixing Typo in readme. --- .../azure-appconfiguration-provider/README.md | 2 +- .../_azureappconfigurationprovider.py | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index f9f0229d33c5..1c78189eb099 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -2,7 +2,7 @@ Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. This provider adds additional functionality above the azure-sdk-for-python. -Using the provider enables loading sets of configurations from a Azure App Configuration store in a managed way. +Using the provider enables loading sets of configurations from an Azure App Configuration store in a managed way. ## Getting started diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index f9101f791746..f668bd6bbd20 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -62,15 +62,15 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): for config in configurations: if config.content_type is None: # Deals with possible null value via Rest API - provider._dict[provider.trim(config.key)] = config.value + provider._dict[provider.__trim(config.key)] = config.value elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) elif "application/json" in config.content_type: j_object = json.loads(config.value) - provider._dict[provider.trim(config.key)] = j_object + provider._dict[provider.__trim(config.key)] = j_object else: - provider._dict[provider.trim(config.key)] = config.value + provider._dict[provider.__trim(config.key)] = config.value return provider def __buildprovider(self, connection_string, endpoint, credential, key_vault_options): @@ -94,9 +94,8 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt def __resolve_keyvault_references(self, config, key_vault_options, secret_clients): if key_vault_options is None: - warnings.warn( - "Key Vault Reference found, but no Key Vault Options were provided") - return + raise AttributeError( + "Key Vault options must be set to resolve Key Vault references.") j_object = json.loads(config.value) uri_value = j_object['uri'] @@ -118,10 +117,12 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client secret_client = SecretClient( vault_url=key_vault_uri, credential=key_vault_options.credential) secret_clients[key_vault_uri] = secret_client - secret = secret_client.get_secret( - key_vault_secret_name) - self._dict[self.__trim(config.key)] = secret.value - return + secret = secret_client.get_secret( + key_vault_secret_name) + self._dict[self.__trim(config.key)] = secret.value + return + raise AttributeError( + "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: if secret_client._vault_url == key_vault_uri: @@ -129,11 +130,13 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client key_vault_secret_name) self._dict[self.__trim( config.key)] = secret.value - break - return + return if key_vault_options.secret_resolver is not None: self._dict[self.__trim( config.key)] = key_vault_options.secret_resolver(uri) + return + raise AttributeError( + "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) def __trim(self, key): for trim in self._trim_prefixes: @@ -152,7 +155,7 @@ def __len__(self): def copy(self): """ - Returns a copy of the configuration settings + Returns a copy of the configuration settings type: () -> dict """ return self._dict.copy() From 14487de8a890172d56507374d6642a4c2a7254f0 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 19 Sep 2022 13:46:56 -0700 Subject: [PATCH 076/129] Fixing Length and vault_url issues. --- .../_azureappconfigurationkeyvaultoptions.py | 6 ++++-- .../_azureappconfigurationprovider.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 976eafeaea98..9657b766143f 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -7,9 +7,11 @@ class AzureAppConfigurationKeyVaultOptions: """ Options for connecting to Key Vault. - :param credential: A credential for authenticating with the key vault. This is optional if secret_clients is provided. + :param credential: A credential for authenticating with the key vault. This is optional if secret_clients is + provided. :type credential: ~azure.core.credentials.TokenCredential - :param secret_clients: A list of SecretClient from azure-keyvault-secrets. This is optional if credential is provided. + :param secret_clients: A list of SecretClient from azure-keyvault-secrets. This is optional if credential is + provided. :type secret_clients: list[~azure.keyvault.secrets.SecretClient] :param secret_resolver: A function that takes a URI and returns a value. :type secret_resolver: callable diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index f668bd6bbd20..6222849b26fb 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -125,7 +125,7 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: - if secret_client._vault_url == key_vault_uri: + if secret_client.vault_url == key_vault_uri: secret = secret_client.get_secret( key_vault_secret_name) self._dict[self.__trim( From 262ba3d9ce9c740d09705219c1fa9ee1c5623d8d Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 11:05:36 -0700 Subject: [PATCH 077/129] Updating from code review comments --- .../azure-appconfiguration-provider/README.md | 3 +- .../_azureappconfigurationprovider.py | 96 ++++++++++++++----- .../appconfigurationprovider/_constants.py | 7 ++ .../_settingselector.py | 4 +- ...vault_reference_provided_clients_sample.py | 6 +- .../samples/key_vault_reference_sample.py | 7 +- 6 files changed, 91 insertions(+), 32 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index 1c78189eb099..f382de19a032 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -67,12 +67,13 @@ In this example all configuration with empty label and the dev label are loaded. ### Trimming Keys -You can trim the prefix off of keys by providing a list of trimmed key prefixes to the provider. +You can trim the prefix off of keys by providing a list of trimmed key prefixes to the provider. For example, if you have the key(s) like `/applicaiton/message` in your configuration store, you could trim `/application/` from them. ```python trimmed_key_prefixes={"/application/"} config = AzureAppConfigurationProvider.load( endpoint=endpoint, credential=default_credential, trimmed_key_prefixes=trimmed_key_prefixes) +print(config["message"]) ``` ### Resolving Key Vault References diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 6222849b26fb..fad3f06807c2 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -6,10 +6,14 @@ from urllib.parse import urlparse import json -import warnings from azure.appconfiguration import AzureAppConfigurationClient from azure.keyvault.secrets import SecretClient +from azure.core.exceptions import ( + HttpResponseError, + ResourceNotFoundError +) from ._settingselector import SettingSelector +from ._constants import KEY_VAULT_REFERNCE_CONTENT_TYPE from ._user_agent import USER_AGENT @@ -51,22 +55,24 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) - provider._trim_prefixes = kwargs.pop("trimmed_key_prefixes", []) + + provider._trim_prefixes = sorted(kwargs.pop( + "trimmed_key_prefixes", []), key=len, reverse=True) provider._dict = {} secret_clients = {} for select in selects: - configurations = provider._client.list_configuration_settings( - key_filter=select.key_filter, label_filter=select.label_filter) + try: + configurations = provider._client.list_configuration_settings( + key_filter=select.key_filter, label_filter=select.label_filter) + except HttpResponseError as e: + raise e for config in configurations: - if config.content_type is None: - # Deals with possible null value via Rest API - provider._dict[provider.__trim(config.key)] = config.value - elif config.content_type == "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8": + if config.content_type == KEY_VAULT_REFERNCE_CONTENT_TYPE: provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) - elif "application/json" in config.content_type: + elif (provider.__is_json_content_type(config.content_type)): j_object = json.loads(config.value) provider._dict[provider.__trim(config.key)] = j_object else: @@ -77,15 +83,18 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt headers = {} correlation_context = "RequestType=Startup" - if (key_vault_options is not None and - (key_vault_options.credential is not None or key_vault_options.secret_clients is not None or - key_vault_options.secret_resolver is not None)): + if (key_vault_options and + (key_vault_options.credential or key_vault_options or key_vault_options.secret_resolver)): correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context useragent = USER_AGENT - if connection_string is not None: + if (connection_string and endpoint): + raise AttributeError( + "Both connection_string and endpoint are set. Only one of these should be set.") + + if connection_string: self._client = AzureAppConfigurationClient.from_connection_string( connection_string, user_agent=useragent, headers=headers) return @@ -97,14 +106,17 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client raise AttributeError( "Key Vault options must be set to resolve Key Vault references.") j_object = json.loads(config.value) - uri_value = j_object['uri'] + uri_value = j_object.get("uri", None) + + if uri_value is None: + raise AttributeError( + "Key Vault reference must have a uri value.") uri = urlparse(uri_value) key_vault_uri = "https://" + uri.hostname key_vault_secret_prefix = "/secrets/" - key_vault_secret_name = uri.path[len( - key_vault_secret_prefix):] + key_vault_secret_name = uri.path[len(key_vault_secret_prefix):] if key_vault_options.credential is not None: secret_client = None @@ -117,20 +129,33 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client secret_client = SecretClient( vault_url=key_vault_uri, credential=key_vault_options.credential) secret_clients[key_vault_uri] = secret_client - secret = secret_client.get_secret( - key_vault_secret_name) - self._dict[self.__trim(config.key)] = secret.value - return + try: + secret = secret_client.get_secret( + key_vault_secret_name) + + self._dict[self.__trim(config.key)] = secret.value + return + except ResourceNotFoundError as e: + raise ValueError("Key Vault %s does not contain secret %s" % ( + key_vault_uri, key_vault_secret_name)) + except HttpResponseError as e: + raise e raise AttributeError( "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: if secret_client.vault_url == key_vault_uri: - secret = secret_client.get_secret( - key_vault_secret_name) - self._dict[self.__trim( - config.key)] = secret.value - return + try: + secret = secret_client.get_secret( + key_vault_secret_name) + self._dict[self.__trim( + config.key)] = secret.value + return + except ResourceNotFoundError as e: + raise ValueError("Key Vault %s does not contain secret %s" % ( + key_vault_uri, key_vault_secret_name)) + except HttpResponseError as e: + raise e if key_vault_options.secret_resolver is not None: self._dict[self.__trim( config.key)] = key_vault_options.secret_resolver(uri) @@ -138,6 +163,27 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client raise AttributeError( "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) + def __is_json_content_type(self, content_type): + if not content_type: + return False + + content_type = content_type.strip().lower() + mime_type = content_type.split(';')[0].strip() + + type_parts = mime_type.split('/') + if len(type_parts) != 2: + return False + + (main_type, sub_type) = type_parts + if main_type != "application": + return False + + sub_types = sub_type.split('+') + if "json" in sub_types: + return True + + return False + def __trim(self, key): for trim in self._trim_prefixes: if key.startswith(trim): diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py new file mode 100644 index 000000000000..99978e2c0ced --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py @@ -0,0 +1,7 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + +KEY_VAULT_REFERNCE_CONTENT_TYPE = u"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py index 3dbb41231db5..a82699284710 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py @@ -9,11 +9,11 @@ class SettingSelector: Selects a set of configuration settings from Azure App Configuration. :param key_filter: A filter to select configuration settings based on their keys. :type key_filter: str - :param label_filter: A filter to select configuration settings based on their labels. + :param label_filter: A filter to select configuration settings based on their labels. Default is value is '\0' :type label_filter: str """ - def __init__(self, key_filter, label_filter): + def __init__(self, key_filter, label_filter="\0"): # type: (str, str) -> None self.key_filter = key_filter self.label_filter = label_filter diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 387f42775c07..9151f1a699ef 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -6,7 +6,8 @@ from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, - AzureAppConfigurationKeyVaultOptions + AzureAppConfigurationKeyVaultOptions, + SettingSelector ) from azure.keyvault.secrets import SecretClient from azure.identity import DefaultAzureCredential @@ -18,9 +19,10 @@ # Connection to Azure App Configuration using AAD with Provided Client secret_client = SecretClient(vault_url=key_vault_uri, credential=credential) +selects = {SettingSelector("*", "prod")} key_vault_options = AzureAppConfigurationKeyVaultOptions(secret_clients=[ secret_client]) config = AzureAppConfigurationProvider.load( - endpoint=endpoint, credential=credential, key_vault_options=key_vault_options) + endpoint=endpoint, credential=credential, key_vault_options=key_vault_options, selects=selects) print(config["secret"]) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index 6fa55b7f0297..a66664f34bcf 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -6,7 +6,8 @@ from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, - AzureAppConfigurationKeyVaultOptions + AzureAppConfigurationKeyVaultOptions, + SettingSelector ) from azure.identity import DefaultAzureCredential import os @@ -16,7 +17,9 @@ # Connection to Azure App Configuration using AAD and Resolving Key Vault References key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=credential) +selects = {SettingSelector("*", "prod")} + config = AzureAppConfigurationProvider.load( - endpoint=endpoint, credential=credential, key_vault_options=key_vault_options) + endpoint=endpoint, credential=credential, key_vault_options=key_vault_options, selects=selects) print(config["secret"]) From 8dec35a1df4ea7a1aaf8480e13d4aa92c373b58b Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 11:59:36 -0700 Subject: [PATCH 078/129] Added more error checking. Made Key_VAULT_SECRET_PREFIX a constant. --- .../_azureappconfigurationprovider.py | 28 +++++++++++++++---- .../appconfigurationprovider/_constants.py | 2 ++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index fad3f06807c2..cc40c27409ac 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -13,7 +13,10 @@ ResourceNotFoundError ) from ._settingselector import SettingSelector -from ._constants import KEY_VAULT_REFERNCE_CONTENT_TYPE +from ._constants import ( + KEY_VAULT_REFERNCE_CONTENT_TYPE, + Key_VAULT_SECRET_PREFIX +) from ._user_agent import USER_AGENT @@ -73,8 +76,12 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) elif (provider.__is_json_content_type(config.content_type)): - j_object = json.loads(config.value) - provider._dict[provider.__trim(config.key)] = j_object + try: + j_object = json.loads(config.value) + provider._dict[provider.__trim(config.key)] = j_object + except json.JSONDecodeError as e: + raise ValueError( + "Invalid JSON value for key: " + config.key) else: provider._dict[provider.__trim(config.key)] = config.value return provider @@ -105,7 +112,12 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client if key_vault_options is None: raise AttributeError( "Key Vault options must be set to resolve Key Vault references.") - j_object = json.loads(config.value) + try: + j_object = json.loads(config.value) + except json.JSONDecodeError as e: + raise ValueError( + "Invalid JSON value for key vault reference: " + config.key) + uri_value = j_object.get("uri", None) if uri_value is None: @@ -115,8 +127,12 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client uri = urlparse(uri_value) key_vault_uri = "https://" + uri.hostname - key_vault_secret_prefix = "/secrets/" - key_vault_secret_name = uri.path[len(key_vault_secret_prefix):] + + if Key_VAULT_SECRET_PREFIX not in uri.path: + raise AttributeError( + "Key Vault reference must have a secret identifier.") + + key_vault_secret_name = uri.path[len(Key_VAULT_SECRET_PREFIX):] if key_vault_options.credential is not None: secret_client = None diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py index 99978e2c0ced..de6be50d218a 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py @@ -5,3 +5,5 @@ # ------------------------------------------------------------------------- KEY_VAULT_REFERNCE_CONTENT_TYPE = u"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" + +Key_VAULT_SECRET_PREFIX = u"/secrets/" From cd5af670b57e8ec6c5651138ffab3ac08623600c Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 12:14:55 -0700 Subject: [PATCH 079/129] Updated to use Key Vault Identifier. --- .../_azureappconfigurationprovider.py | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index cc40c27409ac..00b19e26f24b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -8,6 +8,7 @@ import json from azure.appconfiguration import AzureAppConfigurationClient from azure.keyvault.secrets import SecretClient +from azure.keyvault.secrets import KeyVaultSecretIdentifier from azure.core.exceptions import ( HttpResponseError, ResourceNotFoundError @@ -124,60 +125,53 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client raise AttributeError( "Key Vault reference must have a uri value.") - uri = urlparse(uri_value) + key_vault_idenfier = KeyVaultSecretIdentifier(uri_value) - key_vault_uri = "https://" + uri.hostname - - if Key_VAULT_SECRET_PREFIX not in uri.path: - raise AttributeError( - "Key Vault reference must have a secret identifier.") - - key_vault_secret_name = uri.path[len(Key_VAULT_SECRET_PREFIX):] if key_vault_options.credential is not None: secret_client = None # Clients only should be made once, will reuse if client already made for client_uri in secret_clients: - if client_uri == key_vault_uri: + if client_uri == key_vault_idenfier.vault_url: secret_client = secret_clients[client_uri] break if secret_client is None: secret_client = SecretClient( - vault_url=key_vault_uri, credential=key_vault_options.credential) - secret_clients[key_vault_uri] = secret_client + vault_url=key_vault_idenfier.vault_url, credential=key_vault_options.credential) + secret_clients[key_vault_idenfier.vault_url] = secret_client try: secret = secret_client.get_secret( - key_vault_secret_name) + key_vault_idenfier.name, version=key_vault_idenfier.version) self._dict[self.__trim(config.key)] = secret.value return except ResourceNotFoundError as e: raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_uri, key_vault_secret_name)) + key_vault_idenfier.vault_url, key_vault_idenfier.name)) except HttpResponseError as e: raise e raise AttributeError( - "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) + "No Secret Client found for Key Vault reference %s" % (key_vault_idenfier.vault_url)) if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: - if secret_client.vault_url == key_vault_uri: + if secret_client.vault_url == key_vault_idenfier.vault_url: try: secret = secret_client.get_secret( - key_vault_secret_name) + key_vault_idenfier.name, version=key_vault_idenfier.version) self._dict[self.__trim( config.key)] = secret.value return except ResourceNotFoundError as e: raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_uri, key_vault_secret_name)) + key_vault_idenfier.vault_url, key_vault_idenfier.name)) except HttpResponseError as e: raise e if key_vault_options.secret_resolver is not None: self._dict[self.__trim( - config.key)] = key_vault_options.secret_resolver(uri) + config.key)] = key_vault_options.secret_resolver(key_vault_idenfier.vault_url) return raise AttributeError( - "No Secret Client found for Key Vault reference %s%s" % (key_vault_uri, uri.path)) + "No Secret Client found for Key Vault reference %s" % (key_vault_idenfier.vault_url)) def __is_json_content_type(self, content_type): if not content_type: From 5c888b492b9b947d241998b0a43d184c7e574f0a Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 12:33:03 -0700 Subject: [PATCH 080/129] Fixed Spelling --- .../azure-appconfiguration-provider/README.md | 2 +- .../_azureappconfigurationprovider.py | 29 +++++++++---------- .../appconfigurationprovider/_constants.py | 4 +-- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md index f382de19a032..1a762bfbefd8 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/README.md @@ -67,7 +67,7 @@ In this example all configuration with empty label and the dev label are loaded. ### Trimming Keys -You can trim the prefix off of keys by providing a list of trimmed key prefixes to the provider. For example, if you have the key(s) like `/applicaiton/message` in your configuration store, you could trim `/application/` from them. +You can trim the prefix off of keys by providing a list of trimmed key prefixes to the provider. For example, if you have the key(s) like `/application/message` in your configuration store, you could trim `/application/` from them. ```python trimmed_key_prefixes={"/application/"} diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 00b19e26f24b..95594ec118dd 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -15,8 +15,7 @@ ) from ._settingselector import SettingSelector from ._constants import ( - KEY_VAULT_REFERNCE_CONTENT_TYPE, - Key_VAULT_SECRET_PREFIX + KEY_VAULT_REFERENCE_CONTENT_TYPE ) from ._user_agent import USER_AGENT @@ -73,7 +72,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): except HttpResponseError as e: raise e for config in configurations: - if config.content_type == KEY_VAULT_REFERNCE_CONTENT_TYPE: + if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) elif (provider.__is_json_content_type(config.content_type)): @@ -125,53 +124,53 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client raise AttributeError( "Key Vault reference must have a uri value.") - key_vault_idenfier = KeyVaultSecretIdentifier(uri_value) + key_vault_identifier = KeyVaultSecretIdentifier(uri_value) if key_vault_options.credential is not None: secret_client = None # Clients only should be made once, will reuse if client already made for client_uri in secret_clients: - if client_uri == key_vault_idenfier.vault_url: + if client_uri == key_vault_identifier.vault_url: secret_client = secret_clients[client_uri] break if secret_client is None: secret_client = SecretClient( - vault_url=key_vault_idenfier.vault_url, credential=key_vault_options.credential) - secret_clients[key_vault_idenfier.vault_url] = secret_client + vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) + secret_clients[key_vault_identifier.vault_url] = secret_client try: secret = secret_client.get_secret( - key_vault_idenfier.name, version=key_vault_idenfier.version) + key_vault_identifier.name, version=key_vault_identifier.version) self._dict[self.__trim(config.key)] = secret.value return except ResourceNotFoundError as e: raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_idenfier.vault_url, key_vault_idenfier.name)) + key_vault_identifier.vault_url, key_vault_identifier.name)) except HttpResponseError as e: raise e raise AttributeError( - "No Secret Client found for Key Vault reference %s" % (key_vault_idenfier.vault_url)) + "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) if key_vault_options.secret_clients is not None: for secret_client in key_vault_options.secret_clients: - if secret_client.vault_url == key_vault_idenfier.vault_url: + if secret_client.vault_url == key_vault_identifier.vault_url: try: secret = secret_client.get_secret( - key_vault_idenfier.name, version=key_vault_idenfier.version) + key_vault_identifier.name, version=key_vault_identifier.version) self._dict[self.__trim( config.key)] = secret.value return except ResourceNotFoundError as e: raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_idenfier.vault_url, key_vault_idenfier.name)) + key_vault_identifier.vault_url, key_vault_identifier.name)) except HttpResponseError as e: raise e if key_vault_options.secret_resolver is not None: self._dict[self.__trim( - config.key)] = key_vault_options.secret_resolver(key_vault_idenfier.vault_url) + config.key)] = key_vault_options.secret_resolver(key_vault_identifier.vault_url) return raise AttributeError( - "No Secret Client found for Key Vault reference %s" % (key_vault_idenfier.vault_url)) + "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) def __is_json_content_type(self, content_type): if not content_type: diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py index de6be50d218a..913b7e142627 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py @@ -4,6 +4,4 @@ # license information. # ------------------------------------------------------------------------- -KEY_VAULT_REFERNCE_CONTENT_TYPE = u"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" - -Key_VAULT_SECRET_PREFIX = u"/secrets/" +KEY_VAULT_REFERENCE_CONTENT_TYPE = u"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" From 689487f8cd8133d48c5f92636b3a4e2f151ae9fd Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 13:39:16 -0700 Subject: [PATCH 081/129] Updated Test --- ...urationProvidertest_provider_creation.json | 47 ++++++++++++------- .../tests/test_provider.py | 12 ++--- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index 0dff5970b68d..d2d6fe23a4db 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -183,7 +183,7 @@ "Accept-Encoding": "gzip, deflate", "client-request-id": "72b30cb2-f149-4eeb-a2c8-f318375aa74c", "Connection": "keep-alive", - "Content-Length": "392", + "Content-Length": "296", "Content-Type": "application/x-www-form-urlencoded", "Cookie": "fpc=Ath0zAFi31FNvKANFWwF1y8; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", @@ -195,7 +195,7 @@ "x-client-ver": "1.18.0", "x-ms-lib-capability": "retry-after, h429" }, - "RequestBody": "client_id=5b99b3ef-331b-47b1-b984-a967ab4c2623\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=Endpoint=https://fake_app_config.azconfig-test.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fpython-provider.azconfig.io%2F.default", + "RequestBody": "client_id=5b99b3ef-331b-47b1-b984-a967ab4c2623\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=SomeFakeClientSecretToxCM3YWvEqxHXaBa\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Ffake_app_config.azconfig.io%2F.default", "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-store, no-cache", @@ -226,13 +226,14 @@ } }, { - "RequestUri": "https://fake_app_config.azconfig-test.io/kv/message?label=%00\u0026api-version=1.0", + "RequestUri": "https://fake_app_config.azconfig-test.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", "RequestMethod": "GET", "RequestHeaders": { - "Accept": "application/vnd.microsoft.appconfig.kv\u002Bjson, application/json, application/problem\u002Bjson", + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -241,10 +242,8 @@ "Access-Control-Allow-Origin": "*", "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", - "Content-Type": "application/vnd.microsoft.appconfig.kv\u002Bjson; charset=utf-8", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", "Date": "Fri, 09 Sep 2022 22:21:53 GMT", - "ETag": "\u0022RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk\u0022", - "Last-Modified": "Thu, 01 Sep 2022 17:53:26 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", "Sync-Token": "zAJw6V16=NjoxNyMxNjY5NTQ1Mg==;sn=16695452", @@ -252,16 +251,30 @@ "x-ms-correlation-request-id": "cb587955-b687-4421-8aed-c29479a5b118" }, "ResponseBody": { - "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", - "key": "message", - "label": null, - "content_type": "", - "value": "hi", - "tags": {}, - "locked": false, - "last_modified": "2022-09-01T17:53:26\u002B00:00" + "items": [ + { + "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", + "key": "message", + "label": null, + "content_type": "", + "value": "hi", + "tags": {}, + "locked": false, + "last_modified": "2022-09-01T17:53:26\u002B00:00" + }, + { + "etag": "MUD4TSfiMxgwTqVTAlI_rNyXQz9bAPZ3VXDO-Hk_ejI", + "key": "test.message", + "label": null, + "content_type": "", + "value": "Hi with test Prefix", + "tags": {}, + "locked": false, + "last_modified": "2022-09-01T17:53:46\u002B00:00" + } + ] } } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index 18a64e59bbe5..ccb8ae27497d 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -4,9 +4,8 @@ # license information. # -------------------------------------------------------------------------- import functools -from azure.appconfiguration import AzureAppConfigurationClient +from azure.appconfigurationprovider import AzureAppConfigurationProvider from azure.identity import DefaultAzureCredential - from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy AppConfigProviderPreparer = functools.partial( @@ -16,14 +15,15 @@ appconfiguration_endpoint_string="https://fake_app_config.azconfig-test.io" ) + class TestAppConfigurationProvider(AzureRecordedTestCase): - def buildClient(self, endpoint): - return AzureAppConfigurationClient(base_url=endpoint, credential=DefaultAzureCredential()) + def buildProvider(self, endpoint): + return AzureAppConfigurationProvider.load(endpoint=endpoint, credential=DefaultAzureCredential()) # method: provider_creation @AppConfigProviderPreparer() @recorded_by_proxy def test_provider_creation(self, appconfiguration_endpoint_string): - client = self.buildClient(appconfiguration_endpoint_string) - assert client.get_configuration_setting(key="message",label="\0").value == "hi" \ No newline at end of file + client = self.buildProvider(appconfiguration_endpoint_string) + assert client["message"] == "hi" From 9f0d7c72e10555169d57c3691a4a1e087cbae5f0 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Tue, 20 Sep 2022 14:33:52 -0700 Subject: [PATCH 082/129] Reworked key vault reference resolution. Fixed lint issues. --- .../_azureappconfigurationkeyvaultoptions.py | 2 +- .../_azureappconfigurationprovider.py | 71 ++++++++----------- .../samples/connection_string_sample.py | 1 + 3 files changed, 30 insertions(+), 44 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 9657b766143f..cbaef50e53d4 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -17,7 +17,7 @@ class AzureAppConfigurationKeyVaultOptions: :type secret_resolver: callable """ - def __init__(self, credential=None, secret_clients=None, secret_resolver=None): + def __init__(self, credential=None, secret_clients={}, secret_resolver=None): # type: (TokenCredential, List[SecretClient], Callable) -> None self.credential = credential self.secret_clients = secret_clients diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 95594ec118dd..c1f0c4b30c47 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -4,7 +4,6 @@ # license information. # ------------------------------------------------------------------------- -from urllib.parse import urlparse import json from azure.appconfiguration import AzureAppConfigurationClient from azure.keyvault.secrets import SecretClient @@ -63,7 +62,8 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): "trimmed_key_prefixes", []), key=len, reverse=True) provider._dict = {} - secret_clients = {} + + secret_clients = key_vault_options.secret_clients if key_vault_options else {} for select in selects: try: @@ -75,7 +75,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: provider.__resolve_keyvault_references( config, key_vault_options, secret_clients) - elif (provider.__is_json_content_type(config.content_type)): + elif provider.__is_json_content_type(config.content_type): try: j_object = json.loads(config.value) provider._dict[provider.__trim(config.key)] = j_object @@ -126,45 +126,29 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client key_vault_identifier = KeyVaultSecretIdentifier(uri_value) - if key_vault_options.credential is not None: - secret_client = None - - # Clients only should be made once, will reuse if client already made - for client_uri in secret_clients: - if client_uri == key_vault_identifier.vault_url: - secret_client = secret_clients[client_uri] - break - if secret_client is None: - secret_client = SecretClient( - vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) - secret_clients[key_vault_identifier.vault_url] = secret_client - try: - secret = secret_client.get_secret( - key_vault_identifier.name, version=key_vault_identifier.version) - - self._dict[self.__trim(config.key)] = secret.value - return - except ResourceNotFoundError as e: - raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_identifier.vault_url, key_vault_identifier.name)) - except HttpResponseError as e: - raise e - raise AttributeError( - "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) - if key_vault_options.secret_clients is not None: - for secret_client in key_vault_options.secret_clients: - if secret_client.vault_url == key_vault_identifier.vault_url: - try: - secret = secret_client.get_secret( - key_vault_identifier.name, version=key_vault_identifier.version) - self._dict[self.__trim( - config.key)] = secret.value - return - except ResourceNotFoundError as e: - raise ValueError("Key Vault %s does not contain secret %s" % ( - key_vault_identifier.vault_url, key_vault_identifier.name)) - except HttpResponseError as e: - raise e + referenced_client = None + + for secret_client in secret_clients: + if secret_client.vault_url == key_vault_identifier.vault_url: + referenced_client = secret_client + break + if referenced_client is None and key_vault_options.credential is not None: + referenced_client = SecretClient( + vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) + secret_clients[key_vault_identifier.vault_url] = referenced_client + + if referenced_client: + try: + secret = referenced_client.get_secret( + key_vault_identifier.name, version=key_vault_identifier.version) + self._dict[self.__trim(config.key)] = secret.value + return + except ResourceNotFoundError as e: + raise ValueError("Key Vault %s does not contain secret %s" % ( + key_vault_identifier.vault_url, key_vault_identifier.name)) + except HttpResponseError as e: + raise e + if key_vault_options.secret_resolver is not None: self._dict[self.__trim( config.key)] = key_vault_options.secret_resolver(key_vault_identifier.vault_url) @@ -172,7 +156,8 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client raise AttributeError( "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) - def __is_json_content_type(self, content_type): + @staticmethod + def __is_json_content_type(content_type): if not content_type: return False diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index a9ff30c9ca21..974313a9977e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -17,6 +17,7 @@ connection_string=connection_string) print(config["message"]) +print(config["myjson"]["key"]) # Connecting to Azure App Configuration using connection string and trimmed key prefixes trimmed = {"test."} From 4e977ae8907f3f798be4d1caf66646d0cd968400 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 10:47:06 -0700 Subject: [PATCH 083/129] Fixing Lint Issue. Updating Test Running --- .../_azureappconfigurationkeyvaultoptions.py | 2 +- .../samples/connection_string_sample.py | 2 +- .../tests/conftest.py | 26 ++++++- ...urationProvidertest_provider_creation.json | 68 +++++++++++-------- 4 files changed, 65 insertions(+), 33 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index cbaef50e53d4..534c621dd7c9 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -17,7 +17,7 @@ class AzureAppConfigurationKeyVaultOptions: :type secret_resolver: callable """ - def __init__(self, credential=None, secret_clients={}, secret_resolver=None): + def __init__(self, credential=None, secret_clients=dict(), secret_resolver=None): # type: (TokenCredential, List[SecretClient], Callable) -> None self.credential = credential self.secret_clients = secret_clients diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index 974313a9977e..7550e77039db 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -17,7 +17,7 @@ connection_string=connection_string) print(config["message"]) -print(config["myjson"]["key"]) +print(config["my_json"]["key"]) # Connecting to Azure App Configuration using connection string and trimmed key prefixes trimmed = {"test."} diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py index 9fd3224d9530..5fdf89985f4a 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py @@ -1,7 +1,29 @@ -from devtools_testutils import test_proxy +import os +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer +) import pytest # autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method + + @pytest.fixture(scope="session", autouse=True) def start_proxy(test_proxy): - return \ No newline at end of file + return + +# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method + + +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + add_general_regex_sanitizer(value="fake-endpoint.azconfig.io", + regex=os.environ.get('APPCONFIGURATION_ENDPOINT_STRING')) + add_general_regex_sanitizer(value="fake-connection-string", + regex=os.environ.get('APPCONFIGURATION_CONNECTION_STRING')) + add_general_regex_sanitizer( + value="fake-client-id", regex=os.environ.get('APPCONFIGURATION_CLIENT_ID')) + add_general_regex_sanitizer( + value="fake-client-secret", regex=os.environ.get('APPCONFIGURATION_CLIENT_SECRET')) + add_general_regex_sanitizer( + value="fake-tenant-id", regex=os.environ.get('APPCONFIGURATION_TENANT_ID')) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index d2d6fe23a4db..78579324c398 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0/.well-known/openid-configuration", + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", "RequestMethod": "GET", "RequestHeaders": { "Accept": "*/*", @@ -15,29 +15,29 @@ "Access-Control-Allow-Methods": "GET, OPTIONS", "Access-Control-Allow-Origin": "*", "Cache-Control": "max-age=86400, private", - "Content-Length": "1753", + "Content-Length": "1599", "Content-Type": "application/json; charset=utf-8", - "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "Date": "Wed, 21 Sep 2022 17:42:06 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=Ath0zAFi31FNvKANFWwF1y8; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", - "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrfWar8zX8BblDnJAKRl2Hz_-7zEPqvGMEvPEm4jaimQqfTO66wTmt9q7V3kIc3ezFdZRu3vXykHx7Bl4PfmIfQhjCk4yEqgLFhix1WaTIZlQzYXp7mkOhrDjZJ368eQ0QRAdKtduf_g3kwVBi50QHgTmWYgslpizT-dWmZ65Q39MgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", + "fpc=AtHW-D0oI7BCs5w8PtmWt0M; expires=Fri, 21-Oct-2022 17:42:07 GMT; path=/; secure; HttpOnly; SameSite=None", + "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7Wevrw4PHrGRl95uoBDVdJ6fbkrvGZccTxlEqPtQBJpCoPGW95rWFbbHMqCVjuUHS6707n_jIrHLhtYgeurc1PaEFvYnsAWfWKM-kDnd8q1fmelLXOyur7ddTBsZT-qwYKw4xI-pJWMlOLKh4_4Z7BwuCwIFKl00wt1_JZ1YwZne7wYMMuDk56dBUmH_cx5EP0kCOPqaU37Xwbg7OvtuLpQauiLD4tMlA05hASJpjaO3Bk24gAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13622.7 - NCUS ProdSlices", + "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { - "token_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token", + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": [ "client_secret_post", "private_key_jwt", "client_secret_basic" ], - "jwks_uri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/discovery/v2.0/keys", + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", "response_modes_supported": [ "query", "fragment", @@ -61,14 +61,14 @@ "email", "offline_access" ], - "issuer": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0", + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", - "authorization_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/authorize", - "device_authorization_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/devicecode", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, - "end_session_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/logout", + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", "claims_supported": [ "sub", "iss", @@ -90,7 +90,7 @@ "c_hash", "email" ], - "kerberos_endpoint": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/kerberos", + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", "tenant_region_scope": "WW", "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", @@ -105,7 +105,7 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "Cookie": "fpc=Ath0zAFi31FNvKANFWwF1y8; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "Cookie": "fpc=AtHW-D0oI7BCs5w8PtmWt0M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" }, "RequestBody": null, @@ -116,16 +116,16 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "945", "Content-Type": "application/json; charset=utf-8", - "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "Date": "Wed, 21 Sep 2022 17:42:07 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=Ath0zAFi31FNvKANFWwF1y8; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", + "fpc=AtHW-D0oI7BCs5w8PtmWt0M; expires=Fri, 21-Oct-2022 17:42:07 GMT; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13562.12 - SCUS ProdSlices", + "x-ms-ests-server": "2.1.13622.7 - WUS2 ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -176,16 +176,16 @@ } }, { - "RequestUri": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token", + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", - "client-request-id": "72b30cb2-f149-4eeb-a2c8-f318375aa74c", + "client-request-id": "2a07081c-66f6-4d46-8077-b893dc513f19", "Connection": "keep-alive", - "Content-Length": "296", + "Content-Length": "255", "Content-Type": "application/x-www-form-urlencoded", - "Cookie": "fpc=Ath0zAFi31FNvKANFWwF1y8; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "Cookie": "fpc=AtHW-D0oI7BCs5w8PtmWt0M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", "x-client-cpu": "x64", "x-client-current-telemetry": "4|730,0|", @@ -195,26 +195,26 @@ "x-client-ver": "1.18.0", "x-ms-lib-capability": "retry-after, h429" }, - "RequestBody": "client_id=5b99b3ef-331b-47b1-b984-a967ab4c2623\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=SomeFakeClientSecretToxCM3YWvEqxHXaBa\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Ffake_app_config.azconfig.io%2F.default", + "RequestBody": "client_id=fake-client-id\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=fake-client-secret\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Ffake-endpoint.azconfig.io%2F.default", "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-store, no-cache", - "client-request-id": "72b30cb2-f149-4eeb-a2c8-f318375aa74c", + "client-request-id": "2a07081c-66f6-4d46-8077-b893dc513f19", "Content-Length": "111", "Content-Type": "application/json; charset=utf-8", - "Date": "Fri, 09 Sep 2022 22:21:52 GMT", + "Date": "Wed, 21 Sep 2022 17:42:07 GMT", "Expires": "-1", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Pragma": "no-cache", "Set-Cookie": [ - "fpc=Ath0zAFi31FNvKANFWwF1y8W9qlXAQAAAICzrdoOAAAA; expires=Sun, 09-Oct-2022 22:21:52 GMT; path=/; secure; HttpOnly; SameSite=None", + "fpc=AtHW-D0oI7BCs5w8PtmWt0MW9qlXAQAAAO9DvdoOAAAA; expires=Fri, 21-Oct-2022 17:42:08 GMT; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.13622.7 - NCUS ProdSlices", + "x-ms-ests-server": "2.1.13777.4 - EUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -243,12 +243,12 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Fri, 09 Sep 2022 22:21:53 GMT", + "Date": "Wed, 21 Sep 2022 17:42:08 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjY5NTQ1Mg==;sn=16695452", + "Sync-Token": "zAJw6V16=NjoxNyMxNjg2MzM1Nw==;sn=16863357", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "cb587955-b687-4421-8aed-c29479a5b118" + "x-ms-correlation-request-id": "9478e864-7c4e-4c4d-8659-cfa8da3e7b64" }, "ResponseBody": { "items": [ @@ -262,6 +262,16 @@ "locked": false, "last_modified": "2022-09-01T17:53:26\u002B00:00" }, + { + "etag": "jf2AWA7sfhfRYx0rPoBxqdCf1Lfzpos0v4emLvuYP-4", + "key": "my_json", + "label": null, + "content_type": "application/json", + "value": "{\u0022key\u0022:\u0022value\u0022}", + "tags": {}, + "locked": false, + "last_modified": "2022-09-20T23:10:44\u002B00:00" + }, { "etag": "MUD4TSfiMxgwTqVTAlI_rNyXQz9bAPZ3VXDO-Hk_ejI", "key": "test.message", From 9d0b579275c0e932320a9895fc86ce0b79afbe35 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 11:34:04 -0700 Subject: [PATCH 084/129] Fixing Tests --- .../tests/conftest.py | 2 +- ...urationProvidertest_provider_creation.json | 237 +------------- ...ionProvidertest_provider_creation_aad.json | 291 ++++++++++++++++++ .../tests/test_provider.py | 76 ++++- 4 files changed, 367 insertions(+), 239 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py index 5fdf89985f4a..aa499fb92527 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py @@ -17,7 +17,7 @@ def start_proxy(test_proxy): @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): - add_general_regex_sanitizer(value="fake-endpoint.azconfig.io", + add_general_regex_sanitizer(value="https://fake-endpoint.azconfig.io", regex=os.environ.get('APPCONFIGURATION_ENDPOINT_STRING')) add_general_regex_sanitizer(value="fake-connection-string", regex=os.environ.get('APPCONFIGURATION_CONNECTION_STRING')) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index 78579324c398..63e748faf842 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -1,239 +1,16 @@ { "Entries": [ { - "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Access-Control-Allow-Methods": "GET, OPTIONS", - "Access-Control-Allow-Origin": "*", - "Cache-Control": "max-age=86400, private", - "Content-Length": "1599", - "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 17:42:06 GMT", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Set-Cookie": [ - "fpc=AtHW-D0oI7BCs5w8PtmWt0M; expires=Fri, 21-Oct-2022 17:42:07 GMT; path=/; secure; HttpOnly; SameSite=None", - "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7Wevrw4PHrGRl95uoBDVdJ6fbkrvGZccTxlEqPtQBJpCoPGW95rWFbbHMqCVjuUHS6707n_jIrHLhtYgeurc1PaEFvYnsAWfWKM-kDnd8q1fmelLXOyur7ddTBsZT-qwYKw4xI-pJWMlOLKh4_4Z7BwuCwIFKl00wt1_JZ1YwZne7wYMMuDk56dBUmH_cx5EP0kCOPqaU37Xwbg7OvtuLpQauiLD4tMlA05hASJpjaO3Bk24gAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", - "token_endpoint_auth_methods_supported": [ - "client_secret_post", - "private_key_jwt", - "client_secret_basic" - ], - "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", - "response_modes_supported": [ - "query", - "fragment", - "form_post" - ], - "subject_types_supported": [ - "pairwise" - ], - "id_token_signing_alg_values_supported": [ - "RS256" - ], - "response_types_supported": [ - "code", - "id_token", - "code id_token", - "id_token token" - ], - "scopes_supported": [ - "openid", - "profile", - "email", - "offline_access" - ], - "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", - "request_uri_parameter_supported": false, - "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", - "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", - "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", - "http_logout_supported": true, - "frontchannel_logout_supported": true, - "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", - "claims_supported": [ - "sub", - "iss", - "cloud_instance_name", - "cloud_instance_host_name", - "cloud_graph_host_name", - "msgraph_host", - "aud", - "exp", - "iat", - "auth_time", - "acr", - "nonce", - "preferred_username", - "name", - "tid", - "ver", - "at_hash", - "c_hash", - "email" - ], - "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", - "tenant_region_scope": "WW", - "cloud_instance_name": "microsoftonline.com", - "cloud_graph_host_name": "graph.windows.net", - "msgraph_host": "graph.microsoft.com", - "rbac_url": "https://pas.windows.net" - } - }, - { - "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "Connection": "keep-alive", - "Cookie": "fpc=AtHW-D0oI7BCs5w8PtmWt0M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Access-Control-Allow-Methods": "GET, OPTIONS", - "Access-Control-Allow-Origin": "*", - "Cache-Control": "max-age=86400, private", - "Content-Length": "945", - "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 17:42:07 GMT", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Set-Cookie": [ - "fpc=AtHW-D0oI7BCs5w8PtmWt0M; expires=Fri, 21-Oct-2022 17:42:07 GMT; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13622.7 - WUS2 ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", - "api-version": "1.1", - "metadata": [ - { - "preferred_network": "login.microsoftonline.com", - "preferred_cache": "login.windows.net", - "aliases": [ - "login.microsoftonline.com", - "login.windows.net", - "login.microsoft.com", - "sts.windows.net" - ] - }, - { - "preferred_network": "login.partner.microsoftonline.cn", - "preferred_cache": "login.partner.microsoftonline.cn", - "aliases": [ - "login.partner.microsoftonline.cn", - "login.chinacloudapi.cn" - ] - }, - { - "preferred_network": "login.microsoftonline.de", - "preferred_cache": "login.microsoftonline.de", - "aliases": [ - "login.microsoftonline.de" - ] - }, - { - "preferred_network": "login.microsoftonline.us", - "preferred_cache": "login.microsoftonline.us", - "aliases": [ - "login.microsoftonline.us", - "login.usgovcloudapi.net" - ] - }, - { - "preferred_network": "login-us.microsoftonline.com", - "preferred_cache": "login-us.microsoftonline.com", - "aliases": [ - "login-us.microsoftonline.com" - ] - } - ] - } - }, - { - "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "client-request-id": "2a07081c-66f6-4d46-8077-b893dc513f19", - "Connection": "keep-alive", - "Content-Length": "255", - "Content-Type": "application/x-www-form-urlencoded", - "Cookie": "fpc=AtHW-D0oI7BCs5w8PtmWt0M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", - "x-client-cpu": "x64", - "x-client-current-telemetry": "4|730,0|", - "x-client-last-telemetry": "4|0|||", - "x-client-os": "win32", - "x-client-sku": "MSAL.Python", - "x-client-ver": "1.18.0", - "x-ms-lib-capability": "retry-after, h429" - }, - "RequestBody": "client_id=fake-client-id\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=fake-client-secret\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Ffake-endpoint.azconfig.io%2F.default", - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-store, no-cache", - "client-request-id": "2a07081c-66f6-4d46-8077-b893dc513f19", - "Content-Length": "111", - "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 17:42:07 GMT", - "Expires": "-1", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Pragma": "no-cache", - "Set-Cookie": [ - "fpc=AtHW-D0oI7BCs5w8PtmWt0MW9qlXAQAAAO9DvdoOAAAA; expires=Fri, 21-Oct-2022 17:42:08 GMT; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.13777.4 - EUS ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "token_type": "Bearer", - "expires_in": 86399, - "ext_expires_in": 86399, - "refresh_in": 43199, - "access_token": "Sanitized" - } - }, - { - "RequestUri": "https://fake_app_config.azconfig-test.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestUri": "fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", "RequestMethod": "GET", "RequestHeaders": { "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.6 (Windows-10-10.0.22000-SP0)", + "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", + "x-ms-date": "Sep, 21 2022 18:22:11.213870 GMT" }, "RequestBody": null, "StatusCode": 200, @@ -243,12 +20,12 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Wed, 21 Sep 2022 17:42:08 GMT", + "Date": "Wed, 21 Sep 2022 18:22:11 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjg2MzM1Nw==;sn=16863357", + "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDMyMQ==;sn=16864321", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "9478e864-7c4e-4c4d-8659-cfa8da3e7b64" + "x-ms-correlation-request-id": "d109bdd2-2e35-4748-8dff-b548c55a99e6" }, "ResponseBody": { "items": [ diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json new file mode 100644 index 000000000000..b9005e1077cb --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json @@ -0,0 +1,291 @@ +{ + "Entries": [ + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1599", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=AhyWxyAqvHlIgeVTxU0ZntE; expires=Fri, 21-Oct-2022 18:22:13 GMT; path=/; secure; HttpOnly; SameSite=None", + "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevruzHA3uNG6YmCUn8KDqEbZhkAJIcrqMGz9qDpTSknEwDCtG0wPNEgOrlOiBwApukfwQx_3YJczFMXMGxa1z7c_SimB-PV2g1wuQwEENhCz18MKm3OZ2BanW9AYbk3ocCLWeEFArzoVXfWbIDIVa1fWrWiT477_18wfP3ZBHoNIgbC97_umYvTkWwpMs7pklZ6SfRKTIP6vkMVEhkoNKCgML5uGG5jyrJeGP-h7UjX4jUgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=AhyWxyAqvHlIgeVTxU0ZntE; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=AhyWxyAqvHlIgeVTxU0ZntE; expires=Fri, 21-Oct-2022 18:22:13 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.7 - SCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "client-request-id": "13b2341d-c273-44c9-9927-80fb0dcbdaa6", + "Connection": "keep-alive", + "Content-Length": "255", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": "fpc=AhyWxyAqvHlIgeVTxU0ZntE; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)", + "x-client-cpu": "x64", + "x-client-current-telemetry": "4|730,0|", + "x-client-last-telemetry": "4|0|||", + "x-client-os": "win32", + "x-client-sku": "MSAL.Python", + "x-client-ver": "1.18.0", + "x-ms-lib-capability": "retry-after, h429" + }, + "RequestBody": "client_id=fake-client-id\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=fake-client-secret\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fpython-provider.azconfig.io%2F.default", + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-store, no-cache", + "client-request-id": "13b2341d-c273-44c9-9927-80fb0dcbdaa6", + "Content-Length": "111", + "Content-Security-Policy-Report-Only": "script-src \u0027self\u0027 \u0027nonce-hMw6CXt6AY9vBIalIpW2cg\u0027 \u0027unsafe-eval\u0027 \u0027unsafe-inline\u0027; object-src \u0027none\u0027; base-uri \u0027none\u0027; report-uri https://csp.microsoft.com/report/ESTS-UX-All", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "Expires": "-1", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Pragma": "no-cache", + "Set-Cookie": [ + "fpc=AhyWxyAqvHlIgeVTxU0ZntEW9qlXAQAAAFVNvdoOAAAA; expires=Fri, 21-Oct-2022 18:22:14 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-clitelem": "1,0,0,,", + "x-ms-ests-server": "2.1.13777.4 - WUS2 ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_type": "Bearer", + "expires_in": 86399, + "ext_expires_in": 86399, + "refresh_in": 43199, + "access_token": "Sanitized" + } + }, + { + "RequestUri": "fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Wed, 21 Sep 2022 18:22:14 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDMyMQ==;sn=16864321", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "2d929cdd-7f97-4e20-a757-94498bebb049" + }, + "ResponseBody": { + "items": [ + { + "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", + "key": "message", + "label": null, + "content_type": "", + "value": "hi", + "tags": {}, + "locked": false, + "last_modified": "2022-09-01T17:53:26\u002B00:00" + }, + { + "etag": "jf2AWA7sfhfRYx0rPoBxqdCf1Lfzpos0v4emLvuYP-4", + "key": "my_json", + "label": null, + "content_type": "application/json", + "value": "{\u0022key\u0022:\u0022value\u0022}", + "tags": {}, + "locked": false, + "last_modified": "2022-09-20T23:10:44\u002B00:00" + }, + { + "etag": "MUD4TSfiMxgwTqVTAlI_rNyXQz9bAPZ3VXDO-Hk_ejI", + "key": "test.message", + "label": null, + "content_type": "", + "value": "Hi with test Prefix", + "tags": {}, + "locked": false, + "last_modified": "2022-09-01T17:53:46\u002B00:00" + } + ] + } + } + ], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index ccb8ae27497d..fb656449fc8e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -5,25 +5,85 @@ # -------------------------------------------------------------------------- import functools from azure.appconfigurationprovider import AzureAppConfigurationProvider -from azure.identity import DefaultAzureCredential from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy +from azure.appconfiguration import AzureAppConfigurationClient +import inspect AppConfigProviderPreparer = functools.partial( EnvironmentVariableLoader, "appconfiguration", - appconfiguration_connection_string="Endpoint=https://fake_app_config.azconfig-test.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=", - appconfiguration_endpoint_string="https://fake_app_config.azconfig-test.io" + appconfiguration_connection_string="Endpoint=https://fake-endpoint.azconfig.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=", + appconfiguration_endpoint_string="https://fake-endpoint.azconfig.io", + appconfiguration_client_id="fake-client-id", + appconfiguration_client_secret="fake-client-secret", + appconfiguration_tenant_id="fake-tenant-id", ) +def app_config_decorator(func, **kwargs): + @AppConfigProviderPreparer() + def wrapper(*args, **kwargs): + appconfiguration_connection_string = kwargs.pop( + "appconfiguration_connection_string") + kwargs['appconfiguration_connection_string'] = appconfiguration_connection_string + + trimmed_kwargs = {k: v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + func(*args, **trimmed_kwargs) + return wrapper + + +def app_config_decorator_aad(func, **kwargs): + @AppConfigProviderPreparer() + def wrapper(*args, **kwargs): + appconfiguration_endpoint_string = kwargs.pop( + "appconfiguration_endpoint_string") + kwargs['appconfiguration_endpoint_string'] = appconfiguration_endpoint_string + + trimmed_kwargs = {k: v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + func(*args, **trimmed_kwargs) + return wrapper + + +def trim_kwargs_from_test_function(fn, kwargs): + # the next function is the actual test function. the kwargs need to be trimmed so + # that parameters which are not required will not be passed to it. + if not getattr(fn, '__is_preparer', False): + try: + args, _, kw, _, _, _, _ = inspect.getfullargspec(fn) + except AttributeError: + args, _, kw, _ = inspect.getargspec( + fn) # pylint: disable=deprecated-method + if kw is None: + args = set(args) + for key in [k for k in kwargs if k not in args]: + del kwargs[key] + + class TestAppConfigurationProvider(AzureRecordedTestCase): - def buildProvider(self, endpoint): - return AzureAppConfigurationProvider.load(endpoint=endpoint, credential=DefaultAzureCredential()) + def build_provider_aad(self, endpoint): + cred = self.get_credential(AzureAppConfigurationClient) + return AzureAppConfigurationProvider.load(endpoint=endpoint, credential=cred) + + def build_provider(self, connection_string): + return AzureAppConfigurationProvider.load(connection_string=connection_string) # method: provider_creation - @AppConfigProviderPreparer() @recorded_by_proxy - def test_provider_creation(self, appconfiguration_endpoint_string): - client = self.buildProvider(appconfiguration_endpoint_string) + @app_config_decorator + def test_provider_creation(self, appconfiguration_connection_string): + + client = self.build_provider(appconfiguration_connection_string) + assert client["message"] == "hi" + + # method: provider_creation_aad + @recorded_by_proxy + @app_config_decorator_aad + def test_provider_creation_aad(self, appconfiguration_endpoint_string): + + client = self.build_provider_aad(appconfiguration_endpoint_string) assert client["message"] == "hi" From 47127bffa1895b90ccb41cf27775b99cbf695e2f Mon Sep 17 00:00:00 2001 From: Matthew Metcalf Date: Wed, 21 Sep 2022 11:39:26 -0700 Subject: [PATCH 085/129] Fixed Tests? --- ...urationProvidertest_provider_creation.json | 14 +++--- ...ionProvidertest_provider_creation_aad.json | 45 +++++++++---------- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index 63e748faf842..00cd18ebcfe0 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -1,16 +1,16 @@ { "Entries": [ { - "RequestUri": "fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", "RequestMethod": "GET", "RequestHeaders": { "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.6 (Windows-10-10.0.22000-SP0)", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Sep, 21 2022 18:22:11.213870 GMT" + "x-ms-date": "Sep, 21 2022 18:39:00.013800 GMT" }, "RequestBody": null, "StatusCode": 200, @@ -20,12 +20,12 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:22:11 GMT", + "Date": "Wed, 21 Sep 2022 18:39:00 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDMyMQ==;sn=16864321", + "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDQyNw==;sn=16864427", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "d109bdd2-2e35-4748-8dff-b548c55a99e6" + "x-ms-correlation-request-id": "e49e00e4-8005-4e38-a362-ec7253675842" }, "ResponseBody": { "items": [ @@ -64,4 +64,4 @@ } ], "Variables": {} -} \ No newline at end of file +} diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json index b9005e1077cb..274ab1b8ac7e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json @@ -7,7 +7,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -17,11 +17,11 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "1599", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "Date": "Wed, 21 Sep 2022 18:39:00 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=AhyWxyAqvHlIgeVTxU0ZntE; expires=Fri, 21-Oct-2022 18:22:13 GMT; path=/; secure; HttpOnly; SameSite=None", - "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevruzHA3uNG6YmCUn8KDqEbZhkAJIcrqMGz9qDpTSknEwDCtG0wPNEgOrlOiBwApukfwQx_3YJczFMXMGxa1z7c_SimB-PV2g1wuQwEENhCz18MKm3OZ2BanW9AYbk3ocCLWeEFArzoVXfWbIDIVa1fWrWiT477_18wfP3ZBHoNIgbC97_umYvTkWwpMs7pklZ6SfRKTIP6vkMVEhkoNKCgML5uGG5jyrJeGP-h7UjX4jUgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", + "fpc=AuaI0l5Thi1Ph8qKgY3w55M; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", + "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrXUK8WCbx7_3eLM8Xf9iPBqq-GaEFnitho0XCJynEDnSTZtNHQ0IlZZ2H5Uh-oD7-OLVsDF-fTKQ1-MzOkg6rll2XLpIL0pCqCNbmGhPq_7QQJLyU3I4yOASYKSJvcQR2RFUji-c971-vuLC_yEQHTyrso57pHLqPC0pA2gWYR0DqeuTMgGf7cV3PXCbwlRUUPFquNO44Yfeo3D9Hyog-mTMb_xzZSzrEINr5PfIbMz0gAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], @@ -105,8 +105,8 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "Cookie": "fpc=AhyWxyAqvHlIgeVTxU0ZntE; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + "Cookie": "fpc=AuaI0l5Thi1Ph8qKgY3w55M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -116,16 +116,16 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "945", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "Date": "Wed, 21 Sep 2022 18:39:01 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=AhyWxyAqvHlIgeVTxU0ZntE; expires=Fri, 21-Oct-2022 18:22:13 GMT; path=/; secure; HttpOnly; SameSite=None", + "fpc=AuaI0l5Thi1Ph8qKgY3w55M; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13672.7 - SCUS ProdSlices", + "x-ms-ests-server": "2.1.13622.7 - SCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -181,12 +181,12 @@ "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", - "client-request-id": "13b2341d-c273-44c9-9927-80fb0dcbdaa6", + "client-request-id": "3a839a03-715b-4fc0-b093-fa24c0cfeeef", "Connection": "keep-alive", "Content-Length": "255", "Content-Type": "application/x-www-form-urlencoded", - "Cookie": "fpc=AhyWxyAqvHlIgeVTxU0ZntE; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.9.6 (Windows-10-10.0.22000-SP0)", + "Cookie": "fpc=AuaI0l5Thi1Ph8qKgY3w55M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", "x-client-cpu": "x64", "x-client-current-telemetry": "4|730,0|", "x-client-last-telemetry": "4|0|||", @@ -199,23 +199,22 @@ "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-store, no-cache", - "client-request-id": "13b2341d-c273-44c9-9927-80fb0dcbdaa6", + "client-request-id": "3a839a03-715b-4fc0-b093-fa24c0cfeeef", "Content-Length": "111", - "Content-Security-Policy-Report-Only": "script-src \u0027self\u0027 \u0027nonce-hMw6CXt6AY9vBIalIpW2cg\u0027 \u0027unsafe-eval\u0027 \u0027unsafe-inline\u0027; object-src \u0027none\u0027; base-uri \u0027none\u0027; report-uri https://csp.microsoft.com/report/ESTS-UX-All", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:22:13 GMT", + "Date": "Wed, 21 Sep 2022 18:39:01 GMT", "Expires": "-1", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Pragma": "no-cache", "Set-Cookie": [ - "fpc=AhyWxyAqvHlIgeVTxU0ZntEW9qlXAQAAAFVNvdoOAAAA; expires=Fri, 21-Oct-2022 18:22:14 GMT; path=/; secure; HttpOnly; SameSite=None", + "fpc=AuaI0l5Thi1Ph8qKgY3w55MW9qlXAQAAAEVRvdoOAAAA; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.13777.4 - WUS2 ProdSlices", + "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -227,14 +226,14 @@ } }, { - "RequestUri": "fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", "RequestMethod": "GET", "RequestHeaders": { "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.6 (Windows-10-10.0.22000-SP0)" + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -244,12 +243,12 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:22:14 GMT", + "Date": "Wed, 21 Sep 2022 18:39:02 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDMyMQ==;sn=16864321", + "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDQyNw==;sn=16864427", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "2d929cdd-7f97-4e20-a757-94498bebb049" + "x-ms-correlation-request-id": "d1f48db0-be79-4eca-a13c-7c1caf29edb5" }, "ResponseBody": { "items": [ @@ -288,4 +287,4 @@ } ], "Variables": {} -} \ No newline at end of file +} From 5aa01d1ebe6fd8a19ad22ca396ba230c86151a77 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 13:47:25 -0700 Subject: [PATCH 086/129] Setting secret clients to {} if none. Adding override to shared_requirements --- .../_azureappconfigurationkeyvaultoptions.py | 5 ++++- shared_requirements.txt | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 534c621dd7c9..8d2c646ce084 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -17,8 +17,11 @@ class AzureAppConfigurationKeyVaultOptions: :type secret_resolver: callable """ - def __init__(self, credential=None, secret_clients=dict(), secret_resolver=None): + def __init__(self, credential=None, secret_clients=None, secret_resolver=None): # type: (TokenCredential, List[SecretClient], Callable) -> None self.credential = credential self.secret_clients = secret_clients self.secret_resolver = secret_resolver + + if self.secret_clients is None: + self.secret_clients = {} diff --git a/shared_requirements.txt b/shared_requirements.txt index cd9469a29bf9..0c50f22a2c84 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -185,6 +185,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-eventhub-checkpointstoretable azure-core<2.0.0,>=1.14.0 #override azure-eventhub uamqp>=1.6.0,<2.0.0 #override azure-appconfiguration azure-core<2.0.0,>=1.24.0 +#override azure-appconfiguration azure-keyvault-secrets<5.0.0,>=4.0.0 #override azure-servicebus uamqp>=1.5.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 #override azure-servicebus azure-core<2.0.0,>=1.14.0 From cb71779adca84593652d144196dbc7049e8a7e3c Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 15:07:43 -0700 Subject: [PATCH 087/129] Updating shared requirements --- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 3 +-- shared_requirements.txt | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index e6826bfacd68..59005df4782e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -74,8 +74,7 @@ install_requires=[ "msrest>=0.6.21", "azure-core<2.0.0,>=1.2.2", - "azure-appconfiguration<2.0.0,>=1.1.1", - "azure-identity<2.0.0,>=1.4.0", + "azure-appconfiguration<2.0.0,>=1.2.0", "azure-keyvault-secrets<5.0.0,>=4.0.0", ], ) diff --git a/shared_requirements.txt b/shared_requirements.txt index 0c50f22a2c84..99da4ad55a1e 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -3,6 +3,7 @@ azure-ai-translation-nspkg azure-ai-language-nspkg azure-iot-nspkg azure-monitor-nspkg +azure-appconfiguration<2.0.0,>=1.2.0 azure-applicationinsights~=0.1.0 azure-batch~=4.1 azure-cognitiveservices-nspkg From ac8aa14309c85c6da928f9567d8aa358a95de09d Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 15:28:03 -0700 Subject: [PATCH 088/129] Fixed override. Switched to SecretReferenceConfigurationSetting --- .../_azureappconfigurationprovider.py | 11 ++--------- shared_requirements.txt | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index c1f0c4b30c47..bf1c5044b410 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -112,19 +112,12 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client if key_vault_options is None: raise AttributeError( "Key Vault options must be set to resolve Key Vault references.") - try: - j_object = json.loads(config.value) - except json.JSONDecodeError as e: - raise ValueError( - "Invalid JSON value for key vault reference: " + config.key) - uri_value = j_object.get("uri", None) - - if uri_value is None: + if config.secret_id is None: raise AttributeError( "Key Vault reference must have a uri value.") - key_vault_identifier = KeyVaultSecretIdentifier(uri_value) + key_vault_identifier = KeyVaultSecretIdentifier(config.secret_id) referenced_client = None diff --git a/shared_requirements.txt b/shared_requirements.txt index 99da4ad55a1e..cc63d15c2ad3 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -186,7 +186,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-eventhub-checkpointstoretable azure-core<2.0.0,>=1.14.0 #override azure-eventhub uamqp>=1.6.0,<2.0.0 #override azure-appconfiguration azure-core<2.0.0,>=1.24.0 -#override azure-appconfiguration azure-keyvault-secrets<5.0.0,>=4.0.0 +#override azure-appconfiguration-provider azure-keyvault-secrets<5.0.0,>=4.0.0 #override azure-servicebus uamqp>=1.5.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 #override azure-servicebus azure-core<2.0.0,>=1.14.0 From 6590ae3030397042cb1068a8f81e37326cc24381 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 15:52:54 -0700 Subject: [PATCH 089/129] Updated Requirement KeyVaultSecretIdentifier is needed. --- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 2 +- shared_requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 59005df4782e..596121e98136 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -75,6 +75,6 @@ "msrest>=0.6.21", "azure-core<2.0.0,>=1.2.2", "azure-appconfiguration<2.0.0,>=1.2.0", - "azure-keyvault-secrets<5.0.0,>=4.0.0", + "azure-keyvault-secrets<5.0.0,>=4.3.0", ], ) diff --git a/shared_requirements.txt b/shared_requirements.txt index cc63d15c2ad3..79bec04f6594 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -186,7 +186,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-eventhub-checkpointstoretable azure-core<2.0.0,>=1.14.0 #override azure-eventhub uamqp>=1.6.0,<2.0.0 #override azure-appconfiguration azure-core<2.0.0,>=1.24.0 -#override azure-appconfiguration-provider azure-keyvault-secrets<5.0.0,>=4.0.0 +#override azure-appconfiguration-provider azure-keyvault-secrets<5.0.0,>=4.3.0 #override azure-servicebus uamqp>=1.5.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 #override azure-servicebus azure-core<2.0.0,>=1.14.0 From 0fdaab59f996c57b6013274883005e2899cb8c5e Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 16:52:05 -0700 Subject: [PATCH 090/129] Update ci.yml --- sdk/appconfiguration/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index c6b6d395385b..c2d168cfef8b 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -35,5 +35,7 @@ extends: Artifacts: - name: azure-appconfiguration safeName: azureappconfiguration + - name: azure-appconfiguration-provider + safeName: azureappconfigurationprovider - name: azure-mgmt-appconfiguration safeName: azuremgmtappconfiguration \ No newline at end of file From a3251236485ba142624d4fd35caebac97298a6d3 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 21 Sep 2022 16:53:04 -0700 Subject: [PATCH 091/129] Update ci.yml --- sdk/appconfiguration/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index c2d168cfef8b..498bd0afa9c4 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -32,6 +32,7 @@ extends: ServiceDirectory: appconfiguration VerifyAutorest: false ValidateFormatting: false + TestProxy: true Artifacts: - name: azure-appconfiguration safeName: azureappconfiguration From ffa7a78c2049c3884a1d79ea38c1832be0a0bace Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 08:43:17 -0700 Subject: [PATCH 092/129] Fixed structure --- .../azure/appconfiguration/__init__.py | 2 ++ .../provider}/__init__.py | 0 .../provider}/_azureappconfigurationkeyvaultoptions.py | 0 .../provider}/_azureappconfigurationprovider.py | 0 .../provider}/_constants.py | 0 .../provider}/_settingselector.py | 0 .../provider}/_user_agent.py | 0 .../provider}/_version.py | 0 .../azure-appconfiguration-provider/samples/aad_sample.py | 2 +- .../samples/connection_string_sample.py | 2 +- .../samples/key_vault_reference_provided_clients_sample.py | 2 +- .../samples/key_vault_reference_sample.py | 2 +- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 2 +- .../azure-appconfiguration-provider/tests/test_provider.py | 2 +- 14 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/__init__.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_azureappconfigurationprovider.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_constants.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_settingselector.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_user_agent.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_version.py (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py new file mode 100644 index 000000000000..229d1b3c8804 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py @@ -0,0 +1,2 @@ +__path__ = __import__("pkgutil").extend_path( + __path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index 52ad33fe735b..122daa6ad70c 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index 7550e77039db..bd4f1b1dbc34 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 9151f1a699ef..8d67f617c34c 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index a66664f34bcf..4e02cb434197 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 596121e98136..8da1268eb78b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -13,7 +13,7 @@ from setuptools import find_packages, setup # Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-appconfigurationprovider" +PACKAGE_NAME = "azure-appconfiguration-provider" PACKAGE_PPRINT_NAME = "App Configuration Provider" # a-b-c => a/b/c diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index fb656449fc8e..2b3f5023406b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- import functools -from azure.appconfigurationprovider import AzureAppConfigurationProvider +from azure.appconfiguration.provider import AzureAppConfigurationProvider from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy from azure.appconfiguration import AzureAppConfigurationClient import inspect From 87cf4582f377be92b90fa28bf1bb2bf07050bd52 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 09:51:51 -0700 Subject: [PATCH 093/129] Update dev_requirements.txt --- .../azure-appconfiguration-provider/dev_requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt index adab992bf639..c811a688cdf7 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt +++ b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt @@ -2,6 +2,7 @@ ../../core/azure-core -e ../azure-appconfiguration -e ../../identity/azure-identity +-e ../../keyvault/azure-keyvault-secrets aiohttp>=3.0 -e ../../../tools/azure-sdk-tools -e ../../../tools/azure-devtools \ No newline at end of file From fe5944fb27663134f8fb30aaf6b565d8d404e04c Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 10:32:54 -0700 Subject: [PATCH 094/129] Update sdk_packaging.toml --- .../azure-appconfiguration-provider/sdk_packaging.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml index 1f3da94f6908..7d93f77a90ba 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml +++ b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml @@ -1,5 +1,5 @@ [packaging] -package_name = "azure-app-configuration-provider" +package_name = "azure-appconfiguration-provider" package_nspkg = "azure-data-nspkg" package_pprint_name = "App Configuration Provider" package_doc_id = "" From bc9e94176f780885b14bbb48045f9eff9d4102af Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 15:15:06 -0700 Subject: [PATCH 095/129] Revert working state --- .../azure/appconfiguration/__init__.py | 2 -- .../provider => appconfigurationprovider}/__init__.py | 0 .../_azureappconfigurationkeyvaultoptions.py | 0 .../_azureappconfigurationprovider.py | 6 ++++-- .../provider => appconfigurationprovider}/_constants.py | 0 .../_settingselector.py | 0 .../provider => appconfigurationprovider}/_user_agent.py | 0 .../provider => appconfigurationprovider}/_version.py | 0 .../azure-appconfiguration-provider/samples/aad_sample.py | 2 +- .../samples/key_vault_reference_provided_clients_sample.py | 2 +- .../samples/key_vault_reference_sample.py | 2 +- .../azure-appconfiguration-provider/sdk_packaging.toml | 2 +- .../azure-appconfiguration-provider/setup.py | 2 +- .../azure-appconfiguration-provider/tests/test_provider.py | 2 +- sdk/appconfiguration/ci.yml | 2 +- 15 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/__init__.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_azureappconfigurationprovider.py (98%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_constants.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_settingselector.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_user_agent.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_version.py (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py deleted file mode 100644 index 229d1b3c8804..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__path__ = __import__("pkgutil").extend_path( - __path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py similarity index 98% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index bf1c5044b410..53a517c5db1d 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -6,8 +6,10 @@ import json from azure.appconfiguration import AzureAppConfigurationClient -from azure.keyvault.secrets import SecretClient -from azure.keyvault.secrets import KeyVaultSecretIdentifier +from azure.keyvault.secrets import ( + SecretClient, + KeyVaultSecretIdentifier +) from azure.core.exceptions import ( HttpResponseError, ResourceNotFoundError diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index 122daa6ad70c..52ad33fe735b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 8d67f617c34c..9151f1a699ef 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index 4e02cb434197..a66664f34bcf 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml index 7d93f77a90ba..32efea5975a9 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml +++ b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml @@ -1,5 +1,5 @@ [packaging] -package_name = "azure-appconfiguration-provider" +package_name = "azure-appconfigurationprovider" package_nspkg = "azure-data-nspkg" package_pprint_name = "App Configuration Provider" package_doc_id = "" diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 8da1268eb78b..596121e98136 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -13,7 +13,7 @@ from setuptools import find_packages, setup # Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-appconfiguration-provider" +PACKAGE_NAME = "azure-appconfigurationprovider" PACKAGE_PPRINT_NAME = "App Configuration Provider" # a-b-c => a/b/c diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index 2b3f5023406b..fb656449fc8e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- import functools -from azure.appconfiguration.provider import AzureAppConfigurationProvider +from azure.appconfigurationprovider import AzureAppConfigurationProvider from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy from azure.appconfiguration import AzureAppConfigurationClient import inspect diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index 498bd0afa9c4..2fabc82a86e7 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -36,7 +36,7 @@ extends: Artifacts: - name: azure-appconfiguration safeName: azureappconfiguration - - name: azure-appconfiguration-provider + - name: azure-appconfigurationprovider safeName: azureappconfigurationprovider - name: azure-mgmt-appconfiguration safeName: azuremgmtappconfiguration \ No newline at end of file From f7764544723eabb181f26f0e6f2b9d8ac60761cd Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 15:23:18 -0700 Subject: [PATCH 096/129] Renamed correctly --- .../azure/appconfiguration/__init__.py | 2 ++ .../provider}/__init__.py | 0 .../provider}/_azureappconfigurationkeyvaultoptions.py | 0 .../provider}/_azureappconfigurationprovider.py | 0 .../provider}/_constants.py | 0 .../provider}/_settingselector.py | 0 .../provider}/_user_agent.py | 0 .../provider}/_version.py | 0 .../azure-appconfiguration-provider/samples/aad_sample.py | 2 +- .../samples/key_vault_reference_provided_clients_sample.py | 2 +- .../samples/key_vault_reference_sample.py | 2 +- .../azure-appconfiguration-provider/sdk_packaging.toml | 2 +- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 2 +- .../azure-appconfiguration-provider/tests/test_provider.py | 2 +- sdk/appconfiguration/ci.yml | 2 +- 15 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/__init__.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_azureappconfigurationprovider.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_constants.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_settingselector.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_user_agent.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfigurationprovider => appconfiguration/provider}/_version.py (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py new file mode 100644 index 000000000000..229d1b3c8804 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py @@ -0,0 +1,2 @@ +__path__ = __import__("pkgutil").extend_path( + __path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index 52ad33fe735b..122daa6ad70c 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 9151f1a699ef..8d67f617c34c 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index a66664f34bcf..4e02cb434197 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml index 32efea5975a9..7d93f77a90ba 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml +++ b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml @@ -1,5 +1,5 @@ [packaging] -package_name = "azure-appconfigurationprovider" +package_name = "azure-appconfiguration-provider" package_nspkg = "azure-data-nspkg" package_pprint_name = "App Configuration Provider" package_doc_id = "" diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 596121e98136..8da1268eb78b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -13,7 +13,7 @@ from setuptools import find_packages, setup # Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-appconfigurationprovider" +PACKAGE_NAME = "azure-appconfiguration-provider" PACKAGE_PPRINT_NAME = "App Configuration Provider" # a-b-c => a/b/c diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index fb656449fc8e..2b3f5023406b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- import functools -from azure.appconfigurationprovider import AzureAppConfigurationProvider +from azure.appconfiguration.provider import AzureAppConfigurationProvider from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy from azure.appconfiguration import AzureAppConfigurationClient import inspect diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index 2fabc82a86e7..498bd0afa9c4 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -36,7 +36,7 @@ extends: Artifacts: - name: azure-appconfiguration safeName: azureappconfiguration - - name: azure-appconfigurationprovider + - name: azure-appconfiguration-provider safeName: azureappconfigurationprovider - name: azure-mgmt-appconfiguration safeName: azuremgmtappconfiguration \ No newline at end of file From d585fcd14987e2b42f64e7a00bae4715475d942b Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 16:08:17 -0700 Subject: [PATCH 097/129] Using azure-appconfigurationprovider --- .../azure/appconfiguration/__init__.py | 2 -- .../provider => appconfigurationprovider}/__init__.py | 0 .../_azureappconfigurationkeyvaultoptions.py | 0 .../_azureappconfigurationprovider.py | 0 .../provider => appconfigurationprovider}/_constants.py | 0 .../provider => appconfigurationprovider}/_settingselector.py | 0 .../provider => appconfigurationprovider}/_user_agent.py | 0 .../provider => appconfigurationprovider}/_version.py | 0 .../azure-appconfiguration-provider/samples/README.md | 2 +- .../azure-appconfiguration-provider/samples/aad_sample.py | 2 +- .../samples/connection_string_sample.py | 2 +- .../samples/key_vault_reference_provided_clients_sample.py | 2 +- .../samples/key_vault_reference_sample.py | 2 +- .../azure-appconfiguration-provider/sdk_packaging.toml | 2 +- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 2 +- .../azure-appconfiguration-provider/tests/test_provider.py | 2 +- sdk/appconfiguration/ci.yml | 2 +- 17 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/__init__.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_azureappconfigurationprovider.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_constants.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_settingselector.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_user_agent.py (100%) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/{appconfiguration/provider => appconfigurationprovider}/_version.py (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py deleted file mode 100644 index 229d1b3c8804..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__path__ = __import__("pkgutil").extend_path( - __path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md index 881144ea7209..166e5da217f5 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md @@ -39,7 +39,7 @@ az appconfig kv set-keyvault --name --key secret --secret-id Install the Azure App Configuration Provider client library for Python with pip: ```commandline -pip install azure-appconfiguration-provider +pip install provider ``` ## Contents diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index 122daa6ad70c..52ad33fe735b 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index bd4f1b1dbc34..7550e77039db 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 8d67f617c34c..9151f1a699ef 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index 4e02cb434197..a66664f34bcf 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( +from azure.appconfigurationprovider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml index 7d93f77a90ba..32efea5975a9 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml +++ b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml @@ -1,5 +1,5 @@ [packaging] -package_name = "azure-appconfiguration-provider" +package_name = "azure-appconfigurationprovider" package_nspkg = "azure-data-nspkg" package_pprint_name = "App Configuration Provider" package_doc_id = "" diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 8da1268eb78b..596121e98136 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -13,7 +13,7 @@ from setuptools import find_packages, setup # Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-appconfiguration-provider" +PACKAGE_NAME = "azure-appconfigurationprovider" PACKAGE_PPRINT_NAME = "App Configuration Provider" # a-b-c => a/b/c diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index 2b3f5023406b..fb656449fc8e 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- import functools -from azure.appconfiguration.provider import AzureAppConfigurationProvider +from azure.appconfigurationprovider import AzureAppConfigurationProvider from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy from azure.appconfiguration import AzureAppConfigurationClient import inspect diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index 498bd0afa9c4..2fabc82a86e7 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -36,7 +36,7 @@ extends: Artifacts: - name: azure-appconfiguration safeName: azureappconfiguration - - name: azure-appconfiguration-provider + - name: azure-appconfigurationprovider safeName: azureappconfigurationprovider - name: azure-mgmt-appconfiguration safeName: azuremgmtappconfiguration \ No newline at end of file From 5a3f340b06dfee593195772de2dd77b318e80607 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 22 Sep 2022 16:26:09 -0700 Subject: [PATCH 098/129] Fixing shared Requirements merge issue --- shared_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared_requirements.txt b/shared_requirements.txt index 79bec04f6594..e4c9dbc8cd7f 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -186,7 +186,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-eventhub-checkpointstoretable azure-core<2.0.0,>=1.14.0 #override azure-eventhub uamqp>=1.6.0,<2.0.0 #override azure-appconfiguration azure-core<2.0.0,>=1.24.0 -#override azure-appconfiguration-provider azure-keyvault-secrets<5.0.0,>=4.3.0 +#override azure-appconfigurationprovider azure-keyvault-secrets<5.0.0,>=4.3.0 #override azure-servicebus uamqp>=1.5.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 #override azure-servicebus azure-core<2.0.0,>=1.14.0 From 4af618063b8cd822d74c13eade4b94c36d8fad2b Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 11:10:03 -0700 Subject: [PATCH 099/129] Updated from review comments --- .../_azure_appconfiguration_provider_error.py | 12 +++++++ .../_azureappconfigurationprovider.py | 31 ++++++++----------- 2 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py new file mode 100644 index 000000000000..8b7e2f3dacfa --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py @@ -0,0 +1,12 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + +class KeyVaultReferenceError(ValueError): + """Raised when a Key Vault reference is invalid.""" + + def __init__(self, message, *args): + # type: (str, Any) -> None + super(KeyVaultReferenceError, self).__init__(message, *args) \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 53a517c5db1d..91b5a6c99cd4 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -15,9 +15,9 @@ ResourceNotFoundError ) from ._settingselector import SettingSelector -from ._constants import ( - KEY_VAULT_REFERENCE_CONTENT_TYPE -) +from ._azure_appconfiguration_provider_error import KeyVaultReferenceError +from ._constants import KEY_VAULT_REFERENCE_CONTENT_TYPE + from ._user_agent import USER_AGENT @@ -75,15 +75,15 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): raise e for config in configurations: if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: - provider.__resolve_keyvault_references( - config, key_vault_options, secret_clients) + secret = provider.__resolve_keyvault_reference(config, key_vault_options, secret_clients) + provider._dict[provider.__trim(config.key)] = secret elif provider.__is_json_content_type(config.content_type): try: j_object = json.loads(config.value) provider._dict[provider.__trim(config.key)] = j_object except json.JSONDecodeError as e: - raise ValueError( - "Invalid JSON value for key: " + config.key) + # If the value is not a valid JSON, treat it like regular string value + provider._dict[provider.__trim(config.key)] = config.value else: provider._dict[provider.__trim(config.key)] = config.value return provider @@ -93,7 +93,7 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt correlation_context = "RequestType=Startup" if (key_vault_options and - (key_vault_options.credential or key_vault_options or key_vault_options.secret_resolver)): + (key_vault_options.credential or key_vault_options.secret_clients or key_vault_options.secret_resolver)): correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context @@ -110,7 +110,7 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt self._client = AzureAppConfigurationClient( endpoint, credential, user_agent=useragent, headers=headers) - def __resolve_keyvault_references(self, config, key_vault_options, secret_clients): + def __resolve_keyvault_reference(self, config, key_vault_options, secret_clients): if key_vault_options is None: raise AttributeError( "Key Vault options must be set to resolve Key Vault references.") @@ -134,21 +134,16 @@ def __resolve_keyvault_references(self, config, key_vault_options, secret_client if referenced_client: try: - secret = referenced_client.get_secret( - key_vault_identifier.name, version=key_vault_identifier.version) - self._dict[self.__trim(config.key)] = secret.value - return + return referenced_client.get_secret(key_vault_identifier.name, version=key_vault_identifier.version) except ResourceNotFoundError as e: - raise ValueError("Key Vault %s does not contain secret %s" % ( + raise KeyVaultReferenceError("Key Vault %s does not contain secret %s" % ( key_vault_identifier.vault_url, key_vault_identifier.name)) except HttpResponseError as e: raise e if key_vault_options.secret_resolver is not None: - self._dict[self.__trim( - config.key)] = key_vault_options.secret_resolver(key_vault_identifier.vault_url) - return - raise AttributeError( + return key_vault_options.secret_resolver(config.secret_id) + raise KeyVaultReferenceError( "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) @staticmethod From 20937c8149951de36e9992f5c813272acca91d4f Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 12:13:35 -0700 Subject: [PATCH 100/129] Fixing package folder --- .../CHANGELOG.md | 0 .../LICENSE | 0 .../MANIFEST.in | 0 .../README.md | 0 .../azure/__init__.py | 0 .../azure/appconfigurationprovider/__init__.py | 0 .../_azure_appconfiguration_provider_error.py | 0 .../_azureappconfigurationkeyvaultoptions.py | 0 .../_azureappconfigurationprovider.py | 8 ++------ .../azure/appconfigurationprovider/_constants.py | 0 .../azure/appconfigurationprovider/_settingselector.py | 0 .../azure/appconfigurationprovider/_user_agent.py | 0 .../azure/appconfigurationprovider/_version.py | 0 .../dev_requirements.txt | 0 .../mypy.ini | 0 .../samples/README.md | 0 .../samples/aad_sample.py | 0 .../samples/connection_string_sample.py | 0 .../key_vault_reference_provided_clients_sample.py | 0 .../samples/key_vault_reference_sample.py | 0 .../sdk_packaging.toml | 0 .../setup.py | 2 +- .../tests/conftest.py | 0 ...estAppConfigurationProvidertest_provider_creation.json | 0 ...ppConfigurationProvidertest_provider_creation_aad.json | 0 .../tests/test_provider.py | 0 26 files changed, 3 insertions(+), 7 deletions(-) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/CHANGELOG.md (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/LICENSE (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/MANIFEST.in (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/README.md (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/__init__.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/__init__.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_azureappconfigurationprovider.py (97%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_constants.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_settingselector.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_user_agent.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/azure/appconfigurationprovider/_version.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/dev_requirements.txt (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/mypy.ini (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/samples/README.md (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/samples/aad_sample.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/samples/connection_string_sample.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/samples/key_vault_reference_provided_clients_sample.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/samples/key_vault_reference_sample.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/sdk_packaging.toml (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/setup.py (97%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/tests/conftest.py (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json (100%) rename sdk/appconfiguration/{azure-appconfiguration-provider => azure-appconfigurationprovider}/tests/test_provider.py (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md b/sdk/appconfiguration/azure-appconfigurationprovider/CHANGELOG.md similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md rename to sdk/appconfiguration/azure-appconfigurationprovider/CHANGELOG.md diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/LICENSE b/sdk/appconfiguration/azure-appconfigurationprovider/LICENSE similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/LICENSE rename to sdk/appconfiguration/azure-appconfigurationprovider/LICENSE diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in b/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in rename to sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/README.md b/sdk/appconfiguration/azure-appconfigurationprovider/README.md similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/README.md rename to sdk/appconfiguration/azure-appconfigurationprovider/README.md diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/__init__.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py similarity index 97% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 91b5a6c99cd4..66de236e7936 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -121,12 +121,8 @@ def __resolve_keyvault_reference(self, config, key_vault_options, secret_clients key_vault_identifier = KeyVaultSecretIdentifier(config.secret_id) - referenced_client = None - - for secret_client in secret_clients: - if secret_client.vault_url == key_vault_identifier.vault_url: - referenced_client = secret_client - break + referenced_client = next((client for client in secret_clients if client.vault_url == key_vault_identifier.vault_url), None) + if referenced_client is None and key_vault_options.credential is not None: referenced_client = SecretClient( vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_constants.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_settingselector.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_user_agent.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfigurationprovider/_version.py rename to sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_version.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfigurationprovider/dev_requirements.txt similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt rename to sdk/appconfiguration/azure-appconfigurationprovider/dev_requirements.txt diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini b/sdk/appconfiguration/azure-appconfigurationprovider/mypy.ini similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini rename to sdk/appconfiguration/azure-appconfigurationprovider/mypy.ini diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md b/sdk/appconfiguration/azure-appconfigurationprovider/samples/README.md similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md rename to sdk/appconfiguration/azure-appconfigurationprovider/samples/README.md diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py rename to sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py rename to sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_provided_clients_sample.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py rename to sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_provided_clients_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_sample.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py rename to sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_sample.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfigurationprovider/sdk_packaging.toml similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml rename to sdk/appconfiguration/azure-appconfigurationprovider/sdk_packaging.toml diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfigurationprovider/setup.py similarity index 97% rename from sdk/appconfiguration/azure-appconfiguration-provider/setup.py rename to sdk/appconfiguration/azure-appconfigurationprovider/setup.py index 596121e98136..7d82158a004a 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/setup.py @@ -55,7 +55,7 @@ license="MIT License", author="Microsoft Corporation", author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration-provider", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfigurationprovider", classifiers=[ "Development Status :: 5 - Production/Stable", "Programming Language :: Python", diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py rename to sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json rename to sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json rename to sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py rename to sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py From 6ea9f72baea0031cc86fe0b5cc90ae2f4ecd2028 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 12:34:18 -0700 Subject: [PATCH 101/129] Fix lint, removed extra fixture --- .../_azure_appconfiguration_provider_error.py | 4 ---- .../_azureappconfigurationprovider.py | 6 ++++-- .../azure-appconfigurationprovider/tests/conftest.py | 7 ------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py index 8b7e2f3dacfa..0bc4fdb0c0b3 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py @@ -6,7 +6,3 @@ class KeyVaultReferenceError(ValueError): """Raised when a Key Vault reference is invalid.""" - - def __init__(self, message, *args): - # type: (str, Any) -> None - super(KeyVaultReferenceError, self).__init__(message, *args) \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 66de236e7936..655ea05383b2 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -93,7 +93,8 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt correlation_context = "RequestType=Startup" if (key_vault_options and - (key_vault_options.credential or key_vault_options.secret_clients or key_vault_options.secret_resolver)): + (key_vault_options.credential or + key_vault_options.secret_clients or key_vault_options.secret_resolver)): correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context @@ -110,7 +111,8 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt self._client = AzureAppConfigurationClient( endpoint, credential, user_agent=useragent, headers=headers) - def __resolve_keyvault_reference(self, config, key_vault_options, secret_clients): + @staticmethod + def __resolve_keyvault_reference(config, key_vault_options, secret_clients): if key_vault_options is None: raise AttributeError( "Key Vault options must be set to resolve Key Vault references.") diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py index aa499fb92527..cb502f715c0f 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py @@ -8,13 +8,6 @@ # autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method -@pytest.fixture(scope="session", autouse=True) -def start_proxy(test_proxy): - return - -# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method - - @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): add_general_regex_sanitizer(value="https://fake-endpoint.azconfig.io", From 3157ec47a011bdd6a96d11e811d4b5973475a68d Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 16:10:22 -0700 Subject: [PATCH 102/129] Create py.typed --- .../azure/appconfigurationprovider/py.typed | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/py.typed diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/py.typed b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/py.typed new file mode 100644 index 000000000000..e69de29bb2d1 From e967499d8f16225ff4bb2b2e28fcf91e1bc1d7f3 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 16:12:45 -0700 Subject: [PATCH 103/129] Updated Manifest to use right py.typed file --- sdk/appconfiguration/azure-appconfiguration/MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in b/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in index c33cc70f3bd4..79397d225f59 100644 --- a/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in +++ b/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in @@ -4,4 +4,4 @@ include LICENSE include azure/__init__.py recursive-include samples *.py *.md recursive-include doc *.rst -include azure/appconfiguration/py.typed +include azure/appconfigurationprovider/py.typed From c98f1f85d8daa2bc28286c79c477d1f0b281b836 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 16:21:17 -0700 Subject: [PATCH 104/129] Switched Files --- sdk/appconfiguration/azure-appconfiguration/MANIFEST.in | 2 +- sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in b/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in index 79397d225f59..c33cc70f3bd4 100644 --- a/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in +++ b/sdk/appconfiguration/azure-appconfiguration/MANIFEST.in @@ -4,4 +4,4 @@ include LICENSE include azure/__init__.py recursive-include samples *.py *.md recursive-include doc *.rst -include azure/appconfigurationprovider/py.typed +include azure/appconfiguration/py.typed diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in b/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in index 731abed60dd1..4bb4e84cc2d6 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in +++ b/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in @@ -4,4 +4,4 @@ include LICENSE include azure/__init__.py recursive-include samples *.py *.md recursive-include doc *.rst -include azure/appconfiguration/py.typed \ No newline at end of file +include azure/provider/py.typed \ No newline at end of file From c794d4647b98dbd24b7bde6c658555690ef33692 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 16:45:57 -0700 Subject: [PATCH 105/129] Fixing lint issue --- .../_azureappconfigurationprovider.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 655ea05383b2..e7918a96e5f9 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -93,7 +93,7 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt correlation_context = "RequestType=Startup" if (key_vault_options and - (key_vault_options.credential or + (key_vault_options.credential or key_vault_options.secret_clients or key_vault_options.secret_resolver)): correlation_context += ",UsesKeyVault" @@ -123,8 +123,9 @@ def __resolve_keyvault_reference(config, key_vault_options, secret_clients): key_vault_identifier = KeyVaultSecretIdentifier(config.secret_id) - referenced_client = next((client for client in secret_clients if client.vault_url == key_vault_identifier.vault_url), None) - + referenced_client = next( + (client for client in secret_clients if client.vault_url == key_vault_identifier.vault_url), None) + if referenced_client is None and key_vault_options.credential is not None: referenced_client = SecretClient( vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) From 39eacba2142841e382a08d5b665718f37c984589 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Fri, 23 Sep 2022 17:18:14 -0700 Subject: [PATCH 106/129] Setting defaults for test --- .../azure-appconfigurationprovider/tests/conftest.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py index cb502f715c0f..0f9438676749 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py @@ -10,13 +10,13 @@ @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): - add_general_regex_sanitizer(value="https://fake-endpoint.azconfig.io", - regex=os.environ.get('APPCONFIGURATION_ENDPOINT_STRING')) + add_general_regex_sanitizer(value="https://fake-endpoint.azconfig.io", + regex=os.environ.get('APPCONFIGURATION_ENDPOINT_STRING', "https://fake-endpoint.azconfig.io")) add_general_regex_sanitizer(value="fake-connection-string", - regex=os.environ.get('APPCONFIGURATION_CONNECTION_STRING')) + regex=os.environ.get('APPCONFIGURATION_CONNECTION_STRING', "fake-connection-string")) add_general_regex_sanitizer( - value="fake-client-id", regex=os.environ.get('APPCONFIGURATION_CLIENT_ID')) + value="fake-client-id", regex=os.environ.get('APPCONFIGURATION_CLIENT_ID', "fake-client-id")) add_general_regex_sanitizer( - value="fake-client-secret", regex=os.environ.get('APPCONFIGURATION_CLIENT_SECRET')) + value="fake-client-secret", regex=os.environ.get('APPCONFIGURATION_CLIENT_SECRET', "fake-client-secret")) add_general_regex_sanitizer( - value="fake-tenant-id", regex=os.environ.get('APPCONFIGURATION_TENANT_ID')) + value="fake-tenant-id", regex=os.environ.get('APPCONFIGURATION_TENANT_ID', "fake-tenant-id")) From 23d6fb9aba9ee29c80c2e244640a0a426144dbc4 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 26 Sep 2022 10:29:17 -0700 Subject: [PATCH 107/129] Updating Docs --- .../_azureappconfigurationkeyvaultoptions.py | 1 + .../_azureappconfigurationprovider.py | 5 +++++ .../azure/appconfigurationprovider/_settingselector.py | 1 + 3 files changed, 7 insertions(+) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 8d2c646ce084..5032d2812539 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -7,6 +7,7 @@ class AzureAppConfigurationKeyVaultOptions: """ Options for connecting to Key Vault. + :param credential: A credential for authenticating with the key vault. This is optional if secret_clients is provided. :type credential: ~azure.core.credentials.TokenCredential diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index e7918a96e5f9..e1ac17389592 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -38,6 +38,7 @@ def __init__(self): def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): """ Loads configuration settings from Azure App Configuration into a Python application. + :param connection_string: Connection string (one of connection_string or endpoint and credential must be set) :type connection_string: str :param endpoint: Endpoint (one of connection_string or endpoint and credential must be set) @@ -185,6 +186,7 @@ def __len__(self): def copy(self): """ Returns a copy of the configuration settings + type: () -> dict """ return self._dict.copy() @@ -192,6 +194,7 @@ def copy(self): def has_key(self, k): """ Returns True if the configuration settings has been loaded from Azure App Configuration. + type: (str) -> bool """ return k in self._dict @@ -199,6 +202,7 @@ def has_key(self, k): def keys(self): """ Returns a list of keys loaded from Azure App Configuration. + type: () -> list """ return self._dict.keys() @@ -207,6 +211,7 @@ def values(self): """ Returns a list of values loaded from Azure App Configuration. Any values that are Key Vault references will be resolved. + type: () -> list """ return self._dict.values() diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py index a82699284710..15ee4f0baf85 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py @@ -7,6 +7,7 @@ class SettingSelector: """ Selects a set of configuration settings from Azure App Configuration. + :param key_filter: A filter to select configuration settings based on their keys. :type key_filter: str :param label_filter: A filter to select configuration settings based on their labels. Default is value is '\0' From 8c4bc04dfca0b95f56149b268c66cf0ef6ea2c95 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 26 Sep 2022 11:01:50 -0700 Subject: [PATCH 108/129] Fixing Whitespace --- .../_azureappconfigurationkeyvaultoptions.py | 2 +- .../appconfigurationprovider/_azureappconfigurationprovider.py | 2 +- .../azure/appconfigurationprovider/_settingselector.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index 5032d2812539..d640015c0695 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -7,7 +7,7 @@ class AzureAppConfigurationKeyVaultOptions: """ Options for connecting to Key Vault. - + :param credential: A credential for authenticating with the key vault. This is optional if secret_clients is provided. :type credential: ~azure.core.credentials.TokenCredential diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index e1ac17389592..2560788a9950 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -211,7 +211,7 @@ def values(self): """ Returns a list of values loaded from Azure App Configuration. Any values that are Key Vault references will be resolved. - + type: () -> list """ return self._dict.values() diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py index 15ee4f0baf85..c56d6ca8ae80 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py @@ -7,7 +7,7 @@ class SettingSelector: """ Selects a set of configuration settings from Azure App Configuration. - + :param key_filter: A filter to select configuration settings based on their keys. :type key_filter: str :param label_filter: A filter to select configuration settings based on their labels. Default is value is '\0' From 9b337973915b7e0f87a5a3dedc87c5636eb9495b Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 26 Sep 2022 15:45:11 -0700 Subject: [PATCH 109/129] Updating to support in operation --- .../_azureappconfigurationprovider.py | 8 ++++---- .../samples/connection_string_sample.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 2560788a9950..988badc96c3d 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -191,13 +191,13 @@ def copy(self): """ return self._dict.copy() - def has_key(self, k): + def __contains__(self, __x: object): """ - Returns True if the configuration settings has been loaded from Azure App Configuration. + Returns True if the configuration settings contains the specified key - type: (str) -> bool + type: (object) -> bool """ - return k in self._dict + return self._dict.__contains__(__x) def keys(self): """ diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py index 7550e77039db..d531643e8c56 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py @@ -31,5 +31,5 @@ config = AzureAppConfigurationProvider.load( connection_string=connection_string, selects=selects) -print("message found: " + str(config.has_key("message"))) -print("test.message found: " + str(config.has_key("config.message"))) +print("message found: " + str("message" in config)) +print("test.message found: " + str("test.message" in config)) From 682bd2c3f61e5177f72085aeeca7d7cddb0ffdc6 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 26 Sep 2022 15:47:11 -0700 Subject: [PATCH 110/129] Updated sample with in usage --- .../azure-appconfigurationprovider/samples/aad_sample.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py index 52ad33fe735b..c525bc02f88b 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py @@ -32,5 +32,5 @@ config = AzureAppConfigurationProvider.load( endpoint=endpoint, credential=credential, selects=selects) -print("message found: " + str(config.has_key("message"))) -print("test.message found: " + str(config.has_key("config.message"))) +print("message found: " + str("message" in config)) +print("test.message found: " + str("test.message" in config)) From 22636cd0bbd6a5418f51b169dee6ee9878df5e19 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Mon, 26 Sep 2022 15:58:02 -0700 Subject: [PATCH 111/129] Cleaned up key trimming usage --- .../_azureappconfigurationprovider.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 988badc96c3d..7902e7de0b21 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -75,18 +75,26 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): except HttpResponseError as e: raise e for config in configurations: + + trimmed_key = config.key + # Trim the key if it starts with one of the prefixes provided + for trim in provider._trim_prefixes: + if config.key.startswith(trim): + trimmed_key = config.key[len(trim):] + break + if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: secret = provider.__resolve_keyvault_reference(config, key_vault_options, secret_clients) - provider._dict[provider.__trim(config.key)] = secret + provider._dict[trimmed_key] = secret elif provider.__is_json_content_type(config.content_type): try: j_object = json.loads(config.value) - provider._dict[provider.__trim(config.key)] = j_object + provider._dict[trimmed_key] = j_object except json.JSONDecodeError as e: # If the value is not a valid JSON, treat it like regular string value - provider._dict[provider.__trim(config.key)] = config.value + provider._dict[trimmed_key] = config.value else: - provider._dict[provider.__trim(config.key)] = config.value + provider._dict[trimmed_key] = config.value return provider def __buildprovider(self, connection_string, endpoint, credential, key_vault_options): @@ -168,12 +176,6 @@ def __is_json_content_type(content_type): return False - def __trim(self, key): - for trim in self._trim_prefixes: - if key.startswith(trim): - return key[len(trim):] - return key - def __getitem__(self, key): return self._dict[key] From 784ffeec214b5dc6c818e6ce61f745ee499a0c33 Mon Sep 17 00:00:00 2001 From: mrm9084 Date: Tue, 27 Sep 2022 10:22:08 -0700 Subject: [PATCH 112/129] Removed extra catches for now. Cleaned up lint. --- .../_azureappconfigurationprovider.py | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 7902e7de0b21..d82239dfceb8 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -10,10 +10,7 @@ SecretClient, KeyVaultSecretIdentifier ) -from azure.core.exceptions import ( - HttpResponseError, - ResourceNotFoundError -) +from azure.core.exceptions import ResourceNotFoundError from ._settingselector import SettingSelector from ._azure_appconfiguration_provider_error import KeyVaultReferenceError from ._constants import KEY_VAULT_REFERENCE_CONTENT_TYPE @@ -69,11 +66,8 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): secret_clients = key_vault_options.secret_clients if key_vault_options else {} for select in selects: - try: - configurations = provider._client.list_configuration_settings( - key_filter=select.key_filter, label_filter=select.label_filter) - except HttpResponseError as e: - raise e + configurations = provider._client.list_configuration_settings( + key_filter=select.key_filter, label_filter=select.label_filter) for config in configurations: trimmed_key = config.key @@ -82,7 +76,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): if config.key.startswith(trim): trimmed_key = config.key[len(trim):] break - + if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: secret = provider.__resolve_keyvault_reference(config, key_vault_options, secret_clients) provider._dict[trimmed_key] = secret @@ -90,7 +84,7 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): try: j_object = json.loads(config.value) provider._dict[trimmed_key] = j_object - except json.JSONDecodeError as e: + except json.JSONDecodeError: # If the value is not a valid JSON, treat it like regular string value provider._dict[trimmed_key] = config.value else: @@ -143,11 +137,10 @@ def __resolve_keyvault_reference(config, key_vault_options, secret_clients): if referenced_client: try: return referenced_client.get_secret(key_vault_identifier.name, version=key_vault_identifier.version) - except ResourceNotFoundError as e: + except ResourceNotFoundError: raise KeyVaultReferenceError("Key Vault %s does not contain secret %s" % ( key_vault_identifier.vault_url, key_vault_identifier.name)) - except HttpResponseError as e: - raise e + if key_vault_options.secret_resolver is not None: return key_vault_options.secret_resolver(config.secret_id) From 1bedd5ae27aba3a8857298834eeb42d7748df037 Mon Sep 17 00:00:00 2001 From: mrm9084 Date: Tue, 27 Sep 2022 15:44:15 -0700 Subject: [PATCH 113/129] Adding more tests --- .../_azureappconfigurationprovider.py | 2 +- .../tests/conftest.py | 9 +- .../tests/preparers.py | 60 +++ ...urationProvidertest_provider_creation.json | 28 +- ...rationProvidertest_provider_selectors.json | 47 ++ ...dertest_provider_trimmed_key_prefixes.json | 67 +++ ...onProvidertest_provider_creation_aad.json} | 96 +--- ...rationProvidertest_provider_selectors.json | 219 +++++++++ ...dertest_provider_trimmed_key_prefixes.json | 239 +++++++++ ...nProvidertest_provider_with_key_vault.json | 462 ++++++++++++++++++ .../tests/test_provider.py | 99 ++-- .../tests/test_provider_aad.py | 49 ++ .../test_provider_key_vault_reference.py | 30 ++ 13 files changed, 1247 insertions(+), 160 deletions(-) create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json rename sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/{test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json => test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json} (65%) create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py create mode 100644 sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index d82239dfceb8..7d2bbb4a6cb1 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -136,7 +136,7 @@ def __resolve_keyvault_reference(config, key_vault_options, secret_clients): if referenced_client: try: - return referenced_client.get_secret(key_vault_identifier.name, version=key_vault_identifier.version) + return referenced_client.get_secret(key_vault_identifier.name, version=key_vault_identifier.version).value except ResourceNotFoundError: raise KeyVaultReferenceError("Key Vault %s does not contain secret %s" % ( key_vault_identifier.vault_url, key_vault_identifier.name)) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py index 0f9438676749..244b14a8905c 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py @@ -1,7 +1,9 @@ import os from devtools_testutils import ( test_proxy, - add_general_regex_sanitizer + add_general_regex_sanitizer, + add_body_string_sanitizer, + add_oauth_response_sanitizer ) import pytest @@ -11,7 +13,7 @@ @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): add_general_regex_sanitizer(value="https://fake-endpoint.azconfig.io", - regex=os.environ.get('APPCONFIGURATION_ENDPOINT_STRING', "https://fake-endpoint.azconfig.io")) + regex= os.environ.get('APPCONFIGURATION_ENDPOINT_STRING', "https://fake-endpoint.azconfig.io")) add_general_regex_sanitizer(value="fake-connection-string", regex=os.environ.get('APPCONFIGURATION_CONNECTION_STRING', "fake-connection-string")) add_general_regex_sanitizer( @@ -20,3 +22,6 @@ def add_sanitizers(test_proxy): value="fake-client-secret", regex=os.environ.get('APPCONFIGURATION_CLIENT_SECRET', "fake-client-secret")) add_general_regex_sanitizer( value="fake-tenant-id", regex=os.environ.get('APPCONFIGURATION_TENANT_ID', "fake-tenant-id")) + add_general_regex_sanitizer( + value="https://fake-key-vault.vault.azure.net/", regex="/*" + os.environ.get('APPCONFIGURATION_KEY_VAULT_REFERENCE', "fake-key-vault.vault") + "/*") + add_oauth_response_sanitizer() diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py new file mode 100644 index 000000000000..5febb75fb5f8 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py @@ -0,0 +1,60 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import functools +from devtools_testutils import EnvironmentVariableLoader +import inspect + +AppConfigProviderPreparer = functools.partial( + EnvironmentVariableLoader, + "appconfiguration", + appconfiguration_connection_string="Endpoint=https://fake-endpoint.azconfig.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=", + appconfiguration_endpoint_string="https://fake-endpoint.azconfig.io", + appconfiguration_client_id="fake-client-id", + appconfiguration_client_secret="fake-client-secret", + appconfiguration_tenant_id="fake-tenant-id", +) + + +def app_config_decorator(func, **kwargs): + @AppConfigProviderPreparer() + def wrapper(*args, **kwargs): + appconfiguration_connection_string = kwargs.pop( + "appconfiguration_connection_string") + kwargs['appconfiguration_connection_string'] = appconfiguration_connection_string + + trimmed_kwargs = {k: v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + func(*args, **trimmed_kwargs) + return wrapper + + +def app_config_decorator_aad(func, **kwargs): + @AppConfigProviderPreparer() + def wrapper(*args, **kwargs): + appconfiguration_endpoint_string = kwargs.pop( + "appconfiguration_endpoint_string") + kwargs['appconfiguration_endpoint_string'] = appconfiguration_endpoint_string + + trimmed_kwargs = {k: v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + func(*args, **trimmed_kwargs) + return wrapper + +def trim_kwargs_from_test_function(fn, kwargs): + # the next function is the actual test function. the kwargs need to be trimmed so + # that parameters which are not required will not be passed to it. + if not getattr(fn, '__is_preparer', False): + try: + args, _, kw, _, _, _, _ = inspect.getfullargspec(fn) + except AttributeError: + args, _, kw, _ = inspect.getargspec( + fn) # pylint: disable=deprecated-method + if kw is None: + args = set(args) + for key in [k for k in kwargs if k not in args]: + del kwargs[key] \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index 00cd18ebcfe0..c152eeedd3fa 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -8,9 +8,9 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Sep, 21 2022 18:39:00.013800 GMT" + "x-ms-date": "Sep, 27 2022 22:42:40.104313 GMT" }, "RequestBody": null, "StatusCode": 200, @@ -20,44 +20,44 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:39:00 GMT", + "Date": "Tue, 27 Sep 2022 22:42:40 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDQyNw==;sn=16864427", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "e49e00e4-8005-4e38-a362-ec7253675842" + "x-ms-correlation-request-id": "c7ce670d-847a-4232-93fc-a4efa00562d4" }, "ResponseBody": { "items": [ { - "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", + "etag": "RX6Uzn3YdpSnDk7SX9kzxXwDFdYhR8dGGLEXBZ6i_nM", "key": "message", "label": null, "content_type": "", "value": "hi", "tags": {}, "locked": false, - "last_modified": "2022-09-01T17:53:26\u002B00:00" + "last_modified": "2022-09-27T19:41:40\u002B00:00" }, { - "etag": "jf2AWA7sfhfRYx0rPoBxqdCf1Lfzpos0v4emLvuYP-4", + "etag": "dYgyN_oxYWzXEQN8K8d2q-4rKQJwftuzR75Jagqq_pw", "key": "my_json", "label": null, "content_type": "application/json", "value": "{\u0022key\u0022:\u0022value\u0022}", "tags": {}, "locked": false, - "last_modified": "2022-09-20T23:10:44\u002B00:00" + "last_modified": "2022-09-27T20:35:17\u002B00:00" }, { - "etag": "MUD4TSfiMxgwTqVTAlI_rNyXQz9bAPZ3VXDO-Hk_ejI", - "key": "test.message", + "etag": "7vw5ma2Cc0-eE1cnRaaCv2_VtAS8BQ5jbHP9eNS_MFA", + "key": "test.trimmed", "label": null, - "content_type": "", - "value": "Hi with test Prefix", + "content_type": "key", + "value": "key", "tags": {}, "locked": false, - "last_modified": "2022-09-01T17:53:46\u002B00:00" + "last_modified": "2022-09-27T19:58:41\u002B00:00" } ] } diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json new file mode 100644 index 000000000000..8f48737a4bb7 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json @@ -0,0 +1,47 @@ +{ + "Entries": [ + { + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=message%2A\u0026label=dev\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", + "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", + "x-ms-date": "Sep, 27 2022 22:42:40.650526 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:40 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "06221105-78da-4e5e-8239-20d1d53ea669" + }, + "ResponseBody": { + "items": [ + { + "etag": "yEiVkIl-IHlB26quPXo_Z2GbB5yQm_ENTWI2c1k1J4E", + "key": "message", + "label": "dev", + "content_type": "", + "value": "test", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T20:06:21\u002B00:00" + } + ] + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json new file mode 100644 index 000000000000..cd5910270754 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json @@ -0,0 +1,67 @@ +{ + "Entries": [ + { + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", + "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", + "x-ms-date": "Sep, 27 2022 22:42:40.490235 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:40 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "55e5698f-c69d-4645-81aa-3f25371d56a4" + }, + "ResponseBody": { + "items": [ + { + "etag": "RX6Uzn3YdpSnDk7SX9kzxXwDFdYhR8dGGLEXBZ6i_nM", + "key": "message", + "label": null, + "content_type": "", + "value": "hi", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T19:41:40\u002B00:00" + }, + { + "etag": "dYgyN_oxYWzXEQN8K8d2q-4rKQJwftuzR75Jagqq_pw", + "key": "my_json", + "label": null, + "content_type": "application/json", + "value": "{\u0022key\u0022:\u0022value\u0022}", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T20:35:17\u002B00:00" + }, + { + "etag": "7vw5ma2Cc0-eE1cnRaaCv2_VtAS8BQ5jbHP9eNS_MFA", + "key": "test.trimmed", + "label": null, + "content_type": "key", + "value": "key", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T19:58:41\u002B00:00" + } + ] + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json similarity index 65% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json rename to sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json index 274ab1b8ac7e..b63dadebf96b 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation_aad.json +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json @@ -7,7 +7,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -17,17 +17,17 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "1599", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:39:00 GMT", + "Date": "Tue, 27 Sep 2022 22:42:40 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=AuaI0l5Thi1Ph8qKgY3w55M; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", - "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrXUK8WCbx7_3eLM8Xf9iPBqq-GaEFnitho0XCJynEDnSTZtNHQ0IlZZ2H5Uh-oD7-OLVsDF-fTKQ1-MzOkg6rll2XLpIL0pCqCNbmGhPq_7QQJLyU3I4yOASYKSJvcQR2RFUji-c971-vuLC_yEQHTyrso57pHLqPC0pA2gWYR0DqeuTMgGf7cV3PXCbwlRUUPFquNO44Yfeo3D9Hyog-mTMb_xzZSzrEINr5PfIbMz0gAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", + "fpc=Aih2w7HdW0RLsLtcNXW6NJo; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", + "esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrkYxHw6mf13fuPRCu6v488gBdmaagfm2C8Q8ZiC9pB0nYYkXjS9U5w5mUTT51HcOESfBkGL6zDFmEHCECrlz_k72p8NUOMuj8OHKqWYGUIMnrKLpjfjH0i6lBviGMxCSFlnfEbzZfWev4InHJwQ2u2shZYtE7Y5Hb_K_3kYBp1RkgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", + "x-ms-ests-server": "2.1.13672.11 - NCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -105,8 +105,8 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "Cookie": "fpc=AuaI0l5Thi1Ph8qKgY3w55M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJo; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -116,16 +116,16 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "945", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:39:01 GMT", + "Date": "Tue, 27 Sep 2022 22:42:40 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": [ - "fpc=AuaI0l5Thi1Ph8qKgY3w55M; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", + "fpc=Aih2w7HdW0RLsLtcNXW6NJo; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" ], "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13622.7 - SCUS ProdSlices", + "x-ms-ests-server": "2.1.13672.11 - SCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -175,56 +175,6 @@ ] } }, - { - "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "client-request-id": "3a839a03-715b-4fc0-b093-fa24c0cfeeef", - "Connection": "keep-alive", - "Content-Length": "255", - "Content-Type": "application/x-www-form-urlencoded", - "Cookie": "fpc=AuaI0l5Thi1Ph8qKgY3w55M; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.10.7 (Windows-10-10.0.22000-SP0)", - "x-client-cpu": "x64", - "x-client-current-telemetry": "4|730,0|", - "x-client-last-telemetry": "4|0|||", - "x-client-os": "win32", - "x-client-sku": "MSAL.Python", - "x-client-ver": "1.18.0", - "x-ms-lib-capability": "retry-after, h429" - }, - "RequestBody": "client_id=fake-client-id\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=fake-client-secret\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fpython-provider.azconfig.io%2F.default", - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-store, no-cache", - "client-request-id": "3a839a03-715b-4fc0-b093-fa24c0cfeeef", - "Content-Length": "111", - "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:39:01 GMT", - "Expires": "-1", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Pragma": "no-cache", - "Set-Cookie": [ - "fpc=AuaI0l5Thi1Ph8qKgY3w55MW9qlXAQAAAEVRvdoOAAAA; expires=Fri, 21-Oct-2022 18:39:01 GMT; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.13777.4 - NCUS ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "token_type": "Bearer", - "expires_in": 86399, - "ext_expires_in": 86399, - "refresh_in": 43199, - "access_token": "Sanitized" - } - }, { "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", "RequestMethod": "GET", @@ -233,7 +183,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.10.7 (Windows-10-10.0.22000-SP0)" + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -243,44 +193,44 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Wed, 21 Sep 2022 18:39:02 GMT", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NjoxNyMxNjg2NDQyNw==;sn=16864427", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "d1f48db0-be79-4eca-a13c-7c1caf29edb5" + "x-ms-correlation-request-id": "30054af8-b684-4033-b1b5-9c071f491287" }, "ResponseBody": { "items": [ { - "etag": "RoGYeJO9kYRaIkF69f6aL0yN0lZvGExgomEA8mwYSAk", + "etag": "RX6Uzn3YdpSnDk7SX9kzxXwDFdYhR8dGGLEXBZ6i_nM", "key": "message", "label": null, "content_type": "", "value": "hi", "tags": {}, "locked": false, - "last_modified": "2022-09-01T17:53:26\u002B00:00" + "last_modified": "2022-09-27T19:41:40\u002B00:00" }, { - "etag": "jf2AWA7sfhfRYx0rPoBxqdCf1Lfzpos0v4emLvuYP-4", + "etag": "dYgyN_oxYWzXEQN8K8d2q-4rKQJwftuzR75Jagqq_pw", "key": "my_json", "label": null, "content_type": "application/json", "value": "{\u0022key\u0022:\u0022value\u0022}", "tags": {}, "locked": false, - "last_modified": "2022-09-20T23:10:44\u002B00:00" + "last_modified": "2022-09-27T20:35:17\u002B00:00" }, { - "etag": "MUD4TSfiMxgwTqVTAlI_rNyXQz9bAPZ3VXDO-Hk_ejI", - "key": "test.message", + "etag": "7vw5ma2Cc0-eE1cnRaaCv2_VtAS8BQ5jbHP9eNS_MFA", + "key": "test.trimmed", "label": null, - "content_type": "", - "value": "Hi with test Prefix", + "content_type": "key", + "value": "key", "tags": {}, "locked": false, - "last_modified": "2022-09-01T17:53:46\u002B00:00" + "last_modified": "2022-09-27T19:58:41\u002B00:00" } ] } diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json new file mode 100644 index 000000000000..8daf37f02eef --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json @@ -0,0 +1,219 @@ +{ + "Entries": [ + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1599", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAgAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - EUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAgAAAGBzxdoOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAgAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - SCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=message%2A\u0026label=dev\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "98fc8948-d720-480a-a4f8-837e65f57cd0" + }, + "ResponseBody": { + "items": [ + { + "etag": "yEiVkIl-IHlB26quPXo_Z2GbB5yQm_ENTWI2c1k1J4E", + "key": "message", + "label": "dev", + "content_type": "", + "value": "test", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T20:06:21\u002B00:00" + } + ] + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json new file mode 100644 index 000000000000..78700e7ff862 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json @@ -0,0 +1,239 @@ +{ + "Entries": [ + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1599", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAQAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - NCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAQAAAGBzxdoOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAQAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:41 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - EUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=%00\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:41 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "902e6b7c-5cfa-45b1-a567-c8ca2469af77" + }, + "ResponseBody": { + "items": [ + { + "etag": "RX6Uzn3YdpSnDk7SX9kzxXwDFdYhR8dGGLEXBZ6i_nM", + "key": "message", + "label": null, + "content_type": "", + "value": "hi", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T19:41:40\u002B00:00" + }, + { + "etag": "dYgyN_oxYWzXEQN8K8d2q-4rKQJwftuzR75Jagqq_pw", + "key": "my_json", + "label": null, + "content_type": "application/json", + "value": "{\u0022key\u0022:\u0022value\u0022}", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T20:35:17\u002B00:00" + }, + { + "etag": "7vw5ma2Cc0-eE1cnRaaCv2_VtAS8BQ5jbHP9eNS_MFA", + "key": "test.trimmed", + "label": null, + "content_type": "key", + "value": "key", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T19:58:41\u002B00:00" + } + ] + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json new file mode 100644 index 000000000000..a75dbd8379b1 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json @@ -0,0 +1,462 @@ +{ + "Entries": [ + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1599", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAwAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:42 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - SCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAwAAAGBzxdoOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAwAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:42 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - NCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=prod\u0026api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Correlation-Context": "RequestType=Startup,UsesKeyVault", + "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "362c7696-90d5-42fc-85b1-a28493c8db0a" + }, + "ResponseBody": { + "items": [ + { + "etag": "cuoTxCSuBxPyk2kTGtNoy7AiY8kwWEvkhEM4hVmSZxA", + "key": "secret", + "label": "prod", + "content_type": "application/vnd.microsoft.appconfig.keyvaultref\u002Bjson;charset=utf-8", + "value": "{\u0022uri\u0022:\u0022https://fake-key-vault.vault.azure.net/secrets/secret\u0022}", + "tags": {}, + "locked": false, + "last_modified": "2022-09-27T21:30:56\u002B00:00" + } + ] + } + }, + { + "RequestUri": "https://fake-key-vault.vault.azure.net/secrets/secret/?api-version=7.3", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-keyvault-secrets/4.7.0b1 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 401, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "97", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000;includeSubDomains", + "WWW-Authenticate": "Bearer authorization=\u0022https://login.windows.net/fake-tenant-id\u0022, resource=\u0022https://vault.azure.net\u0022", + "X-Content-Type-Options": "nosniff", + "x-ms-keyvault-network-info": "conn_type=Ipv4;addr=131.107.1.245;act_addr_fam=InterNetwork;", + "x-ms-keyvault-region": "northcentralus", + "x-ms-keyvault-service-version": "1.9.538.1" + }, + "ResponseBody": { + "error": { + "code": "Unauthorized", + "message": "AKV10000: Request is missing a Bearer or PoP token." + } + } + }, + { + "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "1599", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:42 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNBAAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:43 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - SCUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", + "token_endpoint_auth_methods_supported": [ + "client_secret_post", + "private_key_jwt", + "client_secret_basic" + ], + "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", + "response_modes_supported": [ + "query", + "fragment", + "form_post" + ], + "subject_types_supported": [ + "pairwise" + ], + "id_token_signing_alg_values_supported": [ + "RS256" + ], + "response_types_supported": [ + "code", + "id_token", + "code id_token", + "id_token token" + ], + "scopes_supported": [ + "openid", + "profile", + "email", + "offline_access" + ], + "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", + "request_uri_parameter_supported": false, + "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", + "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", + "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", + "claims_supported": [ + "sub", + "iss", + "cloud_instance_name", + "cloud_instance_host_name", + "cloud_graph_host_name", + "msgraph_host", + "aud", + "exp", + "iat", + "auth_time", + "acr", + "nonce", + "preferred_username", + "name", + "tid", + "ver", + "at_hash", + "c_hash", + "email" + ], + "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", + "tenant_region_scope": "WW", + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com", + "rbac_url": "https://pas.windows.net" + } + }, + { + "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNBAAAAGBzxdoOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", + "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Methods": "GET, OPTIONS", + "Access-Control-Allow-Origin": "*", + "Cache-Control": "max-age=86400, private", + "Content-Length": "945", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:43 GMT", + "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", + "Set-Cookie": [ + "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNBAAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:43 GMT; path=/; secure; HttpOnly; SameSite=None", + "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", + "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" + ], + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-ests-server": "2.1.13672.11 - EUS ProdSlices", + "X-XSS-Protection": "0" + }, + "ResponseBody": { + "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", + "api-version": "1.1", + "metadata": [ + { + "preferred_network": "login.microsoftonline.com", + "preferred_cache": "login.windows.net", + "aliases": [ + "login.microsoftonline.com", + "login.windows.net", + "login.microsoft.com", + "sts.windows.net" + ] + }, + { + "preferred_network": "login.partner.microsoftonline.cn", + "preferred_cache": "login.partner.microsoftonline.cn", + "aliases": [ + "login.partner.microsoftonline.cn", + "login.chinacloudapi.cn" + ] + }, + { + "preferred_network": "login.microsoftonline.de", + "preferred_cache": "login.microsoftonline.de", + "aliases": [ + "login.microsoftonline.de" + ] + }, + { + "preferred_network": "login.microsoftonline.us", + "preferred_cache": "login.microsoftonline.us", + "aliases": [ + "login.microsoftonline.us", + "login.usgovcloudapi.net" + ] + }, + { + "preferred_network": "login-us.microsoftonline.com", + "preferred_cache": "login-us.microsoftonline.com", + "aliases": [ + "login-us.microsoftonline.com" + ] + } + ] + } + }, + { + "RequestUri": "https://fake-key-vault.vault.azure.net/secrets/secret/?api-version=7.3", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-keyvault-secrets/4.7.0b1 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "258", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 27 Sep 2022 22:42:43 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000;includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-keyvault-network-info": "conn_type=Ipv4;addr=131.107.1.245;act_addr_fam=InterNetwork;", + "x-ms-keyvault-region": "northcentralus", + "x-ms-keyvault-service-version": "1.9.538.1" + }, + "ResponseBody": { + "value": "my-secret", + "id": "https://fake-key-vault.vault.azure.net/secrets/secret/efa8cdd8eef24d3b8d0ad36d9804af45", + "attributes": { + "enabled": true, + "created": 1664314220, + "updated": 1664314220, + "recoveryLevel": "Recoverable\u002BPurgeable", + "recoverableDays": 90 + }, + "tags": {} + } + } + ], + "Variables": {} +} diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py index fb656449fc8e..fe1642864cf6 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py @@ -3,87 +3,46 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -import functools -from azure.appconfigurationprovider import AzureAppConfigurationProvider -from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy -from azure.appconfiguration import AzureAppConfigurationClient -import inspect - -AppConfigProviderPreparer = functools.partial( - EnvironmentVariableLoader, - "appconfiguration", - appconfiguration_connection_string="Endpoint=https://fake-endpoint.azconfig.io;Id=0-l4-s0:h5htBaY5Z1LwFz50bIQv;Secret=lamefakesecretlamefakesecretlamefakesecrett=", - appconfiguration_endpoint_string="https://fake-endpoint.azconfig.io", - appconfiguration_client_id="fake-client-id", - appconfiguration_client_secret="fake-client-secret", - appconfiguration_tenant_id="fake-tenant-id", +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + SettingSelector ) - - -def app_config_decorator(func, **kwargs): - @AppConfigProviderPreparer() - def wrapper(*args, **kwargs): - appconfiguration_connection_string = kwargs.pop( - "appconfiguration_connection_string") - kwargs['appconfiguration_connection_string'] = appconfiguration_connection_string - - trimmed_kwargs = {k: v for k, v in kwargs.items()} - trim_kwargs_from_test_function(func, trimmed_kwargs) - - func(*args, **trimmed_kwargs) - return wrapper - - -def app_config_decorator_aad(func, **kwargs): - @AppConfigProviderPreparer() - def wrapper(*args, **kwargs): - appconfiguration_endpoint_string = kwargs.pop( - "appconfiguration_endpoint_string") - kwargs['appconfiguration_endpoint_string'] = appconfiguration_endpoint_string - - trimmed_kwargs = {k: v for k, v in kwargs.items()} - trim_kwargs_from_test_function(func, trimmed_kwargs) - - func(*args, **trimmed_kwargs) - return wrapper - - -def trim_kwargs_from_test_function(fn, kwargs): - # the next function is the actual test function. the kwargs need to be trimmed so - # that parameters which are not required will not be passed to it. - if not getattr(fn, '__is_preparer', False): - try: - args, _, kw, _, _, _, _ = inspect.getfullargspec(fn) - except AttributeError: - args, _, kw, _ = inspect.getargspec( - fn) # pylint: disable=deprecated-method - if kw is None: - args = set(args) - for key in [k for k in kwargs if k not in args]: - del kwargs[key] - +from devtools_testutils import ( + AzureRecordedTestCase, + recorded_by_proxy +) +from azure.appconfiguration import AzureAppConfigurationClient +from preparers import app_config_decorator class TestAppConfigurationProvider(AzureRecordedTestCase): - def build_provider_aad(self, endpoint): - cred = self.get_credential(AzureAppConfigurationClient) - return AzureAppConfigurationProvider.load(endpoint=endpoint, credential=cred) - - def build_provider(self, connection_string): - return AzureAppConfigurationProvider.load(connection_string=connection_string) + def build_provider(self, connection_string, trimmed_key_prefixes=[], selects={SettingSelector("*", "\0")}): + return AzureAppConfigurationProvider.load(connection_string=connection_string, trimmed_key_prefixes=trimmed_key_prefixes, selects=selects) # method: provider_creation @recorded_by_proxy @app_config_decorator def test_provider_creation(self, appconfiguration_connection_string): - client = self.build_provider(appconfiguration_connection_string) assert client["message"] == "hi" + assert client["my_json"]["key"] == "value" - # method: provider_creation_aad + # method: provider_trimmed_key_prefixes @recorded_by_proxy - @app_config_decorator_aad - def test_provider_creation_aad(self, appconfiguration_endpoint_string): - - client = self.build_provider_aad(appconfiguration_endpoint_string) + @app_config_decorator + def test_provider_trimmed_key_prefixes(self, appconfiguration_connection_string): + trimmed = {"test."} + client = self.build_provider(appconfiguration_connection_string, trimmed_key_prefixes=trimmed) assert client["message"] == "hi" + assert client["my_json"]["key"] == "value" + assert client["trimmed"] == "key" + assert "test.trimmed" not in client + + # method: provider_selectors + @recorded_by_proxy + @app_config_decorator + def test_provider_selectors(self, appconfiguration_connection_string): + selects = {SettingSelector("message*", "dev")} + client = self.build_provider(appconfiguration_connection_string, selects=selects) + assert client["message"] == "test" + assert "test.trimmed" not in client diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py new file mode 100644 index 000000000000..b5735df3704d --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py @@ -0,0 +1,49 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + SettingSelector +) +from devtools_testutils import ( + AzureRecordedTestCase, + recorded_by_proxy +) +from azure.appconfiguration import AzureAppConfigurationClient +from preparers import app_config_decorator_aad + +class TestAppConfigurationProvider(AzureRecordedTestCase): + + def build_provider_aad(self, endpoint, trimmed_key_prefixes=[], selects={SettingSelector("*", "\0")}): + cred = self.get_credential(AzureAppConfigurationClient) + return AzureAppConfigurationProvider.load(endpoint=endpoint,credential=cred, trimmed_key_prefixes=trimmed_key_prefixes, selects=selects) + + # method: provider_creation_aad + @recorded_by_proxy + @app_config_decorator_aad + def test_provider_creation_aad(self, appconfiguration_endpoint_string): + client = self.build_provider_aad(appconfiguration_endpoint_string) + assert client["message"] == "hi" + assert client["my_json"]["key"] == "value" + + # method: provider_trimmed_key_prefixes + @recorded_by_proxy + @app_config_decorator_aad + def test_provider_trimmed_key_prefixes(self, appconfiguration_endpoint_string): + trimmed = {"test."} + client = self.build_provider_aad(appconfiguration_endpoint_string, trimmed_key_prefixes=trimmed) + assert client["message"] == "hi" + assert client["my_json"]["key"] == "value" + assert client["trimmed"] == "key" + assert "test.trimmed" not in client + + # method: provider_selectors + @recorded_by_proxy + @app_config_decorator_aad + def test_provider_selectors(self, appconfiguration_endpoint_string): + selects = {SettingSelector("message*", "dev")} + client = self.build_provider_aad(appconfiguration_endpoint_string, selects=selects) + assert client["message"] == "test" + assert "test.trimmed" not in client \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py new file mode 100644 index 000000000000..6e42cbc9cbb8 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py @@ -0,0 +1,30 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from azure.appconfigurationprovider import ( + AzureAppConfigurationProvider, + SettingSelector, + AzureAppConfigurationKeyVaultOptions +) +from devtools_testutils import ( + AzureRecordedTestCase, + recorded_by_proxy +) +from azure.appconfiguration import AzureAppConfigurationClient +from preparers import app_config_decorator_aad + +class TestAppConfigurationProvider(AzureRecordedTestCase): + + def build_provider_aad(self, endpoint, key_vault_options): + cred = self.get_credential(AzureAppConfigurationClient) + return AzureAppConfigurationProvider.load(endpoint=endpoint,credential=cred, selects=[SettingSelector("*", "prod")], key_vault_options=key_vault_options) + + # method: provider_with_key_vault + @recorded_by_proxy + @app_config_decorator_aad + def test_provider_with_key_vault(self, appconfiguration_endpoint_string): + key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=self.get_credential(AzureAppConfigurationClient)) + client = self.build_provider_aad(appconfiguration_endpoint_string, key_vault_options=key_vault_options) + assert client["secret"] == "my-secret" \ No newline at end of file From d28b57eb071ae3a78ff806c771b5dd99a68b7ab8 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 28 Sep 2022 09:45:23 -0700 Subject: [PATCH 114/129] Fixed Linting --- .../appconfigurationprovider/_azureappconfigurationprovider.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 7d2bbb4a6cb1..391ea465bad7 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -136,7 +136,8 @@ def __resolve_keyvault_reference(config, key_vault_options, secret_clients): if referenced_client: try: - return referenced_client.get_secret(key_vault_identifier.name, version=key_vault_identifier.version).value + return referenced_client.get_secret(key_vault_identifier.name, + version=key_vault_identifier.version).value except ResourceNotFoundError: raise KeyVaultReferenceError("Key Vault %s does not contain secret %s" % ( key_vault_identifier.vault_url, key_vault_identifier.name)) From 9da907d1551b03c2bf03d2c36c60f7582597e1c0 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 29 Sep 2022 09:09:08 -0700 Subject: [PATCH 115/129] Fixing Auto Format --- .../azure/__init__.py | 3 +- .../appconfigurationprovider/__init__.py | 6 +- .../_azure_appconfiguration_provider_error.py | 1 + .../_azureappconfigurationkeyvaultoptions.py | 1 + .../_azureappconfigurationprovider.py | 66 +++++++++---------- .../appconfigurationprovider/_constants.py | 2 +- .../_settingselector.py | 1 + .../appconfigurationprovider/_user_agent.py | 4 +- 8 files changed, 39 insertions(+), 45 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py index 229d1b3c8804..d55ccad1f573 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py @@ -1,2 +1 @@ -__path__ = __import__("pkgutil").extend_path( - __path__, __name__) # type: ignore +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py index 1ef7efc3de32..a29ac854e457 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py @@ -11,8 +11,4 @@ from ._version import VERSION __version__ = VERSION -__all__ = [ - "AzureAppConfigurationProvider", - "AzureAppConfigurationKeyVaultOptions", - "SettingSelector" -] +__all__ = ["AzureAppConfigurationProvider", "AzureAppConfigurationKeyVaultOptions", "SettingSelector"] diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py index 0bc4fdb0c0b3..3c7021cb71ba 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py @@ -4,5 +4,6 @@ # license information. # ------------------------------------------------------------------------- + class KeyVaultReferenceError(ValueError): """Raised when a Key Vault reference is invalid.""" diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py index d640015c0695..7a6519e1b9be 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py @@ -4,6 +4,7 @@ # license information. # ------------------------------------------------------------------------- + class AzureAppConfigurationKeyVaultOptions: """ Options for connecting to Key Vault. diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py index 391ea465bad7..203ebf6165ca 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py @@ -6,10 +6,7 @@ import json from azure.appconfiguration import AzureAppConfigurationClient -from azure.keyvault.secrets import ( - SecretClient, - KeyVaultSecretIdentifier -) +from azure.keyvault.secrets import SecretClient, KeyVaultSecretIdentifier from azure.core.exceptions import ResourceNotFoundError from ._settingselector import SettingSelector from ._azure_appconfiguration_provider_error import KeyVaultReferenceError @@ -53,13 +50,11 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): key_vault_options = kwargs.pop("key_vault_options", None) - provider.__buildprovider(connection_string, endpoint, - credential, key_vault_options) + provider.__buildprovider(connection_string, endpoint, credential, key_vault_options) selects = kwargs.pop("selects", {SettingSelector("*", "\0")}) - provider._trim_prefixes = sorted(kwargs.pop( - "trimmed_key_prefixes", []), key=len, reverse=True) + provider._trim_prefixes = sorted(kwargs.pop("trimmed_key_prefixes", []), key=len, reverse=True) provider._dict = {} @@ -67,14 +62,15 @@ def load(cls, connection_string=None, endpoint=None, credential=None, **kwargs): for select in selects: configurations = provider._client.list_configuration_settings( - key_filter=select.key_filter, label_filter=select.label_filter) + key_filter=select.key_filter, label_filter=select.label_filter + ) for config in configurations: trimmed_key = config.key # Trim the key if it starts with one of the prefixes provided for trim in provider._trim_prefixes: if config.key.startswith(trim): - trimmed_key = config.key[len(trim):] + trimmed_key = config.key[len(trim) :] break if config.content_type == KEY_VAULT_REFERENCE_CONTENT_TYPE: @@ -95,58 +91,60 @@ def __buildprovider(self, connection_string, endpoint, credential, key_vault_opt headers = {} correlation_context = "RequestType=Startup" - if (key_vault_options and - (key_vault_options.credential or - key_vault_options.secret_clients or key_vault_options.secret_resolver)): + if key_vault_options and ( + key_vault_options.credential or key_vault_options.secret_clients or key_vault_options.secret_resolver + ): correlation_context += ",UsesKeyVault" headers["Correlation-Context"] = correlation_context useragent = USER_AGENT - if (connection_string and endpoint): - raise AttributeError( - "Both connection_string and endpoint are set. Only one of these should be set.") + if connection_string and endpoint: + raise AttributeError("Both connection_string and endpoint are set. Only one of these should be set.") if connection_string: self._client = AzureAppConfigurationClient.from_connection_string( - connection_string, user_agent=useragent, headers=headers) + connection_string, user_agent=useragent, headers=headers + ) return - self._client = AzureAppConfigurationClient( - endpoint, credential, user_agent=useragent, headers=headers) + self._client = AzureAppConfigurationClient(endpoint, credential, user_agent=useragent, headers=headers) @staticmethod def __resolve_keyvault_reference(config, key_vault_options, secret_clients): if key_vault_options is None: - raise AttributeError( - "Key Vault options must be set to resolve Key Vault references.") + raise AttributeError("Key Vault options must be set to resolve Key Vault references.") if config.secret_id is None: - raise AttributeError( - "Key Vault reference must have a uri value.") + raise AttributeError("Key Vault reference must have a uri value.") key_vault_identifier = KeyVaultSecretIdentifier(config.secret_id) referenced_client = next( - (client for client in secret_clients if client.vault_url == key_vault_identifier.vault_url), None) + (client for client in secret_clients if client.vault_url == key_vault_identifier.vault_url), None + ) if referenced_client is None and key_vault_options.credential is not None: referenced_client = SecretClient( - vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential) + vault_url=key_vault_identifier.vault_url, credential=key_vault_options.credential + ) secret_clients[key_vault_identifier.vault_url] = referenced_client if referenced_client: try: - return referenced_client.get_secret(key_vault_identifier.name, - version=key_vault_identifier.version).value + return referenced_client.get_secret( + key_vault_identifier.name, version=key_vault_identifier.version + ).value except ResourceNotFoundError: - raise KeyVaultReferenceError("Key Vault %s does not contain secret %s" % ( - key_vault_identifier.vault_url, key_vault_identifier.name)) - + raise KeyVaultReferenceError( + "Key Vault %s does not contain secret %s" + % (key_vault_identifier.vault_url, key_vault_identifier.name) + ) if key_vault_options.secret_resolver is not None: return key_vault_options.secret_resolver(config.secret_id) raise KeyVaultReferenceError( - "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url)) + "No Secret Client found for Key Vault reference %s" % (key_vault_identifier.vault_url) + ) @staticmethod def __is_json_content_type(content_type): @@ -154,9 +152,9 @@ def __is_json_content_type(content_type): return False content_type = content_type.strip().lower() - mime_type = content_type.split(';')[0].strip() + mime_type = content_type.split(";")[0].strip() - type_parts = mime_type.split('/') + type_parts = mime_type.split("/") if len(type_parts) != 2: return False @@ -164,7 +162,7 @@ def __is_json_content_type(content_type): if main_type != "application": return False - sub_types = sub_type.split('+') + sub_types = sub_type.split("+") if "json" in sub_types: return True diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py index 913b7e142627..eb9425333a1d 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py @@ -4,4 +4,4 @@ # license information. # ------------------------------------------------------------------------- -KEY_VAULT_REFERENCE_CONTENT_TYPE = u"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" +KEY_VAULT_REFERENCE_CONTENT_TYPE = "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8" diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py index c56d6ca8ae80..bef1b4668a6b 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py @@ -4,6 +4,7 @@ # license information. # ------------------------------------------------------------------------- + class SettingSelector: """ Selects a set of configuration settings from Azure App Configuration. diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py index b75e8a607e9f..429a07c30051 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py @@ -6,6 +6,4 @@ from ._version import VERSION -USER_AGENT = "python-appconfigurationprovider/{}".format( - VERSION -) +USER_AGENT = "python-appconfigurationprovider/{}".format(VERSION) From f46b1ab71ceb3553296985bc91a1d850b76c9495 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 6 Oct 2022 10:15:10 -0700 Subject: [PATCH 116/129] Fixing Key Vault Reference Test --- .../tests/test_provider_key_vault_reference.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py index 6e42cbc9cbb8..e77f5adebadb 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py +++ b/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py @@ -8,6 +8,7 @@ SettingSelector, AzureAppConfigurationKeyVaultOptions ) +from azure.keyvault.secrets import SecretClient from devtools_testutils import ( AzureRecordedTestCase, recorded_by_proxy @@ -25,6 +26,7 @@ def build_provider_aad(self, endpoint, key_vault_options): @recorded_by_proxy @app_config_decorator_aad def test_provider_with_key_vault(self, appconfiguration_endpoint_string): - key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=self.get_credential(AzureAppConfigurationClient)) + key_vault_cred = self.get_credential(SecretClient) + key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=key_vault_cred) client = self.build_provider_aad(appconfiguration_endpoint_string, key_vault_options=key_vault_options) assert client["secret"] == "my-secret" \ No newline at end of file From a1feea8e7dc312edcf9c0276217adba9fbc374f3 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 6 Oct 2022 11:20:42 -0700 Subject: [PATCH 117/129] Trying to update the package name --- .../CHANGELOG.md | 0 .../LICENSE | 0 .../MANIFEST.in | 0 .../README.md | 0 .../azure/__init__.py | 0 .../azure/appconfiguration/__init__.py | 1 + .../appconfiguration/provider}/__init__.py | 0 .../_azure_appconfiguration_provider_error.py | 0 .../_azureappconfigurationkeyvaultoptions.py | 0 .../_azureappconfigurationprovider.py | 0 .../appconfiguration/provider}/_constants.py | 0 .../provider}/_settingselector.py | 0 .../appconfiguration/provider}/_user_agent.py | 2 +- .../appconfiguration/provider}/_version.py | 0 .../azure/appconfiguration/provider}/py.typed | 0 .../dev_requirements.txt | 0 .../mypy.ini | 0 .../samples/README.md | 2 +- .../samples/aad_sample.py | 2 +- .../samples/connection_string_sample.py | 2 +- ...vault_reference_provided_clients_sample.py | 2 +- .../samples/key_vault_reference_sample.py | 2 +- .../sdk_packaging.toml | 2 +- .../setup.py | 4 +- .../tests/conftest.py | 0 .../tests/preparers.py | 0 ...urationProvidertest_provider_creation.json | 4 +- ...rationProvidertest_provider_selectors.json | 4 +- ...dertest_provider_trimmed_key_prefixes.json | 4 +- ...ionProvidertest_provider_creation_aad.json | 4 +- ...rationProvidertest_provider_selectors.json | 4 +- ...dertest_provider_trimmed_key_prefixes.json | 4 +- ...nProvidertest_provider_with_key_vault.json | 4 +- .../tests/test_provider.py | 2 +- .../tests/test_provider_aad.py | 2 +- .../test_provider_key_vault_reference.py | 2 +- sdk/appconfiguration/ci.yml | 38 +++++++++---------- shared_requirements.txt | 2 +- 38 files changed, 47 insertions(+), 46 deletions(-) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/CHANGELOG.md (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/LICENSE (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/MANIFEST.in (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/README.md (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/azure/__init__.py (100%) create mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/__init__.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_azure_appconfiguration_provider_error.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_azureappconfigurationkeyvaultoptions.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_azureappconfigurationprovider.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_constants.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_settingselector.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_user_agent.py (83%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/_version.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider/azure/appconfigurationprovider => azure-appconfiguration-provider/azure/appconfiguration/provider}/py.typed (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/dev_requirements.txt (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/mypy.ini (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/samples/README.md (97%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/samples/aad_sample.py (96%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/samples/connection_string_sample.py (96%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/samples/key_vault_reference_provided_clients_sample.py (96%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/samples/key_vault_reference_sample.py (95%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/sdk_packaging.toml (79%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/setup.py (96%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/conftest.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/preparers.py (100%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json (95%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json (93%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json (95%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json (98%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json (98%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json (98%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json (99%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/test_provider.py (97%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/test_provider_aad.py (97%) rename sdk/appconfiguration/{azure-appconfigurationprovider => azure-appconfiguration-provider}/tests/test_provider_key_vault_reference.py (96%) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/CHANGELOG.md rename to sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/LICENSE b/sdk/appconfiguration/azure-appconfiguration-provider/LICENSE similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/LICENSE rename to sdk/appconfiguration/azure-appconfiguration-provider/LICENSE diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in b/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/MANIFEST.in rename to sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/README.md similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/README.md rename to sdk/appconfiguration/azure-appconfiguration-provider/README.md diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/__init__.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py new file mode 100644 index 000000000000..d55ccad1f573 --- /dev/null +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/__init__.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/__init__.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azure_appconfiguration_provider_error.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azure_appconfiguration_provider_error.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azure_appconfiguration_provider_error.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationkeyvaultoptions.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationkeyvaultoptions.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_azureappconfigurationprovider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_constants.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_settingselector.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_settingselector.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py similarity index 83% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py index 429a07c30051..62961551d751 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_user_agent.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_user_agent.py @@ -6,4 +6,4 @@ from ._version import VERSION -USER_AGENT = "python-appconfigurationprovider/{}".format(VERSION) +USER_AGENT = "python-appconfiguration-provider/{}".format(VERSION) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_version.py b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/_version.py rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/py.typed b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/py.typed similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/azure/appconfigurationprovider/py.typed rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/py.typed diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/dev_requirements.txt rename to sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/mypy.ini b/sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/mypy.ini rename to sdk/appconfiguration/azure-appconfiguration-provider/mypy.ini diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/README.md b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md similarity index 97% rename from sdk/appconfiguration/azure-appconfigurationprovider/samples/README.md rename to sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md index 166e5da217f5..6eed2a4059e4 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/README.md +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md @@ -39,7 +39,7 @@ az appconfig kv set-keyvault --name --key secret --secret-id Install the Azure App Configuration Provider client library for Python with pip: ```commandline -pip install provider +pip install azure.appconfiguration.provider ``` ## Contents diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py similarity index 96% rename from sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py rename to sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py index c525bc02f88b..4c875ad53b86 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/aad_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py similarity index 96% rename from sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py rename to sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py index d531643e8c56..c18a5f989fbb 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/connection_string_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_provided_clients_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py similarity index 96% rename from sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_provided_clients_sample.py rename to sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py index 9151f1a699ef..8d67f617c34c 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_provided_clients_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_provided_clients_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_sample.py b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py similarity index 95% rename from sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_sample.py rename to sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py index a66664f34bcf..4e02cb434197 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/samples/key_vault_reference_sample.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/samples/key_vault_reference_sample.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, AzureAppConfigurationKeyVaultOptions, SettingSelector diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/sdk_packaging.toml b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml similarity index 79% rename from sdk/appconfiguration/azure-appconfigurationprovider/sdk_packaging.toml rename to sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml index 32efea5975a9..7d93f77a90ba 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/sdk_packaging.toml +++ b/sdk/appconfiguration/azure-appconfiguration-provider/sdk_packaging.toml @@ -1,5 +1,5 @@ [packaging] -package_name = "azure-appconfigurationprovider" +package_name = "azure-appconfiguration-provider" package_nspkg = "azure-data-nspkg" package_pprint_name = "App Configuration Provider" package_doc_id = "" diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py similarity index 96% rename from sdk/appconfiguration/azure-appconfigurationprovider/setup.py rename to sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 7d82158a004a..8da1268eb78b 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -13,7 +13,7 @@ from setuptools import find_packages, setup # Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-appconfigurationprovider" +PACKAGE_NAME = "azure-appconfiguration-provider" PACKAGE_PPRINT_NAME = "App Configuration Provider" # a-b-c => a/b/c @@ -55,7 +55,7 @@ license="MIT License", author="Microsoft Corporation", author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfigurationprovider", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration-provider", classifiers=[ "Development Status :: 5 - Production/Stable", "Programming Language :: Python", diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/conftest.py rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/preparers.py similarity index 100% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/preparers.py rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/preparers.py diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json similarity index 95% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json index c152eeedd3fa..fd5b1bf899c6 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_creation.json @@ -8,7 +8,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", "x-ms-date": "Sep, 27 2022 22:42:40.104313 GMT" }, @@ -64,4 +64,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json similarity index 93% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json index 8f48737a4bb7..525dccf8aaab 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_selectors.json @@ -8,7 +8,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", "x-ms-date": "Sep, 27 2022 22:42:40.650526 GMT" }, @@ -44,4 +44,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json similarity index 95% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json index cd5910270754..6faf86a93e30 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json @@ -8,7 +8,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", "x-ms-date": "Sep, 27 2022 22:42:40.490235 GMT" }, @@ -64,4 +64,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json similarity index 98% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json index b63dadebf96b..2d4e0036340f 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_creation_aad.json @@ -183,7 +183,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -237,4 +237,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json similarity index 98% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json index 8daf37f02eef..692dc3e00582 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_selectors.json @@ -182,7 +182,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -216,4 +216,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json similarity index 98% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json index 78700e7ff862..ae777e18c7df 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_aad.pyTestAppConfigurationProvidertest_provider_trimmed_key_prefixes.json @@ -182,7 +182,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -236,4 +236,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json similarity index 99% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json index a75dbd8379b1..296e19128463 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json @@ -182,7 +182,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Correlation-Context": "RequestType=Startup,UsesKeyVault", - "User-Agent": "python-appconfigurationprovider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" + "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" }, "RequestBody": null, "StatusCode": 200, @@ -459,4 +459,4 @@ } ], "Variables": {} -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py similarity index 97% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py index fe1642864cf6..ec14c4a5bad8 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_aad.py similarity index 97% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_aad.py index b5735df3704d..5ab9351a2828 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_aad.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_aad.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector ) diff --git a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py similarity index 96% rename from sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py rename to sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py index e77f5adebadb..92a8fd49a95d 100644 --- a/sdk/appconfiguration/azure-appconfigurationprovider/tests/test_provider_key_vault_reference.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from azure.appconfigurationprovider import ( +from azure.appconfiguration.provider import ( AzureAppConfigurationProvider, SettingSelector, AzureAppConfigurationKeyVaultOptions diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index 2fabc82a86e7..f810c578ebc8 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -3,27 +3,27 @@ trigger: branches: include: - - main - - hotfix/* - - release/* - - restapi* + - main + - hotfix/* + - release/* + - restapi* paths: include: - - sdk/appconfiguration/ - - sdk/core/ + - sdk/appconfiguration/ + - sdk/core/ pr: branches: include: - - main - - feature/* - - hotfix/* - - release/* - - restapi* + - main + - feature/* + - hotfix/* + - release/* + - restapi* paths: include: - - sdk/appconfiguration/ - - sdk/core/ + - sdk/appconfiguration/ + - sdk/core/ extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -34,9 +34,9 @@ extends: ValidateFormatting: false TestProxy: true Artifacts: - - name: azure-appconfiguration - safeName: azureappconfiguration - - name: azure-appconfigurationprovider - safeName: azureappconfigurationprovider - - name: azure-mgmt-appconfiguration - safeName: azuremgmtappconfiguration \ No newline at end of file + - name: azure-appconfiguration + safeName: azureappconfiguration + - name: azure-appconfiguration-provider + safeName: azureappconfigurationprovider + - name: azure-mgmt-appconfiguration + safeName: azuremgmtappconfiguration diff --git a/shared_requirements.txt b/shared_requirements.txt index e4c9dbc8cd7f..79bec04f6594 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -186,7 +186,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-eventhub-checkpointstoretable azure-core<2.0.0,>=1.14.0 #override azure-eventhub uamqp>=1.6.0,<2.0.0 #override azure-appconfiguration azure-core<2.0.0,>=1.24.0 -#override azure-appconfigurationprovider azure-keyvault-secrets<5.0.0,>=4.3.0 +#override azure-appconfiguration-provider azure-keyvault-secrets<5.0.0,>=4.3.0 #override azure-servicebus uamqp>=1.5.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 #override azure-servicebus azure-core<2.0.0,>=1.14.0 From e1bd5b494fc6aadc355c2f72b3caa16f06bf0e5a Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 6 Oct 2022 14:35:26 -0700 Subject: [PATCH 118/129] Removing Extra TestProxy --- sdk/appconfiguration/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/appconfiguration/ci.yml b/sdk/appconfiguration/ci.yml index 640cf67c55c1..05db4ccc96ca 100644 --- a/sdk/appconfiguration/ci.yml +++ b/sdk/appconfiguration/ci.yml @@ -32,11 +32,10 @@ extends: ServiceDirectory: appconfiguration VerifyAutorest: false ValidateFormatting: false - TestProxy: true Artifacts: - name: azure-appconfiguration safeName: azureappconfiguration - name: azure-appconfiguration-provider safeName: azureappconfigurationprovider - name: azure-mgmt-appconfiguration - safeName: azuremgmtappconfiguration \ No newline at end of file + safeName: azuremgmtappconfiguration From 16c3795b22c8dfa12b1b929218ccc44bf298433d Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Thu, 6 Oct 2022 14:59:31 -0700 Subject: [PATCH 119/129] Not -e installing azure-appconfiguration --- .../azure-appconfiguration-provider/dev_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt index c811a688cdf7..7fd325b294f8 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt +++ b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt @@ -1,6 +1,6 @@ -e ../../../tools/azure-devtools ../../core/azure-core --e ../azure-appconfiguration +../azure-appconfiguration -e ../../identity/azure-identity -e ../../keyvault/azure-keyvault-secrets aiohttp>=3.0 From acf1b9c95cc4cf099f43169c5150878f7552229b Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Thu, 6 Oct 2022 15:54:01 -0700 Subject: [PATCH 120/129] updates --- .../azure-appconfiguration-provider/MANIFEST.in | 4 +++- .../azure/appconfiguration/{provider => }/py.typed | 0 .../azure-appconfiguration-provider/dev_requirements.txt | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/{provider => }/py.typed (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in b/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in index 4bb4e84cc2d6..b3ffd92a2185 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in +++ b/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in @@ -2,6 +2,8 @@ recursive-include tests *.py include *.md include LICENSE include azure/__init__.py +include azure/appconfiguration/__init__.py +include azure/appconfiguration/provider/*.py recursive-include samples *.py *.md recursive-include doc *.rst -include azure/provider/py.typed \ No newline at end of file +include azure/appconfiguration/py.typed \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/py.typed b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/py.typed similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/py.typed rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/py.typed diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt index 7fd325b294f8..e792e517ac7d 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt +++ b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt @@ -1,6 +1,5 @@ -e ../../../tools/azure-devtools ../../core/azure-core -../azure-appconfiguration -e ../../identity/azure-identity -e ../../keyvault/azure-keyvault-secrets aiohttp>=3.0 From bea39b84ff4cddc8754b63a21a3ba33c2080b7d8 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Thu, 6 Oct 2022 16:22:49 -0700 Subject: [PATCH 121/129] update --- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 8da1268eb78b..c86d27d1e5ab 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -57,11 +57,10 @@ author_email="azpysdkhelp@microsoft.com", url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration-provider", classifiers=[ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", From 9aea9e41079983fbafb17e47a3b4dac9e491e456 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Thu, 6 Oct 2022 16:58:58 -0700 Subject: [PATCH 122/129] update --- .../azure-appconfiguration-provider/dev_requirements.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt index e792e517ac7d..8ca0b23f04e5 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt +++ b/sdk/appconfiguration/azure-appconfiguration-provider/dev_requirements.txt @@ -1,7 +1,7 @@ -e ../../../tools/azure-devtools -../../core/azure-core --e ../../identity/azure-identity --e ../../keyvault/azure-keyvault-secrets +azure-core +azure-appconfiguration +azure-identity +azure-keyvault-secrets aiohttp>=3.0 -e ../../../tools/azure-sdk-tools --e ../../../tools/azure-devtools \ No newline at end of file From 601470f3aaf7f7a4d8bb848695b1a23161d9ec3c Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Fri, 7 Oct 2022 13:07:19 -0700 Subject: [PATCH 123/129] Update sdk/appconfiguration/azure-appconfiguration-provider/setup.py Co-authored-by: Scott Beddall <45376673+scbedd@users.noreply.github.com> --- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index c86d27d1e5ab..eb76db000544 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -41,6 +41,7 @@ "samples", # Exclude packages that will be covered by PEP420 or nspkg "azure", + "azure.appconfiguration" ] if sys.version_info < (3, 5, 3): exclude_packages.extend(["*.aio", "*.aio.*"]) From b5154162563fafeea479cde2dc5519b988fe0afa Mon Sep 17 00:00:00 2001 From: xiangyan99 Date: Fri, 7 Oct 2022 13:46:30 -0700 Subject: [PATCH 124/129] update --- .../azure-appconfiguration-provider/MANIFEST.in | 2 +- .../azure/appconfiguration/{ => provider}/py.typed | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/{ => provider}/py.typed (100%) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in b/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in index b3ffd92a2185..29c30ac7f9c3 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in +++ b/sdk/appconfiguration/azure-appconfiguration-provider/MANIFEST.in @@ -6,4 +6,4 @@ include azure/appconfiguration/__init__.py include azure/appconfiguration/provider/*.py recursive-include samples *.py *.md recursive-include doc *.rst -include azure/appconfiguration/py.typed \ No newline at end of file +include azure/appconfiguration/provider/py.typed \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/py.typed b/sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/py.typed similarity index 100% rename from sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/py.typed rename to sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/py.typed From 5802867146ba7c7d3cc54d3de5dbc0f7b385b1d9 Mon Sep 17 00:00:00 2001 From: mrm9084 Date: Tue, 11 Oct 2022 16:48:21 -0700 Subject: [PATCH 125/129] Updated min version of app config --- sdk/appconfiguration/azure-appconfiguration-provider/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index eb76db000544..6e2821a58357 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -74,7 +74,7 @@ install_requires=[ "msrest>=0.6.21", "azure-core<2.0.0,>=1.2.2", - "azure-appconfiguration<2.0.0,>=1.2.0", + "azure-appconfiguration<2.0.0,>=1.3.0", "azure-keyvault-secrets<5.0.0,>=4.3.0", ], ) From 3290b6fa852d1e48127da93fbea27ba65435f50c Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 12 Oct 2022 09:24:40 -0700 Subject: [PATCH 126/129] Updating sanitizer --- .../azure-appconfiguration-provider/tests/conftest.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py index 244b14a8905c..eb633dd0f1e8 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py @@ -1,9 +1,8 @@ import os from devtools_testutils import ( - test_proxy, add_general_regex_sanitizer, - add_body_string_sanitizer, - add_oauth_response_sanitizer + add_general_string_sanitizer, + add_oauth_response_sanitizer, ) import pytest @@ -22,6 +21,5 @@ def add_sanitizers(test_proxy): value="fake-client-secret", regex=os.environ.get('APPCONFIGURATION_CLIENT_SECRET', "fake-client-secret")) add_general_regex_sanitizer( value="fake-tenant-id", regex=os.environ.get('APPCONFIGURATION_TENANT_ID', "fake-tenant-id")) - add_general_regex_sanitizer( - value="https://fake-key-vault.vault.azure.net/", regex="/*" + os.environ.get('APPCONFIGURATION_KEY_VAULT_REFERENCE', "fake-key-vault.vault") + "/*") + add_general_string_sanitizer(value="https://fake-key-vault.vault.azure.net/", target=os.environ.get("APPCONFIGURATION_KEY_VAULT_REFERENCE", "https://fake-key-vault.vault.azure.net/")) add_oauth_response_sanitizer() From 16cabad5fc405e3eab3a7f5055d1f99286ac6293 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 12 Oct 2022 11:02:22 -0700 Subject: [PATCH 127/129] Updating Shared Requirement --- shared_requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/shared_requirements.txt b/shared_requirements.txt index 79bec04f6594..19f88b6cf136 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -186,6 +186,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-eventhub-checkpointstoretable azure-core<2.0.0,>=1.14.0 #override azure-eventhub uamqp>=1.6.0,<2.0.0 #override azure-appconfiguration azure-core<2.0.0,>=1.24.0 +#override azure-appconfiguration-provider azure-appconfiguration<2.0.0,>=1.3.0 #override azure-appconfiguration-provider azure-keyvault-secrets<5.0.0,>=4.3.0 #override azure-servicebus uamqp>=1.5.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 From fb4bc3af15f6b9466b9b0f07d0e2f0118b5bc979 Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 12 Oct 2022 16:06:46 -0700 Subject: [PATCH 128/129] Temp removing key vault test --- .../tests/test_provider_key_vault_reference.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py index 92a8fd49a95d..9b1cb33e455d 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py @@ -15,6 +15,7 @@ ) from azure.appconfiguration import AzureAppConfigurationClient from preparers import app_config_decorator_aad +import pytest class TestAppConfigurationProvider(AzureRecordedTestCase): @@ -25,6 +26,7 @@ def build_provider_aad(self, endpoint, key_vault_options): # method: provider_with_key_vault @recorded_by_proxy @app_config_decorator_aad + @pytest.mark.skip(reason="Breaks in playback mode in whl pipeline") def test_provider_with_key_vault(self, appconfiguration_endpoint_string): key_vault_cred = self.get_credential(SecretClient) key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=key_vault_cred) From 74043332176893caa9ed8028d7697a9adb59592d Mon Sep 17 00:00:00 2001 From: Matt Metcalf Date: Wed, 12 Oct 2022 16:37:19 -0700 Subject: [PATCH 129/129] Removing actual tests --- ...nProvidertest_provider_with_key_vault.json | 462 ------------------ .../test_provider_key_vault_reference.py | 34 -- 2 files changed, 496 deletions(-) delete mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json delete mode 100644 sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json b/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json deleted file mode 100644 index 296e19128463..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/recordings/test_provider_key_vault_reference.pyTestAppConfigurationProvidertest_provider_with_key_vault.json +++ /dev/null @@ -1,462 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Access-Control-Allow-Methods": "GET, OPTIONS", - "Access-Control-Allow-Origin": "*", - "Cache-Control": "max-age=86400, private", - "Content-Length": "1599", - "Content-Type": "application/json; charset=utf-8", - "Date": "Tue, 27 Sep 2022 22:42:42 GMT", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Set-Cookie": [ - "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAwAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:42 GMT; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13672.11 - SCUS ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", - "token_endpoint_auth_methods_supported": [ - "client_secret_post", - "private_key_jwt", - "client_secret_basic" - ], - "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", - "response_modes_supported": [ - "query", - "fragment", - "form_post" - ], - "subject_types_supported": [ - "pairwise" - ], - "id_token_signing_alg_values_supported": [ - "RS256" - ], - "response_types_supported": [ - "code", - "id_token", - "code id_token", - "id_token token" - ], - "scopes_supported": [ - "openid", - "profile", - "email", - "offline_access" - ], - "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", - "request_uri_parameter_supported": false, - "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", - "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", - "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", - "http_logout_supported": true, - "frontchannel_logout_supported": true, - "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", - "claims_supported": [ - "sub", - "iss", - "cloud_instance_name", - "cloud_instance_host_name", - "cloud_graph_host_name", - "msgraph_host", - "aud", - "exp", - "iat", - "auth_time", - "acr", - "nonce", - "preferred_username", - "name", - "tid", - "ver", - "at_hash", - "c_hash", - "email" - ], - "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", - "tenant_region_scope": "WW", - "cloud_instance_name": "microsoftonline.com", - "cloud_graph_host_name": "graph.windows.net", - "msgraph_host": "graph.microsoft.com", - "rbac_url": "https://pas.windows.net" - } - }, - { - "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "Connection": "keep-alive", - "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAwAAAGBzxdoOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Access-Control-Allow-Methods": "GET, OPTIONS", - "Access-Control-Allow-Origin": "*", - "Cache-Control": "max-age=86400, private", - "Content-Length": "945", - "Content-Type": "application/json; charset=utf-8", - "Date": "Tue, 27 Sep 2022 22:42:42 GMT", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Set-Cookie": [ - "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNAwAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:42 GMT; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13672.11 - NCUS ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", - "api-version": "1.1", - "metadata": [ - { - "preferred_network": "login.microsoftonline.com", - "preferred_cache": "login.windows.net", - "aliases": [ - "login.microsoftonline.com", - "login.windows.net", - "login.microsoft.com", - "sts.windows.net" - ] - }, - { - "preferred_network": "login.partner.microsoftonline.cn", - "preferred_cache": "login.partner.microsoftonline.cn", - "aliases": [ - "login.partner.microsoftonline.cn", - "login.chinacloudapi.cn" - ] - }, - { - "preferred_network": "login.microsoftonline.de", - "preferred_cache": "login.microsoftonline.de", - "aliases": [ - "login.microsoftonline.de" - ] - }, - { - "preferred_network": "login.microsoftonline.us", - "preferred_cache": "login.microsoftonline.us", - "aliases": [ - "login.microsoftonline.us", - "login.usgovcloudapi.net" - ] - }, - { - "preferred_network": "login-us.microsoftonline.com", - "preferred_cache": "login-us.microsoftonline.com", - "aliases": [ - "login-us.microsoftonline.com" - ] - } - ] - } - }, - { - "RequestUri": "https://fake-endpoint.azconfig.io/kv?key=%2A\u0026label=prod\u0026api-version=1.0", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/vnd.microsoft.appconfig.kvset\u002Bjson, application/json, application/problem\u002Bjson", - "Accept-Encoding": "gzip, deflate", - "Connection": "keep-alive", - "Correlation-Context": "RequestType=Startup,UsesKeyVault", - "User-Agent": "python-appconfiguration-provider/1.0.0b1 azsdk-python-appconfiguration/1.4.0 Python/3.9.13 (Windows-10-10.0.19044-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Access-Control-Allow-Credentials": "true", - "Access-Control-Allow-Origin": "*", - "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", - "Connection": "keep-alive", - "Content-Type": "application/vnd.microsoft.appconfig.kvset\u002Bjson; charset=utf-8", - "Date": "Tue, 27 Sep 2022 22:42:42 GMT", - "Server": "openresty/1.17.8.2", - "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NzoxNyMxOTgyNzIxMg==;sn=19827212", - "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "362c7696-90d5-42fc-85b1-a28493c8db0a" - }, - "ResponseBody": { - "items": [ - { - "etag": "cuoTxCSuBxPyk2kTGtNoy7AiY8kwWEvkhEM4hVmSZxA", - "key": "secret", - "label": "prod", - "content_type": "application/vnd.microsoft.appconfig.keyvaultref\u002Bjson;charset=utf-8", - "value": "{\u0022uri\u0022:\u0022https://fake-key-vault.vault.azure.net/secrets/secret\u0022}", - "tags": {}, - "locked": false, - "last_modified": "2022-09-27T21:30:56\u002B00:00" - } - ] - } - }, - { - "RequestUri": "https://fake-key-vault.vault.azure.net/secrets/secret/?api-version=7.3", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "Connection": "keep-alive", - "User-Agent": "azsdk-python-keyvault-secrets/4.7.0b1 Python/3.9.13 (Windows-10-10.0.19044-SP0)" - }, - "RequestBody": null, - "StatusCode": 401, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Length": "97", - "Content-Type": "application/json; charset=utf-8", - "Date": "Tue, 27 Sep 2022 22:42:42 GMT", - "Expires": "-1", - "Pragma": "no-cache", - "Strict-Transport-Security": "max-age=31536000;includeSubDomains", - "WWW-Authenticate": "Bearer authorization=\u0022https://login.windows.net/fake-tenant-id\u0022, resource=\u0022https://vault.azure.net\u0022", - "X-Content-Type-Options": "nosniff", - "x-ms-keyvault-network-info": "conn_type=Ipv4;addr=131.107.1.245;act_addr_fam=InterNetwork;", - "x-ms-keyvault-region": "northcentralus", - "x-ms-keyvault-service-version": "1.9.538.1" - }, - "ResponseBody": { - "error": { - "code": "Unauthorized", - "message": "AKV10000: Request is missing a Bearer or PoP token." - } - } - }, - { - "RequestUri": "https://login.microsoftonline.com/fake-tenant-id/v2.0/.well-known/openid-configuration", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Access-Control-Allow-Methods": "GET, OPTIONS", - "Access-Control-Allow-Origin": "*", - "Cache-Control": "max-age=86400, private", - "Content-Length": "1599", - "Content-Type": "application/json; charset=utf-8", - "Date": "Tue, 27 Sep 2022 22:42:42 GMT", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Set-Cookie": [ - "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNBAAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:43 GMT; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13672.11 - SCUS ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "token_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/token", - "token_endpoint_auth_methods_supported": [ - "client_secret_post", - "private_key_jwt", - "client_secret_basic" - ], - "jwks_uri": "https://login.microsoftonline.com/fake-tenant-id/discovery/v2.0/keys", - "response_modes_supported": [ - "query", - "fragment", - "form_post" - ], - "subject_types_supported": [ - "pairwise" - ], - "id_token_signing_alg_values_supported": [ - "RS256" - ], - "response_types_supported": [ - "code", - "id_token", - "code id_token", - "id_token token" - ], - "scopes_supported": [ - "openid", - "profile", - "email", - "offline_access" - ], - "issuer": "https://login.microsoftonline.com/fake-tenant-id/v2.0", - "request_uri_parameter_supported": false, - "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", - "authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/authorize", - "device_authorization_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/devicecode", - "http_logout_supported": true, - "frontchannel_logout_supported": true, - "end_session_endpoint": "https://login.microsoftonline.com/fake-tenant-id/oauth2/v2.0/logout", - "claims_supported": [ - "sub", - "iss", - "cloud_instance_name", - "cloud_instance_host_name", - "cloud_graph_host_name", - "msgraph_host", - "aud", - "exp", - "iat", - "auth_time", - "acr", - "nonce", - "preferred_username", - "name", - "tid", - "ver", - "at_hash", - "c_hash", - "email" - ], - "kerberos_endpoint": "https://login.microsoftonline.com/fake-tenant-id/kerberos", - "tenant_region_scope": "WW", - "cloud_instance_name": "microsoftonline.com", - "cloud_graph_host_name": "graph.windows.net", - "msgraph_host": "graph.microsoft.com", - "rbac_url": "https://pas.windows.net" - } - }, - { - "RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "Connection": "keep-alive", - "Cookie": "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNBAAAAGBzxdoOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd", - "User-Agent": "azsdk-python-identity/1.12.0b2 Python/3.9.13 (Windows-10-10.0.19044-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Access-Control-Allow-Methods": "GET, OPTIONS", - "Access-Control-Allow-Origin": "*", - "Cache-Control": "max-age=86400, private", - "Content-Length": "945", - "Content-Type": "application/json; charset=utf-8", - "Date": "Tue, 27 Sep 2022 22:42:43 GMT", - "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", - "Set-Cookie": [ - "fpc=Aih2w7HdW0RLsLtcNXW6NJri05sNBAAAAGBzxdoOAAAA; expires=Thu, 27-Oct-2022 22:42:43 GMT; path=/; secure; HttpOnly; SameSite=None", - "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly", - "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly" - ], - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13672.11 - EUS ProdSlices", - "X-XSS-Protection": "0" - }, - "ResponseBody": { - "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", - "api-version": "1.1", - "metadata": [ - { - "preferred_network": "login.microsoftonline.com", - "preferred_cache": "login.windows.net", - "aliases": [ - "login.microsoftonline.com", - "login.windows.net", - "login.microsoft.com", - "sts.windows.net" - ] - }, - { - "preferred_network": "login.partner.microsoftonline.cn", - "preferred_cache": "login.partner.microsoftonline.cn", - "aliases": [ - "login.partner.microsoftonline.cn", - "login.chinacloudapi.cn" - ] - }, - { - "preferred_network": "login.microsoftonline.de", - "preferred_cache": "login.microsoftonline.de", - "aliases": [ - "login.microsoftonline.de" - ] - }, - { - "preferred_network": "login.microsoftonline.us", - "preferred_cache": "login.microsoftonline.us", - "aliases": [ - "login.microsoftonline.us", - "login.usgovcloudapi.net" - ] - }, - { - "preferred_network": "login-us.microsoftonline.com", - "preferred_cache": "login-us.microsoftonline.com", - "aliases": [ - "login-us.microsoftonline.com" - ] - } - ] - } - }, - { - "RequestUri": "https://fake-key-vault.vault.azure.net/secrets/secret/?api-version=7.3", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "Connection": "keep-alive", - "User-Agent": "azsdk-python-keyvault-secrets/4.7.0b1 Python/3.9.13 (Windows-10-10.0.19044-SP0)" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Length": "258", - "Content-Type": "application/json; charset=utf-8", - "Date": "Tue, 27 Sep 2022 22:42:43 GMT", - "Expires": "-1", - "Pragma": "no-cache", - "Strict-Transport-Security": "max-age=31536000;includeSubDomains", - "X-Content-Type-Options": "nosniff", - "x-ms-keyvault-network-info": "conn_type=Ipv4;addr=131.107.1.245;act_addr_fam=InterNetwork;", - "x-ms-keyvault-region": "northcentralus", - "x-ms-keyvault-service-version": "1.9.538.1" - }, - "ResponseBody": { - "value": "my-secret", - "id": "https://fake-key-vault.vault.azure.net/secrets/secret/efa8cdd8eef24d3b8d0ad36d9804af45", - "attributes": { - "enabled": true, - "created": 1664314220, - "updated": 1664314220, - "recoveryLevel": "Recoverable\u002BPurgeable", - "recoverableDays": 90 - }, - "tags": {} - } - } - ], - "Variables": {} -} \ No newline at end of file diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py deleted file mode 100644 index 9b1cb33e455d..000000000000 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_key_vault_reference.py +++ /dev/null @@ -1,34 +0,0 @@ -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -from azure.appconfiguration.provider import ( - AzureAppConfigurationProvider, - SettingSelector, - AzureAppConfigurationKeyVaultOptions -) -from azure.keyvault.secrets import SecretClient -from devtools_testutils import ( - AzureRecordedTestCase, - recorded_by_proxy -) -from azure.appconfiguration import AzureAppConfigurationClient -from preparers import app_config_decorator_aad -import pytest - -class TestAppConfigurationProvider(AzureRecordedTestCase): - - def build_provider_aad(self, endpoint, key_vault_options): - cred = self.get_credential(AzureAppConfigurationClient) - return AzureAppConfigurationProvider.load(endpoint=endpoint,credential=cred, selects=[SettingSelector("*", "prod")], key_vault_options=key_vault_options) - - # method: provider_with_key_vault - @recorded_by_proxy - @app_config_decorator_aad - @pytest.mark.skip(reason="Breaks in playback mode in whl pipeline") - def test_provider_with_key_vault(self, appconfiguration_endpoint_string): - key_vault_cred = self.get_credential(SecretClient) - key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=key_vault_cred) - client = self.build_provider_aad(appconfiguration_endpoint_string, key_vault_options=key_vault_options) - assert client["secret"] == "my-secret" \ No newline at end of file