From 2540716698c80a3795aad64e8e5544b94f4dfa7b Mon Sep 17 00:00:00 2001 From: Minnie Liu Date: Tue, 2 Mar 2021 16:09:30 -0800 Subject: [PATCH 1/5] Clean up SMS SDK --- .../Azure.Communication.Sms/CHANGELOG.md | 2 +- .../Azure.Communication.Sms/README.md | 31 ++--- .../SmsClientLiveTests/SendingSmsMessage.json | 17 ++- .../SendingSmsMessageAsync.json | 17 ++- .../SendingSmsMessageFromFakeNumber.json | 14 +-- .../SendingSmsMessageFromFakeNumberAsync.json | 14 +-- ...ndingSmsMessageFromUnauthorizedNumber.json | 50 ++++++++ ...SmsMessageFromUnauthorizedNumberAsync.json | 50 ++++++++ .../SendingSmsMessageToFakeNumber.json | 60 ++++++++++ .../SendingSmsMessageToFakeNumberAsync.json | 60 ++++++++++ .../SendingSmsMessageToGroupWithOptions.json | 20 ++-- ...dingSmsMessageToGroupWithOptionsAsync.json | 20 ++-- ...SendingSmsMessageUsingTokenCredential.json | 15 ++- ...ngSmsMessageUsingTokenCredentialAsync.json | 15 ++- .../SendingTwoSmsMessages.json | 113 ++++++++++++++++++ .../SendingTwoSmsMessagesAsync.json | 113 ++++++++++++++++++ .../tests/SmsClientLiveTests.cs | 105 ++++++++++++++-- .../tests/samples/Sample1_SmsClient.cs | 36 ++++++ 18 files changed, 654 insertions(+), 98 deletions(-) create mode 100644 sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromUnauthorizedNumber.json create mode 100644 sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromUnauthorizedNumberAsync.json create mode 100644 sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToFakeNumber.json create mode 100644 sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToFakeNumberAsync.json create mode 100644 sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingTwoSmsMessages.json create mode 100644 sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingTwoSmsMessagesAsync.json diff --git a/sdk/communication/Azure.Communication.Sms/CHANGELOG.md b/sdk/communication/Azure.Communication.Sms/CHANGELOG.md index 91104d238f1ba..6a3f079c6e19e 100644 --- a/sdk/communication/Azure.Communication.Sms/CHANGELOG.md +++ b/sdk/communication/Azure.Communication.Sms/CHANGELOG.md @@ -11,7 +11,7 @@ ### Breaking - Updated `Task> SendAsync(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default)` -to `Task> SendAsync(string from, string to, string message, Models.SmsSendOptions options = default)` +to `Task> SendAsync(string from, string to, string message, SmsSendOptions options = default)` - Replaced `SendSmsResponse` with `SmsSendResult` ## 1.0.0-beta.3 (2020-11-16) diff --git a/sdk/communication/Azure.Communication.Sms/README.md b/sdk/communication/Azure.Communication.Sms/README.md index 78d1616b9d178..eaa4db1368791 100644 --- a/sdk/communication/Azure.Communication.Sms/README.md +++ b/sdk/communication/Azure.Communication.Sms/README.md @@ -47,31 +47,32 @@ SmsClient client = new SmsClient(new Uri(endpoint), tokenCredential); ``` ## Examples -### Send a SMS Message +### Send a 1:1 SMS Message To send a SMS message, call the `Send` or `SendAsync` function from the `SmsClient`. ```C# Snippet:Azure_Communication_Sms_Tests_SendAsync -SmsSendResult result = await client.SendAsync( - from: "+18001230000" // Phone number acquired on your Azure Communication resource - to: "+18005670000", - message: "Hi"); -Console.WriteLine($"Sms id: {result.MessageId}"); +SmsSendResult sendResult = await smsClient.SendAsync( + from: "+15550000000", + to: "+15550000001", + message: "Hi"); +Console.WriteLine($"Sms id: {sendResult.MessageId}"); ``` -### Send a Group SMS Message +### Send a 1:N SMS Message To send a SMS message to a list of recipients, call the `Send` or `SendAsync` function from the `SmsClient` with a list of recipient's phone numbers. You may also add pass in an options object to specify whether the delivery report should be enabled and set custom tags. ```C# Snippet:Azure_Communication_SmsClient_Send_GroupSmsWithOptions -Response> response = await client.SendAsync( - from: "+18001230000" // Phone number acquired on your Azure Communication resource - to: new string[] {"+18005670000", "+18008900000}", - message: "Hi", - options: new SmsSendOptions(enableDeliveryReport: true) // OPTIONAL - { - Tag = "marketing", // custom tags - }); +Response> response = await smsClient.SendAsync( + from: "+15550000000", + to: new string[] { "+15550000001", "+15550000002" }, + message: "Weekly Promotion!", + options: new SmsSendOptions(enableDeliveryReport: true) // OPTIONAL + { + Tag = "marketing", // custom tags + }); IEnumerable results = response.Value; foreach (SmsSendResult result in results) { Console.WriteLine($"Sms id: {result.MessageId}"); + Console.WriteLine($"Send Result Successful: {result.Successful}"); } ``` ## Troubleshooting diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessage.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessage.json index 063aeb086f03c..91996db1f3103 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessage.json +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessage.json @@ -8,10 +8,10 @@ "Authorization": "Sanitized", "Content-Length": "146", "Content-Type": "application/json", - "Date": "Mon, 01 Mar 2021 20:59:14 GMT", - "traceparent": "00-2907a0f6c325d649ba6f017c0add83c3-dce26e223dc91741-00", + "Date": "Tue, 02 Mar 2021 23:44:39 GMT", + "traceparent": "00-7156aad063d16d499691f31d63a00afc-80dbeec90d5d0349-00", "User-Agent": [ - "azsdk-net-Communication.Sms/1.0.0-alpha.20210301.1", + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", "(.NET 5.0.3; Microsoft Windows 10.0.19042)" ], "x-ms-client-request-id": "d94de0ec3b168e8a70f9894f483cef21", @@ -33,20 +33,19 @@ "ResponseHeaders": { "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 01 Mar 2021 20:59:15 GMT", - "MS-CV": "fxS0GoUOKU6l3hutlUEpbA.0", + "Date": "Tue, 02 Mar 2021 23:44:39 GMT", + "MS-CV": "E8a3v/PBskWBTOmx8RArBw.0", "Request-Context": "appId=", "Transfer-Encoding": "chunked", - "X-Azure-Ref": "0olU9YAAAAAAOwCltNdBISol2WUO/m2WYRVdSMzBFREdFMDYxNAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", - "X-Processing-Time": "388ms" + "X-Azure-Ref": "0580\u002BYAAAAACMFaMNgNRcTZK\u002BO\u002BGwU6b8RVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "885ms" }, "ResponseBody": { "value": [ { "to": "Sanitized", - "messageId": "Outgoing_2021030120591566141d2a-326b-45e4-ac8c-4b94c5cfa400_noam", + "messageId": "Outgoing_202103022344402077c5b6-8636-4ca7-b8f6-3c2027310e87_noam", "httpStatusCode": 202, - "errorMessage": null, "repeatabilityResult": "accepted", "successful": true } diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageAsync.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageAsync.json index 24171faee43e5..53a7aaaf8372b 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageAsync.json +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageAsync.json @@ -8,10 +8,10 @@ "Authorization": "Sanitized", "Content-Length": "146", "Content-Type": "application/json", - "Date": "Mon, 01 Mar 2021 20:59:18 GMT", - "traceparent": "00-9dbb24776074a442a4520e89e1927550-65bd9770e289c04b-00", + "Date": "Tue, 02 Mar 2021 23:44:44 GMT", + "traceparent": "00-6b19e8124285f349ac4ac5971821736e-3ca4b4aed7176440-00", "User-Agent": [ - "azsdk-net-Communication.Sms/1.0.0-alpha.20210301.1", + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", "(.NET 5.0.3; Microsoft Windows 10.0.19042)" ], "x-ms-client-request-id": "d2da5067b9e869b758c535d03946972b", @@ -33,20 +33,19 @@ "ResponseHeaders": { "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 01 Mar 2021 20:59:17 GMT", - "MS-CV": "deRyofhIsECpl0pq\u002BmTQ\u002BA.0", + "Date": "Tue, 02 Mar 2021 23:44:43 GMT", + "MS-CV": "R3Xbs2NHnUy3Bgom31Qguw.0", "Request-Context": "appId=", "Transfer-Encoding": "chunked", - "X-Azure-Ref": "0pVU9YAAAAABv2lPBc5SKTbNy40tUiSUhRVdSMzBFREdFMDYxNAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", - "X-Processing-Time": "285ms" + "X-Azure-Ref": "07M0\u002BYAAAAADzzcZaMc4sRpSQwx99ngTfRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "299ms" }, "ResponseBody": { "value": [ { "to": "Sanitized", - "messageId": "Outgoing_20210301205917f07b5da8-4c93-4017-9e36-697ab86e7aec_noam", + "messageId": "Outgoing_202103022344449b6cecc8-ed0b-4ecb-9ae9-515d43fe0e7e_noam", "httpStatusCode": 202, - "errorMessage": null, "repeatabilityResult": "accepted", "successful": true } diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromFakeNumber.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromFakeNumber.json index 39ab19adb25a0..840610f2b73be 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromFakeNumber.json +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromFakeNumber.json @@ -8,10 +8,10 @@ "Authorization": "Sanitized", "Content-Length": "146", "Content-Type": "application/json", - "Date": "Mon, 01 Mar 2021 20:59:15 GMT", - "traceparent": "00-8cce08fff9fc0249a634c3cb8e36b3a6-dfa1dc798819b743-00", + "Date": "Tue, 02 Mar 2021 23:44:40 GMT", + "traceparent": "00-f6713212b4c62240a7b7e9f433fa11f3-514712ab2ee14243-00", "User-Agent": [ - "azsdk-net-Communication.Sms/1.0.0-alpha.20210301.1", + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", "(.NET 5.0.3; Microsoft Windows 10.0.19042)" ], "x-ms-client-request-id": "45c8957597a6dffe099e7013371db1f0", @@ -32,12 +32,12 @@ "StatusCode": 400, "ResponseHeaders": { "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 01 Mar 2021 20:59:15 GMT", - "MS-CV": "KHfFYI4KqUemKs\u002BSNq8QQA.0", + "Date": "Tue, 02 Mar 2021 23:44:40 GMT", + "MS-CV": "Afc3Qfz3LESUHZAn9xunfA.0", "Request-Context": "appId=", "Transfer-Encoding": "chunked", - "X-Azure-Ref": "0o1U9YAAAAADWlNTol94BSbjcZrImrcLfRVdSMzBFREdFMDYxNAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", - "X-Processing-Time": "139ms" + "X-Azure-Ref": "06M0\u002BYAAAAABqysAsEgIRS7Jt3wPOFLVtRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "151ms" }, "ResponseBody": { "From": [ diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromFakeNumberAsync.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromFakeNumberAsync.json index 1c217fbb4b7ec..60c443171ae58 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromFakeNumberAsync.json +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromFakeNumberAsync.json @@ -8,10 +8,10 @@ "Authorization": "Sanitized", "Content-Length": "146", "Content-Type": "application/json", - "Date": "Mon, 01 Mar 2021 20:59:18 GMT", - "traceparent": "00-cf4194b8423a3c45b50dd360454db30e-f249e5a5e55bc040-00", + "Date": "Tue, 02 Mar 2021 23:44:44 GMT", + "traceparent": "00-5836e052fbc9dd45a877501af6e358b2-2dd694986813264c-00", "User-Agent": [ - "azsdk-net-Communication.Sms/1.0.0-alpha.20210301.1", + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", "(.NET 5.0.3; Microsoft Windows 10.0.19042)" ], "x-ms-client-request-id": "621800f0d36e41fb0d285a768c6de9b3", @@ -32,12 +32,12 @@ "StatusCode": 400, "ResponseHeaders": { "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 01 Mar 2021 20:59:17 GMT", - "MS-CV": "7yYmccL7l0iP1srg8HQ4kA.0", + "Date": "Tue, 02 Mar 2021 23:44:44 GMT", + "MS-CV": "VksIup1UEkOPntPr9ZIVzg.0", "Request-Context": "appId=", "Transfer-Encoding": "chunked", - "X-Azure-Ref": "0pVU9YAAAAABVZYpOO\u002BoVQYmlC2PHDpYBRVdSMzBFREdFMDYxNAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", - "X-Processing-Time": "143ms" + "X-Azure-Ref": "07M0\u002BYAAAAAB54mQYp2ltSYJw/5iEsykpRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "151ms" }, "ResponseBody": { "From": [ diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromUnauthorizedNumber.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromUnauthorizedNumber.json new file mode 100644 index 0000000000000..d2dce3643fab6 --- /dev/null +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromUnauthorizedNumber.json @@ -0,0 +1,50 @@ +{ + "Entries": [ + { + "RequestUri": "https://smstestapp.communication.azure.com/sms?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "146", + "Content-Type": "application/json", + "Date": "Tue, 02 Mar 2021 23:44:41 GMT", + "traceparent": "00-dec68e68db81944f85a10ada1e0d9118-da1f0ee2dd6e614b-00", + "User-Agent": [ + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", + "(.NET 5.0.3; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "07041c006777da44a4e98ec8aecb0d65", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "from": "Sanitized", + "smsRecipients": [ + { + "to": "Sanitized", + "repeatabilityRequestId": "Sanitized", + "repeatabilityFirstSent": "Sanitized" + } + ], + "message": "Hi" + }, + "StatusCode": 404, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "Content-Length": "0", + "Date": "Tue, 02 Mar 2021 23:44:40 GMT", + "MS-CV": "YJ\u002BdZ9ajL0\u002BHLUFSJ7zfGw.0", + "Request-Context": "appId=", + "X-Azure-Ref": "06c0\u002BYAAAAABLRzenLO5iRKhbBEh8DINARVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "327ms" + }, + "ResponseBody": [] + } + ], + "Variables": { + "AZURE_PHONE_NUMBER": "\u002B18005555555", + "COMMUNICATION_CONNECTION_STRING": "endpoint=https://smstestapp.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "1025377727" + } +} \ No newline at end of file diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromUnauthorizedNumberAsync.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromUnauthorizedNumberAsync.json new file mode 100644 index 0000000000000..6175d182f1a04 --- /dev/null +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageFromUnauthorizedNumberAsync.json @@ -0,0 +1,50 @@ +{ + "Entries": [ + { + "RequestUri": "https://smstestapp.communication.azure.com/sms?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "146", + "Content-Type": "application/json", + "Date": "Tue, 02 Mar 2021 23:44:45 GMT", + "traceparent": "00-34e276e7929bda4b813fed49d7b4fb98-ce7f6e19f61c9940-00", + "User-Agent": [ + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", + "(.NET 5.0.3; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "29955a9cfed96eb9debd52c0effcf838", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "from": "Sanitized", + "smsRecipients": [ + { + "to": "Sanitized", + "repeatabilityRequestId": "Sanitized", + "repeatabilityFirstSent": "Sanitized" + } + ], + "message": "Hi" + }, + "StatusCode": 404, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "Content-Length": "0", + "Date": "Tue, 02 Mar 2021 23:44:44 GMT", + "MS-CV": "47gMnraixU\u002BV4Hb4D9SUxA.0", + "Request-Context": "appId=", + "X-Azure-Ref": "07c0\u002BYAAAAABRGTcBIT3sRain8HMKFZryRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "192ms" + }, + "ResponseBody": [] + } + ], + "Variables": { + "AZURE_PHONE_NUMBER": "\u002B18005555555", + "COMMUNICATION_CONNECTION_STRING": "endpoint=https://smstestapp.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "257421069" + } +} \ No newline at end of file diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToFakeNumber.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToFakeNumber.json new file mode 100644 index 0000000000000..5d7f426150446 --- /dev/null +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToFakeNumber.json @@ -0,0 +1,60 @@ +{ + "Entries": [ + { + "RequestUri": "https://smstestapp.communication.azure.com/sms?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "146", + "Content-Type": "application/json", + "Date": "Tue, 02 Mar 2021 23:44:41 GMT", + "traceparent": "00-6f5869e857979c49ad0288dc6266198f-b1afdf2b586b6d40-00", + "User-Agent": [ + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", + "(.NET 5.0.3; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "fae53e094b1227be96cc60f4a7c8893c", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "from": "Sanitized", + "smsRecipients": [ + { + "to": "Sanitized", + "repeatabilityRequestId": "Sanitized", + "repeatabilityFirstSent": "Sanitized" + } + ], + "message": "Hi" + }, + "StatusCode": 202, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 02 Mar 2021 23:44:41 GMT", + "MS-CV": "0fNsSXnGB0u5kewzNj8xhQ.0", + "Request-Context": "appId=", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "06c0\u002BYAAAAACjMKLMiQJ/RqA8JJl83s5qRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "327ms" + }, + "ResponseBody": { + "value": [ + { + "to": "Sanitized", + "httpStatusCode": 400, + "errorMessage": "Invalid To phone number format.", + "successful": false + } + ] + } + } + ], + "Variables": { + "AZURE_PHONE_NUMBER": "\u002B18005555555", + "COMMUNICATION_CONNECTION_STRING": "endpoint=https://smstestapp.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "543693712" + } +} \ No newline at end of file diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToFakeNumberAsync.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToFakeNumberAsync.json new file mode 100644 index 0000000000000..14dbcf3227144 --- /dev/null +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToFakeNumberAsync.json @@ -0,0 +1,60 @@ +{ + "Entries": [ + { + "RequestUri": "https://smstestapp.communication.azure.com/sms?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "146", + "Content-Type": "application/json", + "Date": "Tue, 02 Mar 2021 23:44:45 GMT", + "traceparent": "00-7789696078d55a46b6282195c3ab83f7-81d9dc897f6db142-00", + "User-Agent": [ + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", + "(.NET 5.0.3; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "d31443484701d4e869dfe7b2fd4c552b", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "from": "Sanitized", + "smsRecipients": [ + { + "to": "Sanitized", + "repeatabilityRequestId": "Sanitized", + "repeatabilityFirstSent": "Sanitized" + } + ], + "message": "Hi" + }, + "StatusCode": 202, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 02 Mar 2021 23:44:44 GMT", + "MS-CV": "lLcb97hh5kqYd9YWLt1QLg.0", + "Request-Context": "appId=", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "07c0\u002BYAAAAACy5t5ha7Y7QbJQ2oPyiOfQRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "186ms" + }, + "ResponseBody": { + "value": [ + { + "to": "Sanitized", + "httpStatusCode": 400, + "errorMessage": "Invalid To phone number format.", + "successful": false + } + ] + } + } + ], + "Variables": { + "AZURE_PHONE_NUMBER": "\u002B18005555555", + "COMMUNICATION_CONNECTION_STRING": "endpoint=https://smstestapp.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "1419695495" + } +} \ No newline at end of file diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToGroupWithOptions.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToGroupWithOptions.json index c8a5822401595..0b98455dfa510 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToGroupWithOptions.json +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToGroupWithOptions.json @@ -8,10 +8,10 @@ "Authorization": "Sanitized", "Content-Length": "304", "Content-Type": "application/json", - "Date": "Mon, 01 Mar 2021 20:59:16 GMT", - "traceparent": "00-436f818fefbe3f4dbd43f38a74fcf938-188b87d9f4272141-00", + "Date": "Tue, 02 Mar 2021 23:44:41 GMT", + "traceparent": "00-8957e9190da6d24c92324051c6b4beb2-590587f8a9699545-00", "User-Agent": [ - "azsdk-net-Communication.Sms/1.0.0-alpha.20210301.1", + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", "(.NET 5.0.3; Microsoft Windows 10.0.19042)" ], "x-ms-client-request-id": "5ec843cdd5febfe0dc325e42938b8de4", @@ -42,28 +42,26 @@ "ResponseHeaders": { "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 01 Mar 2021 20:59:15 GMT", - "MS-CV": "SNl9U08\u002B20WOyESqQ2udDQ.0", + "Date": "Tue, 02 Mar 2021 23:44:41 GMT", + "MS-CV": "cjmAwI\u002BGZkSvZWbGIF6YHg.0", "Request-Context": "appId=", "Transfer-Encoding": "chunked", - "X-Azure-Ref": "0o1U9YAAAAADsXHF0bdo2QLpSH\u002BVBxJlmRVdSMzBFREdFMDYxNAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", - "X-Processing-Time": "370ms" + "X-Azure-Ref": "06c0\u002BYAAAAAC1CNAcnBxcSZg0twPaoZwuRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "478ms" }, "ResponseBody": { "value": [ { "to": "Sanitized", - "messageId": "Outgoing_20210301205915d4f99780-6bff-4766-8674-c5758899a8c1_noam", + "messageId": "Outgoing_20210302234442c48bb807-1306-45e5-82e5-c93151479836_noam", "httpStatusCode": 202, - "errorMessage": null, "repeatabilityResult": "accepted", "successful": true }, { "to": "Sanitized", - "messageId": "Outgoing_20210301205915fb5089d2-932e-44d1-b1f0-9cb428a49d1e_noam", + "messageId": "Outgoing_20210302234442001e0c59-7e1a-44b4-8167-812a514a5074_noam", "httpStatusCode": 202, - "errorMessage": null, "repeatabilityResult": "accepted", "successful": true } diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToGroupWithOptionsAsync.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToGroupWithOptionsAsync.json index fa68091c59612..e077774ba6ef3 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToGroupWithOptionsAsync.json +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageToGroupWithOptionsAsync.json @@ -8,10 +8,10 @@ "Authorization": "Sanitized", "Content-Length": "304", "Content-Type": "application/json", - "Date": "Mon, 01 Mar 2021 20:59:18 GMT", - "traceparent": "00-22fda468da847542bbb5331d0692548c-7f0d51878a40154b-00", + "Date": "Tue, 02 Mar 2021 23:44:45 GMT", + "traceparent": "00-405c7e3d92a6c24891c9531d14f7fcd5-e7c4efa987f4664d-00", "User-Agent": [ - "azsdk-net-Communication.Sms/1.0.0-alpha.20210301.1", + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", "(.NET 5.0.3; Microsoft Windows 10.0.19042)" ], "x-ms-client-request-id": "617c06a557cc9ab5da8c2a02e6ee330c", @@ -42,28 +42,26 @@ "ResponseHeaders": { "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 01 Mar 2021 20:59:18 GMT", - "MS-CV": "FzzvoPgth0KL3rSPdpMkoA.0", + "Date": "Tue, 02 Mar 2021 23:44:45 GMT", + "MS-CV": "4yImgmPLQ0G0\u002B6pRTU37mQ.0", "Request-Context": "appId=", "Transfer-Encoding": "chunked", - "X-Azure-Ref": "0plU9YAAAAACJeEZHKT80R6gafRNLAFevRVdSMzBFREdFMDYxNAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", - "X-Processing-Time": "292ms" + "X-Azure-Ref": "07c0\u002BYAAAAAAqAmqIS6u7RLCofedR8vYoRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "311ms" }, "ResponseBody": { "value": [ { "to": "Sanitized", - "messageId": "Outgoing_202103012059183b5bd60a-52e6-4242-9958-520336c086ba_noam", + "messageId": "Outgoing_20210302234445edb99d3d-207c-40c5-a913-0513761b6026_noam", "httpStatusCode": 202, - "errorMessage": null, "repeatabilityResult": "accepted", "successful": true }, { "to": "Sanitized", - "messageId": "Outgoing_20210301205918b63191e8-d35e-4cbf-97b6-fd7536191f81_noam", + "messageId": "Outgoing_2021030223444515de6435-cfa3-4b50-921c-f97da663bbff_noam", "httpStatusCode": 202, - "errorMessage": null, "repeatabilityResult": "accepted", "successful": true } diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageUsingTokenCredential.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageUsingTokenCredential.json index f8d0b1ba987bd..831e41114fe6e 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageUsingTokenCredential.json +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageUsingTokenCredential.json @@ -8,9 +8,9 @@ "Authorization": "Sanitized", "Content-Length": "146", "Content-Type": "application/json", - "traceparent": "00-b46b64622fa21f44bf4fcb43b79bb3f6-7530a88ad64e9342-00", + "traceparent": "00-49652515f979a64789fa118e879edab6-c5143985ecf23942-00", "User-Agent": [ - "azsdk-net-Communication.Sms/1.0.0-alpha.20210301.1", + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", "(.NET 5.0.3; Microsoft Windows 10.0.19042)" ], "x-ms-client-request-id": "43b277a6a16a3bff6b2e48dfdec028e6", @@ -31,20 +31,19 @@ "ResponseHeaders": { "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 01 Mar 2021 20:59:17 GMT", - "MS-CV": "vpyvzIEEjkyqMewbRyHUFQ.0", + "Date": "Tue, 02 Mar 2021 23:44:42 GMT", + "MS-CV": "B4UTEj0Ws06IzCGxdJu9LA.0", "Request-Context": "appId=", "Transfer-Encoding": "chunked", - "X-Azure-Ref": "0pVU9YAAAAAA14AMV2It1T6F/ckhVjRMHRVdSMzBFREdFMDYxNAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", - "X-Processing-Time": "293ms" + "X-Azure-Ref": "0680\u002BYAAAAADWSTQFJZyzRoZgp04n3PkiRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "335ms" }, "ResponseBody": { "value": [ { "to": "Sanitized", - "messageId": "Outgoing_20210301205917850c1467-c8e1-4930-876b-9609f15a219c_noam", + "messageId": "Outgoing_20210302234443cf8ca9b3-44b0-4198-84cf-c9b7141c1383_noam", "httpStatusCode": 202, - "errorMessage": null, "repeatabilityResult": "accepted", "successful": true } diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageUsingTokenCredentialAsync.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageUsingTokenCredentialAsync.json index 38e9d717f7f4b..e2609750466f1 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageUsingTokenCredentialAsync.json +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingSmsMessageUsingTokenCredentialAsync.json @@ -8,9 +8,9 @@ "Authorization": "Sanitized", "Content-Length": "146", "Content-Type": "application/json", - "traceparent": "00-06b6a8be1d3bc24080e2a9543fb4d98c-f08811170ac4684d-00", + "traceparent": "00-25d2b5e759da814288ff5a31ad0d6640-fb1d52d1058f164b-00", "User-Agent": [ - "azsdk-net-Communication.Sms/1.0.0-alpha.20210301.1", + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", "(.NET 5.0.3; Microsoft Windows 10.0.19042)" ], "x-ms-client-request-id": "211c4f06f8f31aa4758da8322125a8e5", @@ -31,20 +31,19 @@ "ResponseHeaders": { "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 01 Mar 2021 20:59:18 GMT", - "MS-CV": "gJJNdlQdg0WCPXJWRYtqmg.0", + "Date": "Tue, 02 Mar 2021 23:44:45 GMT", + "MS-CV": "qBkTk8rSrUWxlGuf1OSyKQ.0", "Request-Context": "appId=", "Transfer-Encoding": "chunked", - "X-Azure-Ref": "0plU9YAAAAAAwaWzv0xPMS5G/19kIvxAFRVdSMzBFREdFMDYxNAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", - "X-Processing-Time": "292ms" + "X-Azure-Ref": "07s0\u002BYAAAAAAP5AxUT8LMQoCGCsqvbWVMRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "300ms" }, "ResponseBody": { "value": [ { "to": "Sanitized", - "messageId": "Outgoing_202103012059188d2392ee-7e6d-4706-8170-85ef306a97a4_noam", + "messageId": "Outgoing_202103022344465a76b926-801c-49ea-8d4a-f268aa231956_noam", "httpStatusCode": 202, - "errorMessage": null, "repeatabilityResult": "accepted", "successful": true } diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingTwoSmsMessages.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingTwoSmsMessages.json new file mode 100644 index 0000000000000..9e2911aa4e493 --- /dev/null +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingTwoSmsMessages.json @@ -0,0 +1,113 @@ +{ + "Entries": [ + { + "RequestUri": "https://smstestapp.communication.azure.com/sms?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "146", + "Content-Type": "application/json", + "Date": "Tue, 02 Mar 2021 23:44:43 GMT", + "traceparent": "00-7c1b7653ac9d02489ba19857746ba175-f48a81dc5ee9db4c-00", + "User-Agent": [ + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", + "(.NET 5.0.3; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "5343ad252b7d1aae4d84188177d6b15b", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "from": "Sanitized", + "smsRecipients": [ + { + "to": "Sanitized", + "repeatabilityRequestId": "Sanitized", + "repeatabilityFirstSent": "Sanitized" + } + ], + "message": "Hi" + }, + "StatusCode": 202, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 02 Mar 2021 23:44:43 GMT", + "MS-CV": "yIkxW4sfFU\u002BIYTvPpH\u002BXSw.0", + "Request-Context": "appId=", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "0680\u002BYAAAAABoxxnAVgetS4tezlIMKzzTRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "302ms" + }, + "ResponseBody": { + "value": [ + { + "to": "Sanitized", + "messageId": "Outgoing_202103022344431ee02a60-4bd9-4115-943a-56cf73ff5c51_noam", + "httpStatusCode": 202, + "repeatabilityResult": "accepted", + "successful": true + } + ] + } + }, + { + "RequestUri": "https://smstestapp.communication.azure.com/sms?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "146", + "Content-Type": "application/json", + "Date": "Tue, 02 Mar 2021 23:44:43 GMT", + "traceparent": "00-06734da62931234ab287b278487d0ede-aebc239b04dffd42-00", + "User-Agent": [ + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", + "(.NET 5.0.3; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "eeb77bd91b80173c8379017571460eb3", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "from": "Sanitized", + "smsRecipients": [ + { + "to": "Sanitized", + "repeatabilityRequestId": "Sanitized", + "repeatabilityFirstSent": "Sanitized" + } + ], + "message": "Hi" + }, + "StatusCode": 202, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 02 Mar 2021 23:44:43 GMT", + "MS-CV": "0AGGVrwefkqJoxTLnmio4A.0", + "Request-Context": "appId=", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "07M0\u002BYAAAAACIqwlzBq3zRKbl/qAOOyZERVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "307ms" + }, + "ResponseBody": { + "value": [ + { + "to": "Sanitized", + "messageId": "Outgoing_202103022344448082cbd2-c2d8-450c-8010-220c605990da_noam", + "httpStatusCode": 202, + "repeatabilityResult": "accepted", + "successful": true + } + ] + } + } + ], + "Variables": { + "AZURE_PHONE_NUMBER": "\u002B18005555555", + "COMMUNICATION_CONNECTION_STRING": "endpoint=https://smstestapp.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "210482935" + } +} \ No newline at end of file diff --git a/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingTwoSmsMessagesAsync.json b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingTwoSmsMessagesAsync.json new file mode 100644 index 0000000000000..8c3ad735cec56 --- /dev/null +++ b/sdk/communication/Azure.Communication.Sms/tests/SessionRecords/SmsClientLiveTests/SendingTwoSmsMessagesAsync.json @@ -0,0 +1,113 @@ +{ + "Entries": [ + { + "RequestUri": "https://smstestapp.communication.azure.com/sms?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "146", + "Content-Type": "application/json", + "Date": "Tue, 02 Mar 2021 23:44:46 GMT", + "traceparent": "00-f806cd16491a4a4ba6975c8cd8398c5e-eace1609312edd41-00", + "User-Agent": [ + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", + "(.NET 5.0.3; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "88b7067210caa5e061a1e638b75e90ad", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "from": "Sanitized", + "smsRecipients": [ + { + "to": "Sanitized", + "repeatabilityRequestId": "Sanitized", + "repeatabilityFirstSent": "Sanitized" + } + ], + "message": "Hi" + }, + "StatusCode": 202, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 02 Mar 2021 23:44:46 GMT", + "MS-CV": "191umGC4KkOs7eMGl9cjCw.0", + "Request-Context": "appId=", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "07s0\u002BYAAAAACkCdBUYOopQb6Uf8VE60cQRVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "429ms" + }, + "ResponseBody": { + "value": [ + { + "to": "Sanitized", + "messageId": "Outgoing_202103022344461b5a4ab9-1faa-4e3a-84ca-74d98b714629_noam", + "httpStatusCode": 202, + "repeatabilityResult": "accepted", + "successful": true + } + ] + } + }, + { + "RequestUri": "https://smstestapp.communication.azure.com/sms?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "146", + "Content-Type": "application/json", + "Date": "Tue, 02 Mar 2021 23:44:46 GMT", + "traceparent": "00-69b01046a622ab449223d27b1648413b-7cdb7a5a55e11b4f-00", + "User-Agent": [ + "azsdk-net-Communication.Sms/1.0.0-alpha.20210302.1", + "(.NET 5.0.3; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "427574d3b632022eac493e894b6f0e57", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "from": "Sanitized", + "smsRecipients": [ + { + "to": "Sanitized", + "repeatabilityRequestId": "Sanitized", + "repeatabilityFirstSent": "Sanitized" + } + ], + "message": "Hi" + }, + "StatusCode": 202, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 02 Mar 2021 23:44:46 GMT", + "MS-CV": "5IJ6l\u002BvieE2bafVeGeXvoA.0", + "Request-Context": "appId=", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "0780\u002BYAAAAACbku1\u002BtJO3QoaIz02Vh/mORVdSMzBFREdFMDUwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Processing-Time": "545ms" + }, + "ResponseBody": { + "value": [ + { + "to": "Sanitized", + "messageId": "Outgoing_2021030223444717be6937-7bd9-4186-bcaf-ec48de9de067_noam", + "httpStatusCode": 202, + "repeatabilityResult": "accepted", + "successful": true + } + ] + } + } + ], + "Variables": { + "AZURE_PHONE_NUMBER": "\u002B18005555555", + "COMMUNICATION_CONNECTION_STRING": "endpoint=https://smstestapp.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "203598891" + } +} \ No newline at end of file diff --git a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs index 1c7c64ac3d5ab..b4e1432c462e1 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs +++ b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs @@ -30,7 +30,6 @@ public async Task SendingSmsMessage() #region Snippet:Azure_Communication_Sms_Tests_Troubleshooting try { - #region Snippet:Azure_Communication_Sms_Tests_SendAsync SmsSendResult result = await client.SendAsync( //@@ from: "+18001230000" // Phone number acquired on your Azure Communication resource //@@ to: "+18005670000", @@ -38,7 +37,6 @@ public async Task SendingSmsMessage() /*@@*/ to: TestEnvironment.ToPhoneNumber, message: "Hi"); Console.WriteLine($"Sms id: {result.MessageId}"); - #endregion Snippet:Azure_Communication_Sms_Tests_SendAsync /*@@*/ Assert.IsFalse(string.IsNullOrWhiteSpace(result.MessageId)); /*@@*/ Assert.AreEqual(202, result.HttpStatusCode); /*@@*/ Assert.IsTrue(result.Successful); @@ -103,13 +101,67 @@ public async Task SendingSmsMessageFromFakeNumber() try { SmsSendResult result = await client.SendAsync( - from: "+18001234567", + from: "+15550000000", to: TestEnvironment.ToPhoneNumber, message: "Hi"); } catch (RequestFailedException ex) { Assert.IsNotEmpty(ex.Message); + Assert.True(ex.Message.Contains("400")); + Console.WriteLine(ex.Message); + } + + catch (Exception ex) + { + Assert.Fail($"Unexpected error: {ex}"); + } + } + + [Test] + public async Task SendingSmsMessageToFakeNumber() + { + SmsClient client = InstrumentClient( + new SmsClient( + TestEnvironment.ConnectionString, + InstrumentClientOptions(new SmsClientOptions()))); + try + { + SmsSendResult result = await client.SendAsync( + from: TestEnvironment.FromPhoneNumber, + to: "+15550000000", + message: "Hi"); + Assert.AreEqual("400", result.HttpStatusCode); + } + catch (RequestFailedException ex) + { + Console.WriteLine(ex.Message); + } + + catch (Exception ex) + { + Assert.Fail($"Unexpected error: {ex}"); + } + } + + [Test] + public async Task SendingSmsMessageFromUnauthorizedNumber() + { + SmsClient client = InstrumentClient( + new SmsClient( + TestEnvironment.ConnectionString, + InstrumentClientOptions(new SmsClientOptions()))); + try + { + SmsSendResult result = await client.SendAsync( + from: "+18007342577", + to: TestEnvironment.ToPhoneNumber, + message: "Hi"); + } + catch (RequestFailedException ex) + { + Assert.IsNotEmpty(ex.Message); + Assert.True(ex.Message.Contains("404")); Console.WriteLine(ex.Message); } @@ -128,12 +180,9 @@ public async Task SendingSmsMessageToGroupWithOptions() InstrumentClientOptions(new SmsClientOptions()))); try { - #region Snippet:Azure_Communication_SmsClient_Send_GroupSmsWithOptions Response> response = await client.SendAsync( - //@@ from: "+18001230000" // Phone number acquired on your Azure Communication resource - //@@ to: new string[] {"+18005670000", "+18008900000}", - /*@@*/ from: TestEnvironment.FromPhoneNumber, - /*@@*/ to: new string[] { TestEnvironment.ToPhoneNumber, TestEnvironment.ToPhoneNumber }, + from: TestEnvironment.FromPhoneNumber, + to: new string[] { TestEnvironment.ToPhoneNumber, TestEnvironment.ToPhoneNumber }, message: "Hi", options: new SmsSendOptions(enableDeliveryReport: true) // OPTIONAL { @@ -143,12 +192,44 @@ public async Task SendingSmsMessageToGroupWithOptions() foreach (SmsSendResult result in results) { Console.WriteLine($"Sms id: {result.MessageId}"); - /*@@*/ Assert.IsFalse(string.IsNullOrWhiteSpace(result.MessageId)); - /*@@*/ Assert.AreEqual(202, result.HttpStatusCode); - /*@@*/ Assert.IsTrue(result.Successful); + Assert.IsFalse(string.IsNullOrWhiteSpace(result.MessageId)); + Assert.AreEqual(202, result.HttpStatusCode); + Assert.IsTrue(result.Successful); } - #endregion Snippet:Azure_Communication_SmsClient_Send_GroupSmsWithOptions + } + catch (RequestFailedException ex) + { + Console.WriteLine(ex.Message); + } + catch (Exception ex) + { + Assert.Fail($"Unexpected error: {ex}"); + } + } + + [Test] + public async Task SendingTwoSmsMessages() + { + SmsClient client = InstrumentClient( + new SmsClient( + TestEnvironment.ConnectionString, + InstrumentClientOptions(new SmsClientOptions()))); + try + { + SmsSendResult firstMessageResult = await client.SendAsync( + from: TestEnvironment.FromPhoneNumber, + to: TestEnvironment.ToPhoneNumber, + message: "Hi"); + SmsSendResult secondMessageResult = await client.SendAsync( + from: TestEnvironment.FromPhoneNumber, + to: TestEnvironment.ToPhoneNumber, + message: "Hi"); + Assert.AreNotEqual(firstMessageResult.MessageId, secondMessageResult.MessageId); + Assert.True(firstMessageResult.Successful); + Assert.True(secondMessageResult.Successful); + Assert.AreEqual(202, firstMessageResult.HttpStatusCode); + Assert.AreEqual(202, secondMessageResult.HttpStatusCode); } catch (RequestFailedException ex) { diff --git a/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs b/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs index 1adb81f100b80..3abed43ff9efc 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs +++ b/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs @@ -2,6 +2,8 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; +using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -29,5 +31,39 @@ public SmsClient CreateSmsClientWithToken() #endregion Snippet:Azure_Communication_Sms_Tests_Samples_CreateSmsClientWithToken return client; } + + public async Task SendingSMSMessage() + { + SmsClient smsClient = CreateSmsClient(); + #region Snippet:Azure_Communication_Sms_Tests_SendAsync + SmsSendResult sendResult = await smsClient.SendAsync( + from: "+15550000000", + to: "+15550000001", + message: "Hi"); + Console.WriteLine($"Sms id: {sendResult.MessageId}"); + #endregion Snippet:Azure_Communication_Sms_Tests_SendAsync + Console.WriteLine($"Send Result Successful: {sendResult.Successful}"); + } + + public async Task SendingGroupSMSMessageWithOptions() + { + SmsClient smsClient = CreateSmsClient(); + #region Snippet:Azure_Communication_SmsClient_Send_GroupSmsWithOptions + Response> response = await smsClient.SendAsync( + from: "+15550000000", + to: new string[] { "+15550000001", "+15550000002" }, + message: "Weekly Promotion!", + options: new SmsSendOptions(enableDeliveryReport: true) // OPTIONAL + { + Tag = "marketing", // custom tags + }); + IEnumerable results = response.Value; + foreach (SmsSendResult result in results) + { + Console.WriteLine($"Sms id: {result.MessageId}"); + Console.WriteLine($"Send Result Successful: {result.Successful}"); + } + #endregion Snippet:Azure_Communication_SmsClient_Send_GroupSmsWithOptions + } } } From 864cb0f52137216d7536c3a24ed65bb814740f6d Mon Sep 17 00:00:00 2001 From: Minnie Liu Date: Tue, 2 Mar 2021 16:32:15 -0800 Subject: [PATCH 2/5] Fix build --- .../Azure.Communication.Sms/tests/SmsClientLiveTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs index b4e1432c462e1..4981fcdc525cd 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs +++ b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs @@ -131,7 +131,7 @@ public async Task SendingSmsMessageToFakeNumber() from: TestEnvironment.FromPhoneNumber, to: "+15550000000", message: "Hi"); - Assert.AreEqual("400", result.HttpStatusCode); + Assert.AreEqual(400, result.HttpStatusCode); } catch (RequestFailedException ex) { From eb2cda70773378e514d592da2b294cb1df1bafc9 Mon Sep 17 00:00:00 2001 From: Minnie Liu Date: Tue, 2 Mar 2021 16:45:14 -0800 Subject: [PATCH 3/5] Remove fake numbers from the samples --- sdk/communication/Azure.Communication.Sms/README.md | 12 ++++++------ .../tests/SmsClientLiveTests.cs | 4 ++-- .../tests/samples/Sample1_SmsClient.cs | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sdk/communication/Azure.Communication.Sms/README.md b/sdk/communication/Azure.Communication.Sms/README.md index eaa4db1368791..085ec00934054 100644 --- a/sdk/communication/Azure.Communication.Sms/README.md +++ b/sdk/communication/Azure.Communication.Sms/README.md @@ -51,8 +51,8 @@ SmsClient client = new SmsClient(new Uri(endpoint), tokenCredential); To send a SMS message, call the `Send` or `SendAsync` function from the `SmsClient`. ```C# Snippet:Azure_Communication_Sms_Tests_SendAsync SmsSendResult sendResult = await smsClient.SendAsync( - from: "+15550000000", - to: "+15550000001", + from: "", + to: "", message: "Hi"); Console.WriteLine($"Sms id: {sendResult.MessageId}"); ``` @@ -61,8 +61,8 @@ To send a SMS message to a list of recipients, call the `Send` or `SendAsync` fu You may also add pass in an options object to specify whether the delivery report should be enabled and set custom tags. ```C# Snippet:Azure_Communication_SmsClient_Send_GroupSmsWithOptions Response> response = await smsClient.SendAsync( - from: "+15550000000", - to: new string[] { "+15550000001", "+15550000002" }, + from: "", + to: new string[] { "", "" }, message: "Weekly Promotion!", options: new SmsSendOptions(enableDeliveryReport: true) // OPTIONAL { @@ -82,8 +82,8 @@ All SMS operations will throw a RequestFailedException on failure. try { SmsSendResult result = await client.SendAsync( - from: "+18001230000" // Phone number acquired on your Azure Communication resource - to: "+18005670000", + from: "" // Phone number acquired on your Azure Communication resource + to: "", message: "Hi"); Console.WriteLine($"Sms id: {result.MessageId}"); } diff --git a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs index 4981fcdc525cd..115ddbdef3267 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs +++ b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs @@ -31,8 +31,8 @@ public async Task SendingSmsMessage() try { SmsSendResult result = await client.SendAsync( - //@@ from: "+18001230000" // Phone number acquired on your Azure Communication resource - //@@ to: "+18005670000", + //@@ from: "" // Phone number acquired on your Azure Communication resource + //@@ to: "", /*@@*/ from: TestEnvironment.FromPhoneNumber, /*@@*/ to: TestEnvironment.ToPhoneNumber, message: "Hi"); diff --git a/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs b/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs index 3abed43ff9efc..e0ee02b8174d2 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs +++ b/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs @@ -37,8 +37,8 @@ public async Task SendingSMSMessage() SmsClient smsClient = CreateSmsClient(); #region Snippet:Azure_Communication_Sms_Tests_SendAsync SmsSendResult sendResult = await smsClient.SendAsync( - from: "+15550000000", - to: "+15550000001", + from: "", + to: "", message: "Hi"); Console.WriteLine($"Sms id: {sendResult.MessageId}"); #endregion Snippet:Azure_Communication_Sms_Tests_SendAsync @@ -50,8 +50,8 @@ public async Task SendingGroupSMSMessageWithOptions() SmsClient smsClient = CreateSmsClient(); #region Snippet:Azure_Communication_SmsClient_Send_GroupSmsWithOptions Response> response = await smsClient.SendAsync( - from: "+15550000000", - to: new string[] { "+15550000001", "+15550000002" }, + from: "", + to: new string[] { "", "" }, message: "Weekly Promotion!", options: new SmsSendOptions(enableDeliveryReport: true) // OPTIONAL { From 8edef13c3f842369ab96a1d5f0092f05ca891c02 Mon Sep 17 00:00:00 2001 From: Minnie Liu Date: Tue, 2 Mar 2021 16:56:03 -0800 Subject: [PATCH 4/5] Address review comments --- sdk/communication/Azure.Communication.Sms/README.md | 12 ++++++------ .../tests/SmsClientLiveTests.cs | 5 ++--- .../tests/samples/Sample1_SmsClient.cs | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sdk/communication/Azure.Communication.Sms/README.md b/sdk/communication/Azure.Communication.Sms/README.md index 085ec00934054..beb868d3c1a8e 100644 --- a/sdk/communication/Azure.Communication.Sms/README.md +++ b/sdk/communication/Azure.Communication.Sms/README.md @@ -51,8 +51,8 @@ SmsClient client = new SmsClient(new Uri(endpoint), tokenCredential); To send a SMS message, call the `Send` or `SendAsync` function from the `SmsClient`. ```C# Snippet:Azure_Communication_Sms_Tests_SendAsync SmsSendResult sendResult = await smsClient.SendAsync( - from: "", - to: "", + from: "", // Your E.164 formatted from phone number used to send SMS + to: "", // E.164 formatted recipient phone number message: "Hi"); Console.WriteLine($"Sms id: {sendResult.MessageId}"); ``` @@ -61,8 +61,8 @@ To send a SMS message to a list of recipients, call the `Send` or `SendAsync` fu You may also add pass in an options object to specify whether the delivery report should be enabled and set custom tags. ```C# Snippet:Azure_Communication_SmsClient_Send_GroupSmsWithOptions Response> response = await smsClient.SendAsync( - from: "", - to: new string[] { "", "" }, + from: "", // Your E.164 formatted from phone number used to send SMS + to: new string[] { "", "" }, // E.164 formatted recipient phone numbers message: "Weekly Promotion!", options: new SmsSendOptions(enableDeliveryReport: true) // OPTIONAL { @@ -82,8 +82,8 @@ All SMS operations will throw a RequestFailedException on failure. try { SmsSendResult result = await client.SendAsync( - from: "" // Phone number acquired on your Azure Communication resource - to: "", + from: "" // Your E.164 formatted phone number used to send SMS + to: "", // E.164 formatted recipient phone number message: "Hi"); Console.WriteLine($"Sms id: {result.MessageId}"); } diff --git a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs index 115ddbdef3267..7e4c4d263b861 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs +++ b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs @@ -31,8 +31,8 @@ public async Task SendingSmsMessage() try { SmsSendResult result = await client.SendAsync( - //@@ from: "" // Phone number acquired on your Azure Communication resource - //@@ to: "", + //@@ from: "" // Your E.164 formatted phone number used to send SMS + //@@ to: "", // E.164 formatted recipient phone number /*@@*/ from: TestEnvironment.FromPhoneNumber, /*@@*/ to: TestEnvironment.ToPhoneNumber, message: "Hi"); @@ -111,7 +111,6 @@ public async Task SendingSmsMessageFromFakeNumber() Assert.True(ex.Message.Contains("400")); Console.WriteLine(ex.Message); } - catch (Exception ex) { Assert.Fail($"Unexpected error: {ex}"); diff --git a/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs b/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs index e0ee02b8174d2..379ba44691fd3 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs +++ b/sdk/communication/Azure.Communication.Sms/tests/samples/Sample1_SmsClient.cs @@ -37,8 +37,8 @@ public async Task SendingSMSMessage() SmsClient smsClient = CreateSmsClient(); #region Snippet:Azure_Communication_Sms_Tests_SendAsync SmsSendResult sendResult = await smsClient.SendAsync( - from: "", - to: "", + from: "", // Your E.164 formatted from phone number used to send SMS + to: "", // E.164 formatted recipient phone number message: "Hi"); Console.WriteLine($"Sms id: {sendResult.MessageId}"); #endregion Snippet:Azure_Communication_Sms_Tests_SendAsync @@ -50,8 +50,8 @@ public async Task SendingGroupSMSMessageWithOptions() SmsClient smsClient = CreateSmsClient(); #region Snippet:Azure_Communication_SmsClient_Send_GroupSmsWithOptions Response> response = await smsClient.SendAsync( - from: "", - to: new string[] { "", "" }, + from: "", // Your E.164 formatted from phone number used to send SMS + to: new string[] { "", "" }, // E.164 formatted recipient phone numbers message: "Weekly Promotion!", options: new SmsSendOptions(enableDeliveryReport: true) // OPTIONAL { From bd638561440f61c20237eda83fd010bc5ed571bf Mon Sep 17 00:00:00 2001 From: Minnie Liu Date: Wed, 3 Mar 2021 10:32:30 -0800 Subject: [PATCH 5/5] Address comments --- .../tests/SmsClientLiveTests.cs | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs index 7e4c4d263b861..73dcbf12f61de 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs +++ b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs @@ -37,9 +37,7 @@ public async Task SendingSmsMessage() /*@@*/ to: TestEnvironment.ToPhoneNumber, message: "Hi"); Console.WriteLine($"Sms id: {result.MessageId}"); - /*@@*/ Assert.IsFalse(string.IsNullOrWhiteSpace(result.MessageId)); - /*@@*/ Assert.AreEqual(202, result.HttpStatusCode); - /*@@*/ Assert.IsTrue(result.Successful); + /*@@*/ assertHappyPath(result); } catch (RequestFailedException ex) { @@ -77,9 +75,7 @@ public async Task SendingSmsMessageUsingTokenCredential() to: TestEnvironment.ToPhoneNumber, message: "Hi"); Console.WriteLine($"Sms id: {result.MessageId}"); - Assert.IsFalse(string.IsNullOrWhiteSpace(result.MessageId)); - Assert.AreEqual(202, result.HttpStatusCode); - Assert.IsTrue(result.Successful); + assertHappyPath(result); } catch (RequestFailedException ex) { @@ -163,7 +159,6 @@ public async Task SendingSmsMessageFromUnauthorizedNumber() Assert.True(ex.Message.Contains("404")); Console.WriteLine(ex.Message); } - catch (Exception ex) { Assert.Fail($"Unexpected error: {ex}"); @@ -191,9 +186,7 @@ public async Task SendingSmsMessageToGroupWithOptions() foreach (SmsSendResult result in results) { Console.WriteLine($"Sms id: {result.MessageId}"); - Assert.IsFalse(string.IsNullOrWhiteSpace(result.MessageId)); - Assert.AreEqual(202, result.HttpStatusCode); - Assert.IsTrue(result.Successful); + assertHappyPath(result); } } catch (RequestFailedException ex) @@ -225,10 +218,8 @@ public async Task SendingTwoSmsMessages() message: "Hi"); Assert.AreNotEqual(firstMessageResult.MessageId, secondMessageResult.MessageId); - Assert.True(firstMessageResult.Successful); - Assert.True(secondMessageResult.Successful); - Assert.AreEqual(202, firstMessageResult.HttpStatusCode); - Assert.AreEqual(202, secondMessageResult.HttpStatusCode); + assertHappyPath(firstMessageResult); + assertHappyPath(secondMessageResult); } catch (RequestFailedException ex) { @@ -239,5 +230,12 @@ public async Task SendingTwoSmsMessages() Assert.Fail($"Unexpected error: {ex}"); } } + + public void assertHappyPath(SmsSendResult sendResult) + { + Assert.True(sendResult.Successful); + Assert.AreEqual(202, sendResult.HttpStatusCode); + Assert.IsFalse(string.IsNullOrWhiteSpace(sendResult.MessageId)); + } } }