-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Communication]Migrate ACS Rooms Python to use new Test Proxy (#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]>
- Loading branch information
Showing
79 changed files
with
3,859 additions
and
14,527 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
sdk/communication/azure-communication-rooms/tests/acs_rooms_test_case.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# coding: utf-8 | ||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# -------------------------------------------------------------------------- | ||
import os | ||
from devtools_testutils import AzureRecordedTestCase, is_live | ||
from azure.communication.rooms._shared.utils import parse_connection_str | ||
|
||
class ACSRoomsTestCase(AzureRecordedTestCase): | ||
def setUp(self): | ||
if is_live(): | ||
self.connection_str = os.getenv('COMMUNICATION_CONNECTION_STRING_ROOMS') | ||
self.endpoint, _ = parse_connection_str(self.connection_str) | ||
self._resource_name = self.endpoint.split(".")[0] | ||
else: | ||
self.connection_str = "endpoint=https://sanitized.communication.azure.com/;accesskey=fake===" | ||
self.endpoint, _ = parse_connection_str(self.connection_str) | ||
self._resource_name = self.endpoint.split(".")[0] | ||
|
54 changes: 54 additions & 0 deletions
54
sdk/communication/azure-communication-rooms/tests/conftest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -------------------------------------------------------------------------- | ||
# | ||
# 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. | ||
# | ||
# -------------------------------------------------------------------------- | ||
import pytest | ||
import os | ||
from devtools_testutils import add_general_string_sanitizer, add_header_regex_sanitizer, add_body_key_sanitizer, set_default_session_settings | ||
from azure.communication.rooms._shared.utils import parse_connection_str | ||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def add_sanitizers(test_proxy): | ||
set_default_session_settings() | ||
|
||
communication_connection_string = os.getenv("COMMUNICATION_CONNECTION_STRING_ROOMS", "endpoint=https://sanitized.communication.azure.com/;accesskey=fake===") | ||
|
||
add_general_string_sanitizer(target=communication_connection_string, value="endpoint=https://sanitized.communication.azure.com/;accesskey=fake===") | ||
endpoint, _ = parse_connection_str(communication_connection_string) | ||
add_general_string_sanitizer(target=endpoint, value="sanitized.communication.azure.com") | ||
add_header_regex_sanitizer(key="x-ms-content-sha256", value="sanitized") | ||
add_header_regex_sanitizer(key="Set-Cookie", value="sanitized") | ||
add_header_regex_sanitizer(key="Date", value="sanitized") | ||
add_header_regex_sanitizer(key="Cookie", value="sanitized") | ||
add_header_regex_sanitizer(key="client-request-id", value="sanitized") | ||
add_header_regex_sanitizer(key="MS-CV", value="sanitized") | ||
add_header_regex_sanitizer(key="X-Azure-Ref", value="sanitized") | ||
add_header_regex_sanitizer(key="x-ms-content-sha256", value="sanitized") | ||
add_header_regex_sanitizer(key="x-ms-client-request-id", value="sanitized") | ||
add_header_regex_sanitizer(key="x-ms-date", value="sanitized") | ||
add_header_regex_sanitizer(key="x-ms-request-id", value="sanitized") | ||
add_header_regex_sanitizer( | ||
key="Content-Security-Policy-Report-Only", value="sanitized") | ||
add_header_regex_sanitizer(key="Repeatability-First-Sent", value="sanitized") | ||
add_header_regex_sanitizer(key="Repeatability-Request-ID", value="sanitized") |
20 changes: 0 additions & 20 deletions
20
sdk/communication/azure-communication-rooms/tests/helper.py
This file was deleted.
Oops, something went wrong.
166 changes: 166 additions & 0 deletions
166
.../tests/recordings/test_rooms_client.pyTestRoomsClienttest_add_or_update_participants.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
{ | ||
"Entries": [ | ||
{ | ||
"RequestUri": "https://sanitized.communication.azure.com/rooms?api-version=2023-03-31-preview", | ||
"RequestMethod": "POST", | ||
"RequestHeaders": { | ||
"Accept": "application/json", | ||
"Accept-Encoding": "gzip, deflate", | ||
"Authorization": "Sanitized", | ||
"Connection": "keep-alive", | ||
"Content-Length": "142", | ||
"Content-Type": "application/json", | ||
"Repeatability-First-Sent": "sanitized", | ||
"Repeatability-Request-ID": "sanitized", | ||
"User-Agent": "azsdk-python-communication-rooms/1.0.0b3 Python/3.10.0 (Windows-10-10.0.22621-SP0)", | ||
"x-ms-client-request-id": "sanitized", | ||
"x-ms-content-sha256": "sanitized", | ||
"x-ms-date": "sanitized", | ||
"x-ms-return-client-request-id": "true" | ||
}, | ||
"RequestBody": { | ||
"validFrom": null, | ||
"validUntil": null, | ||
"participants": { | ||
"8:acs:sanitized1": { | ||
"role": "Presenter" | ||
}, | ||
"8:acs:sanitized3": { | ||
"role": "Attendee" | ||
} | ||
} | ||
}, | ||
"StatusCode": 201, | ||
"ResponseHeaders": { | ||
"api-deprecated-versions": "2021-04-07", | ||
"api-supported-versions": "2022-02-01, 2023-03-31-preview", | ||
"Content-Type": "application/json; charset=utf-8", | ||
"Date": "sanitized", | ||
"Location": "99438909571195444", | ||
"MS-CV": "sanitized", | ||
"Repeatability-Result": "accepted", | ||
"Request-Context": "appId=", | ||
"Transfer-Encoding": "chunked", | ||
"X-Azure-Ref": "sanitized", | ||
"X-Cache": "CONFIG_NOCACHE" | ||
}, | ||
"ResponseBody": { | ||
"id": "99438909571195444", | ||
"createdAt": "2023-05-05T21:09:08.8167074\u002B00:00", | ||
"validFrom": "2023-05-05T21:09:08.7637676\u002B00:00", | ||
"validUntil": "2023-11-01T21:09:08.7637676\u002B00:00" | ||
} | ||
}, | ||
{ | ||
"RequestUri": "https://sanitized.communication.azure.com/rooms/99438909571195444/participants?api-version=2023-03-31-preview", | ||
"RequestMethod": "PATCH", | ||
"RequestHeaders": { | ||
"Accept": "application/json", | ||
"Accept-Encoding": "gzip, deflate", | ||
"Authorization": "Sanitized", | ||
"Connection": "keep-alive", | ||
"Content-Length": "102", | ||
"Content-Type": "application/merge-patch\u002Bjson", | ||
"User-Agent": "azsdk-python-communication-rooms/1.0.0b3 Python/3.10.0 (Windows-10-10.0.22621-SP0)", | ||
"x-ms-client-request-id": "sanitized", | ||
"x-ms-content-sha256": "sanitized", | ||
"x-ms-date": "sanitized", | ||
"x-ms-return-client-request-id": "true" | ||
}, | ||
"RequestBody": { | ||
"participants": { | ||
"8:acs:sanitized1": { | ||
"role": "Consumer" | ||
}, | ||
"8:acs:sanitized2": { | ||
"role": "Consumer" | ||
} | ||
} | ||
}, | ||
"StatusCode": 200, | ||
"ResponseHeaders": { | ||
"api-supported-versions": "2022-02-01, 2023-03-31-preview", | ||
"Content-Type": "application/json; charset=utf-8", | ||
"Date": "sanitized", | ||
"MS-CV": "sanitized", | ||
"Request-Context": "appId=", | ||
"Transfer-Encoding": "chunked", | ||
"X-Azure-Ref": "sanitized", | ||
"X-Cache": "CONFIG_NOCACHE" | ||
}, | ||
"ResponseBody": {} | ||
}, | ||
{ | ||
"RequestUri": "https://sanitized.communication.azure.com/rooms/99438909571195444/participants?api-version=2023-03-31-preview", | ||
"RequestMethod": "GET", | ||
"RequestHeaders": { | ||
"Accept": "application/json", | ||
"Accept-Encoding": "gzip, deflate", | ||
"Authorization": "Sanitized", | ||
"Connection": "keep-alive", | ||
"User-Agent": "azsdk-python-communication-rooms/1.0.0b3 Python/3.10.0 (Windows-10-10.0.22621-SP0)", | ||
"x-ms-client-request-id": "sanitized", | ||
"x-ms-content-sha256": "sanitized", | ||
"x-ms-date": "sanitized", | ||
"x-ms-return-client-request-id": "true" | ||
}, | ||
"RequestBody": null, | ||
"StatusCode": 200, | ||
"ResponseHeaders": { | ||
"api-supported-versions": "2022-02-01, 2023-03-31-preview", | ||
"Content-Type": "application/json; charset=utf-8", | ||
"Date": "sanitized", | ||
"MS-CV": "sanitized", | ||
"Request-Context": "appId=", | ||
"Transfer-Encoding": "chunked", | ||
"X-Azure-Ref": "sanitized", | ||
"X-Cache": "CONFIG_NOCACHE" | ||
}, | ||
"ResponseBody": { | ||
"value": [ | ||
{ | ||
"rawId": "8:acs:sanitized1", | ||
"role": "Consumer" | ||
}, | ||
{ | ||
"rawId": "8:acs:sanitized3", | ||
"role": "Attendee" | ||
}, | ||
{ | ||
"rawId": "8:acs:sanitized2", | ||
"role": "Consumer" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"RequestUri": "https://sanitized.communication.azure.com/rooms/99438909571195444?api-version=2023-03-31-preview", | ||
"RequestMethod": "DELETE", | ||
"RequestHeaders": { | ||
"Accept": "application/json", | ||
"Accept-Encoding": "gzip, deflate", | ||
"Authorization": "Sanitized", | ||
"Connection": "keep-alive", | ||
"Content-Length": "0", | ||
"User-Agent": "azsdk-python-communication-rooms/1.0.0b3 Python/3.10.0 (Windows-10-10.0.22621-SP0)", | ||
"x-ms-client-request-id": "sanitized", | ||
"x-ms-content-sha256": "sanitized", | ||
"x-ms-date": "sanitized", | ||
"x-ms-return-client-request-id": "true" | ||
}, | ||
"RequestBody": null, | ||
"StatusCode": 204, | ||
"ResponseHeaders": { | ||
"api-deprecated-versions": "2021-04-07", | ||
"api-supported-versions": "2022-02-01, 2023-03-31-preview", | ||
"Date": "sanitized", | ||
"MS-CV": "sanitized", | ||
"Request-Context": "appId=", | ||
"X-Azure-Ref": "sanitized", | ||
"X-Cache": "CONFIG_NOCACHE" | ||
}, | ||
"ResponseBody": null | ||
} | ||
], | ||
"Variables": {} | ||
} |
Oops, something went wrong.