Skip to content

Commit 5ae47b7

Browse files
authored
[CI] Update more tests for the new TestProxy (#35562)
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]>
1 parent dd7fd47 commit 5ae47b7

File tree

23 files changed

+137
-36
lines changed

23 files changed

+137
-36
lines changed

sdk/advisor/azure-mgmt-advisor/tests/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from dotenv import load_dotenv
3232

33-
from devtools_testutils import test_proxy, add_general_regex_sanitizer
33+
from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
3434
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer
3535

3636
# Ignore async tests for Python < 3.5
@@ -52,4 +52,8 @@ def add_sanitizers(test_proxy):
5252
add_general_regex_sanitizer(regex=client_secret, value="00000000-0000-0000-0000-000000000000")
5353
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
5454
add_header_regex_sanitizer(key="Cookie", value="cookie;")
55-
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
55+
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
56+
57+
# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
58+
# - AZSDK2003: Location
59+
remove_batch_sanitizers(["AZSDK2003"])

sdk/batch/azure-mgmt-batch/tests/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from dotenv import load_dotenv
3232

33-
from devtools_testutils import test_proxy, add_general_regex_sanitizer
33+
from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
3434
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer
3535

3636
load_dotenv()
@@ -48,4 +48,8 @@ def add_sanitizers(test_proxy):
4848
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
4949
add_header_regex_sanitizer(key="Cookie", value="cookie;")
5050
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
51-
add_body_key_sanitizer(json_path="$..storageUrl", value="storageUrl")
51+
add_body_key_sanitizer(json_path="$..storageUrl", value="storageUrl")
52+
53+
# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
54+
# - AZSDK3493: $..name
55+
remove_batch_sanitizers(["AZSDK3493"])

sdk/compute/azure-mgmt-compute/tests/conftest.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
from dotenv import load_dotenv
3232

3333
from devtools_testutils import test_proxy, add_general_regex_sanitizer, add_body_key_sanitizer
34-
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer
34+
from devtools_testutils import add_header_regex_sanitizer, remove_batch_sanitizers
3535

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

41-
41+
4242
load_dotenv()
4343

4444
@pytest.fixture(scope="session", autouse=True)
@@ -54,4 +54,8 @@ def add_sanitizers(test_proxy):
5454
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
5555
add_header_regex_sanitizer(key="Cookie", value="cookie;")
5656
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
57-
add_body_key_sanitizer(json_path="$....accessSAS", value="accessSAS")
57+
add_body_key_sanitizer(json_path="$....accessSAS", value="accessSAS")
58+
59+
# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
60+
# - AZSDK2003: Location
61+
remove_batch_sanitizers(["AZSDK2003"])

sdk/compute/azure-mgmt-compute/tests/test_mgmt_compute_galleries.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,9 @@ def test_compute_galleries(self, resource_group):
308308
result = self.mgmt_client.gallery_images.begin_delete(resource_group.name, GALLERY_NAME, IMAGE_NAME)
309309
result = result.result()
310310

311-
import time
312-
time.sleep(180)
311+
if self.is_live:
312+
import time
313+
time.sleep(180)
313314

314315
# TODO: need finish
315316
# # Delete a gallery Application Version.[delete]

sdk/confidentialledger/azure-confidentialledger/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/confidentialledger/azure-confidentialledger",
5-
"Tag": "python/confidentialledger/azure-confidentialledger_995077cfcf"
5+
"Tag": "python/confidentialledger/azure-confidentialledger_27130e59c6"
66
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
from devtools_testutils import test_proxy
1+
from devtools_testutils import test_proxy, remove_batch_sanitizers
22

33
import pytest
44

55
# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method
66
@pytest.fixture(scope="session", autouse=True)
7-
def start_proxy(test_proxy):
8-
return
7+
def add_sanitizers(test_proxy):
8+
# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
9+
# - AZSDK3433: $..userid
10+
remove_batch_sanitizers(["AZSDK3433"])

sdk/consumption/azure-mgmt-consumption/tests/test_budgets.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ def test_budgets(self, resource_group):
2626
SUBSCRIPTION_ID = self.get_settings_value('SUBSCRIPTION_ID')
2727
SCOPE = '/subscriptions/{}/resourceGroups/{}'.format(SUBSCRIPTION_ID, resource_group.name)
2828
BUDGET_NAME = self.get_resource_name('budget')
29-
TODAY = datetime.datetime.now()
30-
start_date = TODAY.strftime('%Y-%m-01T00:00:00Z')
31-
end_date = (TODAY+datetime.timedelta(180)).strftime('%Y-%m-01T00:00:00Z')
29+
start_date = "2022-12-01T00:00:00.000Z"
30+
end_date = "2023-06-01T00:00:00.000Z"
3231
# create
3332
BODY = {
3433
"category": "Cost",

sdk/devcenter/azure-developer-devcenter/tests/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Licensed under the MIT License. See License.txt in the project root for
55
# license information.
66
# --------------------------------------------------------------------------
7-
from devtools_testutils import test_proxy, add_body_key_sanitizer, add_oauth_response_sanitizer
7+
from devtools_testutils import test_proxy, add_body_key_sanitizer, add_oauth_response_sanitizer, remove_batch_sanitizers
88
import pytest
99

1010
# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method
@@ -13,4 +13,8 @@ def start_proxy(test_proxy):
1313
add_body_key_sanitizer(json_path="$..id_token", value="Sanitized")
1414
add_body_key_sanitizer(json_path="$..client_info", value="Sanitized")
1515
add_oauth_response_sanitizer()
16+
# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
17+
# - AZSDK2003: Location
18+
# - AZSDK3493: $..name
19+
remove_batch_sanitizers(["AZSDK2003", "AZSDK3493"])
1620
return

sdk/devtestlabs/azure-mgmt-devtestlabs/tests/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from dotenv import load_dotenv
3232

33-
from devtools_testutils import test_proxy, add_general_regex_sanitizer
33+
from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
3434
from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer
3535

3636
# Ignore async tests for Python < 3.5
@@ -52,4 +52,8 @@ def add_sanitizers(test_proxy):
5252
add_general_regex_sanitizer(regex=client_secret, value="00000000-0000-0000-0000-000000000000")
5353
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
5454
add_header_regex_sanitizer(key="Cookie", value="cookie;")
55-
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
55+
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
56+
57+
# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
58+
# - AZSDK3493: $..name
59+
remove_batch_sanitizers(["AZSDK3493"])

sdk/digitaltwins/azure-digitaltwins-core/tests/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
add_body_key_sanitizer,
1010
add_header_regex_sanitizer,
1111
add_oauth_response_sanitizer,
12-
add_remove_header_sanitizer
12+
add_remove_header_sanitizer,
13+
remove_batch_sanitizers,
1314
)
1415

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

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

4349
@pytest.fixture(scope="session")
4450
def digitaltwin(environment_variables):

0 commit comments

Comments
 (0)