Skip to content

Commit

Permalink
Merge branch 'master' into bogavril/3000
Browse files Browse the repository at this point in the history
  • Loading branch information
bgavrilMS authored Sep 19, 2024
2 parents 908827f + 96e9735 commit 7f5d651
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 83 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,5 @@ MigrationBackup/

# Playwright e2e testing trace files
/tests/E2E Tests/PlaywrightTraces
/tests/IntegrationTests/PlaywrightTraces
/tests/IntegrationTests/PlaywrightTraces
/.SharedData
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

<PropertyGroup Label="Common dependency versions">
<MicrosoftIdentityModelVersion Condition="'$(MicrosoftIdentityModelVersion)' == ''">8.0.2</MicrosoftIdentityModelVersion>
<MicrosoftIdentityClientVersion Condition="'$(MicrosoftIdentityClientVersion)' == ''">4.61.3</MicrosoftIdentityClientVersion>
<MicrosoftIdentityClientVersion Condition="'$(MicrosoftIdentityClientVersion)' == ''">4.64.1</MicrosoftIdentityClientVersion>
<FxCopAnalyzersVersion>3.3.0</FxCopAnalyzersVersion>
<SystemTextEncodingsWebVersion>4.7.2</SystemTextEncodingsWebVersion>
<AzureSecurityKeyVaultSecretsVersion>4.6.0</AzureSecurityKeyVaultSecretsVersion>
Expand Down
4 changes: 2 additions & 2 deletions tests/DevApps/ciam/myWebApp/myWebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup Condition="'$(UseWIP)' == 'false' ">
<PackageReference Include="Microsoft.Identity.Web" Version="2.17.1" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.17.1" />
<PackageReference Include="Microsoft.Identity.Web" Version="3.1.0" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="3.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(UseWIP)' == 'true' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup Condition="'$(UseWip)' != 'true'">
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="2.15.3" />
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="3.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(UseWip)' == 'true'">
Expand Down
33 changes: 14 additions & 19 deletions tests/Microsoft.Identity.Web.Test/CacheExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,42 +33,40 @@ public void InMemoryCacheExtensionsTests()
public async Task CacheExtensions_CcaAlreadyExists_TestsAsync()
{
AuthenticationResult result;
TestTelemetryClient testTelemetryClient = new TestTelemetryClient(TestConstants.ClientId);
// new InMemory serializer and new cca
result = await CreateAppAndGetTokenAsync(CacheType.InMemory, testTelemetryClient).ConfigureAwait(false);
result = await CreateAppAndGetTokenAsync(CacheType.InMemory).ConfigureAwait(false);
Assert.Equal(TokenSource.IdentityProvider, result.AuthenticationResultMetadata.TokenSource);
AssertCacheTelemetry(testTelemetryClient, CacheLevel.None);
AssertCacheTelemetry(result, CacheLevel.None);

result = await CreateAppAndGetTokenAsync(CacheType.InMemory, testTelemetryClient, addTokenMock: false).ConfigureAwait(false);
result = await CreateAppAndGetTokenAsync(CacheType.InMemory, addTokenMock: false).ConfigureAwait(false);
Assert.Equal(TokenSource.Cache, result.AuthenticationResultMetadata.TokenSource);
AssertCacheTelemetry(testTelemetryClient, CacheLevel.L1Cache);
AssertCacheTelemetry(result, CacheLevel.L1Cache);

//Resetting token caches due to potential collision with other tests
TokenCacheExtensions.s_serviceProviderFromAction.Clear();

// new DistributedInMemory and same cca
result = await CreateAppAndGetTokenAsync(CacheType.DistributedInMemory, testTelemetryClient).ConfigureAwait(false);
result = await CreateAppAndGetTokenAsync(CacheType.DistributedInMemory).ConfigureAwait(false);
Assert.Equal(TokenSource.IdentityProvider, result.AuthenticationResultMetadata.TokenSource);
AssertCacheTelemetry(testTelemetryClient, CacheLevel.None);
AssertCacheTelemetry(result, CacheLevel.None);

result = await CreateAppAndGetTokenAsync(CacheType.DistributedInMemory, testTelemetryClient, addTokenMock: false).ConfigureAwait(false);
result = await CreateAppAndGetTokenAsync(CacheType.DistributedInMemory, addTokenMock: false).ConfigureAwait(false);
Assert.Equal(TokenSource.Cache, result.AuthenticationResultMetadata.TokenSource);
AssertCacheTelemetry(testTelemetryClient, CacheLevel.L1Cache);
AssertCacheTelemetry(result, CacheLevel.L1Cache);
}

[Fact]
public async Task CacheExtensions_CcaAlreadyExistsL2_TestsAsync()
{
AuthenticationResult result;
TestTelemetryClient testTelemetryClient = new TestTelemetryClient(TestConstants.ClientId);
// new DistributedInMemory serializer with L1 cache disabled
result = await CreateAppAndGetTokenAsync(CacheType.DistributedInMemory, testTelemetryClient, disableL1Cache: true).ConfigureAwait(false);
result = await CreateAppAndGetTokenAsync(CacheType.DistributedInMemory, disableL1Cache: true).ConfigureAwait(false);
Assert.Equal(TokenSource.IdentityProvider, result.AuthenticationResultMetadata.TokenSource);
AssertCacheTelemetry(testTelemetryClient, CacheLevel.None);
AssertCacheTelemetry(result, CacheLevel.None);

result = await CreateAppAndGetTokenAsync(CacheType.DistributedInMemory, testTelemetryClient, addTokenMock: false, disableL1Cache: true).ConfigureAwait(false);
result = await CreateAppAndGetTokenAsync(CacheType.DistributedInMemory, addTokenMock: false, disableL1Cache: true).ConfigureAwait(false);
Assert.Equal(TokenSource.Cache, result.AuthenticationResultMetadata.TokenSource);
AssertCacheTelemetry(testTelemetryClient, CacheLevel.L2Cache);
AssertCacheTelemetry(result, CacheLevel.L2Cache);
}

[Fact]
Expand Down Expand Up @@ -200,7 +198,6 @@ private enum CacheType

private static async Task<AuthenticationResult> CreateAppAndGetTokenAsync(
CacheType cacheType,
ITelemetryClient telemetryClient,
bool addTokenMock = true,
bool disableL1Cache = false)
{
Expand All @@ -221,7 +218,6 @@ private static async Task<AuthenticationResult> CreateAppAndGetTokenAsync(
.WithAuthority(TestConstants.AuthorityCommonTenant)
.WithHttpClientFactory(mockHttp)
.WithClientSecret(TestConstants.ClientSecret)
.WithTelemetryClient(telemetryClient)
.Build();

switch (cacheType)
Expand Down Expand Up @@ -255,10 +251,9 @@ private static async Task<AuthenticationResult> CreateAppAndGetTokenAsync(
return result;
}

private void AssertCacheTelemetry(TestTelemetryClient testTelemetryClient, CacheLevel cacheLevel)
private void AssertCacheTelemetry(AuthenticationResult result, CacheLevel expectedCacheLevel)
{
TelemetryEventDetails eventDetails = testTelemetryClient.TestTelemetryEventDetails;
Assert.Equal(Convert.ToInt64(cacheLevel, new CultureInfo("en-US")), eventDetails.Properties["CacheLevel"]);
Assert.Equal(result.AuthenticationResultMetadata.CacheLevel, expectedCacheLevel);
}

private IConfidentialClientApplication CreateCca() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
<Compile Include="Certificates\DefaultCertificateLoaderTests.cs" />
<Compile Include="CacheExtensionsTests.cs" />
<Compile Include="CacheEncryptionTests.cs" />
<Compile Include="TestTelemetryClient.cs" />
<Compile Include="TestDistributedCache.cs" />
</ItemGroup>

Expand Down
58 changes: 0 additions & 58 deletions tests/Microsoft.Identity.Web.Test/TestTelemetryClient.cs

This file was deleted.

0 comments on commit 7f5d651

Please sign in to comment.