Skip to content

Commit

Permalink
[CI] Update more tests for the new TestProxy (#35562)
Browse files Browse the repository at this point in the history
Several tests still need a few opt-outs for sanitizers.
Some recordings were adjusted with extra sanitization in place.

Signed-off-by: Paul Van Eck <[email protected]>
  • Loading branch information
pvaneck authored May 9, 2024
1 parent dd7fd47 commit 5ae47b7
Show file tree
Hide file tree
Showing 23 changed files with 137 additions and 36 deletions.
8 changes: 6 additions & 2 deletions sdk/advisor/azure-mgmt-advisor/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer
from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer

# Ignore async tests for Python < 3.5
Expand All @@ -52,4 +52,8 @@ def add_sanitizers(test_proxy):
add_general_regex_sanitizer(regex=client_secret, 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_body_key_sanitizer(json_path="$..access_token", value="access_token")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK2003: Location
remove_batch_sanitizers(["AZSDK2003"])
8 changes: 6 additions & 2 deletions sdk/batch/azure-mgmt-batch/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer
from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer

load_dotenv()
Expand All @@ -48,4 +48,8 @@ def add_sanitizers(test_proxy):
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
add_header_regex_sanitizer(key="Cookie", value="cookie;")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
add_body_key_sanitizer(json_path="$..storageUrl", value="storageUrl")
add_body_key_sanitizer(json_path="$..storageUrl", value="storageUrl")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3493: $..name
remove_batch_sanitizers(["AZSDK3493"])
10 changes: 7 additions & 3 deletions sdk/compute/azure-mgmt-compute/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer, add_body_key_sanitizer
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer
from devtools_testutils import add_header_regex_sanitizer, remove_batch_sanitizers

# Ignore async tests for Python < 3.5
collect_ignore_glob = []
if sys.version_info < (3, 5) or platform.python_implementation() == "PyPy":
collect_ignore_glob.append("*_async.py")


load_dotenv()

@pytest.fixture(scope="session", autouse=True)
Expand All @@ -54,4 +54,8 @@ def add_sanitizers(test_proxy):
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
add_header_regex_sanitizer(key="Cookie", value="cookie;")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
add_body_key_sanitizer(json_path="$....accessSAS", value="accessSAS")
add_body_key_sanitizer(json_path="$....accessSAS", value="accessSAS")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK2003: Location
remove_batch_sanitizers(["AZSDK2003"])
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ def test_compute_galleries(self, resource_group):
result = self.mgmt_client.gallery_images.begin_delete(resource_group.name, GALLERY_NAME, IMAGE_NAME)
result = result.result()

import time
time.sleep(180)
if self.is_live:
import time
time.sleep(180)

# TODO: need finish
# # Delete a gallery Application Version.[delete]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/confidentialledger/azure-confidentialledger",
"Tag": "python/confidentialledger/azure-confidentialledger_995077cfcf"
"Tag": "python/confidentialledger/azure-confidentialledger_27130e59c6"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from devtools_testutils import test_proxy
from devtools_testutils import test_proxy, remove_batch_sanitizers

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
def add_sanitizers(test_proxy):
# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3433: $..userid
remove_batch_sanitizers(["AZSDK3433"])
5 changes: 2 additions & 3 deletions sdk/consumption/azure-mgmt-consumption/tests/test_budgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ def test_budgets(self, resource_group):
SUBSCRIPTION_ID = self.get_settings_value('SUBSCRIPTION_ID')
SCOPE = '/subscriptions/{}/resourceGroups/{}'.format(SUBSCRIPTION_ID, resource_group.name)
BUDGET_NAME = self.get_resource_name('budget')
TODAY = datetime.datetime.now()
start_date = TODAY.strftime('%Y-%m-01T00:00:00Z')
end_date = (TODAY+datetime.timedelta(180)).strftime('%Y-%m-01T00:00:00Z')
start_date = "2022-12-01T00:00:00.000Z"
end_date = "2023-06-01T00:00:00.000Z"
# create
BODY = {
"category": "Cost",
Expand Down
6 changes: 5 additions & 1 deletion sdk/devcenter/azure-developer-devcenter/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from devtools_testutils import test_proxy, add_body_key_sanitizer, add_oauth_response_sanitizer
from devtools_testutils import test_proxy, add_body_key_sanitizer, add_oauth_response_sanitizer, remove_batch_sanitizers
import pytest

# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method
Expand All @@ -13,4 +13,8 @@ def start_proxy(test_proxy):
add_body_key_sanitizer(json_path="$..id_token", value="Sanitized")
add_body_key_sanitizer(json_path="$..client_info", value="Sanitized")
add_oauth_response_sanitizer()
# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK2003: Location
# - AZSDK3493: $..name
remove_batch_sanitizers(["AZSDK2003", "AZSDK3493"])
return
8 changes: 6 additions & 2 deletions sdk/devtestlabs/azure-mgmt-devtestlabs/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer
from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer

# Ignore async tests for Python < 3.5
Expand All @@ -52,4 +52,8 @@ def add_sanitizers(test_proxy):
add_general_regex_sanitizer(regex=client_secret, 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_body_key_sanitizer(json_path="$..access_token", value="access_token")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3493: $..name
remove_batch_sanitizers(["AZSDK3493"])
8 changes: 7 additions & 1 deletion sdk/digitaltwins/azure-digitaltwins-core/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
add_body_key_sanitizer,
add_header_regex_sanitizer,
add_oauth_response_sanitizer,
add_remove_header_sanitizer
add_remove_header_sanitizer,
remove_batch_sanitizers,
)

# Environment variable keys
Expand Down Expand Up @@ -39,6 +40,11 @@ def add_sanitizers(test_proxy, environment_variables):
add_oauth_response_sanitizer()
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3430: $..id
# - AZSDK3493: $..name
remove_batch_sanitizers(["AZSDK3430", "AZSDK3493"])


@pytest.fixture(scope="session")
def digitaltwin(environment_variables):
Expand Down
8 changes: 6 additions & 2 deletions sdk/digitaltwins/azure-mgmt-digitaltwins/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer
from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer

# Ignore async tests for Python < 3.5
Expand All @@ -52,4 +52,8 @@ def add_sanitizers(test_proxy):
add_general_regex_sanitizer(regex=client_secret, 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_body_key_sanitizer(json_path="$..access_token", value="access_token")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3493: $..name
remove_batch_sanitizers(["AZSDK3493"])
2 changes: 1 addition & 1 deletion sdk/easm/azure-defender-easm/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/easm/azure-defender-easm",
"Tag": "python/easm/azure-defender-easm_1ce88f356c"
"Tag": "python/easm/azure-defender-easm_615067aba2"
}
7 changes: 6 additions & 1 deletion sdk/easm/azure-defender-easm/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import pytest
from devtools_testutils import test_proxy
from devtools_testutils import test_proxy, remove_batch_sanitizers


# 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):
# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3430: $..id
# - AZSDK3493: $..name
remove_batch_sanitizers(["AZSDK3430", "AZSDK3493"])
return
5 changes: 5 additions & 0 deletions sdk/iothub/azure-iot-deviceprovisioning/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
EnvironmentVariableLoader,
add_general_regex_sanitizer,
add_header_regex_sanitizer,
remove_batch_sanitizers,
test_proxy,
)

Expand Down Expand Up @@ -89,6 +90,10 @@ def add_sanitizers(test_proxy):
add_body_key_sanitizer(json_path="$..secondaryKey", value="secondaryKey")
add_body_key_sanitizer(json_path="$..sha256Thumbprint", value="thumbprint")
add_body_key_sanitizer(json_path="$..sha1Thumbprint", value="thumbprint")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3490: $..etag
remove_batch_sanitizers(["AZSDK3490"])
return


Expand Down
9 changes: 7 additions & 2 deletions sdk/iothub/azure-mgmt-iothub/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer
from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer

# Ignore async tests for Python < 3.5
Expand All @@ -52,4 +52,9 @@ def add_sanitizers(test_proxy):
add_general_regex_sanitizer(regex=client_secret, 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_body_key_sanitizer(json_path="$..access_token", value="access_token")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3493: $..name
remove_batch_sanitizers(["AZSDK3493"])
return
10 changes: 8 additions & 2 deletions sdk/netapp/azure-mgmt-netapp/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer
from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
from devtools_testutils import add_header_regex_sanitizer, add_general_string_sanitizer, add_body_key_sanitizer

# Ignore async tests for Python < 3.5
Expand All @@ -53,4 +53,10 @@ def add_sanitizers(test_proxy):
add_general_string_sanitizer(value="00000000-0000-0000-0000-000000000000", target=urllib.parse.quote(client_secret))
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
add_header_regex_sanitizer(key="Cookie", value="cookie;")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3430: $..id
# - AZSDK3493: $..name
# - AZSDK2003: Location
remove_batch_sanitizers(["AZSDK3430", "AZSDK3493", "AZSDK2003"])
8 changes: 6 additions & 2 deletions sdk/network/azure-mgmt-dns/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer
from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer

# Ignore async tests for Python < 3.5
Expand All @@ -52,4 +52,8 @@ def add_sanitizers(test_proxy):
add_general_regex_sanitizer(regex=client_secret, 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_body_key_sanitizer(json_path="$..access_token", value="access_token")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3493: $..name
remove_batch_sanitizers(["AZSDK3493"])
7 changes: 6 additions & 1 deletion sdk/network/azure-mgmt-network/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer
from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer


Expand All @@ -54,3 +54,8 @@ def add_sanitizers(test_proxy):
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
add_header_regex_sanitizer(key="Cookie", value="cookie;")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3493: $..name
# - AZSDK2003: Location
remove_batch_sanitizers(["AZSDK3493", "AZSDK2003"])
12 changes: 11 additions & 1 deletion sdk/purview/azure-purview-sharing/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@

from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer, add_body_key_sanitizer, add_header_regex_sanitizer
from devtools_testutils import (
test_proxy,
add_general_regex_sanitizer,
add_body_key_sanitizer,
add_header_regex_sanitizer,
remove_batch_sanitizers,
)


# Ignore async tests for Python < 3.5
collect_ignore_glob = []
Expand Down Expand Up @@ -61,3 +68,6 @@ def add_sanitizers(test_proxy):
add_body_key_sanitizer(json_path="$..atlasKafkaPrimaryEndpoint", value="000")
add_body_key_sanitizer(json_path="$..atlasKafkaSecondaryEndpoint", value="000")
add_body_key_sanitizer(json_path="$..systemData.createdBy", value="000")
# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3430: $..id
remove_batch_sanitizers(["AZSDK3430"])
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
add_body_key_sanitizer,
add_general_regex_sanitizer,
add_remove_header_sanitizer,
is_live
is_live,
remove_batch_sanitizers,
)

# Environment variable keys
Expand Down Expand Up @@ -58,6 +59,10 @@ def add_sanitizers(test_proxy, environment_variables):
value=TEST_ID_PLACEHOLDER
)

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3430: $..id
remove_batch_sanitizers(["AZSDK3430"])


@pytest.fixture(scope="session")
def account_info(environment_variables):
Expand Down
11 changes: 10 additions & 1 deletion sdk/schemaregistry/azure-schemaregistry-avroencoder/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import pytest
from devtools_testutils import add_general_regex_sanitizer, test_proxy, add_oauth_response_sanitizer
from devtools_testutils import (
test_proxy,
add_general_regex_sanitizer,
add_oauth_response_sanitizer,
remove_batch_sanitizers,
)

# 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(regex="(?<=\\/\\/)[a-z-]+(?=\\.servicebus\\.windows\\.net)", value="fake_resource_avro")
add_oauth_response_sanitizer()

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3493: $..name
remove_batch_sanitizers(["AZSDK3493"])

# 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):
Expand Down
Loading

0 comments on commit 5ae47b7

Please sign in to comment.