-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send user agent header as "acs-test" (#39937)
* Always send x-ms-useragent header from tests * Test fix * Update assets file with test recordings stamp * Updating test recordings * Remove default value of user-agent header and use only value from environment variable if it's set
- Loading branch information
1 parent
36ab08b
commit 6b5f6d1
Showing
5 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...tion/Azure.Communication.PhoneNumbers/src/SipRouting/SipRoutingClientOptionsExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Azure.Communication.Pipeline; | ||
using Azure.Core.Pipeline; | ||
using Azure.Core; | ||
|
||
namespace Azure.Communication.PhoneNumbers.SipRouting | ||
{ | ||
internal static class SipRoutingClientOptionsExtensions | ||
{ | ||
public static HttpPipeline BuildSipRoutingHttpPipeline(this ClientOptions options, ConnectionString connectionString) | ||
{ | ||
var pipelineOptions = new HttpPipelineOptions(options) | ||
{ | ||
RequestFailedDetailsParser = new CommunicationRequestFailedDetailsParser(), | ||
PerRetryPolicies = | ||
{ | ||
new HMACAuthenticationPolicy(new AzureKeyCredential(connectionString.GetRequired("accesskey"))), | ||
new MSUserAgentPolicy() | ||
} | ||
}; | ||
HttpPipelineTransportOptions httpPipelineTransportOptions = new() { IsClientRedirectEnabled = true }; | ||
return HttpPipelineBuilder.Build(pipelineOptions, httpPipelineTransportOptions); | ||
} | ||
|
||
public static HttpPipeline BuildSipRoutingHttpPipeline(this ClientOptions options, AzureKeyCredential keyCredential) | ||
{ | ||
var pipelineOptions = new HttpPipelineOptions(options) | ||
{ | ||
RequestFailedDetailsParser = new CommunicationRequestFailedDetailsParser(), | ||
PerRetryPolicies = | ||
{ | ||
new HMACAuthenticationPolicy(keyCredential), | ||
new MSUserAgentPolicy() | ||
} | ||
}; | ||
HttpPipelineTransportOptions httpPipelineTransportOptions = new() { IsClientRedirectEnabled = true }; | ||
return HttpPipelineBuilder.Build(pipelineOptions, httpPipelineTransportOptions); | ||
} | ||
|
||
public static HttpPipeline BuildSipRoutingHttpPipeline(this ClientOptions options, TokenCredential tokenCredential) | ||
{ | ||
var pipelineOptions = new HttpPipelineOptions(options) | ||
{ | ||
RequestFailedDetailsParser = new CommunicationRequestFailedDetailsParser(), | ||
PerRetryPolicies = | ||
{ | ||
new BearerTokenAuthenticationPolicy(tokenCredential, "https://communication.azure.com//.default"), | ||
new MSUserAgentPolicy() | ||
} | ||
}; | ||
return HttpPipelineBuilder.Build(pipelineOptions); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters