From 9637250fa81cb4b3374f3aeec1f6ce3aede5bfc6 Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Wed, 15 May 2024 09:24:46 -0500 Subject: [PATCH] All credentials have parameterless ctor (#43962) --- .../Azure.Identity/api/Azure.Identity.netstandard2.0.cs | 2 ++ .../Azure.Identity/src/Credentials/ChainedTokenCredential.cs | 4 ++-- .../Azure.Identity/src/Credentials/DefaultAzureCredential.cs | 5 ++++- .../Azure.Identity/tests/AzurePipelinesCredentialTests.cs | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sdk/identity/Azure.Identity/api/Azure.Identity.netstandard2.0.cs b/sdk/identity/Azure.Identity/api/Azure.Identity.netstandard2.0.cs index 6d04b1eb31d49..535a08859ddd9 100644 --- a/sdk/identity/Azure.Identity/api/Azure.Identity.netstandard2.0.cs +++ b/sdk/identity/Azure.Identity/api/Azure.Identity.netstandard2.0.cs @@ -115,6 +115,7 @@ public BrowserCustomizationOptions() { } } public partial class ChainedTokenCredential : Azure.Core.TokenCredential { + protected ChainedTokenCredential() { } public ChainedTokenCredential(params Azure.Core.TokenCredential[] sources) { } public override Azure.Core.AccessToken GetToken(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public override System.Threading.Tasks.ValueTask GetTokenAsync(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -180,6 +181,7 @@ public CredentialUnavailableException(string message, System.Exception innerExce } public partial class DefaultAzureCredential : Azure.Core.TokenCredential { + protected DefaultAzureCredential() { } public DefaultAzureCredential(Azure.Identity.DefaultAzureCredentialOptions options) { } public DefaultAzureCredential(bool includeInteractiveCredentials = false) { } public override Azure.Core.AccessToken GetToken(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } diff --git a/sdk/identity/Azure.Identity/src/Credentials/ChainedTokenCredential.cs b/sdk/identity/Azure.Identity/src/Credentials/ChainedTokenCredential.cs index 731fc68056c1d..9c9952ee56aa2 100644 --- a/sdk/identity/Azure.Identity/src/Credentials/ChainedTokenCredential.cs +++ b/sdk/identity/Azure.Identity/src/Credentials/ChainedTokenCredential.cs @@ -37,9 +37,9 @@ public class ChainedTokenCredential : TokenCredential private readonly TokenCredential[] _sources; /// - /// Constructor for instrumenting in tests + /// Protected constructor for mocking. /// - internal ChainedTokenCredential() + protected ChainedTokenCredential() { _sources = Array.Empty(); } diff --git a/sdk/identity/Azure.Identity/src/Credentials/DefaultAzureCredential.cs b/sdk/identity/Azure.Identity/src/Credentials/DefaultAzureCredential.cs index 16b1c6bc547b5..cfea7989d1b8a 100644 --- a/sdk/identity/Azure.Identity/src/Credentials/DefaultAzureCredential.cs +++ b/sdk/identity/Azure.Identity/src/Credentials/DefaultAzureCredential.cs @@ -64,7 +64,10 @@ public class DefaultAzureCredential : TokenCredential internal TokenCredential[] _sources; - internal DefaultAzureCredential() : this(false) { } + /// + /// Protected constructor for mocking. + /// + protected DefaultAzureCredential() : this(false) { } /// /// Creates an instance of the DefaultAzureCredential class. diff --git a/sdk/identity/Azure.Identity/tests/AzurePipelinesCredentialTests.cs b/sdk/identity/Azure.Identity/tests/AzurePipelinesCredentialTests.cs index d56ff1de76abd..2c38e3daa795d 100644 --- a/sdk/identity/Azure.Identity/tests/AzurePipelinesCredentialTests.cs +++ b/sdk/identity/Azure.Identity/tests/AzurePipelinesCredentialTests.cs @@ -40,7 +40,8 @@ public override TokenCredential GetTokenCredential(CommonCredentialTestConfig co PlanId = "myplan", JobId = "myjob", TeamProjectId = "myteamproject", - SystemAccessToken = "mytoken" + SystemAccessToken = "mytoken", + HubName = "myhub", }; if (config.Transport != null) {