Skip to content

Commit 4a7307f

Browse files
committed
Fix the pipeline error
1 parent c4e665c commit 4a7307f

11 files changed

+12
-33
lines changed

src/Accounts/Accounts.Test/AccessTokenCmdletTest.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ public AccessTokenCmdletTests(ITestOutputHelper output)
5151
{
5252
TestExecutionHelpers.SetUpSessionAndProfile();
5353
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
54-
if (!AzureSession.Instance.TryGetComponent(AuthenticationTelemetry.Name, out AuthenticationTelemetry authenticationTelemetry))
55-
{
56-
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
57-
}
58-
54+
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
5955
var defaultContext = new AzureContext(
6056
new AzureSubscription()
6157
{

src/Accounts/Accounts.Test/AutosaveTests.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ void ResetState()
6767
PowerShellTokenCacheProvider tokenProvider = new InMemoryTokenCacheProvider();
6868
AzureSession.Instance.RegisterComponent(PowerShellTokenCacheProvider.PowerShellTokenCacheProviderKey, () => tokenProvider, true);
6969
AzureSession.Instance.RegisterComponent(AzKeyStore.Name, () => keyStore, true);
70-
if (!AzureSession.Instance.TryGetComponent(nameof(AuthenticationTelemetry), out AuthenticationTelemetry authenticationTelemetry))
71-
{
72-
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(nameof(AuthenticationTelemetry), () => new AuthenticationTelemetry());
73-
}
70+
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
7471
}
7572

7673
[Fact]

src/Accounts/Accounts.Test/AzureRMProfileTests.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,7 @@ public AzureRMProfileTests(ITestOutputHelper output)
175175
{
176176
TestExecutionHelpers.SetUpSessionAndProfile();
177177
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
178-
if (!AzureSession.Instance.TryGetComponent(nameof(AuthenticationTelemetry), out AuthenticationTelemetry authenticationTelemetry))
179-
{
180-
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(nameof(AuthenticationTelemetry), () => new AuthenticationTelemetry());
181-
}
178+
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
182179
}
183180

184181
[Fact]

src/Accounts/Accounts.Test/AzureSessionTestInitializer.cs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public static void Initialize()
3333
AzureSession.Instance.RegisterComponent(AuthenticatorBuilder.AuthenticatorBuilderKey, () => builder);
3434
AzureSession.Instance.RegisterComponent(nameof(AzureCredentialFactory), () => new AzureCredentialFactory());
3535
AzureSession.Instance.RegisterComponent(nameof(MsalAccessTokenAcquirerFactory), () => new MsalAccessTokenAcquirerFactory());
36+
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
3637
}
3738

3839
}

src/Accounts/Accounts.Test/ContextCmdletTests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public ContextCmdletTests(ITestOutputHelper output)
6666
string profilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), Resources.AzureDirectoryName);
6767
azKeyStore = new AzKeyStore(profilePath, AzureSession.Instance.KeyStoreFile, true, storageMocker.Object);
6868
AzureSession.Instance.RegisterComponent(AzKeyStore.Name, () => azKeyStore, true);
69+
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
6970
}
7071

7172
[Fact]

src/Accounts/Accounts.Test/ErrorResolutionTests.cs

+2-8
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ public TestHyakException(string message, CloudHttpRequestErrorInfo request, Clou
4646
public void DoesNotThrowWithNullError()
4747
{
4848
TestExecutionHelpers.SetUpSessionAndProfile();
49-
if (!AzureSession.Instance.TryGetComponent(nameof(AuthenticationTelemetry), out AuthenticationTelemetry authenticationTelemetry))
50-
{
51-
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(nameof(AuthenticationTelemetry), () => new AuthenticationTelemetry());
52-
}
49+
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
5350
var cmdlet = new ResolveError();
5451
var output = cmdlet.ExecuteCmdletInPipeline<AzureErrorRecord>("Resolve-Error");
5552
Assert.True(output == null || output.Count == 0);
@@ -175,10 +172,7 @@ public void HandlesNullValuesInArmExceptions()
175172
public void LastParameterFindsLastError()
176173
{
177174
TestExecutionHelpers.SetUpSessionAndProfile();
178-
if (!AzureSession.Instance.TryGetComponent(nameof(AuthenticationTelemetry), out AuthenticationTelemetry authenticationTelemetry))
179-
{
180-
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(nameof(AuthenticationTelemetry), () => new AuthenticationTelemetry());
181-
}
175+
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
182176
var mock = new MockCommandRuntime();
183177
var cmdlet = new ResolveError { CommandRuntime = mock };
184178
var message = "RuntimeErrorMessage";

src/Accounts/Accounts.Test/ProfileCmdletTests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public ProfileCmdletTests(ITestOutputHelper output)
5555
AzureSession.Instance.DataStore = dataStore;
5656
commandRuntimeMock = new MockCommandRuntime();
5757
AzureSession.Instance.AuthenticationFactory = new MockTokenAuthenticationFactory();
58+
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
5859
keyStore = SetMockedAzKeyStore();
5960
}
6061

src/Accounts/Accounts.Test/SilentReAuthByTenantCmdletTest.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,7 @@ private void InitializeSession()
325325
};
326326
cmdlet.profileClient = new RMProfileClient(profile);
327327

328-
if (!AzureSession.Instance.TryGetComponent(nameof(AuthenticationTelemetry), out AuthenticationTelemetry authenticationTelemetry))
329-
{
330-
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(nameof(AuthenticationTelemetry), () => new AuthenticationTelemetry());
331-
}
328+
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
332329
}
333330

334331
~SilentReAuthByTenantCmdletTest()

src/Accounts/Accounts.Test/TenantCmdletMockTests.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ public TenantCmdletMockTests(ITestOutputHelper output)
5454
{
5555
TestExecutionHelpers.SetUpSessionAndProfile();
5656
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
57-
if (!AzureSession.Instance.TryGetComponent(nameof(AuthenticationTelemetry), out AuthenticationTelemetry authenticationTelemetry))
58-
{
59-
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(nameof(AuthenticationTelemetry), () => new AuthenticationTelemetry());
60-
}
57+
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
6158
AzureSession.Instance.AuthenticationFactory = new MockTokenAuthenticationFactory();
6259
((MockTokenAuthenticationFactory)AzureSession.Instance.AuthenticationFactory).TokenProvider = (account, environment, tenant) =>
6360
new MockAccessToken

src/Accounts/Accounts/ChangeLog.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Fix token in auxiliary authentication header.
2223
* Collected authentication method for telemetry in end process of cmdlet.
2324

2425
## Version 4.1.0

src/Accounts/Authentication.Test/AuthenticatorsTest/SilentAuthenticatorTests.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ public override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext request
5454
public SilentAuthenticatorTests(ITestOutputHelper output)
5555
{
5656
AzureSessionInitializer.InitializeAzureSession();
57-
if (!AzureSession.Instance.TryGetComponent(AuthenticationTelemetry.Name, out AuthenticationTelemetry authenticationTelemetry))
58-
{
59-
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
60-
}
57+
AzureSession.Instance.RegisterComponent<AuthenticationTelemetry>(AuthenticationTelemetry.Name, () => new AuthenticationTelemetry());
6158
Output = output;
6259
}
6360

0 commit comments

Comments
 (0)