diff --git a/sdk/communication/azure-communication-sms/CHANGELOG.md b/sdk/communication/azure-communication-sms/CHANGELOG.md index bfc455120cf9..4cc8f6ebe347 100644 --- a/sdk/communication/azure-communication-sms/CHANGELOG.md +++ b/sdk/communication/azure-communication-sms/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History ## 1.0.0-beta.5 (Unreleased) -###Added +### Added - Support for creating SmsClient with TokenCredential. - Added support for 1:N SMS messaging. - Added support for tagging SMS messages. @@ -8,9 +8,9 @@ - Added `SmsOptions` ### Breaking Change -- Updated `public Mono sendMessage(PhoneNumberIdentifier from, PhoneNumberIdentifier to, String message)` to `public Mono sendMessage(PhoneNumberIdentifier from,List to, String message)` -- Replaced `SendSmsResponse` with `SmsSendResult` - +- Updated `public Mono sendMessage(PhoneNumberIdentifier from, PhoneNumberIdentifier to, String message)` to `public Mono send(String from, String to, String message)`. +- Updated `public Mono> sendMessageWithResponse(PhoneNumberIdentifier from,List to, String message, SendSmsOptions smsOptions, Context context)` to `Mono> sendWithResponse(String from, String to, String message, SmsSendOptions options, Context context)`. +- Replaced `SendSmsResponse` with `SmsSendResult`. ## 1.0.0-beta.4 (Skipped) ### Added @@ -21,7 +21,7 @@ - Support directly passing connection string to the SmsClientBuilder using connectionString(). ### Breaking Change -- Removed credential(CommunicationClientCredential credential) and replaced with +- Removed credential(CommunicationClientCredential credential) and replaced with accessKey(String accessKey) within CommunicationIdentityClientBuilder. ## 1.0.0-beta.2 (2020-10-06) diff --git a/sdk/communication/azure-communication-sms/README.md b/sdk/communication/azure-communication-sms/README.md index 9d1101b74f88..dd80c04ee861 100644 --- a/sdk/communication/azure-communication-sms/README.md +++ b/sdk/communication/azure-communication-sms/README.md @@ -21,102 +21,126 @@ Azure Communication SMS is used to send simple text messages. com.azure azure-communication-sms - 1.0.0-beta.4 + 1.0.0-beta.4 ``` -## Key concepts - -There are two different forms of authentication to use the Azure Communication SMS Service. +## Authenticate the client ### Azure Active Directory Token Authentication +A `DefaultAzureCredential` object must be passed to the `SmsClientBuilder` via the credential() function. Endpoint and httpClient must also be set via the endpoint() and httpClient() functions respectively. -The `DefaultAzureCredential` object must be passed to the `SmsClientBuilder` via -the credential() funtion. Endpoint and httpClient must also be set -via the endpoint() and httpClient() functions respectively. - -`AZURE_CLIENT_SECRET`, `AZURE_CLIENT_ID` and `AZURE_TENANT_ID` environment variables +`AZURE_CLIENT_SECRET`, `AZURE_CLIENT_ID` and `AZURE_TENANT_ID` environment variables are needed to create a DefaultAzureCredential object. -To create a SmsClient - + ```java // You can find your endpoint and access key from your resource in the Azure Portal String endpoint = "https://.communication.azure.com"; -//Enter your azureKeyCredential -AzureKeyCredential azureKeyCredential = new AzureKeyCredential("SECRET"); -// Instantiate the http client + +// Create an HttpClient builder of your choice and customize it HttpClient httpClient = new NettyAsyncHttpClientBuilder().build(); -// Create a new SmsClientBuilder to instantiate an SmsClient -SmsClientBuilder smsClientBuilder = new SmsClientBuilder(); -// Set the endpoint, access key, and the HttpClient -smsClientBuilder.endpoint(endpoint) - .credential(azureKeyCredential) - .httpClient(httpClient); -// Build a new SmsClient -SmsClient smsClient = smsClientBuilder.buildClient(); + +SmsClient smsClient = new SmsClientBuilder() + .endpoint(endpoint) + .credential(new DefaultAzureCredentialBuilder().build()) + .httpClient(httpClient) + .buildClient(); ``` -Alternatively, you can provide the entire connection string using the connectionString() function instead of providing the endpoint and access key. - +### Access Key Authentication +SMS uses HMAC authentication with the resource access key. +The access key must be provided to the `SmsClientBuilder` via the credential() function. Endpoint and httpClient must also be set via the endpoint() and httpClient() functions respectively. + + ```java +// You can find your endpoint and access key from your resource in the Azure Portal +String endpoint = "https://.communication.azure.com"; +AzureKeyCredential azureKeyCredential = new AzureKeyCredential(""); + // Create an HttpClient builder of your choice and customize it HttpClient httpClient = new NettyAsyncHttpClientBuilder().build(); + +SmsClient smsClient = new SmsClientBuilder() + .endpoint(endpoint) + .credential(azureKeyCredential) + .httpClient(httpClient) + .buildClient(); +``` + +Alternatively, you can provide the entire connection string using the connectionString() function instead of providing the endpoint and access key. + +```java // You can find your connection string from your resource in the Azure Portal -String connectionString = ""; +String connectionString = "https://.communication.azure.com/;"; + +// Create an HttpClient builder of your choice and customize it +HttpClient httpClient = new NettyAsyncHttpClientBuilder().build(); + SmsClient smsClient = new SmsClientBuilder() .connectionString(connectionString) .httpClient(httpClient) .buildClient(); ``` +## Key concepts + +There are two different forms of authentication to use the Azure Communication SMS Service. + ## Examples -### Sending a message to a single recipient -Use the `send` function to send a new message to a phone number. -Once you send the message, you'll receive a response where you can access several -properties such as the message id with the `messageResponseItem.getMessageId()` function. +### Send a 1:1 SMS Message +Use the `send` or `sendWithResponse` function to send a SMS message to a single phone number. - + ```java -//Send an sms to only one phone number -SmsSendOptions options = new SmsSendOptions(); -options.setDeliveryReportEnabled(true); -options.setTag("Tag"); /* Optional */ -// Send the message to a list of phone Numbers and check the response for a messages ids -SmsSendResult response = smsClient.send( +SmsSendResult sendResult = smsClient.send( "", "", - "your message", - options /* Optional */); -System.out.println("MessageId: " + response.getMessageId()); + "Hi"); + +System.out.println("Message Id: " + sendResult.getMessageId()); +System.out.println("Recipient Number: " + sendResult.getTo()); +System.out.println("Send Result Successful:" + sendResult.isSuccessful()); ``` -### Sending a message to multiple recipients -Use the `send` function to send a new message to a list of phone numbers. -Once you send the message, you'll receive a PagedIterable response where you can access several -properties such as the message id with the `messageResponseItem.getMessageId()` function. +### Send a 1:N SMS Message +To send a SMS message to a list of recipients, call the `send` or `sendWithResponse` function with a list of recipient phone numbers. You may also add pass in an options object to specify whether the delivery report should be enabled and set custom tags. - + ```java -//Send an sms to multiple phone numbers SmsSendOptions options = new SmsSendOptions(); options.setDeliveryReportEnabled(true); -options.setTag("Tag"); /* Optional */ -// Send the message to a list of phone Numbers and check the response for a messages ids -Iterable responseMultiplePhones = smsClient.send( +options.setTag("Tag"); + +Iterable sendResults = smsClient.sendWithResponse( "", - new ArrayList(Arrays.asList("", "")), - "your message", + Arrays.asList("", ""), + "Hi", options /* Optional */, - null); -for (SmsSendResult messageResponseItem : responseMultiplePhones) { - System.out.println("MessageId sent to " + messageResponseItem.getTo() + ": " + messageResponseItem.getMessageId()); -``` + Context.NONE).getValue(); +for (SmsSendResult result : sendResults) { + System.out.println("Message Id: " + result.getMessageId()); + System.out.println("Recipient Number: " + result.getTo()); + System.out.println("Send Result Successful:" + result.isSuccessful()); +} +``` ## Troubleshooting -In progress. +All SMS service operations will throw an exception on failure. + +```java +try { + SmsSendResult sendResult = smsClient.send( + "", + "", + "Hi" + ); +} catch (RuntimeException ex) { + System.out.println(ex.getMessage()); +} +``` ## Next steps diff --git a/sdk/communication/azure-communication-sms/src/main/java/com/azure/communication/sms/SmsAsyncClient.java b/sdk/communication/azure-communication-sms/src/main/java/com/azure/communication/sms/SmsAsyncClient.java index 8c6657d077e2..a3fe4f6f62b4 100644 --- a/sdk/communication/azure-communication-sms/src/main/java/com/azure/communication/sms/SmsAsyncClient.java +++ b/sdk/communication/azure-communication-sms/src/main/java/com/azure/communication/sms/SmsAsyncClient.java @@ -4,6 +4,7 @@ package com.azure.communication.sms; import com.azure.communication.sms.implementation.AzureCommunicationSMSServiceImpl; +import com.azure.communication.sms.implementation.SmsImpl; import com.azure.communication.sms.implementation.models.SmsSendResponseItem; import com.azure.communication.sms.implementation.models.SendMessageRequest; import com.azure.communication.sms.implementation.models.SmsRecipient; @@ -13,9 +14,12 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; import java.util.List; import java.util.ArrayList; +import java.util.Arrays; import java.util.Objects; import reactor.core.publisher.Mono; import static com.azure.core.util.FluxUtil.monoError; @@ -26,16 +30,15 @@ */ @ServiceClient(builder = SmsClientBuilder.class, isAsync = true) public final class SmsAsyncClient { - private final AzureCommunicationSMSServiceImpl smsServiceClient; + private final SmsImpl smsClient; private final ClientLogger logger = new ClientLogger(SmsAsyncClient.class); SmsAsyncClient(AzureCommunicationSMSServiceImpl smsServiceClient) { - this.smsServiceClient = smsServiceClient; + smsClient = smsServiceClient.getSms(); } /** * Sends an SMS message from a phone number that belongs to the authenticated account. - * Phone number has to be in the format 000 - 00 - 00 * * @param from Number that is sending the message. * @param to The recipient's phone number. @@ -44,7 +47,9 @@ public final class SmsAsyncClient { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono send(String from, String to, String message) { - return send(from, to, message, null); + return sendWithResponse(from, to, message, null, null).flatMap(response -> { + return Mono.just(response.getValue()); + }); } /** @@ -53,30 +58,31 @@ public Mono send(String from, String to, String message) { * @param from Number that is sending the message. * @param to The recipient's phone number. * @param message message to send to recipient. - * @param smsOptions set options on the SMS request, like enable delivery report, which sends a report + * @param options set options on the SMS request, like enable delivery report, which sends a report * for this message to the Azure Resource Event Grid. * @return response for a successful send Sms request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono send(String from, String to, String message, SmsSendOptions smsOptions) { - List recipients = new ArrayList(); - recipients.add(to); - SendMessageRequest request = createSendMessageRequest(from, recipients, message, smsOptions); + public Mono> sendWithResponse(String from, String to, String message, SmsSendOptions options) { + return sendWithResponse(from, to, message, options, null); + } + + Mono> sendWithResponse(String from, String to, String message, SmsSendOptions options, Context context) { try { Objects.requireNonNull(from, "'from' cannot be null."); Objects.requireNonNull(to, "'to' cannot be null."); - Mono> responseMono = withContext(context -> this.smsServiceClient.getSms().sendWithResponseAsync(request, context)); - Response response = responseMono.block(); - SmsSendResponse smsSendResponse = response.getValue(); - - List result = convertSmsResults(smsSendResponse.getValue()); - if (result.size() == 1) { - return Mono.just(result.get(0)); - } else { - return monoError(logger, new NullPointerException("no response")); - } - } catch (NullPointerException ex) { - return monoError(logger, ex); + List recipients = Arrays.asList(to); + SendMessageRequest request = createSendMessageRequest(from, recipients, message, options); + return withContext(contextValue -> { + if (context != null) { + contextValue = context; + } + return smsClient.sendWithResponseAsync(request, contextValue) + .flatMap((Response response) -> { + List smsSendResults = convertSmsSendResults(response.getValue().getValue()); + return Mono.just(new SimpleResponse(response, smsSendResults.get(0))); + }); + }); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -93,7 +99,10 @@ public Mono send(String from, String to, String message, SmsSendO */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> send(String from, Iterable to, String message) { - return send(from, to, message, null); + return sendWithResponse(from, to, message, null) + .flatMap((Response> response) -> { + return Mono.just(response.getValue()); + }); } /** @@ -102,38 +111,44 @@ public Mono> send(String from, Iterable to, Stri * @param from Number that is sending the message. * @param to A list of the recipient's phone numbers. * @param message message to send to recipient. - * @param smsOptions set options on the SMS request, like enable delivery report, which sends a report + * @param options set options on the SMS request, like enable delivery report, which sends a report * for this message to the Azure Resource Event Grid. * @return response for a successful send Sms request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> send(String from, Iterable to, String message, SmsSendOptions smsOptions) { - SendMessageRequest request = createSendMessageRequest(from, to, message, smsOptions); + public Mono>> sendWithResponse(String from, Iterable to, String message, SmsSendOptions options) { + return sendWithResponse(from, to, message, options, null); + } + + Mono>> sendWithResponse(String from, Iterable to, String message, SmsSendOptions options, Context context) { try { Objects.requireNonNull(from, "'from' cannot be null."); Objects.requireNonNull(to, "'to' cannot be null."); - Mono> responseMono = withContext(context -> this.smsServiceClient.getSms().sendWithResponseAsync(request, context)); - Response response = responseMono.block(); - SmsSendResponse smsSendResponse = response.getValue(); - List result = convertSmsResults(smsSendResponse.getValue()); - return Mono.just(result); - } catch (NullPointerException ex) { - return monoError(logger, ex); + SendMessageRequest request = createSendMessageRequest(from, to, message, options); + return withContext(contextValue -> { + if (context != null) { + contextValue = context; + } + return this.smsClient.sendWithResponseAsync(request, contextValue) + .flatMap((Response response) -> { + Iterable smsSendResults = convertSmsSendResults(response.getValue().getValue()); + return Mono.just(new SimpleResponse>(response, smsSendResults)); + }); + }); } catch (RuntimeException ex) { return monoError(logger, ex); } } - private List convertSmsResults(Iterable resultsIterable) { - List iterableWrapper = new ArrayList<>(); - for (SmsSendResponseItem item : resultsIterable - ) { + private List convertSmsSendResults(Iterable resultsIterable) { + List iterableWrapper = new ArrayList<>(); + for (SmsSendResponseItem item : resultsIterable) { iterableWrapper.add(new SmsSendResult(item)); } return iterableWrapper; } - private SendMessageRequest createSendMessageRequest(String from, Iterable smsRecipient, String message, SmsSendOptions smsOptions) { + private SendMessageRequest createSendMessageRequest(String from, Iterable smsRecipient, String message, SmsSendOptions options) { SendMessageRequest request = new SendMessageRequest(); List recipients = new ArrayList(); for (String s : smsRecipient) { @@ -142,7 +157,7 @@ private SendMessageRequest createSendMessageRequest(String from, Iterable sendWithResponse(String from, String to, String message, SmsSendOptions options, Context context) { + return smsAsyncClient.sendWithResponse(from, to, message, options, context).block(); } /** @@ -87,13 +71,13 @@ public Iterable send(String from, Iterable to, String mes * @param from Number that is sending the message. * @param to A list of the recipient's phone numbers. * @param message message to send to recipient. - * @param smsOptions set options on the SMS request, like enable delivery report, which sends a report + * @param options set options on the SMS request, like enable delivery report, which sends a report * for this message to the Azure Resource Event Grid. - * @param context sets the context for the call + * @param context A {@link Context} representing the request context * @return response for a successful send Sms request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Iterable send(String from, Iterable to, String message, SmsSendOptions smsOptions, Context context) { - return smsAsyncClient.send(from, to, message, smsOptions).block(); + public Response> sendWithResponse(String from, Iterable to, String message, SmsSendOptions options, Context context) { + return smsAsyncClient.sendWithResponse(from, to, message, options, context).block(); } } diff --git a/sdk/communication/azure-communication-sms/src/main/java/com/azure/communication/sms/SmsClientBuilder.java b/sdk/communication/azure-communication-sms/src/main/java/com/azure/communication/sms/SmsClientBuilder.java index 231cf845df70..e91b6bf71bdc 100644 --- a/sdk/communication/azure-communication-sms/src/main/java/com/azure/communication/sms/SmsClientBuilder.java +++ b/sdk/communication/azure-communication-sms/src/main/java/com/azure/communication/sms/SmsClientBuilder.java @@ -16,6 +16,7 @@ import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; import com.azure.core.http.policy.CookiePolicy; import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; import com.azure.core.http.policy.HttpPipelinePolicy; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; @@ -58,7 +59,7 @@ public final class SmsClientBuilder { * @return SmsClientBuilder */ public SmsClientBuilder endpoint(String endpoint) { - this.endpoint = endpoint; + this.endpoint = Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); return this; } @@ -70,7 +71,7 @@ public SmsClientBuilder endpoint(String endpoint) { * @return SmsClientBuilder */ public SmsClientBuilder pipeline(HttpPipeline pipeline) { - this.pipeline = pipeline; + this.pipeline = Objects.requireNonNull(pipeline, "'pipeline' cannot be null."); return this; } @@ -122,7 +123,7 @@ public SmsClientBuilder connectionString(String connectionString) { * @return SmsClientBuilder */ public SmsClientBuilder retryPolicy(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); return this; } @@ -172,7 +173,7 @@ public SmsClientBuilder serviceVersion(SmsServiceVersion version) { * @return SmsClientBuilder */ public SmsClientBuilder httpClient(HttpClient httpClient) { - this.httpClient = httpClient; + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); return this; } @@ -184,7 +185,7 @@ public SmsClientBuilder httpClient(HttpClient httpClient) { * @return SmsClientBuilder */ public SmsClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { - this.customPolicies.add(customPolicy); + this.customPolicies.add(Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null.")); return this; } @@ -217,15 +218,7 @@ private AzureCommunicationSMSServiceImpl createServiceImpl() { } HttpPipeline builderPipeline = this.pipeline; if (this.pipeline == null) { - HttpPipelinePolicy[] customPolicyArray = null; - if (customPolicies.size() > 0) { - customPolicyArray = new HttpPipelinePolicy[customPolicies.size()]; - customPolicyArray = customPolicies.toArray(customPolicyArray); - } - - builderPipeline = createHttpPipeline(httpClient, - createHttpPipelineAuthPolicy(), - customPolicyArray); + builderPipeline = createHttpPipeline(httpClient); } AzureCommunicationSMSServiceImplBuilder clientBuilder = new AzureCommunicationSMSServiceImplBuilder(); @@ -261,37 +254,58 @@ private HttpPipelinePolicy createHttpPipelineAuthPolicy() { } } - private HttpPipeline createHttpPipeline(HttpClient httpClient, - HttpPipelinePolicy authorizationPolicy, - HttpPipelinePolicy[] additionalPolicies) { + private HttpPipeline createHttpPipeline(HttpClient httpClient) { + if (this.pipeline != null) { + return this.pipeline; + } + + List policyList = new ArrayList<>(); + + ClientOptions buildClientOptions = (clientOptions == null) ? new ClientOptions() : clientOptions; + HttpLogOptions buildLogOptions = (httpLogOptions == null) ? new HttpLogOptions() : httpLogOptions; + + String applicationId = null; + if (!CoreUtils.isNullOrEmpty(buildClientOptions.getApplicationId())) { + applicationId = buildClientOptions.getApplicationId(); + } else if (!CoreUtils.isNullOrEmpty(buildLogOptions.getApplicationId())) { + applicationId = buildLogOptions.getApplicationId(); + } + + // Add required policies + policyList.add(this.createHttpPipelineAuthPolicy()); + String clientName = properties.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion"); + policyList.add(new UserAgentPolicy(applicationId, clientName, clientVersion, configuration)); + policyList.add((this.retryPolicy == null) ? new RetryPolicy() : this.retryPolicy); + policyList.add(new CookiePolicy()); - HttpPipelinePolicy[] policies = new HttpPipelinePolicy[4]; - if (additionalPolicies != null) { - policies = new HttpPipelinePolicy[4 + additionalPolicies.length]; - applyAdditionalPolicies(policies, additionalPolicies); + // Add additional policies + if (!this.customPolicies.isEmpty()) { + policyList.addAll(this.customPolicies); } - policies[0] = authorizationPolicy; - applyRequirePolicies(policies); + + // Add logging policy + policyList.add(this.createHttpLoggingPolicy(this.getHttpLogOptions())); return new HttpPipelineBuilder() - .policies(policies) + .policies(policyList.toArray(new HttpPipelinePolicy[0])) .httpClient(httpClient) .build(); } - private void applyRequirePolicies(HttpPipelinePolicy[] policies) { - String clientName = properties.getOrDefault(SDK_NAME, "UnknownName"); - String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion"); - policies[1] = new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion, configuration); - policies[2] = new RetryPolicy(); - policies[3] = new CookiePolicy(); + private HttpLogOptions getHttpLogOptions() { + if (this.httpLogOptions == null) { + this.httpLogOptions = this.createDefaultHttpLogOptions(); + } + + return this.httpLogOptions; } - private void applyAdditionalPolicies(HttpPipelinePolicy[] policies, - HttpPipelinePolicy[] customPolicies) { - for (int i = 0; i < customPolicies.length; i++) { - policies[4 + i] = customPolicies[i]; + HttpLogOptions createDefaultHttpLogOptions() { + return new HttpLogOptions(); + } - } + HttpLoggingPolicy createHttpLoggingPolicy(HttpLogOptions httpLogOptions) { + return new HttpLoggingPolicy(httpLogOptions); } } diff --git a/sdk/communication/azure-communication-sms/src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java b/sdk/communication/azure-communication-sms/src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java index 9d46c5b97285..f151036d6855 100644 --- a/sdk/communication/azure-communication-sms/src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java +++ b/sdk/communication/azure-communication-sms/src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java @@ -2,7 +2,6 @@ // Licensed under the MIT License. package com.azure.communication.sms.samples.quickstart; -import java.util.ArrayList; import java.util.Arrays; import com.azure.communication.sms.SmsClient; import com.azure.communication.sms.SmsClientBuilder; @@ -11,71 +10,105 @@ import com.azure.core.credential.AzureKeyCredential; import com.azure.core.http.HttpClient; import com.azure.core.http.netty.NettyAsyncHttpClientBuilder; +import com.azure.core.util.Context; +import com.azure.identity.DefaultAzureCredentialBuilder; -/** - * Hello world! - */ public class ReadmeSamples { - - - public void createSmsClient() { + public SmsClient createSmsClientUsingAzureKeyCredential() { // You can find your endpoint and access key from your resource in the Azure Portal - String endpoint = "https://.communication.azure.com"; - //Enter your azureKeyCredential - AzureKeyCredential azureKeyCredential = new AzureKeyCredential("SECRET"); - // Instantiate the http client + String endpoint = "https://.communication.azure.com"; + AzureKeyCredential azureKeyCredential = new AzureKeyCredential(""); + + // Create an HttpClient builder of your choice and customize it HttpClient httpClient = new NettyAsyncHttpClientBuilder().build(); - // Create a new SmsClientBuilder to instantiate an SmsClient - SmsClientBuilder smsClientBuilder = new SmsClientBuilder(); - // Set the endpoint, access key, and the HttpClient - smsClientBuilder.endpoint(endpoint) + + SmsClient smsClient = new SmsClientBuilder() + .endpoint(endpoint) .credential(azureKeyCredential) - .httpClient(httpClient); - // Build a new SmsClient - SmsClient smsClient = smsClientBuilder.buildClient(); + .httpClient(httpClient) + .buildClient(); + + return smsClient; } - public void createSmsClientWithConnectionString() { + public SmsClient createSmsClientWithConnectionString() { + // You can find your connection string from your resource in the Azure Portal + String connectionString = "https://.communication.azure.com/;"; + // Create an HttpClient builder of your choice and customize it HttpClient httpClient = new NettyAsyncHttpClientBuilder().build(); - // You can find your connection string from your resource in the Azure Portal - String connectionString = ""; + SmsClient smsClient = new SmsClientBuilder() .connectionString(connectionString) .httpClient(httpClient) .buildClient(); + + return smsClient; } - public void sendMessageToOneRecipient(SmsClient smsClient) { - //Send an sms to only one phone number - SmsSendOptions options = new SmsSendOptions(); - options.setDeliveryReportEnabled(true); - options.setTag("Tag"); /* Optional */ - // Send the message to a list of phone Numbers and check the response for a messages ids - SmsSendResult response = smsClient.send( + public SmsClient createSmsClientWithAAD() { + // You can find your endpoint and access key from your resource in the Azure Portal + String endpoint = "https://.communication.azure.com"; + + // Create an HttpClient builder of your choice and customize it + HttpClient httpClient = new NettyAsyncHttpClientBuilder().build(); + + SmsClient smsClient = new SmsClientBuilder() + .endpoint(endpoint) + .credential(new DefaultAzureCredentialBuilder().build()) + .httpClient(httpClient) + .buildClient(); + + return smsClient; + } + + public void sendMessageToOneRecipient() { + SmsClient smsClient = createSmsClientUsingAzureKeyCredential(); + + SmsSendResult sendResult = smsClient.send( "", "", - "your message", - options /* Optional */); - System.out.println("MessageId: " + response.getMessageId()); + "Hi"); + + System.out.println("Message Id: " + sendResult.getMessageId()); + System.out.println("Recipient Number: " + sendResult.getTo()); + System.out.println("Send Result Successful:" + sendResult.isSuccessful()); } - public void sendMessageToMultipleRecipients(SmsClient smsClient) { - //Send an sms to multiple phone numbers + public void sendMessageToGroupWithOptions() { + SmsClient smsClient = createSmsClientUsingAzureKeyCredential(); + SmsSendOptions options = new SmsSendOptions(); options.setDeliveryReportEnabled(true); - options.setTag("Tag"); /* Optional */ - // Send the message to a list of phone Numbers and check the response for a messages ids - Iterable responseMultiplePhones = smsClient.send( + options.setTag("Tag"); + + Iterable sendResults = smsClient.sendWithResponse( "", - new ArrayList(Arrays.asList("", "")), - "your message", + Arrays.asList("", ""), + "Hi", options /* Optional */, - null); - for (SmsSendResult messageResponseItem : responseMultiplePhones) { - System.out.println("MessageId sent to " + messageResponseItem.getTo() + ": " + messageResponseItem.getMessageId()); + Context.NONE).getValue(); + + for (SmsSendResult result : sendResults) { + System.out.println("Message Id: " + result.getMessageId()); + System.out.println("Recipient Number: " + result.getTo()); + System.out.println("Send Result Successful:" + result.isSuccessful()); } } - + /** + * Sample code for troubleshooting + */ + public void sendSMSTroubleshooting() { + SmsClient smsClient = createSmsClientUsingAzureKeyCredential(); + try { + SmsSendResult sendResult = smsClient.send( + "", + "", + "Hi" + ); + } catch (RuntimeException ex) { + System.out.println(ex.getMessage()); + } + } } diff --git a/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsAsyncClientTests.java b/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsAsyncClientTests.java index 716c354076e9..c308a2b0d3f8 100644 --- a/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsAsyncClientTests.java +++ b/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsAsyncClientTests.java @@ -10,15 +10,14 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.Response; + import reactor.core.publisher.Mono; import reactor.test.StepVerifier; -import java.util.ArrayList; -import java.util.List; +import java.util.Arrays; import static org.junit.jupiter.api.Assertions.*; - public class SmsAsyncClientTests extends SmsTestBase { - private List to; private SmsAsyncClient asyncClient; @Override @@ -28,16 +27,13 @@ protected void beforeTest() { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void createAsyncClientUsingConnectionString(HttpClient httpClient) { - to = new ArrayList(); - to.add(SMS_SERVICE_PHONE_NUMBER); + public void sendSmsUsingConnectionString(HttpClient httpClient) { SmsClientBuilder builder = getSmsClientUsingConnectionString(httpClient); - asyncClient = setupAsyncClient(builder, "createAsyncSmsClientUsingConnectionString"); + asyncClient = setupAsyncClient(builder, "sendSmsUsingConnectionString"); assertNotNull(asyncClient); - Mono> response = asyncClient.send(SMS_SERVICE_PHONE_NUMBER, to, MESSAGE, null); - StepVerifier.create(response) - .assertNext(item -> { - assertNotNull(item); + StepVerifier.create(asyncClient.send(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE)) + .assertNext(sendResult -> { + assertHappyPath(sendResult); }) .verifyComplete(); } @@ -46,86 +42,83 @@ public void createAsyncClientUsingConnectionString(HttpClient httpClient) { @MethodSource("com.azure.core.test.TestBase#getHttpClients") public void sendSmsUsingTokenCredential(HttpClient httpClient) { TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); - to = new ArrayList<>(); - to.add(SMS_SERVICE_PHONE_NUMBER); - SmsClientBuilder builder = getSmsClientWithToken(httpClient, tokenCredential); + SmsClientBuilder builder = getSmsClientWithToken(httpClient, tokenCredential); asyncClient = setupAsyncClient(builder, "sendSmsUsingTokenCredential"); assertNotNull(asyncClient); - Mono> response = asyncClient.send(SMS_SERVICE_PHONE_NUMBER, to, MESSAGE, null); - StepVerifier.create(response) - .assertNext(item -> { - assertNotNull(item); + StepVerifier.create(asyncClient.send(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE)) + .assertNext(sendResult -> { + assertHappyPath(sendResult); }) .verifyComplete(); } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendToMultipleUsers(HttpClient httpClient) { - to = new ArrayList(); - to.add(SMS_SERVICE_PHONE_NUMBER); + public void sendSmsToGroup(HttpClient httpClient) { // Arrange SmsClientBuilder builder = getSmsClient(httpClient); - asyncClient = setupAsyncClient(builder, "sendToMultipleUsers"); + asyncClient = setupAsyncClient(builder, "sendSmsToGroup"); + // Action & Assert - Mono> response = asyncClient.send(SMS_SERVICE_PHONE_NUMBER, to, MESSAGE, null); - StepVerifier.create(response) - .assertNext(item -> { - assertNotNull(item); + StepVerifier.create(asyncClient.send(FROM_PHONE_NUMBER, Arrays.asList(TO_PHONE_NUMBER, TO_PHONE_NUMBER), MESSAGE)) + .assertNext((Iterable sendResults) -> { + for (SmsSendResult result : sendResults) { + assertHappyPath(result); + } }) .verifyComplete(); } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendToSingleUser(HttpClient httpClient) { + public void sendSmsToGroupWithOptions(HttpClient httpClient) { // Arrange SmsClientBuilder builder = getSmsClient(httpClient); - asyncClient = setupAsyncClient(builder, "sendToSingleUser"); + asyncClient = setupAsyncClient(builder, "sendSmsToGroupWithOptions"); + SmsSendOptions options = new SmsSendOptions(); + options.setDeliveryReportEnabled(true); + options.setTag("New Tag"); + // Action & Assert - Mono response = asyncClient.send(SMS_SERVICE_PHONE_NUMBER, SMS_SERVICE_PHONE_NUMBER, MESSAGE, null); - StepVerifier.create(response) - .assertNext(item -> { - assertNotNull(item); + StepVerifier.create(asyncClient.sendWithResponse(FROM_PHONE_NUMBER, Arrays.asList(TO_PHONE_NUMBER, TO_PHONE_NUMBER), MESSAGE, options)) + .assertNext((Response> response) -> { + for (SmsSendResult result : response.getValue()) { + assertHappyPath(result); + } }) .verifyComplete(); } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendToSingleUserWithOptions(HttpClient httpClient) { - - SmsSendOptions options = new SmsSendOptions(); - options.setDeliveryReportEnabled(true); - options.setTag("New Tag"); + public void sendSmsToSingleNumber(HttpClient httpClient) { // Arrange SmsClientBuilder builder = getSmsClient(httpClient); - asyncClient = setupAsyncClient(builder, "sendToSingleUserWithOptions"); + asyncClient = setupAsyncClient(builder, "sendSmsToSingleNumber"); + // Action & Assert - Mono response = asyncClient.send(SMS_SERVICE_PHONE_NUMBER, SMS_SERVICE_PHONE_NUMBER, MESSAGE, options); + Mono response = asyncClient.send(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE); StepVerifier.create(response) - .assertNext(item -> { - assertNotNull(item); + .assertNext(sendResult -> { + assertHappyPath(sendResult); }) .verifyComplete(); } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendToMultipleUsersWithOptions(HttpClient httpClient) { + public void sendSmsToSingleNumberWithOptions(HttpClient httpClient) { + // Arrange + SmsClientBuilder builder = getSmsClient(httpClient); + asyncClient = setupAsyncClient(builder, "sendSmsToSingleNumberWithOptions"); SmsSendOptions options = new SmsSendOptions(); options.setDeliveryReportEnabled(true); options.setTag("New Tag"); - to = new ArrayList(); - to.add(SMS_SERVICE_PHONE_NUMBER); - // Arrange - SmsClientBuilder builder = getSmsClient(httpClient); - asyncClient = setupAsyncClient(builder, "sendToMultipleUsersWithOptions"); + // Action & Assert - Mono> response = asyncClient.send(SMS_SERVICE_PHONE_NUMBER, to, MESSAGE, options); - StepVerifier.create(response) - .assertNext(item -> { - assertNotNull(item); + StepVerifier.create(asyncClient.sendWithResponse(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE, options)) + .assertNext((Response response) -> { + assertHappyPath(response.getValue()); }) .verifyComplete(); } @@ -133,74 +126,37 @@ public void sendToMultipleUsersWithOptions(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") public void sendFromFakeNumber(HttpClient httpClient) { - SmsSendOptions options = new SmsSendOptions(); - options.setDeliveryReportEnabled(true); - options.setTag("New Tag"); // Arrange SmsClientBuilder builder = getSmsClient(httpClient); asyncClient = setupAsyncClient(builder, "sendFromFakeNumber"); // Action & Assert - Mono response = asyncClient.send("+155512345678", SMS_SERVICE_PHONE_NUMBER, MESSAGE, options); + Mono response = asyncClient.send("+155512345678", TO_PHONE_NUMBER, MESSAGE); StepVerifier.create(response) .expectErrorMatches(exception -> - ((HttpResponseException) exception).getResponse().getStatusCode() == 400 - ).verify(); + ((HttpResponseException) exception).getResponse().getStatusCode() == 400).verify(); } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") public void sendFromUnauthorizedNumber(HttpClient httpClient) { - SmsSendOptions options = new SmsSendOptions(); - options.setDeliveryReportEnabled(true); - options.setTag("New Tag"); // Arrange SmsClientBuilder builder = getSmsClient(httpClient); asyncClient = setupAsyncClient(builder, "sendFromUnauthorizedNumber"); + // Action & Assert - Mono response = asyncClient.send("+18007342577", SMS_SERVICE_PHONE_NUMBER, MESSAGE, options); + Mono response = asyncClient.send("+18007342577", TO_PHONE_NUMBER, MESSAGE); StepVerifier.create(response) .expectErrorMatches(exception -> - ((HttpResponseException) exception).getResponse().getStatusCode() == 404 - ).verify(); - - } - - @ParameterizedTest - @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendIdempotencyCheck(HttpClient httpClient) { - SmsSendOptions options = new SmsSendOptions(); - options.setDeliveryReportEnabled(true); - options.setTag("New Tag"); - // Arrange - SmsClientBuilder builder = getSmsClient(httpClient); - asyncClient = setupAsyncClient(builder, "sendIdempotencyCheck"); - // Action & Assert - Mono response1 = asyncClient.send(SMS_SERVICE_PHONE_NUMBER, SMS_SERVICE_PHONE_NUMBER, MESSAGE, options); - StepVerifier.create(response1) - .assertNext(item -> { - assertNotNull(item); - }) - .verifyComplete(); - assertTrue(response1.block().isSuccessful()); - Mono response2 = asyncClient.send(SMS_SERVICE_PHONE_NUMBER, SMS_SERVICE_PHONE_NUMBER, MESSAGE, options); - StepVerifier.create(response2) - .assertNext(item -> { - assertNotNull(item); - }) - .verifyComplete(); - assertTrue(response2.block().isSuccessful()); - assertNotEquals(response1.block().getMessageId(), response2.block().getMessageId()); + ((HttpResponseException) exception).getResponse().getStatusCode() == 404).verify(); } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendToIncorrectPhoneNumber(HttpClient httpClient) { - to = new ArrayList(); - to.add("+155512345678"); + public void sendToFakePhoneNumber(HttpClient httpClient) { SmsClientBuilder builder = getSmsClientUsingConnectionString(httpClient); - asyncClient = setupAsyncClient(builder, "sendToIncorrectPhoneNumber"); + asyncClient = setupAsyncClient(builder, "sendToFakePhoneNumber"); assertNotNull(asyncClient); - Mono> response = asyncClient.send(SMS_SERVICE_PHONE_NUMBER, to, MESSAGE, null); + Mono> response = asyncClient.send(FROM_PHONE_NUMBER, Arrays.asList("+15550000000"), MESSAGE); assertNotNull(response); StepVerifier.create(response) .assertNext(item -> { @@ -214,8 +170,60 @@ public void sendToIncorrectPhoneNumber(HttpClient httpClient) { } } + @ParameterizedTest + @MethodSource("com.azure.core.test.TestBase#getHttpClients") + public void sendTwoMessages(HttpClient httpClient) { + // Arrange + SmsClientBuilder builder = getSmsClient(httpClient); + asyncClient = setupAsyncClient(builder, "sendTwoMessages"); + + // Action & Assert + StepVerifier.create(asyncClient.send(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE)) + .assertNext(firstResult -> { + StepVerifier.create(asyncClient.send(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE)) + .assertNext((SmsSendResult secondResult) -> { + assertNotEquals(firstResult.getMessageId(), secondResult.getMessageId()); + assertHappyPath(firstResult); + assertHappyPath(secondResult); + }); + }) + .verifyComplete(); + } + + @ParameterizedTest + @MethodSource("com.azure.core.test.TestBase#getHttpClients") + public void sendSmsToNullNumber(HttpClient httpClient) { + // Arrange + SmsClientBuilder builder = getSmsClient(httpClient); + asyncClient = setupAsyncClient(builder, "sendSmsToSingleNumber"); + + // Action & Assert + String to = null; + Mono response = asyncClient.send(FROM_PHONE_NUMBER, to, MESSAGE); + StepVerifier.create(response).verifyError(); + } + + @ParameterizedTest + @MethodSource("com.azure.core.test.TestBase#getHttpClients") + public void sendSmsFromNullNumber(HttpClient httpClient) { + // Arrange + SmsClientBuilder builder = getSmsClient(httpClient); + asyncClient = setupAsyncClient(builder, "sendSmsFromNullNumber"); + + // Action & Assert + String from = null; + Mono response = asyncClient.send(from, TO_PHONE_NUMBER, MESSAGE); + StepVerifier.create(response).verifyError(); + } + + private SmsAsyncClient setupAsyncClient(SmsClientBuilder builder, String testName) { return addLoggingPolicy(builder, testName).buildAsyncClient(); } + private void assertHappyPath(SmsSendResult sendResult) { + assertTrue(sendResult.isSuccessful()); + assertEquals(sendResult.getHttpStatusCode(), 202); + assertNotNull(sendResult.getMessageId()); + } } diff --git a/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsBuilderTests.java b/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsBuilderTests.java new file mode 100644 index 000000000000..d63efd70fe74 --- /dev/null +++ b/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsBuilderTests.java @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.communication.sms; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.net.MalformedURLException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.HttpResponse; + +import org.junit.jupiter.api.Test; + +import reactor.core.publisher.Mono; + +public class SmsBuilderTests { + static final String MOCK_URL = "https://REDACTED.communication.azure.com"; + static final String MOCK_ACCESS_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaGfQSflKxwRJSMeKKF2QT4fwpMeJf36POk6yJVadQssw5c"; + static final String MOCK_CONNECTION_STRING = "endpoint=https://REDACTED.communication.azure.com/;accesskey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaGfQSflKxwRJSMeKKF2QT4fwpMeJf36POk6yJVadQssw5c"; + + static class NoOpHttpClient implements HttpClient { + @Override + public Mono send(HttpRequest request) { + return Mono.empty(); // NOP + } + } + + private final SmsClientBuilder builder = new SmsClientBuilder(); + + @Test + public void missingTokenCredentialTest() + throws NullPointerException, MalformedURLException, InvalidKeyException, NoSuchAlgorithmException { + builder + .endpoint(MOCK_URL) + .httpClient(new NoOpHttpClient()); + assertThrows(Exception.class, () -> { + builder.buildAsyncClient(); + }); + } + + @Test + public void missingUrlTest() + throws NullPointerException, MalformedURLException { + builder + .credential(new AzureKeyCredential(MOCK_ACCESS_KEY)) + .httpClient(new NoOpHttpClient()); + assertThrows(Exception.class, () -> { + builder.buildAsyncClient(); + }); + } + + @Test + public void nullPipelineTest() { + assertThrows(NullPointerException.class, () -> { + builder + .connectionString(MOCK_CONNECTION_STRING) + .httpClient(new NoOpHttpClient()) + .pipeline(null); + }); + } + + @Test + public void nullCustomPolicyTest() { + assertThrows(NullPointerException.class, () -> { + builder + .connectionString(MOCK_CONNECTION_STRING) + .httpClient(new NoOpHttpClient()) + .addPolicy(null); + }); + } + + @Test + public void nullConfigurationTest() { + assertThrows(NullPointerException.class, () -> { + builder + .connectionString(MOCK_CONNECTION_STRING) + .httpClient(new NoOpHttpClient()) + .configuration(null); + }); + } + + @Test + public void nullHttpLogOptionsTest() { + assertThrows(NullPointerException.class, () -> { + builder + .connectionString(MOCK_CONNECTION_STRING) + .httpClient(new NoOpHttpClient()) + .httpLogOptions(null); + }); + } + + @Test + public void nullRetryPolicyTest() { + assertThrows(NullPointerException.class, () -> { + builder + .connectionString(MOCK_CONNECTION_STRING) + .httpClient(new NoOpHttpClient()) + .retryPolicy(null); + }); + } + + @Test + public void buildPiplineForClient() { + SmsAsyncClient smsClient = builder + .connectionString(MOCK_CONNECTION_STRING) + .httpClient(new NoOpHttpClient()) + .pipeline(new HttpPipelineBuilder().build()) + .buildAsyncClient(); + assertNotNull(smsClient); + } +} diff --git a/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsClientTests.java b/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsClientTests.java index 9aeb0cc4446d..4c01a4c99972 100644 --- a/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsClientTests.java +++ b/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsClientTests.java @@ -3,33 +3,23 @@ package com.azure.communication.sms; -import com.azure.communication.common.implementation.HmacAuthenticationPolicy; import com.azure.communication.sms.models.SmsSendOptions; -import com.azure.core.credential.AzureKeyCredential; import com.azure.core.credential.TokenCredential; import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.HttpClient;; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.policy.UserAgentPolicy; -import com.azure.core.test.http.NoOpHttpClient; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.Response; import com.azure.core.util.Context; import com.azure.identity.DefaultAzureCredentialBuilder; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import java.util.ArrayList; -import java.util.List; +import java.util.Arrays; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; public class SmsClientTests extends SmsTestBase { - private List to; private SmsClient client; @Override @@ -39,217 +29,145 @@ protected void beforeTest() { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void createSyncClientUsingConnectionString(HttpClient httpClient) { - to = new ArrayList(); - to.add(SMS_SERVICE_PHONE_NUMBER); + public void sendSmsUsingConnectionString(HttpClient httpClient) { SmsClientBuilder builder = getSmsClientUsingConnectionString(httpClient); - client = setupSyncClient(builder, "createSyncClientUsingConnectionString"); - assertNotNull(client); - Iterable response = client.send(SMS_SERVICE_PHONE_NUMBER, to, MESSAGE, null, Context.NONE); - assertNotNull(response); - for (SmsSendResult r : response) { - assertTrue(r.isSuccessful()); - assertNull(r.getErrorMessage()); - } - } - - @ParameterizedTest - @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void builderNoEndpoint(HttpClient httpClient) { - SmsClientBuilder builder = getSmsClientUsingConnectionString(httpClient); - builder - .endpoint(null) - .httpClient(new NoOpHttpClient()); - assertThrows(Exception.class, () -> { - builder.buildAsyncClient(); - }); - - } - - @ParameterizedTest - @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void builderServiceVersion(HttpClient httpClient) { - assertNotNull(SmsServiceVersion.getLatest()); - } - - @ParameterizedTest - @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void builderTestsConfigurations(HttpClient httpClient) { - - SmsClientBuilder builder = getSmsClientUsingConnectionString(httpClient); - builder.retryPolicy(null); - AzureKeyCredential credential = new AzureKeyCredential(ACCESSKEY); - HttpPipelinePolicy[] policies = new HttpPipelinePolicy[2]; - policies[0] = new HmacAuthenticationPolicy(credential); - policies[1] = new UserAgentPolicy(); - HttpPipeline pipeline = new HttpPipelineBuilder() - .policies(policies) - .httpClient(httpClient) - .build(); - builder.pipeline(pipeline); - client = setupSyncClient(builder, "builderTestsConfigurations"); - assertNotNull(client); - } - - @ParameterizedTest - @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void builderNotRetryPolicy(HttpClient httpClient) { - SmsClientBuilder builder = getSmsClientUsingConnectionString(httpClient); - builder.retryPolicy(null); - client = setupSyncClient(builder, "builderNotRetryPolicy"); - assertNotNull(client); - + client = setupSyncClient(builder, "sendSmsUsingConnectionStringSync"); + SmsSendResult sendResult = client.send(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE); + assertHappyPath(sendResult); } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") public void sendSmsUsingTokenCredential(HttpClient httpClient) { TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); - to = new ArrayList<>(); - to.add(SMS_SERVICE_PHONE_NUMBER); SmsClientBuilder builder = getSmsClientWithToken(httpClient, tokenCredential); - client = setupSyncClient(builder, "sendSmsUsingTokenCredential"); - assertNotNull(client); - Iterable response = client.send(SMS_SERVICE_PHONE_NUMBER, to, MESSAGE, null, Context.NONE); - assertNotNull(response); - for (SmsSendResult r : response) { - assertTrue(r.isSuccessful()); - } + client = setupSyncClient(builder, "sendSmsUsingTokenCredentialSync"); + SmsSendResult sendResult = client.send(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE); + assertHappyPath(sendResult); } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendToIncorrectPhoneNumber(HttpClient httpClient) { - to = new ArrayList(); - to.add("+155512345678"); - SmsClientBuilder builder = getSmsClientUsingConnectionString(httpClient); - client = setupSyncClient(builder, "sendToIncorrectPhoneNumber"); - assertNotNull(client); - Iterable response = client.send(SMS_SERVICE_PHONE_NUMBER, to, MESSAGE, null, Context.NONE); - assertNotNull(response); - for (SmsSendResult r : response) { - assertFalse(r.isSuccessful()); + public void sendSmsToGroup(HttpClient httpClient) { + // Arrange + SmsClientBuilder builder = getSmsClient(httpClient); + client = setupSyncClient(builder, "sendSmsToGroupSync"); + // Action & Assert + Iterable sendResults = client.send(FROM_PHONE_NUMBER, Arrays.asList(TO_PHONE_NUMBER, TO_PHONE_NUMBER), MESSAGE); + for (SmsSendResult result : sendResults) { + assertHappyPath(result); } } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendFromFakeNumber(HttpClient httpClient) { + public void sendSmsToGroupWithOptions(HttpClient httpClient) { + // Arrange + SmsClientBuilder builder = getSmsClient(httpClient); + client = setupSyncClient(builder, "sendSmsToGroupWithOptionsSync"); SmsSendOptions options = new SmsSendOptions(); options.setDeliveryReportEnabled(true); options.setTag("New Tag"); - // Arrange - SmsClientBuilder builder = getSmsClient(httpClient); - client = setupSyncClient(builder, "sendFromFakeNumber"); // Action & Assert - try { - SmsSendResult response = client.send("+155512345678", SMS_SERVICE_PHONE_NUMBER, MESSAGE, options); - } catch (Exception exception) { - assertEquals(400, ((HttpResponseException) exception).getResponse().getStatusCode()); + Response> sendResults = client.sendWithResponse(FROM_PHONE_NUMBER, Arrays.asList(TO_PHONE_NUMBER, TO_PHONE_NUMBER), MESSAGE, options, Context.NONE); + for (SmsSendResult result : sendResults.getValue()) { + assertHappyPath(result); } } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendFromUnauthorizedNumber(HttpClient httpClient) { - SmsSendOptions options = new SmsSendOptions(); - options.setDeliveryReportEnabled(true); - options.setTag("New Tag"); + public void sendSmsToSingleNumber(HttpClient httpClient) { // Arrange SmsClientBuilder builder = getSmsClient(httpClient); - client = setupSyncClient(builder, "sendFromUnauthorizedNumber"); + client = setupSyncClient(builder, "sendSmsToSingleNumberSync"); + // Action & Assert - try { - SmsSendResult response = client.send("+18007342577", SMS_SERVICE_PHONE_NUMBER, MESSAGE, options, Context.NONE); - } catch (Exception exception) { - assertEquals(404, ((HttpResponseException) exception).getResponse().getStatusCode()); - } + SmsSendResult sendResult = client.send(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE); + assertHappyPath(sendResult); } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendToMultipleUsers(HttpClient httpClient) { - to = new ArrayList(); - to.add(SMS_SERVICE_PHONE_NUMBER); + public void sendSmsToSingleNumberWithOptions(HttpClient httpClient) { // Arrange SmsClientBuilder builder = getSmsClient(httpClient); - client = setupSyncClient(builder, "sendToMultipleUsers"); + client = setupSyncClient(builder, "sendSmsToSingleNumberWithOptionsSync"); + SmsSendOptions options = new SmsSendOptions(); + options.setDeliveryReportEnabled(true); + options.setTag("New Tag"); + // Action & Assert - Iterable response = client.send(SMS_SERVICE_PHONE_NUMBER, to, MESSAGE); - assertNotNull(response); - for (SmsSendResult r : response) { - assertTrue(r.isSuccessful()); - } + Response response = client.sendWithResponse(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE, options, Context.NONE); + assertHappyPath(response.getValue()); } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendToMultipleUsersWithOptions(HttpClient httpClient) { - SmsSendOptions options = new SmsSendOptions(); - options.setDeliveryReportEnabled(true); - options.setTag("New Tag"); - to = new ArrayList(); - to.add(SMS_SERVICE_PHONE_NUMBER); + public void sendFromFakeNumber(HttpClient httpClient) { // Arrange SmsClientBuilder builder = getSmsClient(httpClient); - client = setupSyncClient(builder, "sendToMultipleUsersWithOptions"); + client = setupSyncClient(builder, "sendFromFakeNumberSync"); + // Action & Assert - Iterable response = client.send(SMS_SERVICE_PHONE_NUMBER, to, MESSAGE, options, Context.NONE); - assertNotNull(response); - for (SmsSendResult r : response) { - assertTrue(r.isSuccessful()); + try { + client.send("+15550000000", TO_PHONE_NUMBER, MESSAGE); + } catch (Exception exception) { + assertEquals(400, ((HttpResponseException) exception).getResponse().getStatusCode()); } } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendToSingleUser(HttpClient httpClient) { + public void sendFromUnauthorizedNumber(HttpClient httpClient) { // Arrange SmsClientBuilder builder = getSmsClient(httpClient); - client = setupSyncClient(builder, "sendToSingleUser"); + client = setupSyncClient(builder, "sendFromUnauthorizedNumberSync"); + // Action & Assert - SmsSendResult response = client.send(SMS_SERVICE_PHONE_NUMBER, SMS_SERVICE_PHONE_NUMBER, MESSAGE); - assertNotNull(response); - assertTrue(response.isSuccessful()); - assertNull(response.getErrorMessage()); + try { + SmsSendResult response = client.send("+18007342577", TO_PHONE_NUMBER, MESSAGE); + } catch (Exception exception) { + assertEquals(404, ((HttpResponseException) exception).getResponse().getStatusCode()); + } } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendIdempotencyCheck(HttpClient httpClient) { - SmsSendOptions options = new SmsSendOptions(); - options.setDeliveryReportEnabled(true); - options.setTag("New Tag"); + public void sendToFakePhoneNumber(HttpClient httpClient) { // Arrange - SmsClientBuilder builder = getSmsClient(httpClient); - client = setupSyncClient(builder, "sendIdempotencyCheck"); + SmsClientBuilder builder = getSmsClientUsingConnectionString(httpClient); + client = setupSyncClient(builder, "sendToFakePhoneNumberSync"); + // Action & Assert - SmsSendResult response1 = client.send(SMS_SERVICE_PHONE_NUMBER, SMS_SERVICE_PHONE_NUMBER, MESSAGE, options); - assertTrue(response1.isSuccessful()); - SmsSendResult response2 = client.send(SMS_SERVICE_PHONE_NUMBER, SMS_SERVICE_PHONE_NUMBER, MESSAGE, options); - assertTrue(response2.isSuccessful()); - assertNotEquals(response1.getMessageId(), response2.getMessageId()); + SmsSendResult sendResult = client.send(FROM_PHONE_NUMBER, "+15550000000", MESSAGE); + assertFalse(sendResult.isSuccessful()); + assertEquals(sendResult.getHttpStatusCode(), 400); } @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") - public void sendToSingleUserWithOptions(HttpClient httpClient) { - SmsSendOptions options = new SmsSendOptions(); - options.setDeliveryReportEnabled(true); - options.setTag("New Tag"); - to = new ArrayList(); - to.add(SMS_SERVICE_PHONE_NUMBER); + public void sendTwoMessages(HttpClient httpClient) { // Arrange SmsClientBuilder builder = getSmsClient(httpClient); - client = setupSyncClient(builder, "sendToSingleUserWithOptions"); + client = setupSyncClient(builder, "sendTwoMessagesSync"); + // Action & Assert - SmsSendResult response = client.send(SMS_SERVICE_PHONE_NUMBER, SMS_SERVICE_PHONE_NUMBER, MESSAGE, options, Context.NONE); - assertNotNull(response); - assertTrue(response.isSuccessful()); + SmsSendResult firstResponse = client.send(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE); + SmsSendResult secondResponse = client.send(FROM_PHONE_NUMBER, TO_PHONE_NUMBER, MESSAGE); + assertNotEquals(firstResponse.getMessageId(), secondResponse.getMessageId()); + assertHappyPath(firstResponse); + assertHappyPath(secondResponse); } private SmsClient setupSyncClient(SmsClientBuilder builder, String testName) { return addLoggingPolicy(builder, testName).buildClient(); } + + private void assertHappyPath(SmsSendResult sendResult) { + assertTrue(sendResult.isSuccessful()); + assertEquals(sendResult.getHttpStatusCode(), 202); + assertNotNull(sendResult.getMessageId()); + } } diff --git a/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsTestBase.java b/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsTestBase.java index d8ee80f5508b..a802858f0d14 100644 --- a/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsTestBase.java +++ b/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsTestBase.java @@ -28,7 +28,7 @@ import com.azure.core.http.HttpResponse; public class SmsTestBase extends TestBase { - + protected static final TestMode TEST_MODE = initializeTestMode(); protected static final String ENDPOINT = Configuration.getGlobalConfiguration() .get("COMMUNICATION_SERVICE_ENDPOINT", "https://REDACTED.communication.azure.com"); @@ -43,7 +43,10 @@ public class SmsTestBase extends TestBase { protected static final String CONNECTION_STRING = Configuration.getGlobalConfiguration() .get("COMMUNICATION_CONNECTION_STRING", "endpoint=https://REDACTED.communication.azure.com/;accesskey=" + ACCESSKEYENCODED); - protected static final String SMS_SERVICE_PHONE_NUMBER = Configuration.getGlobalConfiguration() + protected static final String TO_PHONE_NUMBER = Configuration.getGlobalConfiguration() + .get("SMS_SERVICE_PHONE_NUMBER", "+15551234567"); + + protected static final String FROM_PHONE_NUMBER = Configuration.getGlobalConfiguration() .get("SMS_SERVICE_PHONE_NUMBER", "+15551234567"); protected static final String MESSAGE = Configuration.getGlobalConfiguration() @@ -51,13 +54,11 @@ public class SmsTestBase extends TestBase { private static final StringJoiner JSON_PROPERTIES_TO_REDACT = new StringJoiner("\":\"|\"", "\"", "\":\"") - .add("id") - .add("token"); + .add("to"); private static final Pattern JSON_PROPERTY_VALUE_REDACTION_PATTERN = Pattern.compile(String.format("(?:%s)(.*?)(?:\",|\"})", JSON_PROPERTIES_TO_REDACT.toString()), Pattern.CASE_INSENSITIVE); - private static Runnable exceptionThrower; protected SmsClientBuilder getSmsClient(HttpClient httpClient) { AzureKeyCredential azureKeyCredential = new AzureKeyCredential(ACCESSKEY); @@ -70,7 +71,6 @@ protected SmsClientBuilder getSmsClient(HttpClient httpClient) { redactors.add(data -> redact(data, JSON_PROPERTY_VALUE_REDACTION_PATTERN.matcher(data), "REDACTED")); builder.addPolicy(interceptorManager.getRecordPolicy(redactors)); } - return builder; } @@ -88,11 +88,9 @@ protected SmsClientBuilder getSmsClientWithToken(HttpClient httpClient, TokenCre redactors.add(data -> redact(data, JSON_PROPERTY_VALUE_REDACTION_PATTERN.matcher(data), "REDACTED")); builder.addPolicy(interceptorManager.getRecordPolicy(redactors)); } - return builder; } - protected SmsClientBuilder getSmsClientUsingConnectionString(HttpClient httpClient) { SmsClientBuilder builder = new SmsClientBuilder(); builder @@ -104,7 +102,6 @@ protected SmsClientBuilder getSmsClientUsingConnectionString(HttpClient httpClie redactors.add(data -> redact(data, JSON_PROPERTY_VALUE_REDACTION_PATTERN.matcher(data), "REDACTED")); builder.addPolicy(interceptorManager.getRecordPolicy(redactors)); } - return builder; } @@ -155,8 +152,6 @@ private String redact(String content, Matcher matcher, String replacement) { content = content.replace(matcher.group(1), replacement); } } - return content; } - } diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendFromFakeNumber[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendFromFakeNumber[1].json index bee6a28b97e2..9406613f03f3 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendFromFakeNumber[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendFromFakeNumber[1].json @@ -3,18 +3,18 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", - "X-Processing-Time" : "182ms", - "MS-CV" : "krTaG7CSmEOfhfzj0PEnew.0", + "X-Processing-Time" : "12ms", + "MS-CV" : "0O6hkY7090WJtzm+aB9BJg.0", "retry-after" : "0", - "X-Azure-Ref" : "0x55AYAAAAABV1ajKRNPySbWbnV/HQALQREFMRURHRTEwMTIAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0FH5CYAAAAAAbL3Nq8DjNRaDmwEcKMLo7WVZSMzBFREdFMDQwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "400", "Body" : "{\"From\":[\"Invalid From phone number format\"]}", - "Date" : "Thu, 04 Mar 2021 08:48:07 GMT", + "Date" : "Fri, 05 Mar 2021 18:53:08 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendFromUnauthorizedNumber[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendFromUnauthorizedNumber[1].json index 55dcb6389f23..cd0904326c1b 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendFromUnauthorizedNumber[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendFromUnauthorizedNumber[1].json @@ -3,18 +3,18 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "195ms", - "MS-CV" : "vOieBij+LkGynnUnOMPRmQ.0", + "X-Processing-Time" : "276ms", + "MS-CV" : "02V0pMyhYEqt9Ppq6IsUzg.0", "retry-after" : "0", - "X-Azure-Ref" : "0ZalAYAAAAABjz5Mnq2H/RofGtBE8OK6yREFMRURHRTEwMTIAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0FX5CYAAAAAD59GhqbPjwSYIPbDxPd0ORWVZSMzBFREdFMDQwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "Content-Length" : "0", "StatusCode" : "404", - "Date" : "Thu, 04 Mar 2021 09:33:25 GMT", + "Date" : "Fri, 05 Mar 2021 18:53:10 GMT", "Request-Context" : "appId=" }, "Exception" : null diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderAddCustomPolicy[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsFromNullNumber[1].json similarity index 100% rename from sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderAddCustomPolicy[1].json rename to sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsFromNullNumber[1].json diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.createAsyncClientUsingTokenCredential[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToGroupWithOptions[1].json similarity index 55% rename from sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.createAsyncClientUsingTokenCredential[1].json rename to sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToGroupWithOptions[1].json index b5eccc256c3d..a0e5eec7764b 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.createAsyncClientUsingTokenCredential[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToGroupWithOptions[1].json @@ -3,19 +3,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "724ms", - "MS-CV" : "dIfAiw6530a2x7koHuJqqQ.0", + "X-Processing-Time" : "623ms", + "MS-CV" : "4/De6pRIyECzgR5+Mz+yEg.0", "retry-after" : "0", - "X-Azure-Ref" : "0X909YAAAAACB9KHfF1dvSbBbR9dOCnh7REFMRURHRTEwMDUAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0FX5CYAAAAABgC4HgAE76QqegjH4OhEUtWVZSMzBFREdFMDQwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210302063824a476a1b5-5511-4723-8a22-bef76ef5b964_noam\",\"httpStatusCode\":202,\"errorMessage\":null,\"repeatabilityResult\":null,\"successful\":true}]}", - "Date" : "Tue, 02 Mar 2021 06:38:24 GMT", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202103051853093f5028de-8ac5-4263-973f-9b0d23ee91a5_noam\",\"httpStatusCode\":202,\"successful\":true},{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185309644e6ef7-af16-40ab-a3f0-f164187ab449_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:53:09 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToGroup[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToGroup[1].json new file mode 100644 index 000000000000..843b66b7bfd2 --- /dev/null +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToGroup[1].json @@ -0,0 +1,25 @@ +{ + "networkCallRecords" : [ { + "Method" : "POST", + "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", + "Headers" : { + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", + "Content-Type" : "application/json" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "X-Processing-Time" : "451ms", + "MS-CV" : "YrhFuMSDX0G4oLFiLo5H5g.0", + "retry-after" : "0", + "X-Azure-Ref" : "0Fn5CYAAAAAAv4V8LzryWRLTFjso7E2iHWVZSMzBFREdFMDQwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "StatusCode" : "202", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202103051853100b22344b-28de-47fe-b7f3-3d9f75862006_noam\",\"httpStatusCode\":202,\"successful\":true},{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185310bada1967-50ef-4ad5-98d3-b7fc403f17af_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:53:10 GMT", + "Content-Type" : "application/json; charset=utf-8", + "Request-Context" : "appId=" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderNoEndpoint[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToNullNumber[1].json similarity index 100% rename from sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderNoEndpoint[1].json rename to sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToNullNumber[1].json diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.createAsyncClientUsingConnectionString[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToSingleNumberWithOptions[1].json similarity index 67% rename from sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.createAsyncClientUsingConnectionString[1].json rename to sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToSingleNumberWithOptions[1].json index fad1bbbc97c9..e5a7226c8dd0 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.createAsyncClientUsingConnectionString[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToSingleNumberWithOptions[1].json @@ -3,19 +3,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "233ms", - "MS-CV" : "xN3QN5dSFU+uXAh3tgfkwQ.0", + "X-Processing-Time" : "620ms", + "MS-CV" : "kNlN2GFqUU2EY8PANxGa9g.0", "retry-after" : "0", - "X-Azure-Ref" : "0JhtAYAAAAABfsATFLhVkR74NjHRlyqm+REFMRURHRTEwMTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0Fn5CYAAAAAC0dNZhMPh0Rqimy8F9GyTpWVZSMzBFREdFMDQwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210303232630ca1305d7-1a32-404d-ba19-387d7b9aae1a_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Wed, 03 Mar 2021 23:26:30 GMT", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_2021030518531146333cd2-4143-40d5-903f-b5b87b63756b_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:53:11 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToSingleUserWithOptions[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToSingleNumber[1].json similarity index 67% rename from sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToSingleUserWithOptions[1].json rename to sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToSingleNumber[1].json index be962859d433..d3c81395a7a5 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToSingleUserWithOptions[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsToSingleNumber[1].json @@ -3,19 +3,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "544ms", - "MS-CV" : "DuUXEVJD/Ea6JTYfLsbtWA.0", + "X-Processing-Time" : "443ms", + "MS-CV" : "dQUPVVUEXEKuKhKf7ZTjFQ.0", "retry-after" : "0", - "X-Azure-Ref" : "0JhtAYAAAAADESnQpNvgVRJ7njIshz7mWREFMRURHRTEwMTkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0FH5CYAAAAADEjTQHac2IRp9cXXJuYUbOWVZSMzBFREdFMDQwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_2021030323263098d9f165-1610-45f6-9e3e-2d7a240201ae_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Wed, 03 Mar 2021 23:26:30 GMT", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185308659b115b-ccd5-4893-9390-ea0d85b6ec7d_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:53:08 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToMultipleUsersWithOptions[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsUsingConnectionString[1].json similarity index 67% rename from sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToMultipleUsersWithOptions[1].json rename to sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsUsingConnectionString[1].json index 75e2a7bcf856..b5f12254a77c 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToMultipleUsersWithOptions[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsUsingConnectionString[1].json @@ -3,19 +3,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "505ms", - "MS-CV" : "HPQyt3vp2E6DLD+8oUW4bQ.0", + "X-Processing-Time" : "711ms", + "MS-CV" : "xg9i59/z9UO95nds4KnRdA.0", "retry-after" : "0", - "X-Azure-Ref" : "0JhtAYAAAAACRvSz6DEiHRoxsTksd6MhcREFMRURHRTEwMTEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0TH5CYAAAAAA50zU3qRHzSI4Zwff4lNUiWVZSMzBFREdFMDMwOQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202103032326301043c580-f532-4fdd-92c5-44d1f4f8f11a_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Wed, 03 Mar 2021 23:26:30 GMT", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_2021030518540495750066-532d-4d6d-b21d-d4bbbcb8b456_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:54:04 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsUsingTokenCredential[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsUsingTokenCredential[1].json index 4eed96318efa..8a8c72473016 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsUsingTokenCredential[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendSmsUsingTokenCredential[1].json @@ -3,19 +3,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "708ms", - "MS-CV" : "Adlhsx46OUGpnjpdym+TKg.0", + "X-Processing-Time" : "793ms", + "MS-CV" : "kURE7+qwKUSHQPeBgkEwPw.0", "retry-after" : "0", - "X-Azure-Ref" : "00R5AYAAAAADd42cH6aEoSqeZB4fpEAUbREFMRURHRTEwMTAAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0GX5CYAAAAAA0ms760bmURaz7Qyg3zLXAWVZSMzBFREdFMDQwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202103032342093577ff8a-b16d-4c93-a2eb-ddba8b0c0b7d_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Wed, 03 Mar 2021 23:42:08 GMT", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185313a451cf06-728f-4e02-be4a-923130fa0dff_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:53:13 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendIdempotencyCheck[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToFakePhoneNumber[1].json similarity index 55% rename from sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendIdempotencyCheck[1].json rename to sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToFakePhoneNumber[1].json index b7ca65ba97d8..82598960a47a 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendIdempotencyCheck[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToFakePhoneNumber[1].json @@ -3,19 +3,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "519ms", - "MS-CV" : "0KpM/WOQNk2QUbzQPVkJ9A.0", + "X-Processing-Time" : "341ms", + "MS-CV" : "8liv5wlfaU6zr0Rq8584PA.0", "retry-after" : "0", - "X-Azure-Ref" : "0O5JAYAAAAACcX6khEAGFTJcQnELdLhbgREFMRURHRTEwMjEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0F35CYAAAAACq5T9dSTBIQ7KF4ofd8zjPWVZSMzBFREdFMDQwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210304075436729aca2d-a642-476c-9142-b8e5fc060e9c_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Thu, 04 Mar 2021 07:54:36 GMT", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"httpStatusCode\":400,\"errorMessage\":\"Invalid To phone number format.\",\"successful\":false}]}", + "Date" : "Fri, 05 Mar 2021 18:53:11 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, @@ -24,19 +24,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "449ms", - "MS-CV" : "PEWmpzcLQEWk1xb+ILrfsw.0", + "X-Processing-Time" : "283ms", + "MS-CV" : "tZxw0tC1zEeUHxiUtxJw3A.0", "retry-after" : "0", - "X-Azure-Ref" : "0PJJAYAAAAAATn7HvCmeQSKqw/tcGfzKnREFMRURHRTEwMjEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0F35CYAAAAADo09h3YQgTToMe7oAIA1tYWVZSMzBFREdFMDQwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"+18335102092\",\"messageId\":\"Outgoing_2021030407543732e5e08f-14ba-4cd9-b85f-d6a26409bb81_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Thu, 04 Mar 2021 07:54:36 GMT", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"httpStatusCode\":400,\"errorMessage\":\"Invalid To phone number format.\",\"successful\":false}]}", + "Date" : "Fri, 05 Mar 2021 18:53:12 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToIncorrectPhoneNumber[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToIncorrectPhoneNumber[1].json deleted file mode 100644 index a82afc0531ca..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToIncorrectPhoneNumber[1].json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", - "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "Transfer-Encoding" : "chunked", - "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "385ms", - "MS-CV" : "NwIlaQ1+OES8ERnusUf/xw.0", - "retry-after" : "0", - "X-Azure-Ref" : "0RyBAYAAAAAAae6xoDN1WR7YGLpdF/XfWREFMRURHRTEwMDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"httpStatusCode\":400,\"errorMessage\":\"Invalid To phone number format.\",\"successful\":false}]}", - "Date" : "Wed, 03 Mar 2021 23:48:23 GMT", - "Content-Type" : "application/json; charset=utf-8", - "Request-Context" : "appId=" - }, - "Exception" : null - } ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToSingleUser[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToSingleUser[1].json deleted file mode 100644 index 32099711af94..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToSingleUser[1].json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", - "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "Transfer-Encoding" : "chunked", - "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "553ms", - "MS-CV" : "PgyJQyaHGkmo4CJvVxpw7w.0", - "retry-after" : "0", - "X-Azure-Ref" : "0JhtAYAAAAADqRAmWaJ3FRLJGmWEjN5UQREFMRURHRTEwMTEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202103032326306a62e880-c0d3-4806-a7e7-0fb422e10e6d_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Wed, 03 Mar 2021 23:26:30 GMT", - "Content-Type" : "application/json; charset=utf-8", - "Request-Context" : "appId=" - }, - "Exception" : null - } ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToMultipleUsers[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendTwoMessages[1].json similarity index 67% rename from sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToMultipleUsers[1].json rename to sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendTwoMessages[1].json index 90878bdc62c9..3104244977fc 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendToMultipleUsers[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendTwoMessages[1].json @@ -3,19 +3,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "332ms", - "MS-CV" : "y5bxAPxsF0Cbpgd+1rWsMw.0", + "X-Processing-Time" : "444ms", + "MS-CV" : "ojYKBS1tJ0CHrdQcBO1yFA.0", "retry-after" : "0", - "X-Azure-Ref" : "0JhtAYAAAAACC1O1vrHVKRb4pFmIo/b3FREFMRURHRTEwMjIAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0E35CYAAAAABPBTCwsyugQbTMC29+YpPfWVZSMzBFREdFMDQwOAA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210303232630be2dcb4a-bfae-46be-940a-92dd6cccc0b4_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Wed, 03 Mar 2021 23:26:29 GMT", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185308baab9cc0-bad0-4b3b-938e-864090105682_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:53:08 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendWithOptions[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendWithOptions[1].json deleted file mode 100644 index 71d5d535fe56..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.sendWithOptions[1].json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", - "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.4 (15.0.1; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "Transfer-Encoding" : "chunked", - "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "870ms", - "MS-CV" : "FaDe5wZ+zkuBAhqB2Q8d/A.0", - "retry-after" : "0", - "X-Azure-Ref" : "0n4s4YAAAAAAvx7DoiohpSbeauJJPRF5nREFMRURHRTEwMTEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202102260548152eb72a86-ea5f-4cb3-9e18-68c1f0808d8d_noam\",\"httpStatusCode\":202,\"errorMessage\":null,\"repeatabilityResult\":null,\"successful\":true}]}", - "Date" : "Fri, 26 Feb 2021 05:48:16 GMT", - "Content-Type" : "application/json; charset=utf-8", - "Request-Context" : "appId=" - }, - "Exception" : null - } ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.send[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.send[1].json deleted file mode 100644 index 1cf0dccf3bd7..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsAsyncClientTests.send[1].json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", - "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.4 (15.0.1; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "Transfer-Encoding" : "chunked", - "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "452ms", - "MS-CV" : "YLsQ422FQEeY6Lt8210dLw.0", - "retry-after" : "0", - "X-Azure-Ref" : "09z04YAAAAADLXbU20DA9SY/aSBuszWfaREFMRURHRTEwMjEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210226001656961fe417-8871-4db8-ba5f-2b893f2e8b00_noam\",\"httpStatusCode\":202,\"errorMessage\":null,\"repeatabilityResult\":null,\"successful\":true}]}", - "Date" : "Fri, 26 Feb 2021 00:16:55 GMT", - "Request-Context" : "appId=", - "Content-Type" : "application/json; charset=utf-8" - }, - "Exception" : null - } ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderNotRetryPolicy[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderNotRetryPolicy[1].json deleted file mode 100644 index ba5f37f8f855..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderNotRetryPolicy[1].json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "networkCallRecords" : [ ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderServiceVersion[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderServiceVersion[1].json deleted file mode 100644 index ba5f37f8f855..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderServiceVersion[1].json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "networkCallRecords" : [ ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderTestsConfigurations[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderTestsConfigurations[1].json deleted file mode 100644 index ba5f37f8f855..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.builderTestsConfigurations[1].json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "networkCallRecords" : [ ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.createAsyncClientUsingConnectionString[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.createAsyncClientUsingConnectionString[1].json deleted file mode 100644 index ddc69b6a8de6..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.createAsyncClientUsingConnectionString[1].json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", - "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.4 (15.0.1; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "Transfer-Encoding" : "chunked", - "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "236ms", - "MS-CV" : "ahCAiV0Ab0yOij/BWjIUmw.0", - "retry-after" : "0", - "X-Azure-Ref" : "06Dg3YAAAAACJYb5ZqjGEQ6dOatSqO3EjREFMRURHRTEwMTIAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202102250543049e08d499-9837-4842-8432-e3a0b9a6a01c_noam\",\"httpStatusCode\":202,\"errorMessage\":null,\"repeatabilityResult\":\"accepted\",\"successful\":true}]}", - "Date" : "Thu, 25 Feb 2021 05:43:03 GMT", - "Request-Context" : "appId=", - "Content-Type" : "application/json; charset=utf-8" - }, - "Exception" : null - } ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.createSyncClientUsingConnectionString[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.createSyncClientUsingConnectionString[1].json deleted file mode 100644 index 727ad7ffd5bd..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.createSyncClientUsingConnectionString[1].json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", - "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "Transfer-Encoding" : "chunked", - "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "596ms", - "MS-CV" : "9ZHrd+EY4kKS4wJRvzYY1g.0", - "retry-after" : "0", - "X-Azure-Ref" : "0aSRAYAAAAABFAEjttYkaSrLNXXE4sskhREFMRURHRTEwMTQAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202103040006027e691189-3a1b-4c8e-a6da-18d0d154e90d_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Thu, 04 Mar 2021 00:06:01 GMT", - "Content-Type" : "application/json; charset=utf-8", - "Request-Context" : "appId=" - }, - "Exception" : null - } ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendFromFakeNumber[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendFromFakeNumber[1].json index 4e2658ede812..5356b11c95c3 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendFromFakeNumber[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendFromFakeNumber[1].json @@ -3,18 +3,18 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", - "X-Processing-Time" : "169ms", - "MS-CV" : "4LkNdPOL60OFZ5JqId46+A.0", + "X-Processing-Time" : "13ms", + "MS-CV" : "ntfdwHaLX0WLa8Gw91wmkQ.0", "retry-after" : "0", - "X-Azure-Ref" : "0MLVAYAAAAACaSI48gKQ9QrHsQptVFX4pREFMRURHRTEwMTIAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0cX5CYAAAAAAw+Pt0msqgTJ5KHyXOCszGWVZSMzBFREdFMDQxNQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "400", "Body" : "{\"From\":[\"Invalid From phone number format\"]}", - "Date" : "Thu, 04 Mar 2021 10:23:45 GMT", + "Date" : "Fri, 05 Mar 2021 18:54:40 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendFromUnauthorizedNumber[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendFromUnauthorizedNumber[1].json index 1c8217437288..fe09ce9b7b48 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendFromUnauthorizedNumber[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendFromUnauthorizedNumber[1].json @@ -3,18 +3,18 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "216ms", - "MS-CV" : "/b/UGH3uNUeLZXotqg8R9Q.0", + "X-Processing-Time" : "279ms", + "MS-CV" : "y0RQshIEZ0eA/g8YUeD8NA.0", "retry-after" : "0", - "X-Azure-Ref" : "0MLVAYAAAAADXCfB8y8FTQ4uc6I7c8UkHREFMRURHRTEwMTQAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0c35CYAAAAABHcM9dqJCESLz3NefWeYBnWVZSMzBFREdFMDQxNQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "Content-Length" : "0", "StatusCode" : "404", - "Date" : "Thu, 04 Mar 2021 10:23:44 GMT", + "Date" : "Fri, 05 Mar 2021 18:54:42 GMT", "Request-Context" : "appId=" }, "Exception" : null diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToGroupWithOptions[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToGroupWithOptions[1].json new file mode 100644 index 000000000000..ad8f17799687 --- /dev/null +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToGroupWithOptions[1].json @@ -0,0 +1,25 @@ +{ + "networkCallRecords" : [ { + "Method" : "POST", + "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", + "Headers" : { + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", + "Content-Type" : "application/json" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "X-Processing-Time" : "599ms", + "MS-CV" : "nGXEmrQfWEex8uIYxoNKQw.0", + "retry-after" : "0", + "X-Azure-Ref" : "0cn5CYAAAAABfad2nzzauSpIngO36gSbVWVZSMzBFREdFMDQxNQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "StatusCode" : "202", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185442b1aa7739-ca1b-4f45-a4e8-6548831f143b_noam\",\"httpStatusCode\":202,\"successful\":true},{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202103051854422d22f14a-bb5b-4e54-85dc-7aefedfb6912_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:54:42 GMT", + "Content-Type" : "application/json; charset=utf-8", + "Request-Context" : "appId=" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToGroup[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToGroup[1].json new file mode 100644 index 000000000000..0969813feaea --- /dev/null +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToGroup[1].json @@ -0,0 +1,25 @@ +{ + "networkCallRecords" : [ { + "Method" : "POST", + "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", + "Headers" : { + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", + "Content-Type" : "application/json" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "X-Processing-Time" : "445ms", + "MS-CV" : "emBS5Wc1hk21pUErpA5WzQ.0", + "retry-after" : "0", + "X-Azure-Ref" : "0c35CYAAAAABkuz+AwLtrQqDlrPxvLdIqWVZSMzBFREdFMDQxNQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "StatusCode" : "202", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185443824ff0e8-585c-421a-a8c0-e6bce2825260_noam\",\"httpStatusCode\":202,\"successful\":true},{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185443f4110185-fce6-4d65-8ae0-80bceaf8e702_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:54:43 GMT", + "Content-Type" : "application/json; charset=utf-8", + "Request-Context" : "appId=" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToSingleNumberWithOptions[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToSingleNumberWithOptions[1].json new file mode 100644 index 000000000000..5030b5fca7e4 --- /dev/null +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToSingleNumberWithOptions[1].json @@ -0,0 +1,25 @@ +{ + "networkCallRecords" : [ { + "Method" : "POST", + "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", + "Headers" : { + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", + "Content-Type" : "application/json" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "X-Processing-Time" : "386ms", + "MS-CV" : "XGyXQVDlAEi9KYoPiKAuEg.0", + "retry-after" : "0", + "X-Azure-Ref" : "0dH5CYAAAAAAyr8NJh+nDQIvvQNVejwmRWVZSMzBFREdFMDQxNQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "StatusCode" : "202", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202103051854445d3f75b2-f8fd-4e38-ab79-5b68eb72cd1e_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:54:43 GMT", + "Content-Type" : "application/json; charset=utf-8", + "Request-Context" : "appId=" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToSingleNumber[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToSingleNumber[1].json new file mode 100644 index 000000000000..8bae3641556a --- /dev/null +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsToSingleNumber[1].json @@ -0,0 +1,25 @@ +{ + "networkCallRecords" : [ { + "Method" : "POST", + "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", + "Headers" : { + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", + "Content-Type" : "application/json" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "X-Processing-Time" : "324ms", + "MS-CV" : "0akar9pmPUm7dLAdkiAZ6g.0", + "retry-after" : "0", + "X-Azure-Ref" : "0cX5CYAAAAABJ9IuLJDkiRKylI02vlYKIWVZSMzBFREdFMDQxNQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "StatusCode" : "202", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185441230b1b7a-de5b-42f1-812d-bc340f47445c_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:54:41 GMT", + "Content-Type" : "application/json; charset=utf-8", + "Request-Context" : "appId=" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsUsingConnectionString[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsUsingConnectionString[1].json new file mode 100644 index 000000000000..c5958b768be2 --- /dev/null +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsUsingConnectionString[1].json @@ -0,0 +1,25 @@ +{ + "networkCallRecords" : [ { + "Method" : "POST", + "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", + "Headers" : { + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", + "Content-Type" : "application/json" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", + "X-Processing-Time" : "327ms", + "MS-CV" : "l5/wD78L1EK1+lVviYqYSA.0", + "retry-after" : "0", + "X-Azure-Ref" : "0dH5CYAAAAABl8OqefehRQ7Ji/L69HlTfWVZSMzBFREdFMDQxNQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "StatusCode" : "202", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185444c6919ae5-6eca-45ff-8c18-23ee817eddfc_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:54:44 GMT", + "Content-Type" : "application/json; charset=utf-8", + "Request-Context" : "appId=" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsUsingTokenCredential[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsUsingTokenCredential[1].json index fb2e9387216e..79d5b660ddd4 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsUsingTokenCredential[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendSmsUsingTokenCredential[1].json @@ -3,19 +3,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "579ms", - "MS-CV" : "1hfFTpcFpEef7AqElKheVw.0", + "X-Processing-Time" : "479ms", + "MS-CV" : "iQCFIzhQf0SdT2epzd1eFg.0", "retry-after" : "0", - "X-Azure-Ref" : "0WI5AYAAAAAD8An/i6GsdQKc7MgZHkA1zREFMRURHRTEwMTcAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0dn5CYAAAAADjcDEIvfyUS5xnwTED88s/WVZSMzBFREdFMDQxNQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210304073801c8eb644a-64c1-46bf-a4e0-bf6d5f7da4dc_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Thu, 04 Mar 2021 07:38:00 GMT", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185447a8744399-5a67-4d54-9d24-4858810e130b_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:54:46 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToIncorrectPhoneNumber[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToFakePhoneNumber[1].json similarity index 72% rename from sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToIncorrectPhoneNumber[1].json rename to sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToFakePhoneNumber[1].json index 47213ff66928..03ca20b29dd4 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToIncorrectPhoneNumber[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToFakePhoneNumber[1].json @@ -3,19 +3,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "206ms", - "MS-CV" : "bbOzfeDfckqMbNXARA2gLg.0", + "X-Processing-Time" : "327ms", + "MS-CV" : "Xd46nzdtHk+GryCI16lKbw.0", "retry-after" : "0", - "X-Azure-Ref" : "0aSRAYAAAAAA7bjjdLPU3QbIS5RmQoUurREFMRURHRTEwMDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0dX5CYAAAAAClqRp7W6BbS7VJGQkf9DOdWVZSMzBFREdFMDQxNQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"httpStatusCode\":400,\"errorMessage\":\"Invalid To phone number format.\",\"successful\":false}]}", - "Date" : "Thu, 04 Mar 2021 00:06:01 GMT", + "Date" : "Fri, 05 Mar 2021 18:54:44 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToMultipleUsersWithOptions[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToMultipleUsersWithOptions[1].json deleted file mode 100644 index 4a5f56f57c71..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToMultipleUsersWithOptions[1].json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", - "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "Transfer-Encoding" : "chunked", - "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "699ms", - "MS-CV" : "4D0UFl0wXEabpU3Lic/H0Q.0", - "retry-after" : "0", - "X-Azure-Ref" : "0aSRAYAAAAAAzgwGYEdsHSY1c+IOx9yohREFMRURHRTEwMDUAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202103040006021a474135-368e-4bd0-8154-c39dca1b57b1_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Thu, 04 Mar 2021 00:06:02 GMT", - "Content-Type" : "application/json; charset=utf-8", - "Request-Context" : "appId=" - }, - "Exception" : null - } ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToMultipleUsers[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToMultipleUsers[1].json deleted file mode 100644 index a61a46f6acbf..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToMultipleUsers[1].json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", - "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "Transfer-Encoding" : "chunked", - "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "600ms", - "MS-CV" : "wTT2lSvyBk6hK2EtleOSyg.0", - "retry-after" : "0", - "X-Azure-Ref" : "0aSRAYAAAAACNihwWopWDQaWPt9dmz1PlREFMRURHRTEwMjEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210304000602d3407952-8aac-4c03-b7d9-add3778e6c9c_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Thu, 04 Mar 2021 00:06:02 GMT", - "Content-Type" : "application/json; charset=utf-8", - "Request-Context" : "appId=" - }, - "Exception" : null - } ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToSingleUserWithOptions[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToSingleUserWithOptions[1].json deleted file mode 100644 index 162514471652..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToSingleUserWithOptions[1].json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", - "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "Transfer-Encoding" : "chunked", - "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "442ms", - "MS-CV" : "qksAoNtyqEqRH75Qt1FnCg.0", - "retry-after" : "0", - "X-Azure-Ref" : "0aSRAYAAAAAC1vqSDiG63SbCVnifQKkTsREFMRURHRTEwMTEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210304000602552d7acc-3330-4f3a-8644-8024ded011b7_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Thu, 04 Mar 2021 00:06:02 GMT", - "Content-Type" : "application/json; charset=utf-8", - "Request-Context" : "appId=" - }, - "Exception" : null - } ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToSingleUser[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToSingleUser[1].json deleted file mode 100644 index cfc118ae8ad2..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendToSingleUser[1].json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", - "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "Transfer-Encoding" : "chunked", - "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "551ms", - "MS-CV" : "bhYVp91viU2/OPRacqObyg.0", - "retry-after" : "0", - "X-Azure-Ref" : "0aSRAYAAAAADYTsyA1lWyS5+pcSMK93RzREFMRURHRTEwMDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202103040006021497d710-f4ab-4030-ab07-3150e5ee4dd2_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Thu, 04 Mar 2021 00:06:02 GMT", - "Content-Type" : "application/json; charset=utf-8", - "Request-Context" : "appId=" - }, - "Exception" : null - } ], - "variables" : [ ] -} \ No newline at end of file diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendIdempotencyCheck[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendTwoMessages[1].json similarity index 61% rename from sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendIdempotencyCheck[1].json rename to sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendTwoMessages[1].json index 2c72e0f8ca46..e2da69457864 100644 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendIdempotencyCheck[1].json +++ b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.sendTwoMessages[1].json @@ -3,19 +3,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "622ms", - "MS-CV" : "GSf80UC1GUGHxnY4OdEh9g.0", + "X-Processing-Time" : "652ms", + "MS-CV" : "d+k5+7YYvUCeVy6xVkoZRQ.0", "retry-after" : "0", - "X-Azure-Ref" : "0z5JAYAAAAADqqIY2ySSjSpdXtEV/i7ssREFMRURHRTEwMDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0b35CYAAAAABXvAxPMu+MRIZQdt2VQ4A6WVZSMzBFREdFMDQxNQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210304075704febb52e0-3641-4622-8491-1d08a6358a32_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Thu, 04 Mar 2021 07:57:03 GMT", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_202103051854402d40f943-9559-4d58-94d7-6f39e6d9d93d_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:54:39 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, @@ -24,19 +24,19 @@ "Method" : "POST", "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (15.0.1; Windows 10; 10.0)", + "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.5 (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" }, "Response" : { "Transfer-Encoding" : "chunked", "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "415ms", - "MS-CV" : "A73ZRadboU6mRNkN4v7DKw.0", + "X-Processing-Time" : "367ms", + "MS-CV" : "y0SVYD0FHkGzy0ouN0teiA.0", "retry-after" : "0", - "X-Azure-Ref" : "00JJAYAAAAABvTQ11qRzTTL2jk2zniM84REFMRURHRTEwMTIAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Azure-Ref" : "0cH5CYAAAAABqJzR3lElwSIuX6JvIV75hWVZSMzBFREdFMDQxNQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"+18335102092\",\"messageId\":\"Outgoing_202103040757046b2bcb68-8151-4ee6-8b27-5face2344ece_noam\",\"httpStatusCode\":202,\"successful\":true}]}", - "Date" : "Thu, 04 Mar 2021 07:57:04 GMT", + "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210305185441669bb6cf-9e6d-473b-b8c9-09debaf05ae2_noam\",\"httpStatusCode\":202,\"successful\":true}]}", + "Date" : "Fri, 05 Mar 2021 18:54:40 GMT", "Content-Type" : "application/json; charset=utf-8", "Request-Context" : "appId=" }, diff --git a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.send[1].json b/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.send[1].json deleted file mode 100644 index 45d4db76c6e1..000000000000 --- a/sdk/communication/azure-communication-sms/src/test/resources/session-records/SmsClientTests.send[1].json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "networkCallRecords" : [ { - "Method" : "POST", - "Uri" : "https://REDACTED.communication.azure.com/sms?api-version=2021-03-07", - "Headers" : { - "User-Agent" : "azsdk-java-azure-communication-sms/1.0.0-beta.4 (15.0.1; Windows 10; 10.0)", - "Content-Type" : "application/json" - }, - "Response" : { - "Transfer-Encoding" : "chunked", - "api-supported-versions" : "2020-07-20-preview1, 2020-08-20-preview, 2021-03-07", - "X-Processing-Time" : "696ms", - "MS-CV" : "HCepvzvwgEOxuO4cWV0qSg.0", - "retry-after" : "0", - "X-Azure-Ref" : "0VTc3YAAAAAAKfQllVmrETKJIPOuTBKUDREFMRURHRTEwMTUAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "StatusCode" : "202", - "Body" : "{\"value\":[{\"to\":\"REDACTED\",\"messageId\":\"Outgoing_20210225053621a9626003-88d0-43d1-b5ce-084cbb0cbd03_noam\",\"httpStatusCode\":202,\"errorMessage\":null,\"repeatabilityResult\":\"accepted\",\"successful\":true}]}", - "Date" : "Thu, 25 Feb 2021 05:36:21 GMT", - "Request-Context" : "appId=", - "Content-Type" : "application/json; charset=utf-8" - }, - "Exception" : null - } ], - "variables" : [ ] -} \ No newline at end of file