Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>

<ItemGroup>
Expand All @@ -27,6 +25,7 @@
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web.GraphServiceClient\Microsoft.Identity.Web.GraphServiceClient.csproj" />
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web.OidcFIC\Microsoft.Identity.Web.OidcFIC.csproj" />
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web.TokenAcquisition\Microsoft.Identity.Web.TokenAcquisition.csproj" />
<ProjectReference Include="..\..\Microsoft.Identity.Web.Test.Common\Microsoft.Identity.Web.Test.Common.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions tests/E2E Tests/AgentApplications/GetFicAsyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Identity.Abstractions;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.Test.Common;

namespace AgentApplicationsTests
{
[Collection(nameof(TokenAcquirerFactorySingletonProtection))]
public class GetFicAsyncTests
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace WebAppUiTests
#if !FROM_GITHUB_ACTION
{
// since these tests change environment variables we'd prefer it not run at the same time as other tests
[CollectionDefinition(nameof(UiTestNoParallelization), DisableParallelization = true)]
[Collection(nameof(UiTestNoParallelization))]
public class B2CWebAppCallsWebApiLocally : IClassFixture<InstallPlaywrightBrowserFixture>
{
private const string KeyvaultEmailName = "IdWeb-B2C-user";
Expand Down Expand Up @@ -69,7 +69,7 @@ public async Task Susi_B2C_LocalAccount_TodoAppFunctionsCorrectlyAsync()
IBrowserContext context = await browser.NewContextAsync(new BrowserNewContextOptions { IgnoreHTTPSErrors = true });
await context.Tracing.StartAsync(new() { Screenshots = true, Snapshots = true, Sources = true });

Process? serviceProcess= null;
Process? serviceProcess = null;
Process? clientProcess = null;

try
Expand Down
2 changes: 1 addition & 1 deletion tests/E2E Tests/WebAppUiTests/TestingWebAppLocally.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace WebAppUiTests;
#if !FROM_GITHUB_ACTION && !AZURE_DEVOPS_BUILD

// Since this test affects Kestrel environment variables it can cause a race condition when run in parallel with other UI tests.
[CollectionDefinition(nameof(UiTestNoParallelization), DisableParallelization = true)]
[Collection(nameof(UiTestNoParallelization))]
public class TestingWebAppLocally : IClassFixture<InstallPlaywrightBrowserFixture>
{
private const string UrlString = "https://localhost:5001/MicrosoftIdentity/Account/signin";
Expand Down
4 changes: 2 additions & 2 deletions tests/E2E Tests/WebAppUiTests/UiTestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ internal static bool StartAndVerifyProcessesAreRunning(List<ProcessStartOptions>
{
if (!UiTestHelpers.ProcessesAreAlive(processes.Values.ToList()))
{
RestartProcesses(processes, processDataEntries , output);
RestartProcesses(processes, processDataEntries, output);
}
}

Expand All @@ -384,7 +384,7 @@ static void RestartProcesses(Dictionary<string, Process> processes, List<Process
processDataEntry.TestAssemblyLocation,
processDataEntry.AppLocation,
processDataEntry.ExecutableName,
output,
output,
processDataEntry.EnvironmentVariables);
Thread.Sleep(5000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace WebAppUiTests
#if !FROM_GITHUB_ACTION
{
// since these tests change environment variables we'd prefer it not run at the same time as other tests
[CollectionDefinition(nameof(UiTestNoParallelization), DisableParallelization = true)]
[Collection(nameof(UiTestNoParallelization))]
public class WebAppCallsApiCallsGraphLocally : IClassFixture<InstallPlaywrightBrowserFixture>
{
private const uint GrpcPort = 5001;
Expand Down Expand Up @@ -116,7 +116,7 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds
_output.WriteLine("Starting web app sign-in flow using Todo List button after sign out.");
await page.GetByRole(AriaRole.Link, new() { Name = "TodoList" }).ClickAsync();
await UiTestHelpers.SuccessiveLogin_MicrosoftIdFlow_ValidEmailPasswordAsync(page, email, labResponse.User.GetOrFetchPassword(), _output);
var todoLink = page.GetByRole(AriaRole.Link, new() { Name = "Create New" });
var todoLink = page.GetByRole(AriaRole.Link, new() { Name = "Create New" });
await Assertions.Expect(todoLink).ToBeVisibleAsync(_assertVisibleOptions);
_output.WriteLine("Web app sign-in flow successful using Todo List button after sign out.");

Expand Down Expand Up @@ -226,7 +226,7 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds
foreach (var process in processes)
{
#pragma warning disable CA1305 // Specify IFormatProvider
runningProcesses.AppendLine($"Is {process.Key} running: {UiTestHelpers.ProcessIsAlive(process.Value )}");
runningProcesses.AppendLine($"Is {process.Key} running: {UiTestHelpers.ProcessIsAlive(process.Value)}");
#pragma warning restore CA1305 // Specify IFormatProvider
}
Assert.Fail(TC.WebAppCrashedString + " " + runningProcesses.ToString());
Expand Down
5 changes: 3 additions & 2 deletions tests/E2E Tests/WebAppUiTests/WebAppIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
using Xunit;

namespace WebAppUiTests
{
#if !FROM_GITHUB_ACTION
{

[Collection(nameof(UiTestNoParallelization))]
public class WebAppIntegrationTests
{
const string UrlString = "https://webapptestmsidweb.azurewebsites.net/MicrosoftIdentity/Account/signin";
Expand Down Expand Up @@ -47,6 +48,6 @@ public async Task ChallengeUser_MicrosoftIdentityFlow_RemoteApp_ValidEmailPasswo
}

}
#endif //FROM_GITHUB_ACTION
}
}
#endif //FROM_GITHUB_ACTION
7 changes: 4 additions & 3 deletions tests/Microsoft.Identity.Web.Test/FmiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Identity.Abstractions;
using Microsoft.Identity.Client;
using Microsoft.Identity.Web.Test.Common;
using Microsoft.Identity.Web.Test.Common.Mocks;
using Microsoft.Identity.Web.TestOnly;
using Xunit;

namespace Microsoft.Identity.Web.Test
{
[Collection("Run tests - serial")]
[Collection(nameof(TokenAcquirerFactorySingletonProtection))]
public class FmiTests
{
[Fact]
Expand Down Expand Up @@ -52,12 +53,12 @@ private TokenAcquirerFactory InitTokenAcquirerFactoryForFmi()
options.ClientId = "urn:microsoft:identity:fmi";
options.ExtraQueryParameters = new Dictionary<string, string>
{
{ "dc", "ESTS-PUB-SCUS-LZ1-FD000-TEST1" }
{ "dc", "ESTS-PUB-SCUS-LZ1-FD000-TEST1" }
};
options.ClientCredentials = [ new CredentialDescription() {
SourceType = CredentialSource.ClientSecret,
ClientSecret = "someSecret"
}];
}];
});

// Add MockedHttpClientFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.Identity.Web.TestOnly;
using Xunit;
using Microsoft.Identity.Web.Test;
using Microsoft.Identity.Web.Test.Common;
using NSubstitute;
using System.Collections.Generic;
using System.Net.Http;
Expand All @@ -20,7 +21,7 @@

namespace Microsoft.Identity.Web.Tests.Certificateless
{
[Collection("Run tests - serial")]
[Collection(nameof(TokenAcquirerFactorySingletonProtection))]
public class ManagedIdentityTests
{
private const string Scope = "https://management.azure.com/.default";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
using Microsoft.Extensions.Options;
using Microsoft.Identity.Abstractions;
using Microsoft.Identity.Client;
using Microsoft.Identity.Web.Test.Common;
using Xunit;

namespace Microsoft.Identity.Web.Test
{
[Collection(nameof(TokenAcquirerFactorySingletonProtection))]
public class ServiceCollectionExtensionsTests
{
[Fact]
Expand Down
23 changes: 0 additions & 23 deletions tests/Microsoft.Identity.Web.Test/TokenAcquirerCollection.cs

This file was deleted.

22 changes: 12 additions & 10 deletions tests/Microsoft.Identity.Web.Test/TokenAcquisitionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Identity.Abstractions;
using Microsoft.Identity.Client;
using Microsoft.Identity.Web.Test.Common;
using Microsoft.Identity.Web.Test.Common.Mocks;
using Microsoft.Identity.Web.TestOnly;
using Xunit;


namespace Microsoft.Identity.Web.Test
{
[Collection(nameof(TokenAcquirerFactorySingletonProtection))]
public class TokenAcquisitionTests
{
private const string Tenant = "tenant";
Expand Down Expand Up @@ -61,10 +63,10 @@ public void TestManagedIdentityWithCommonTenantShouldNotCallResolveTenant()
{
// This test verifies that ResolveTenant is not called when using managed identity,
// which prevents the IDW10405 error when tenant is "common" or "organizations"

// The fix ensures that when ManagedIdentity is specified in tokenAcquisitionOptions,
// ResolveTenant is skipped entirely, so this scenario should not throw

// Create test options with managed identity
var tokenOptions = new TokenAcquisitionOptions
{
Expand All @@ -73,15 +75,15 @@ public void TestManagedIdentityWithCommonTenantShouldNotCallResolveTenant()
UserAssignedClientId = "test-client-id"
}
};
var mergedOptions = new MergedOptions
{

var mergedOptions = new MergedOptions
{
TenantId = Constants.Common // This would normally cause ResolveTenant to throw
};

// This should not throw because ResolveTenant should not be called for managed identity scenarios
// The actual method call would be tested in integration tests, but we can test the logic here

// Verify that ResolveTenant still throws for non-managed identity scenarios
var exception = Assert.Throws<ArgumentException>(() => TokenAcquisition.ResolveTenant(null, mergedOptions));
Assert.StartsWith(IDWebErrorMessage.ClientCredentialTenantShouldBeTenanted, exception.Message, StringComparison.Ordinal);
Expand Down Expand Up @@ -134,9 +136,9 @@ private TokenAcquirerFactory InitTokenAcquirerFactory()
options.TenantId = "f645ad92-e38d-4d1a-b510-d1b09a74a8ca";
options.ClientId = "idu773ld-e38d-jud3-45lk-d1b09a74a8ca";
options.ExtraQueryParameters = new Dictionary<string, string>
{
{ "dc", "ESTS-PUB-SCUS-LZ1-FD000-TEST1" }
};
{
{ "dc", "ESTS-PUB-SCUS-LZ1-FD000-TEST1" }
};
options.ClientCredentials = [ new CredentialDescription() {
SourceType = CredentialSource.ClientSecret,
ClientSecret = "someSecret"
Expand Down
Loading