Skip to content

Commit

Permalink
[Communication]: use x-ms-date for hmac (#19396)
Browse files Browse the repository at this point in the history
* Use x-ms-date for Hmac

* Update chat recorded sessions

* Fix SMS hmac; update sms recorded sessions

* Update phone number code and recorded sessions

Co-authored-by: JP Chen <jiach@microsoft.com>
  • Loading branch information
JianpingChen and JP Chen authored Jun 22, 2021
1 parent cb2031c commit 0c01e24
Show file tree
Hide file tree
Showing 102 changed files with 4,211 additions and 3,685 deletions.
3 changes: 3 additions & 0 deletions sdk/communication/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Let's get started with how to setup the repo itself.

To get started with any of the packages, change directory to the package you want to install and run the `pip install .` command. This will install all of the local files necessary for you to run the corresponding tests. It's important to note that if you made changes to the local files and want to run the tests again, you must run the `pip install .` command from the package root folder to update the files with your new changes.

In each SDK directory, run the following command to ensure packages to support development is installed correctly,
`python -m pip install -r .\dev_requirements.txt`.

Once the package has been installed on your machine, let's jump on how to run the tests to see that everything is in order.

## Testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _sign_request(self, request):
if self._decode_url:
query_url = urllib.parse.unquote(query_url)

signed_headers = "date;host;x-ms-content-sha256"
signed_headers = "x-ms-date;host;x-ms-content-sha256"

utc_now = get_current_utc_time()
if request.http_request.body is None:
Expand All @@ -76,7 +76,7 @@ def _sign_request(self, request):
signature = self._compute_hmac(string_to_sign)

signature_header = {
"Date": utc_now,
"x-ms-date": utc_now,
"x-ms-content-sha256": content_hash,
"x-ms-return-client-request-id": "true",
"Authorization": "HMAC-SHA256 SignedHeaders=" +\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,35 @@ interactions:
- '2'
Content-Type:
- application/json
Date:
- Tue, 23 Mar 2021 01:59:44 GMT
User-Agent:
- azsdk-python-communication-identity/1.0.0b6 Python/3.7.9 (Windows-10-10.0.19041-SP0)
- azsdk-python-communication-identity/1.0.1 Python/3.8.6rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Tue, 22 Jun 2021 20:51:50 GMT
x-ms-return-client-request-id:
- 'true'
method: POST
uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07
response:
body: '{"identity": {"id": "8:acs:fac4607d-d2d0-40e5-84df-6f32ebd1251a_00000008-fcb0-c7c7-54b7-a43a0d000907"}}'
body: '{"identity": {"id": "8:acs:ac80d96a-85de-48b1-995d-a3a3fa3627c8_0000000a-d55f-fdf3-f6c7-593a0d009fe2"}}'
headers:
api-supported-versions:
- 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07
- 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1
content-type:
- application/json; charset=utf-8
date:
- Tue, 23 Mar 2021 01:59:41 GMT
- Tue, 22 Jun 2021 20:51:50 GMT
ms-cv:
- fHGI8ZHBdE6FWWcLXb9+rw.0
- vSCUJP34TE698k75/G+nGQ.0
request-context:
- appId=
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
x-cache:
- CONFIG_NOCACHE
x-processing-time:
- 18ms
- 49ms
status:
code: 201
message: Created
Expand All @@ -55,33 +57,35 @@ interactions:
- '20'
Content-Type:
- application/json
Date:
- Tue, 23 Mar 2021 01:59:44 GMT
User-Agent:
- azsdk-python-communication-identity/1.0.0b6 Python/3.7.9 (Windows-10-10.0.19041-SP0)
- azsdk-python-communication-identity/1.0.1 Python/3.8.6rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Tue, 22 Jun 2021 20:51:50 GMT
x-ms-return-client-request-id:
- 'true'
method: POST
uri: https://sanitized.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07
response:
body: '{"token": "sanitized", "expiresOn": "2021-03-24T01:59:41.6383161+00:00"}'
body: '{"token": "sanitized", "expiresOn": "2021-06-23T20:51:50.0857826+00:00"}'
headers:
api-supported-versions:
- 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07
- 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1
content-type:
- application/json; charset=utf-8
date:
- Tue, 23 Mar 2021 01:59:41 GMT
- Tue, 22 Jun 2021 20:51:50 GMT
ms-cv:
- EfrrYu6M0kqvH0XENzwnDQ.0
- cAHNVCW16kaXydTs9QHoPA.0
request-context:
- appId=
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
x-cache:
- CONFIG_NOCACHE
x-processing-time:
- 149ms
- 65ms
status:
code: 200
message: OK
Expand All @@ -99,32 +103,34 @@ interactions:
Content-Type:
- application/json
User-Agent:
- azsdk-python-communication-chat/1.0.0b6 Python/3.7.9 (Windows-10-10.0.19041-SP0)
repeatability-Request-Id:
- 183597c1-141c-48f7-8f36-536594b699bf
- azsdk-python-communication-chat/1.0.1 Python/3.8.6rc1 (Windows-10-10.0.19041-SP0)
repeatability-request-id:
- fa6291de-4be7-4a5d-9269-277457040344
method: POST
uri: https://sanitized.communication.azure.com/chat/threads?api-version=2021-03-07
response:
body: '{"chatThread": {"id": "19:QpGlH_w2Jtw0OFUlTwFjkp_BMdOpuYobb064odI3LEo1@thread.v2",
"topic": "test topic1", "createdOn": "2021-03-23T01:59:42Z", "createdByCommunicationIdentifier":
{"rawId": "8:acs:fac4607d-d2d0-40e5-84df-6f32ebd1251a_00000008-fcb0-c7c7-54b7-a43a0d000907",
"communicationUser": {"id": "8:acs:fac4607d-d2d0-40e5-84df-6f32ebd1251a_00000008-fcb0-c7c7-54b7-a43a0d000907"}}}}'
body: '{"chatThread": {"id": "19:0OpwXD84zHNn-hB5SAUm4xePrMNmulZ33M6QIOQKNdU1@thread.v2",
"topic": "test topic1", "createdOn": "2021-06-22T20:51:51Z", "createdByCommunicationIdentifier":
{"rawId": "8:acs:ac80d96a-85de-48b1-995d-a3a3fa3627c8_0000000a-d55f-fdf3-f6c7-593a0d009fe2",
"communicationUser": {"id": "8:acs:ac80d96a-85de-48b1-995d-a3a3fa3627c8_0000000a-d55f-fdf3-f6c7-593a0d009fe2"}}}}'
headers:
api-supported-versions:
- 2020-09-21-preview2, 2020-11-01-preview3, 2021-01-27-preview4, 2021-03-01-preview5,
2021-03-07
2021-03-07, 2021-04-05-preview6
content-type:
- application/json; charset=utf-8
date:
- Tue, 23 Mar 2021 01:59:42 GMT
- Tue, 22 Jun 2021 20:51:52 GMT
ms-cv:
- 0QDsoA/PIkSNRfA85F0svg.0
- +0LZ8diz9UmrKxeDG80Jnw.0
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
x-cache:
- CONFIG_NOCACHE
x-processing-time:
- 863ms
- 958ms
status:
code: 201
message: Created
Expand All @@ -138,27 +144,29 @@ interactions:
Connection:
- keep-alive
User-Agent:
- azsdk-python-communication-chat/1.0.0b6 Python/3.7.9 (Windows-10-10.0.19041-SP0)
- azsdk-python-communication-chat/1.0.1 Python/3.8.6rc1 (Windows-10-10.0.19041-SP0)
method: GET
uri: https://sanitized.communication.azure.com/chat/threads?api-version=2021-03-07
response:
body: '{"value": "sanitized"}'
headers:
api-supported-versions:
- 2020-09-21-preview2, 2020-11-01-preview3, 2021-01-27-preview4, 2021-03-01-preview5,
2021-03-07
2021-03-07, 2021-04-05-preview6
content-type:
- application/json; charset=utf-8
date:
- Tue, 23 Mar 2021 01:59:42 GMT
- Tue, 22 Jun 2021 20:51:52 GMT
ms-cv:
- K4ohqxXMoUiwfIc1+DvMDA.0
- Ppc2hEf7IE2e1hwxmRJAkg.0
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
x-cache:
- CONFIG_NOCACHE
x-processing-time:
- 145ms
- 83ms
status:
code: 200
message: OK
Expand All @@ -173,30 +181,27 @@ interactions:
- keep-alive
Content-Length:
- '0'
Date:
- Tue, 23 Mar 2021 01:59:46 GMT
User-Agent:
- azsdk-python-communication-identity/1.0.0b6 Python/3.7.9 (Windows-10-10.0.19041-SP0)
x-ms-return-client-request-id:
- 'true'
- azsdk-python-communication-chat/1.0.1 Python/3.8.6rc1 (Windows-10-10.0.19041-SP0)
method: DELETE
uri: https://sanitized.communication.azure.com/identities/sanitized?api-version=2021-03-07
uri: https://sanitized.communication.azure.com/chat/threads/sanitized?api-version=2021-03-07
response:
body:
string: ''
headers:
api-supported-versions:
- 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07
- 2020-09-21-preview2, 2020-11-01-preview3, 2021-01-27-preview4, 2021-03-01-preview5,
2021-03-07, 2021-04-05-preview6
date:
- Tue, 23 Mar 2021 01:59:43 GMT
- Tue, 22 Jun 2021 20:51:52 GMT
ms-cv:
- lhO99myGHEqzfNHwBCBFIQ.0
request-context:
- appId=
- fOJFQH20WkCsu48gFB3gTg.0
strict-transport-security:
- max-age=2592000
x-cache:
- CONFIG_NOCACHE
x-processing-time:
- 625ms
- 281ms
status:
code: 204
message: No Content
Expand All @@ -212,24 +217,31 @@ interactions:
Content-Length:
- '0'
User-Agent:
- azsdk-python-communication-chat/1.0.0b6 Python/3.7.9 (Windows-10-10.0.19041-SP0)
- azsdk-python-communication-identity/1.0.1 Python/3.8.6rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Tue, 22 Jun 2021 20:51:53 GMT
x-ms-return-client-request-id:
- 'true'
method: DELETE
uri: https://sanitized.communication.azure.com/chat/threads/sanitized?api-version=2021-03-07
uri: https://sanitized.communication.azure.com/identities/sanitized?api-version=2021-03-07
response:
body:
string: ''
headers:
api-supported-versions:
- 2020-09-21-preview2, 2020-11-01-preview3, 2021-01-27-preview4, 2021-03-01-preview5,
2021-03-07
- 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1
date:
- Tue, 23 Mar 2021 01:59:44 GMT
- Tue, 22 Jun 2021 20:51:53 GMT
ms-cv:
- 6ya6A5CIZUmKVJS7j0PAQQ.0
- yB9hp9ZolUu13FJoHHgR0w.0
request-context:
- appId=
strict-transport-security:
- max-age=2592000
x-cache:
- CONFIG_NOCACHE
x-processing-time:
- 164ms
- 497ms
status:
code: 204
message: No Content
Expand Down
Loading

0 comments on commit 0c01e24

Please sign in to comment.