Skip to content

Commit

Permalink
Address review: Makes UniverseDomainKey internal
Browse files Browse the repository at this point in the history
  • Loading branch information
amanda-tarafa committed Feb 21, 2024
1 parent 5c5fb32 commit ab34224
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ public async Task UniverseDomain_RequestAndCredentialSame()
string universeDomain = "custom.domain";

HttpRequestMessage request = new HttpRequestMessage();
request.SetOption(ConfigurableMessageHandler.UniverseDomainKey, universeDomain);
request.SetOption(GoogleAuthConsts.UniverseDomainKey, universeDomain);

IHttpExecuteInterceptor credential = GoogleCredential.FromAccessToken("fake_token")
.CreateWithUniverseDomain(universeDomain);
Expand Down Expand Up @@ -762,7 +762,7 @@ public async Task UniverseDomain_NoneInRequestCustomInCredential()
public async Task UniverseDomain_DefaultInRequestNoneInCredential()
{
HttpRequestMessage request = new HttpRequestMessage();
request.SetOption(ConfigurableMessageHandler.UniverseDomainKey, "googleapis.com");
request.SetOption(GoogleAuthConsts.UniverseDomainKey, "googleapis.com");

IHttpExecuteInterceptor credential = GoogleCredential.FromAccessToken("fake_token");

Expand All @@ -776,7 +776,7 @@ public async Task UniverseDomain_DefaultInRequestNoneInCredential()
public async Task UniverseDomain_CustomInRequestNoneInCredential()
{
HttpRequestMessage request = new HttpRequestMessage();
request.SetOption(ConfigurableMessageHandler.UniverseDomainKey, "custom.domain");
request.SetOption(GoogleAuthConsts.UniverseDomainKey, "custom.domain");

IHttpExecuteInterceptor credential = GoogleCredential.FromAccessToken("fake_token");

Expand All @@ -790,7 +790,7 @@ public async Task UniverseDomain_CustomInRequestNoneInCredential()
public async Task UniverseDomain_DifferentCustomInRequestAndCredential()
{
HttpRequestMessage request = new HttpRequestMessage();
request.SetOption(ConfigurableMessageHandler.UniverseDomainKey, "custom1.domain");
request.SetOption(GoogleAuthConsts.UniverseDomainKey, "custom1.domain");

IHttpExecuteInterceptor credential = GoogleCredential.FromAccessToken("fake_token")
.CreateWithUniverseDomain("custom2.domain");
Expand Down
6 changes: 6 additions & 0 deletions Src/Support/Google.Apis.Auth/OAuth2/GoogleAuthConsts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
*/

using System;
using System.Net.Http;

namespace Google.Apis.Auth.OAuth2
{
Expand Down Expand Up @@ -105,6 +106,11 @@ public static class GoogleAuthConsts
/// </summary>
internal const string DefaultUniverseDomain = "googleapis.com";

/// <summary>
/// Key for a universe domain in a <see cref="HttpRequestMessage"/> options.
/// </summary>
internal const string UniverseDomainKey = "__UniverseDomainKey";

/// <summary>
/// The non empty value set on <see cref="QuotaProjectEnvironmentVariable"/>, if any;
/// null otherwise.
Expand Down
2 changes: 1 addition & 1 deletion Src/Support/Google.Apis.Auth/OAuth2/GoogleCredential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public static GoogleCredential FromServiceAccountCredential(ServiceAccountCreden
// Proxy IHttpExecuteInterceptor's only method.
async Task IHttpExecuteInterceptor.InterceptAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request?.TryGetOption(ConfigurableMessageHandler.UniverseDomainKey, out string targetUniverseDomain) == true)
if (request?.TryGetOption(GoogleAuthConsts.UniverseDomainKey, out string targetUniverseDomain) == true)
{
string credentialUniverseDomain = await credential.GetUniverseDomainAsync(cancellationToken).ConfigureAwait(false);
if (targetUniverseDomain != credentialUniverseDomain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class ConfigurableMessageHandler : DelegatingHandler
/// <summary>
/// Key for a universe domain in a <see cref="HttpRequestMessage"/> options.
/// </summary>
public const string UniverseDomainKey = "__UniverseDomainKey";
internal const string UniverseDomainKey = "__UniverseDomainKey";

/// <summary>
/// Key for request specific max retries.
Expand Down

0 comments on commit ab34224

Please sign in to comment.