diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/base_client.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/base_client.py index 44fd5f87d2f9..7f6c43fecfd2 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/base_client.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/base_client.py @@ -56,10 +56,10 @@ _LOGGER = logging.getLogger(__name__) _SERVICE_PARAMS = { - "blob": {"primary": "BlobEndpoint", "secondary": "BlobSecondaryEndpoint"}, - "queue": {"primary": "QueueEndpoint", "secondary": "QueueSecondaryEndpoint"}, - "file": {"primary": "FileEndpoint", "secondary": "FileSecondaryEndpoint"}, - "dfs": {"primary": "BlobEndpoint", "secondary": "BlobEndpoint"}, + "blob": {"primary": "BLOBENDPOINT", "secondary": "BLOBSECONDARYENDPOINT"}, + "queue": {"primary": "QUEUEENDPOINT", "secondary": "QUEUESECONDARYENDPOINT"}, + "file": {"primary": "FILEENDPOINT", "secondary": "FILESECONDARYENDPOINT"}, + "dfs": {"primary": "BLOBENDPOINT", "secondary": "BLOBENDPOINT"}, } @@ -364,15 +364,15 @@ def parse_connection_str(conn_str, credential, service): conn_settings = [s.split("=", 1) for s in conn_str.split(";")] if any(len(tup) != 2 for tup in conn_settings): raise ValueError("Connection string is either blank or malformed.") - conn_settings = dict(conn_settings) + conn_settings = dict((key.upper(), val) for key, val in conn_settings) endpoints = _SERVICE_PARAMS[service] primary = None secondary = None if not credential: try: - credential = {"account_name": conn_settings["AccountName"], "account_key": conn_settings["AccountKey"]} + credential = {"account_name": conn_settings["ACCOUNTNAME"], "account_key": conn_settings["ACCOUNTKEY"]} except KeyError: - credential = conn_settings.get("SharedAccessSignature") + credential = conn_settings.get("SHAREDACCESSSIGNATURE") if endpoints["primary"] in conn_settings: primary = conn_settings[endpoints["primary"]] if endpoints["secondary"] in conn_settings: @@ -382,13 +382,13 @@ def parse_connection_str(conn_str, credential, service): raise ValueError("Connection string specifies only secondary endpoint.") try: primary = "{}://{}.{}.{}".format( - conn_settings["DefaultEndpointsProtocol"], - conn_settings["AccountName"], + conn_settings["DEFAULTENDPOINTSPROTOCOL"], + conn_settings["ACCOUNTNAME"], service, - conn_settings["EndpointSuffix"], + conn_settings["ENDPOINTSUFFIX"], ) secondary = "{}-secondary.{}.{}".format( - conn_settings["AccountName"], service, conn_settings["EndpointSuffix"] + conn_settings["ACCOUNTNAME"], service, conn_settings["ENDPOINTSUFFIX"] ) except KeyError: pass @@ -396,7 +396,7 @@ def parse_connection_str(conn_str, credential, service): if not primary: try: primary = "https://{}.{}.{}".format( - conn_settings["AccountName"], service, conn_settings.get("EndpointSuffix", SERVICE_HOST_BASE) + conn_settings["ACCOUNTNAME"], service, conn_settings.get("ENDPOINTSUFFIX", SERVICE_HOST_BASE) ) except KeyError: raise ValueError("Connection string missing required connection details.") diff --git a/sdk/storage/azure-storage-blob/tests/_shared/testcase.py b/sdk/storage/azure-storage-blob/tests/_shared/testcase.py index dc6199e47bd8..8d203eb6db00 100644 --- a/sdk/storage/azure-storage-blob/tests/_shared/testcase.py +++ b/sdk/storage/azure-storage-blob/tests/_shared/testcase.py @@ -159,7 +159,7 @@ def __init__(self, *args, **kwargs): self.configure_logging() def connection_string(self, account, key): - return "DefaultEndpointsProtocol=https;AccountName=" + account.name + ";AccountKey=" + str(key) + ";EndpointSuffix=core.windows.net" + return "DefaultEndpointsProtocol=https;AcCounTName=" + account.name + ";AccOuntKey=" + str(key) + ";EndpoIntSuffix=core.windows.net" def account_url(self, storage_account, storage_type): """Return an url of storage account. diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/base_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/base_client.py index 44fd5f87d2f9..3028a8d8512b 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/base_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/base_client.py @@ -56,13 +56,12 @@ _LOGGER = logging.getLogger(__name__) _SERVICE_PARAMS = { - "blob": {"primary": "BlobEndpoint", "secondary": "BlobSecondaryEndpoint"}, - "queue": {"primary": "QueueEndpoint", "secondary": "QueueSecondaryEndpoint"}, - "file": {"primary": "FileEndpoint", "secondary": "FileSecondaryEndpoint"}, - "dfs": {"primary": "BlobEndpoint", "secondary": "BlobEndpoint"}, + "blob": {"primary": "BLOBENDPOINT", "secondary": "BLOBSECONDARYENDPOINT"}, + "queue": {"primary": "QUEUEENDPOINT", "secondary": "QUEUESECONDARYENDPOINT"}, + "file": {"primary": "FILEENDPOINT", "secondary": "FILESECONDARYENDPOINT"}, + "dfs": {"primary": "BLOBENDPOINT", "secondary": "BLOBENDPOINT"}, } - class StorageAccountHostsMixin(object): # pylint: disable=too-many-instance-attributes def __init__( self, @@ -364,15 +363,15 @@ def parse_connection_str(conn_str, credential, service): conn_settings = [s.split("=", 1) for s in conn_str.split(";")] if any(len(tup) != 2 for tup in conn_settings): raise ValueError("Connection string is either blank or malformed.") - conn_settings = dict(conn_settings) + conn_settings = dict((key.upper(), val) for key, val in conn_settings) endpoints = _SERVICE_PARAMS[service] primary = None secondary = None if not credential: try: - credential = {"account_name": conn_settings["AccountName"], "account_key": conn_settings["AccountKey"]} + credential = {"account_name": conn_settings["ACCOUNTNAME"], "account_key": conn_settings["ACCOUNTKEY"]} except KeyError: - credential = conn_settings.get("SharedAccessSignature") + credential = conn_settings.get("SHAREDACCESSSIGNATURE") if endpoints["primary"] in conn_settings: primary = conn_settings[endpoints["primary"]] if endpoints["secondary"] in conn_settings: @@ -382,13 +381,13 @@ def parse_connection_str(conn_str, credential, service): raise ValueError("Connection string specifies only secondary endpoint.") try: primary = "{}://{}.{}.{}".format( - conn_settings["DefaultEndpointsProtocol"], - conn_settings["AccountName"], + conn_settings["DEFAULTENDPOINTSPROTOCOL"], + conn_settings["ACCOUNTNAME"], service, - conn_settings["EndpointSuffix"], + conn_settings["ENDPOINTSUFFIX"], ) secondary = "{}-secondary.{}.{}".format( - conn_settings["AccountName"], service, conn_settings["EndpointSuffix"] + conn_settings["ACCOUNTNAME"], service, conn_settings["ENDPOINTSUFFIX"] ) except KeyError: pass @@ -396,7 +395,7 @@ def parse_connection_str(conn_str, credential, service): if not primary: try: primary = "https://{}.{}.{}".format( - conn_settings["AccountName"], service, conn_settings.get("EndpointSuffix", SERVICE_HOST_BASE) + conn_settings["ACCOUNTNAME"], service, conn_settings.get("ENDPOINTSUFFIX", SERVICE_HOST_BASE) ) except KeyError: raise ValueError("Connection string missing required connection details.") diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/base_client.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/base_client.py index 44fd5f87d2f9..3028a8d8512b 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/base_client.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/base_client.py @@ -56,13 +56,12 @@ _LOGGER = logging.getLogger(__name__) _SERVICE_PARAMS = { - "blob": {"primary": "BlobEndpoint", "secondary": "BlobSecondaryEndpoint"}, - "queue": {"primary": "QueueEndpoint", "secondary": "QueueSecondaryEndpoint"}, - "file": {"primary": "FileEndpoint", "secondary": "FileSecondaryEndpoint"}, - "dfs": {"primary": "BlobEndpoint", "secondary": "BlobEndpoint"}, + "blob": {"primary": "BLOBENDPOINT", "secondary": "BLOBSECONDARYENDPOINT"}, + "queue": {"primary": "QUEUEENDPOINT", "secondary": "QUEUESECONDARYENDPOINT"}, + "file": {"primary": "FILEENDPOINT", "secondary": "FILESECONDARYENDPOINT"}, + "dfs": {"primary": "BLOBENDPOINT", "secondary": "BLOBENDPOINT"}, } - class StorageAccountHostsMixin(object): # pylint: disable=too-many-instance-attributes def __init__( self, @@ -364,15 +363,15 @@ def parse_connection_str(conn_str, credential, service): conn_settings = [s.split("=", 1) for s in conn_str.split(";")] if any(len(tup) != 2 for tup in conn_settings): raise ValueError("Connection string is either blank or malformed.") - conn_settings = dict(conn_settings) + conn_settings = dict((key.upper(), val) for key, val in conn_settings) endpoints = _SERVICE_PARAMS[service] primary = None secondary = None if not credential: try: - credential = {"account_name": conn_settings["AccountName"], "account_key": conn_settings["AccountKey"]} + credential = {"account_name": conn_settings["ACCOUNTNAME"], "account_key": conn_settings["ACCOUNTKEY"]} except KeyError: - credential = conn_settings.get("SharedAccessSignature") + credential = conn_settings.get("SHAREDACCESSSIGNATURE") if endpoints["primary"] in conn_settings: primary = conn_settings[endpoints["primary"]] if endpoints["secondary"] in conn_settings: @@ -382,13 +381,13 @@ def parse_connection_str(conn_str, credential, service): raise ValueError("Connection string specifies only secondary endpoint.") try: primary = "{}://{}.{}.{}".format( - conn_settings["DefaultEndpointsProtocol"], - conn_settings["AccountName"], + conn_settings["DEFAULTENDPOINTSPROTOCOL"], + conn_settings["ACCOUNTNAME"], service, - conn_settings["EndpointSuffix"], + conn_settings["ENDPOINTSUFFIX"], ) secondary = "{}-secondary.{}.{}".format( - conn_settings["AccountName"], service, conn_settings["EndpointSuffix"] + conn_settings["ACCOUNTNAME"], service, conn_settings["ENDPOINTSUFFIX"] ) except KeyError: pass @@ -396,7 +395,7 @@ def parse_connection_str(conn_str, credential, service): if not primary: try: primary = "https://{}.{}.{}".format( - conn_settings["AccountName"], service, conn_settings.get("EndpointSuffix", SERVICE_HOST_BASE) + conn_settings["ACCOUNTNAME"], service, conn_settings.get("ENDPOINTSUFFIX", SERVICE_HOST_BASE) ) except KeyError: raise ValueError("Connection string missing required connection details.") diff --git a/sdk/storage/azure-storage-file-share/tests/_shared/testcase.py b/sdk/storage/azure-storage-file-share/tests/_shared/testcase.py index 717f7701dc2b..2c64504cab1c 100644 --- a/sdk/storage/azure-storage-file-share/tests/_shared/testcase.py +++ b/sdk/storage/azure-storage-file-share/tests/_shared/testcase.py @@ -142,7 +142,7 @@ def __init__(self, *args, **kwargs): self.replay_processors.append(XMSRequestIDBody()) def connection_string(self, account, key): - return "DefaultEndpointsProtocol=https;AccountName=" + account.name + ";AccountKey=" + str(key) + ";EndpointSuffix=core.windows.net" + return "DefaultEndpointsProtocol=https;AcCounTName=" + account.name + ";AccOuntKey=" + str(key) + ";EndpoIntSuffix=core.windows.net" def account_url(self, storage_account, storage_type): """Return an url of storage account. diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client.py index 44fd5f87d2f9..3028a8d8512b 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client.py @@ -56,13 +56,12 @@ _LOGGER = logging.getLogger(__name__) _SERVICE_PARAMS = { - "blob": {"primary": "BlobEndpoint", "secondary": "BlobSecondaryEndpoint"}, - "queue": {"primary": "QueueEndpoint", "secondary": "QueueSecondaryEndpoint"}, - "file": {"primary": "FileEndpoint", "secondary": "FileSecondaryEndpoint"}, - "dfs": {"primary": "BlobEndpoint", "secondary": "BlobEndpoint"}, + "blob": {"primary": "BLOBENDPOINT", "secondary": "BLOBSECONDARYENDPOINT"}, + "queue": {"primary": "QUEUEENDPOINT", "secondary": "QUEUESECONDARYENDPOINT"}, + "file": {"primary": "FILEENDPOINT", "secondary": "FILESECONDARYENDPOINT"}, + "dfs": {"primary": "BLOBENDPOINT", "secondary": "BLOBENDPOINT"}, } - class StorageAccountHostsMixin(object): # pylint: disable=too-many-instance-attributes def __init__( self, @@ -364,15 +363,15 @@ def parse_connection_str(conn_str, credential, service): conn_settings = [s.split("=", 1) for s in conn_str.split(";")] if any(len(tup) != 2 for tup in conn_settings): raise ValueError("Connection string is either blank or malformed.") - conn_settings = dict(conn_settings) + conn_settings = dict((key.upper(), val) for key, val in conn_settings) endpoints = _SERVICE_PARAMS[service] primary = None secondary = None if not credential: try: - credential = {"account_name": conn_settings["AccountName"], "account_key": conn_settings["AccountKey"]} + credential = {"account_name": conn_settings["ACCOUNTNAME"], "account_key": conn_settings["ACCOUNTKEY"]} except KeyError: - credential = conn_settings.get("SharedAccessSignature") + credential = conn_settings.get("SHAREDACCESSSIGNATURE") if endpoints["primary"] in conn_settings: primary = conn_settings[endpoints["primary"]] if endpoints["secondary"] in conn_settings: @@ -382,13 +381,13 @@ def parse_connection_str(conn_str, credential, service): raise ValueError("Connection string specifies only secondary endpoint.") try: primary = "{}://{}.{}.{}".format( - conn_settings["DefaultEndpointsProtocol"], - conn_settings["AccountName"], + conn_settings["DEFAULTENDPOINTSPROTOCOL"], + conn_settings["ACCOUNTNAME"], service, - conn_settings["EndpointSuffix"], + conn_settings["ENDPOINTSUFFIX"], ) secondary = "{}-secondary.{}.{}".format( - conn_settings["AccountName"], service, conn_settings["EndpointSuffix"] + conn_settings["ACCOUNTNAME"], service, conn_settings["ENDPOINTSUFFIX"] ) except KeyError: pass @@ -396,7 +395,7 @@ def parse_connection_str(conn_str, credential, service): if not primary: try: primary = "https://{}.{}.{}".format( - conn_settings["AccountName"], service, conn_settings.get("EndpointSuffix", SERVICE_HOST_BASE) + conn_settings["ACCOUNTNAME"], service, conn_settings.get("ENDPOINTSUFFIX", SERVICE_HOST_BASE) ) except KeyError: raise ValueError("Connection string missing required connection details.") diff --git a/sdk/storage/azure-storage-queue/tests/_shared/testcase.py b/sdk/storage/azure-storage-queue/tests/_shared/testcase.py index 1b18fcf9a006..737432d80cf3 100644 --- a/sdk/storage/azure-storage-queue/tests/_shared/testcase.py +++ b/sdk/storage/azure-storage-queue/tests/_shared/testcase.py @@ -142,7 +142,7 @@ def __init__(self, *args, **kwargs): self.replay_processors.append(XMSRequestIDBody()) def connection_string(self, account, key): - return "DefaultEndpointsProtocol=https;AccountName=" + account.name + ";AccountKey=" + str(key) + ";EndpointSuffix=core.windows.net" + return "DefaultEndpointsProtocol=https;AcCounTName=" + account.name + ";AccOuntKey=" + str(key) + ";EndpoIntSuffix=core.windows.net" def account_url(self, storage_account, storage_type): """Return an url of storage account.