Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storage] Migrate test_queue_client.py to test proxy #27039

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 30 additions & 29 deletions sdk/storage/azure-storage-queue/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
# --------------------------------------------------------------------------
#
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# The MIT License (MIT)
#
# 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.
#
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import sys

# fixture needs to be visible from conftest
# Ignore async tests for Python < 3.5
collect_ignore_glob = []
if sys.version_info < (3, 5):
collect_ignore_glob.append("*_async.py")
import os
import platform

import pytest

from devtools_testutils import (
add_general_regex_sanitizer,
add_header_regex_sanitizer,
add_oauth_response_sanitizer,
add_uri_string_sanitizer,
test_proxy
)

@pytest.fixture(scope="session", autouse=True)
def add_sanitizers(test_proxy):
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000")
tenant_id = os.environ.get("STORAGE_TENANT_ID", "00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=subscription_id, value="00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=tenant_id, value="00000000-0000-0000-0000-000000000000")
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
add_header_regex_sanitizer(key="Cookie", value="cookie;")
add_oauth_response_sanitizer()

add_header_regex_sanitizer(key="x-ms-copy-source-authorization", value="Sanitized")
add_header_regex_sanitizer(key="x-ms-encryption-key", value="Sanitized")

add_uri_string_sanitizer(target=".preprod.", value=".")
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"Entries": [
{
"RequestUri": "https://storagename.queue.core.windows.net/cont4acf311e",
"RequestMethod": "PUT",
"RequestHeaders": {
"Accept": "application/xml",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Content-Length": "0",
"User-Agent": "azsdk-python-storage-queue/12.5.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)",
"x-ms-date": "Tue, 25 Oct 2022 21:32:00 GMT",
"x-ms-meta-hello": "world",
"x-ms-version": "2021-02-12"
},
"RequestBody": null,
"StatusCode": 201,
"ResponseHeaders": {
"Content-Length": "0",
"Date": "Tue, 25 Oct 2022 21:31:59 GMT",
"Server": [
"Windows-Azure-Queue/1.0",
"Microsoft-HTTPAPI/2.0"
],
"x-ms-version": "2021-02-12"
},
"ResponseBody": null
},
{
"RequestUri": "https://storagename.queue.core.windows.net/cont4acf311e?comp=metadata",
"RequestMethod": "GET",
"RequestHeaders": {
"Accept": "application/xml",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"User-Agent": "azsdk-python-storage-queue/12.5.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)",
"x-ms-date": "Tue, 25 Oct 2022 21:32:01 GMT",
"x-ms-version": "2021-02-12"
},
"RequestBody": null,
"StatusCode": 200,
"ResponseHeaders": {
"Cache-Control": "no-cache",
"Content-Length": "0",
"Date": "Tue, 25 Oct 2022 21:31:59 GMT",
"Server": [
"Windows-Azure-Queue/1.0",
"Microsoft-HTTPAPI/2.0"
],
"x-ms-approximate-messages-count": "0",
"x-ms-meta-hello": "world",
"x-ms-version": "2021-02-12"
},
"ResponseBody": null
},
{
"RequestUri": "https://storagename.queue.core.windows.net/cont4acf311e",
"RequestMethod": "DELETE",
"RequestHeaders": {
"Accept": "application/xml",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Content-Length": "0",
"User-Agent": "azsdk-python-storage-queue/12.5.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)",
"x-ms-date": "Tue, 25 Oct 2022 21:32:01 GMT",
"x-ms-version": "2021-02-12"
},
"RequestBody": null,
"StatusCode": 204,
"ResponseHeaders": {
"Content-Length": "0",
"Date": "Tue, 25 Oct 2022 21:32:00 GMT",
"Server": [
"Windows-Azure-Queue/1.0",
"Microsoft-HTTPAPI/2.0"
],
"x-ms-version": "2021-02-12"
},
"ResponseBody": null
}
],
"Variables": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"Entries": [
{
"RequestUri": "https://storagename.queue.core.windows.net/conte1852be3?comp=metadata",
"RequestMethod": "GET",
"RequestHeaders": {
"Accept": "application/xml",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"User-Agent": "azsdk-python-storage-queue/12.5.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)",
"x-ms-date": "Tue, 25 Oct 2022 21:32:01 GMT",
"x-ms-version": "2021-02-12"
},
"RequestBody": null,
"StatusCode": 404,
"ResponseHeaders": {
"Content-Length": "217",
"Content-Type": "application/xml",
"Date": "Tue, 25 Oct 2022 21:32:00 GMT",
"Server": [
"Windows-Azure-Queue/1.0",
"Microsoft-HTTPAPI/2.0"
],
"x-ms-error-code": "QueueNotFound",
"x-ms-version": "2021-02-12"
},
"ResponseBody": [
"\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CError\u003E\u003CCode\u003EQueueNotFound\u003C/Code\u003E\u003CMessage\u003EThe specified queue does not exist.\n",
"RequestId:beead3c9-a003-007d-1fb9-e88702000000\n",
"Time:2022-10-25T21:32:01.2354880Z\u003C/Message\u003E\u003C/Error\u003E"
]
}
],
"Variables": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"Entries": [
{
"RequestUri": "https://storagename.queue.core.windows.net/?restype=service\u0026comp=properties",
"RequestMethod": "GET",
"RequestHeaders": {
"Accept": "application/xml",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"User-Agent": "customer_user_agent azsdk-python-storage-queue/12.5.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)",
"x-ms-date": "Tue, 25 Oct 2022 21:32:02 GMT",
"x-ms-version": "2021-02-12"
},
"RequestBody": null,
"StatusCode": 200,
"ResponseHeaders": {
"Cache-Control": "no-cache",
"Content-Type": "application/xml",
"Date": "Tue, 25 Oct 2022 21:32:01 GMT",
"Server": [
"Windows-Azure-Queue/1.0",
"Microsoft-HTTPAPI/2.0"
],
"Transfer-Encoding": "chunked",
"x-ms-version": "2021-02-12"
},
"ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Efalse\u003C/Read\u003E\u003CWrite\u003Efalse\u003C/Write\u003E\u003CDelete\u003Efalse\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E7\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors /\u003E\u003C/StorageServiceProperties\u003E"
}
],
"Variables": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"Entries": [
{
"RequestUri": "https://storagename.queue.core.windows.net/?restype=service\u0026comp=properties",
"RequestMethod": "GET",
"RequestHeaders": {
"Accept": "application/xml",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"User-Agent": "TestApp/v1.0 azsdk-python-storage-queue/12.5.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)",
"x-ms-date": "Tue, 25 Oct 2022 21:32:02 GMT",
"x-ms-version": "2021-02-12"
},
"RequestBody": null,
"StatusCode": 200,
"ResponseHeaders": {
"Cache-Control": "no-cache",
"Content-Type": "application/xml",
"Date": "Tue, 25 Oct 2022 21:32:01 GMT",
"Server": [
"Windows-Azure-Queue/1.0",
"Microsoft-HTTPAPI/2.0"
],
"Transfer-Encoding": "chunked",
"x-ms-version": "2021-02-12"
},
"ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Efalse\u003C/Read\u003E\u003CWrite\u003Efalse\u003C/Write\u003E\u003CDelete\u003Efalse\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E7\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors /\u003E\u003C/StorageServiceProperties\u003E"
},
{
"RequestUri": "https://storagename.queue.core.windows.net/?restype=service\u0026comp=properties",
"RequestMethod": "GET",
"RequestHeaders": {
"Accept": "application/xml",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"User-Agent": "TestApp/v2.0 TestApp/v1.0 azsdk-python-storage-queue/12.5.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)",
"x-ms-date": "Tue, 25 Oct 2022 21:32:02 GMT",
"x-ms-version": "2021-02-12"
},
"RequestBody": null,
"StatusCode": 200,
"ResponseHeaders": {
"Cache-Control": "no-cache",
"Content-Type": "application/xml",
"Date": "Tue, 25 Oct 2022 21:32:01 GMT",
"Server": [
"Windows-Azure-Queue/1.0",
"Microsoft-HTTPAPI/2.0"
],
"Transfer-Encoding": "chunked",
"x-ms-version": "2021-02-12"
},
"ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Efalse\u003C/Read\u003E\u003CWrite\u003Efalse\u003C/Write\u003E\u003CDelete\u003Efalse\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E7\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors /\u003E\u003C/StorageServiceProperties\u003E"
}
],
"Variables": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"Entries": [
{
"RequestUri": "https://storagename.queue.core.windows.net/?restype=service\u0026comp=properties",
"RequestMethod": "GET",
"RequestHeaders": {
"Accept": "application/xml",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"User-Agent": "azsdk-python-storage-queue/12.5.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)",
"x-ms-date": "Tue, 25 Oct 2022 21:32:01 GMT",
"x-ms-version": "2021-02-12"
},
"RequestBody": null,
"StatusCode": 200,
"ResponseHeaders": {
"Cache-Control": "no-cache",
"Content-Type": "application/xml",
"Date": "Tue, 25 Oct 2022 21:32:00 GMT",
"Server": [
"Windows-Azure-Queue/1.0",
"Microsoft-HTTPAPI/2.0"
],
"Transfer-Encoding": "chunked",
"x-ms-version": "2021-02-12"
},
"ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Efalse\u003C/Read\u003E\u003CWrite\u003Efalse\u003C/Write\u003E\u003CDelete\u003Efalse\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E7\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors /\u003E\u003C/StorageServiceProperties\u003E"
}
],
"Variables": {}
}
Loading