From 49d097071cf0c1d51617bf2fd2983312c8b120cf Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Thu, 9 May 2024 15:47:24 -0500 Subject: [PATCH 1/2] All credentials have parameterless ctor --- .../Azure.Identity/src/Credentials/ChainedTokenCredential.cs | 4 ++-- .../Azure.Identity/src/Credentials/DefaultAzureCredential.cs | 5 ++++- .../Azure.Identity/tests/AzurePipelinesCredentialTests.cs | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) 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) { From 2eea62bf33a3c7d451f47a97266792e2c24269ab Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Thu, 9 May 2024 16:00:30 -0500 Subject: [PATCH 2/2] export --- .../Azure.Identity/api/Azure.Identity.netstandard2.0.cs | 2 ++ 1 file changed, 2 insertions(+) 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; }