Skip to content

Commit 25fccfc

Browse files
turalfturalf
andauthored
[Communication] Fix playback mode run (Azure#15451)
* Add playback mode running * Fix playback run bug * Rename scrubbed resource name * Remove caching; enable playbackmode * Add recodings for utm tests * Remove main from test file. Co-authored-by: turalf <tufarhad@microsoft.com>
1 parent 1786f77 commit 25fccfc

12 files changed

+149
-139
lines changed

sdk/communication/azure-communication-administration/tests/_shared/communication_service_preparer.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
from azure.mgmt.communication import CommunicationServiceManagementClient
99
from azure.mgmt.communication.models import CommunicationServiceResource
10-
from devtools_testutils import AzureMgmtPreparer, ResourceGroupPreparer
10+
from devtools_testutils import(
11+
AzureMgmtPreparer,
12+
ResourceGroupPreparer,
13+
FakeResource
14+
)
1115
from devtools_testutils.resource_testcase import RESOURCE_GROUP_PARAM
1216
from azure_devtools.scenario_tests.exceptions import AzureTestError
1317

@@ -36,6 +40,7 @@ def __init__(
3640
self.service_name = "TEST-SERVICE-NAME"
3741
self.mgmt_client = None
3842
self.set_cache(use_cache)
43+
self.scrubbed_resource_name = "communicationegrcrs"
3944

4045
def _get_resource_group(self, **kwargs):
4146
try:
@@ -48,26 +53,27 @@ def _get_resource_group(self, **kwargs):
4853
raise AzureTestError(template.format(ResourceGroupPreparer.__name__))
4954

5055
def create_resource(self, name, **kwargs):
51-
self.service_name = self.create_random_name()
52-
5356
if not self.is_live:
57+
self.resource = FakeResource(name=self.scrubbed_resource_name, id=name)
58+
5459
return {
55-
"connection_string": "endpoint=https://fake-resource.communication.azure.com/;accesskey=fake===",
60+
"connection_string": "endpoint=https://{}.communication.azure.com/;accesskey=fake===".format(self.resource.name),
5661
}
5762

63+
self.test_class_instance.scrubber.register_name_pair(name, self.scrubbed_resource_name)
5864
group_name = self._get_resource_group(**kwargs).name
5965

60-
self.mgmt_client = self.create_mgmt_client(CommunicationServiceManagementClient, polling_interval=30)
66+
self.client = self.create_mgmt_client(CommunicationServiceManagementClient, polling_interval=30)
6167

62-
resource = self.mgmt_client.communication_service.begin_create_or_update(
68+
self.resource = self.client.communication_service.begin_create_or_update(
6369
group_name,
64-
self.service_name,
70+
name,
6571
CommunicationServiceResource(location="global", data_location="UnitedStates")
6672
).result()
6773

68-
primary_connection_string = self.mgmt_client.communication_service.list_keys(
74+
primary_connection_string = self.client.communication_service.list_keys(
6975
group_name,
70-
resource.name).primary_connection_string
76+
self.resource.name).primary_connection_string
7177

7278
return {
7379
"connection_string": primary_connection_string,
@@ -78,4 +84,4 @@ def remove_resource(self, name, **kwargs):
7884
return
7985

8086
group_name = self._get_resource_group(**kwargs).name
81-
self.mgmt_client.communication_service.begin_delete(group_name, self.service_name).wait()
87+
self.client.communication_service.begin_delete(group_name, self.service_name).wait()

sdk/communication/azure-communication-administration/tests/_shared/testcase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def process_request(self, request):
4545

4646
def process_response(self, response):
4747
if is_text_payload(response) and response['body']['string']:
48-
response['body'] = self._replace_keys(response['body']['string'])
48+
response['body']['string'] = self._replace_keys(response['body']['string'])
4949

5050
return response
5151

sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_create_user.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,31 @@ interactions:
1111
Content-Length:
1212
- '0'
1313
Date:
14-
- Tue, 27 Oct 2020 19:38:10 GMT
14+
- Thu, 19 Nov 2020 20:09:02 GMT
1515
User-Agent:
1616
- azsdk-python-communication-administration/1.0.0b2 Python/3.8.5 (Linux-5.4.0-52-generic-x86_64-with-glibc2.29)
1717
x-ms-return-client-request-id:
1818
- 'true'
1919
method: POST
20-
uri: https://communicationk453hklaelp.communication.azure.com/identities?api-version=2020-07-20-preview2
20+
uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2
2121
response:
22-
body: '{"id": "sanitized"}'
22+
body:
23+
string: '{"id": "sanitized"}'
2324
headers:
2425
api-supported-versions:
25-
- 2020-07-20-preview1, 2020-07-20-preview2
26+
- 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2
2627
content-type:
2728
- application/json; charset=utf-8
2829
date:
29-
- Tue, 27 Oct 2020 19:38:10 GMT
30+
- Thu, 19 Nov 2020 20:09:02 GMT
3031
ms-cv:
31-
- /tvMPee3QkWdY1zilCt7Hw.0
32+
- SeQmVHk3FUCFqaCWXyTm4A.0
3233
strict-transport-security:
3334
- max-age=2592000
3435
transfer-encoding:
3536
- chunked
3637
x-processing-time:
37-
- 22ms
38+
- 31ms
3839
status:
3940
code: 200
4041
message: OK

sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_delete_user.yaml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,31 @@ interactions:
1111
Content-Length:
1212
- '0'
1313
Date:
14-
- Tue, 27 Oct 2020 19:38:10 GMT
14+
- Thu, 19 Nov 2020 20:09:37 GMT
1515
User-Agent:
1616
- azsdk-python-communication-administration/1.0.0b2 Python/3.8.5 (Linux-5.4.0-52-generic-x86_64-with-glibc2.29)
1717
x-ms-return-client-request-id:
1818
- 'true'
1919
method: POST
20-
uri: https://communicationk453hklaelp.communication.azure.com/identities?api-version=2020-07-20-preview2
20+
uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2
2121
response:
22-
body: '{"id": "sanitized"}'
22+
body:
23+
string: '{"id": "sanitized"}'
2324
headers:
2425
api-supported-versions:
25-
- 2020-07-20-preview1, 2020-07-20-preview2
26+
- 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2
2627
content-type:
2728
- application/json; charset=utf-8
2829
date:
29-
- Tue, 27 Oct 2020 19:38:10 GMT
30+
- Thu, 19 Nov 2020 20:09:37 GMT
3031
ms-cv:
31-
- pLZpgFtDakK6j3p1p8EwKw.0
32+
- 7RkXhKu55E6VvGuHXPJetw.0
3233
strict-transport-security:
3334
- max-age=2592000
3435
transfer-encoding:
3536
- chunked
3637
x-processing-time:
37-
- 19ms
38+
- 78ms
3839
status:
3940
code: 200
4041
message: OK
@@ -50,27 +51,27 @@ interactions:
5051
Content-Length:
5152
- '0'
5253
Date:
53-
- Tue, 27 Oct 2020 19:38:10 GMT
54+
- Thu, 19 Nov 2020 20:09:37 GMT
5455
User-Agent:
5556
- azsdk-python-communication-administration/1.0.0b2 Python/3.8.5 (Linux-5.4.0-52-generic-x86_64-with-glibc2.29)
5657
x-ms-return-client-request-id:
5758
- 'true'
5859
method: DELETE
59-
uri: https://communicationk453hklaelp.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2
60+
uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2
6061
response:
6162
body:
6263
string: ''
6364
headers:
6465
api-supported-versions:
65-
- 2020-07-20-preview1, 2020-07-20-preview2
66+
- 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2
6667
date:
67-
- Tue, 27 Oct 2020 19:38:11 GMT
68+
- Thu, 19 Nov 2020 20:09:38 GMT
6869
ms-cv:
69-
- IOMT4R5ZVUiXvVMzxjVrXQ.0
70+
- ae2evu2bf0+8rarm+wY0jQ.0
7071
strict-transport-security:
7172
- max-age=2592000
7273
x-processing-time:
73-
- 918ms
74+
- 1285ms
7475
status:
7576
code: 204
7677
message: No Content

sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_issue_token.yaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,25 @@ interactions:
1111
Content-Length:
1212
- '0'
1313
Date:
14-
- Tue, 27 Oct 2020 19:38:11 GMT
14+
- Thu, 19 Nov 2020 20:10:11 GMT
1515
User-Agent:
1616
- azsdk-python-communication-administration/1.0.0b2 Python/3.8.5 (Linux-5.4.0-52-generic-x86_64-with-glibc2.29)
1717
x-ms-return-client-request-id:
1818
- 'true'
1919
method: POST
20-
uri: https://communicationk453hklaelp.communication.azure.com/identities?api-version=2020-07-20-preview2
20+
uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2
2121
response:
22-
body: '{"id": "sanitized"}'
22+
body:
23+
string: '{"id": "sanitized"}'
2324
headers:
2425
api-supported-versions:
25-
- 2020-07-20-preview1, 2020-07-20-preview2
26+
- 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2
2627
content-type:
2728
- application/json; charset=utf-8
2829
date:
29-
- Tue, 27 Oct 2020 19:38:11 GMT
30+
- Thu, 19 Nov 2020 20:10:11 GMT
3031
ms-cv:
31-
- ubcdMU2Bk0aDuEpT+Wgitg.0
32+
- j8nyRpS3NEm7eC+ebtDK+Q.0
3233
strict-transport-security:
3334
- max-age=2592000
3435
transfer-encoding:
@@ -52,30 +53,31 @@ interactions:
5253
Content-Type:
5354
- application/json
5455
Date:
55-
- Tue, 27 Oct 2020 19:38:11 GMT
56+
- Thu, 19 Nov 2020 20:10:11 GMT
5657
User-Agent:
5758
- azsdk-python-communication-administration/1.0.0b2 Python/3.8.5 (Linux-5.4.0-52-generic-x86_64-with-glibc2.29)
5859
x-ms-return-client-request-id:
5960
- 'true'
6061
method: POST
61-
uri: https://communicationk453hklaelp.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2
62+
uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2
6263
response:
63-
body: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-10-28T19:38:10.9160451+00:00"}'
64+
body:
65+
string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-11-20T20:10:10.8016523+00:00"}'
6466
headers:
6567
api-supported-versions:
66-
- 2020-07-20-preview1, 2020-07-20-preview2
68+
- 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2
6769
content-type:
6870
- application/json; charset=utf-8
6971
date:
70-
- Tue, 27 Oct 2020 19:38:11 GMT
72+
- Thu, 19 Nov 2020 20:10:11 GMT
7173
ms-cv:
72-
- eD+1kQTuikWnfWgc8xKMKw.0
74+
- gD1WooUYFU25kvMH/SQoGg.0
7375
strict-transport-security:
7476
- max-age=2592000
7577
transfer-encoding:
7678
- chunked
7779
x-processing-time:
78-
- 29ms
80+
- 27ms
7981
status:
8082
code: 200
8183
message: OK

sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,31 @@ interactions:
1111
Content-Length:
1212
- '0'
1313
Date:
14-
- Tue, 27 Oct 2020 19:38:11 GMT
14+
- Thu, 19 Nov 2020 20:10:47 GMT
1515
User-Agent:
1616
- azsdk-python-communication-administration/1.0.0b2 Python/3.8.5 (Linux-5.4.0-52-generic-x86_64-with-glibc2.29)
1717
x-ms-return-client-request-id:
1818
- 'true'
1919
method: POST
20-
uri: https://communicationk453hklaelp.communication.azure.com/identities?api-version=2020-07-20-preview2
20+
uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2
2121
response:
22-
body: '{"id": "sanitized"}'
22+
body:
23+
string: '{"id": "sanitized"}'
2324
headers:
2425
api-supported-versions:
25-
- 2020-07-20-preview1, 2020-07-20-preview2
26+
- 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2
2627
content-type:
2728
- application/json; charset=utf-8
2829
date:
29-
- Tue, 27 Oct 2020 19:38:11 GMT
30+
- Thu, 19 Nov 2020 20:10:47 GMT
3031
ms-cv:
31-
- HSwQ+Cp/pEaQxTLGZxF68w.0
32+
- Nm38LCz7pE2hza6n/zBH0A.0
3233
strict-transport-security:
3334
- max-age=2592000
3435
transfer-encoding:
3536
- chunked
3637
x-processing-time:
37-
- 20ms
38+
- 19ms
3839
status:
3940
code: 200
4041
message: OK
@@ -52,30 +53,31 @@ interactions:
5253
Content-Type:
5354
- application/json
5455
Date:
55-
- Tue, 27 Oct 2020 19:38:12 GMT
56+
- Thu, 19 Nov 2020 20:10:47 GMT
5657
User-Agent:
5758
- azsdk-python-communication-administration/1.0.0b2 Python/3.8.5 (Linux-5.4.0-52-generic-x86_64-with-glibc2.29)
5859
x-ms-return-client-request-id:
5960
- 'true'
6061
method: POST
61-
uri: https://communicationk453hklaelp.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2
62+
uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2
6263
response:
63-
body: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-10-28T19:38:11.1260242+00:00"}'
64+
body:
65+
string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-11-20T20:10:46.7287557+00:00"}'
6466
headers:
6567
api-supported-versions:
66-
- 2020-07-20-preview1, 2020-07-20-preview2
68+
- 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2
6769
content-type:
6870
- application/json; charset=utf-8
6971
date:
70-
- Tue, 27 Oct 2020 19:38:11 GMT
72+
- Thu, 19 Nov 2020 20:10:47 GMT
7173
ms-cv:
72-
- rPK4RVKyPku6NhzzsDRFMg.0
74+
- Ig6PdxC/80S2rA+fN93cLQ.0
7375
strict-transport-security:
7476
- max-age=2592000
7577
transfer-encoding:
7678
- chunked
7779
x-processing-time:
78-
- 27ms
80+
- 24ms
7981
status:
8082
code: 200
8183
message: OK
@@ -93,27 +95,27 @@ interactions:
9395
Content-Type:
9496
- application/merge-patch+json
9597
Date:
96-
- Tue, 27 Oct 2020 19:38:12 GMT
98+
- Thu, 19 Nov 2020 20:10:47 GMT
9799
User-Agent:
98100
- azsdk-python-communication-administration/1.0.0b2 Python/3.8.5 (Linux-5.4.0-52-generic-x86_64-with-glibc2.29)
99101
x-ms-return-client-request-id:
100102
- 'true'
101103
method: PATCH
102-
uri: https://communicationk453hklaelp.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2
104+
uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2
103105
response:
104106
body:
105107
string: ''
106108
headers:
107109
api-supported-versions:
108-
- 2020-07-20-preview1, 2020-07-20-preview2
110+
- 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2
109111
date:
110-
- Tue, 27 Oct 2020 19:38:11 GMT
112+
- Thu, 19 Nov 2020 20:10:47 GMT
111113
ms-cv:
112-
- auQLGlHFdEy3NcesL/fU3A.0
114+
- 12BMvuMoKkGm0YTr7RH02Q.0
113115
strict-transport-security:
114116
- max-age=2592000
115117
x-processing-time:
116-
- 11ms
118+
- 10ms
117119
status:
118120
code: 204
119121
message: No Content

0 commit comments

Comments
 (0)