Skip to content

Commit cbb3590

Browse files
minnieliuMinnie Liu
andauthored
[Communication]Migrate ACS Rooms Python to use new Test Proxy (Azure#30217)
* Migrate ACS Rooms Python to use new Test Proxy * santizie MS-CV and other response headers * Address comments * Fix tests in playback mode * Fix tests in playback mode * Refactor --------- Co-authored-by: Minnie Liu <[email protected]>
1 parent fbb7a4a commit cbb3590

File tree

79 files changed

+3859
-14527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3859
-14527
lines changed

sdk/communication/azure-communication-rooms/dev_requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-e ../azure-communication-identity
44
../../core/azure-core
55
../../identity/azure-identity
6-
aiohttp>=3.0;
6+
aiohttp>=3.0
77
typing_extensions>=3.7.2
88
aiounittest>=1.4
9-
asyncio
9+
asyncio

sdk/communication/azure-communication-rooms/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ stages:
2222
Clouds: Public,Int
2323
TestResourceDirectories:
2424
- communication/test-resources/
25+
EnvVars:
26+
AZURE_SKIP_LIVE_RECORDING: 'True'
27+
AZURE_TEST_RUN_LIVE: 'true'
2528

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# coding: utf-8
2+
# -------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
# --------------------------------------------------------------------------
7+
import os
8+
from devtools_testutils import AzureRecordedTestCase, is_live
9+
from azure.communication.rooms._shared.utils import parse_connection_str
10+
11+
class ACSRoomsTestCase(AzureRecordedTestCase):
12+
def setUp(self):
13+
if is_live():
14+
self.connection_str = os.getenv('COMMUNICATION_CONNECTION_STRING_ROOMS')
15+
self.endpoint, _ = parse_connection_str(self.connection_str)
16+
self._resource_name = self.endpoint.split(".")[0]
17+
else:
18+
self.connection_str = "endpoint=https://sanitized.communication.azure.com/;accesskey=fake==="
19+
self.endpoint, _ = parse_connection_str(self.connection_str)
20+
self._resource_name = self.endpoint.split(".")[0]
21+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# --------------------------------------------------------------------------
2+
#
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
#
5+
# The MIT License (MIT)
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the ""Software""), to
9+
# deal in the Software without restriction, including without limitation the
10+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11+
# sell copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in
15+
# all copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23+
# IN THE SOFTWARE.
24+
#
25+
# --------------------------------------------------------------------------
26+
import pytest
27+
import os
28+
from devtools_testutils import add_general_string_sanitizer, add_header_regex_sanitizer, add_body_key_sanitizer, set_default_session_settings
29+
from azure.communication.rooms._shared.utils import parse_connection_str
30+
31+
@pytest.fixture(scope="session", autouse=True)
32+
def add_sanitizers(test_proxy):
33+
set_default_session_settings()
34+
35+
communication_connection_string = os.getenv("COMMUNICATION_CONNECTION_STRING_ROOMS", "endpoint=https://sanitized.communication.azure.com/;accesskey=fake===")
36+
37+
add_general_string_sanitizer(target=communication_connection_string, value="endpoint=https://sanitized.communication.azure.com/;accesskey=fake===")
38+
endpoint, _ = parse_connection_str(communication_connection_string)
39+
add_general_string_sanitizer(target=endpoint, value="sanitized.communication.azure.com")
40+
add_header_regex_sanitizer(key="x-ms-content-sha256", value="sanitized")
41+
add_header_regex_sanitizer(key="Set-Cookie", value="sanitized")
42+
add_header_regex_sanitizer(key="Date", value="sanitized")
43+
add_header_regex_sanitizer(key="Cookie", value="sanitized")
44+
add_header_regex_sanitizer(key="client-request-id", value="sanitized")
45+
add_header_regex_sanitizer(key="MS-CV", value="sanitized")
46+
add_header_regex_sanitizer(key="X-Azure-Ref", value="sanitized")
47+
add_header_regex_sanitizer(key="x-ms-content-sha256", value="sanitized")
48+
add_header_regex_sanitizer(key="x-ms-client-request-id", value="sanitized")
49+
add_header_regex_sanitizer(key="x-ms-date", value="sanitized")
50+
add_header_regex_sanitizer(key="x-ms-request-id", value="sanitized")
51+
add_header_regex_sanitizer(
52+
key="Content-Security-Policy-Report-Only", value="sanitized")
53+
add_header_regex_sanitizer(key="Repeatability-First-Sent", value="sanitized")
54+
add_header_regex_sanitizer(key="Repeatability-Request-ID", value="sanitized")

sdk/communication/azure-communication-rooms/tests/helper.py

Lines changed: 0 additions & 20 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "https://sanitized.communication.azure.com/rooms?api-version=2023-03-31-preview",
5+
"RequestMethod": "POST",
6+
"RequestHeaders": {
7+
"Accept": "application/json",
8+
"Accept-Encoding": "gzip, deflate",
9+
"Authorization": "Sanitized",
10+
"Connection": "keep-alive",
11+
"Content-Length": "142",
12+
"Content-Type": "application/json",
13+
"Repeatability-First-Sent": "sanitized",
14+
"Repeatability-Request-ID": "sanitized",
15+
"User-Agent": "azsdk-python-communication-rooms/1.0.0b3 Python/3.10.0 (Windows-10-10.0.22621-SP0)",
16+
"x-ms-client-request-id": "sanitized",
17+
"x-ms-content-sha256": "sanitized",
18+
"x-ms-date": "sanitized",
19+
"x-ms-return-client-request-id": "true"
20+
},
21+
"RequestBody": {
22+
"validFrom": null,
23+
"validUntil": null,
24+
"participants": {
25+
"8:acs:sanitized1": {
26+
"role": "Presenter"
27+
},
28+
"8:acs:sanitized3": {
29+
"role": "Attendee"
30+
}
31+
}
32+
},
33+
"StatusCode": 201,
34+
"ResponseHeaders": {
35+
"api-deprecated-versions": "2021-04-07",
36+
"api-supported-versions": "2022-02-01, 2023-03-31-preview",
37+
"Content-Type": "application/json; charset=utf-8",
38+
"Date": "sanitized",
39+
"Location": "99438909571195444",
40+
"MS-CV": "sanitized",
41+
"Repeatability-Result": "accepted",
42+
"Request-Context": "appId=",
43+
"Transfer-Encoding": "chunked",
44+
"X-Azure-Ref": "sanitized",
45+
"X-Cache": "CONFIG_NOCACHE"
46+
},
47+
"ResponseBody": {
48+
"id": "99438909571195444",
49+
"createdAt": "2023-05-05T21:09:08.8167074\u002B00:00",
50+
"validFrom": "2023-05-05T21:09:08.7637676\u002B00:00",
51+
"validUntil": "2023-11-01T21:09:08.7637676\u002B00:00"
52+
}
53+
},
54+
{
55+
"RequestUri": "https://sanitized.communication.azure.com/rooms/99438909571195444/participants?api-version=2023-03-31-preview",
56+
"RequestMethod": "PATCH",
57+
"RequestHeaders": {
58+
"Accept": "application/json",
59+
"Accept-Encoding": "gzip, deflate",
60+
"Authorization": "Sanitized",
61+
"Connection": "keep-alive",
62+
"Content-Length": "102",
63+
"Content-Type": "application/merge-patch\u002Bjson",
64+
"User-Agent": "azsdk-python-communication-rooms/1.0.0b3 Python/3.10.0 (Windows-10-10.0.22621-SP0)",
65+
"x-ms-client-request-id": "sanitized",
66+
"x-ms-content-sha256": "sanitized",
67+
"x-ms-date": "sanitized",
68+
"x-ms-return-client-request-id": "true"
69+
},
70+
"RequestBody": {
71+
"participants": {
72+
"8:acs:sanitized1": {
73+
"role": "Consumer"
74+
},
75+
"8:acs:sanitized2": {
76+
"role": "Consumer"
77+
}
78+
}
79+
},
80+
"StatusCode": 200,
81+
"ResponseHeaders": {
82+
"api-supported-versions": "2022-02-01, 2023-03-31-preview",
83+
"Content-Type": "application/json; charset=utf-8",
84+
"Date": "sanitized",
85+
"MS-CV": "sanitized",
86+
"Request-Context": "appId=",
87+
"Transfer-Encoding": "chunked",
88+
"X-Azure-Ref": "sanitized",
89+
"X-Cache": "CONFIG_NOCACHE"
90+
},
91+
"ResponseBody": {}
92+
},
93+
{
94+
"RequestUri": "https://sanitized.communication.azure.com/rooms/99438909571195444/participants?api-version=2023-03-31-preview",
95+
"RequestMethod": "GET",
96+
"RequestHeaders": {
97+
"Accept": "application/json",
98+
"Accept-Encoding": "gzip, deflate",
99+
"Authorization": "Sanitized",
100+
"Connection": "keep-alive",
101+
"User-Agent": "azsdk-python-communication-rooms/1.0.0b3 Python/3.10.0 (Windows-10-10.0.22621-SP0)",
102+
"x-ms-client-request-id": "sanitized",
103+
"x-ms-content-sha256": "sanitized",
104+
"x-ms-date": "sanitized",
105+
"x-ms-return-client-request-id": "true"
106+
},
107+
"RequestBody": null,
108+
"StatusCode": 200,
109+
"ResponseHeaders": {
110+
"api-supported-versions": "2022-02-01, 2023-03-31-preview",
111+
"Content-Type": "application/json; charset=utf-8",
112+
"Date": "sanitized",
113+
"MS-CV": "sanitized",
114+
"Request-Context": "appId=",
115+
"Transfer-Encoding": "chunked",
116+
"X-Azure-Ref": "sanitized",
117+
"X-Cache": "CONFIG_NOCACHE"
118+
},
119+
"ResponseBody": {
120+
"value": [
121+
{
122+
"rawId": "8:acs:sanitized1",
123+
"role": "Consumer"
124+
},
125+
{
126+
"rawId": "8:acs:sanitized3",
127+
"role": "Attendee"
128+
},
129+
{
130+
"rawId": "8:acs:sanitized2",
131+
"role": "Consumer"
132+
}
133+
]
134+
}
135+
},
136+
{
137+
"RequestUri": "https://sanitized.communication.azure.com/rooms/99438909571195444?api-version=2023-03-31-preview",
138+
"RequestMethod": "DELETE",
139+
"RequestHeaders": {
140+
"Accept": "application/json",
141+
"Accept-Encoding": "gzip, deflate",
142+
"Authorization": "Sanitized",
143+
"Connection": "keep-alive",
144+
"Content-Length": "0",
145+
"User-Agent": "azsdk-python-communication-rooms/1.0.0b3 Python/3.10.0 (Windows-10-10.0.22621-SP0)",
146+
"x-ms-client-request-id": "sanitized",
147+
"x-ms-content-sha256": "sanitized",
148+
"x-ms-date": "sanitized",
149+
"x-ms-return-client-request-id": "true"
150+
},
151+
"RequestBody": null,
152+
"StatusCode": 204,
153+
"ResponseHeaders": {
154+
"api-deprecated-versions": "2021-04-07",
155+
"api-supported-versions": "2022-02-01, 2023-03-31-preview",
156+
"Date": "sanitized",
157+
"MS-CV": "sanitized",
158+
"Request-Context": "appId=",
159+
"X-Azure-Ref": "sanitized",
160+
"X-Cache": "CONFIG_NOCACHE"
161+
},
162+
"ResponseBody": null
163+
}
164+
],
165+
"Variables": {}
166+
}

0 commit comments

Comments
 (0)