-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding CIAM E2E tests and improvements to build infrastructure (#2753) (
#2769) * Adding web app and web app call web api CIAM non CUD tests * Adding CIAM deamon test app for non CUD domain * Integrating lab client apps Refactoring * Refactoring * Setting ui test to headless * Update WebAppCallsApiCallsGraphLocally.cs * Adding CIAM CUD integration tests (#2737) * Adding CIAM CUD tests * Updating comments * Updating test --------- * Enabling test runs with VSTest * Test updates * test * Testing * Disabling test * Test * Updating the CIAM tests to use the lab API (manual testing) * Revert "Test" This reverts commit c3f3d3a. * Revert "Disabling test" This reverts commit 5f2a384. * Using hosted agents * Always publish traces * Revert "Using hosted agents" This reverts commit 7484c58. * Updating process error * Publish screenshots * Updating tests * Adding additional statements * Updating screenshot staging * Fix typo * Updating endpoint to use Http * Reconfiguring ports * hiding UI * Enabling web app tests * Resolving test issue * Fixing run time and hiding ui * Adding asp auth * Enabling test * Refactoring test YAML * Disabling restore * Fixing build task * Test * Test * Fixing parameters * Unit tests * Install test platform * Changing test runner * Updating test directories * Updating test run * Fix typo * Updating test run * Updating check * Refactoring process restart logic * Clean up YAML * Revert "Adding asp auth" This reverts commit b7622cd. * Refactoring * Enabling code coverage settings * Fix indentation --------- Co-authored-by: Bogdan Gavril <[email protected]> Co-authored-by: trwalke <[email protected]> Co-authored-by: Jean-Marc Prieur <[email protected]>
- Loading branch information
1 parent
3083a3c
commit 54afc21
Showing
16 changed files
with
468 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
using Xunit; | ||
using Xunit.Abstractions; | ||
using System.Threading; | ||
using System.Net; | ||
|
||
namespace WebAppUiTests; | ||
|
||
|
@@ -24,6 +25,7 @@ public class TestingWebAppLocally : IClassFixture<InstallPlaywrightBrowserFixtur | |
{ | ||
private const string UrlString = "https://localhost:5001/MicrosoftIdentity/Account/signin"; | ||
private const string TraceFileClassName = "TestingWebAppLocally"; | ||
private const string TraceFileClassNameCiam = "TestingWebAppLocallyCiam"; | ||
private readonly ITestOutputHelper _output; | ||
private readonly string _devAppExecutable = Path.DirectorySeparatorChar.ToString() + "WebAppCallsMicrosoftGraph.exe"; | ||
private readonly string _devAppPath = "DevApps" + Path.DirectorySeparatorChar.ToString() + "WebAppCallsMicrosoftGraph"; | ||
|
@@ -38,20 +40,48 @@ public TestingWebAppLocally(ITestOutputHelper output) | |
[Fact] | ||
[SupportedOSPlatform("windows")] | ||
public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPassword() | ||
{ | ||
LabResponse labResponse = await LabUserHelper.GetDefaultUserAsync().ConfigureAwait(false); | ||
|
||
var clientEnvVars = new Dictionary<string, string>(); | ||
|
||
await ExecuteWebAppCallsGraphFlow(labResponse.User.Upn, labResponse.User.GetOrFetchPassword(), clientEnvVars, TraceFileClassName).ConfigureAwait(false); | ||
} | ||
|
||
[Theory] | ||
[InlineData("https://MSIDLABCIAM6.ciamlogin.com")] // CIAM authority | ||
[InlineData("https://login.msidlabsciam.com/fe362aec-5d43-45d1-b730-9755e60dc3b9/v2.0/")] // CIAM CUD Authority | ||
[SupportedOSPlatform("windows")] | ||
public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailWithCiamPassword(string authority) | ||
{ | ||
var clientEnvVars = new Dictionary<string, string> | ||
{ | ||
{"AzureAd__ClientId", "b244c86f-ed88-45bf-abda-6b37aa482c79"}, | ||
{"AzureAd__Authority", authority}, | ||
{"AzureAd__TenantId", ""}, | ||
{"AzureAd__Domain", ""}, | ||
{"AzureAd__Instance", "" } | ||
}; | ||
|
||
await ExecuteWebAppCallsGraphFlow("[email protected]", LabUserHelper.FetchUserPassword("msidlabciam6"), clientEnvVars, TraceFileClassNameCiam).ConfigureAwait(false); | ||
} | ||
|
||
private async Task ExecuteWebAppCallsGraphFlow(string upn, string credential, Dictionary<string, string>? clientEnvVars, string traceFileClassName) | ||
{ | ||
// Arrange | ||
Process? process = null; | ||
const string TraceFileName = TraceFileClassName + "_ValidEmailPassword"; | ||
string TraceFileName = traceFileClassName + "_ValidEmailPassword"; | ||
using IPlaywright playwright = await Playwright.CreateAsync(); | ||
IBrowser browser = await playwright.Chromium.LaunchAsync(new() { Headless = true }); | ||
IBrowserContext context = await browser.NewContextAsync(new BrowserNewContextOptions { IgnoreHTTPSErrors = true }); | ||
await context.Tracing.StartAsync(new() { Screenshots = true, Snapshots = true, Sources = true }); | ||
|
||
try | ||
{ | ||
process = UiTestHelpers.StartProcessLocally(_uiTestAssemblyLocation, _devAppPath, _devAppExecutable); | ||
process = UiTestHelpers.StartProcessLocally(_uiTestAssemblyLocation, _devAppPath, _devAppExecutable, clientEnvVars); | ||
|
||
if (!UiTestHelpers.ProcessIsAlive(process)) { Assert.Fail(TC.WebAppCrashedString); } | ||
if (!UiTestHelpers.ProcessIsAlive(process)) | ||
{ Assert.Fail(TC.WebAppCrashedString); } | ||
|
||
IPage page = await browser.NewPageAsync(); | ||
|
||
|
@@ -68,16 +98,15 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPassword() | |
{ | ||
await Task.Delay(1000); | ||
InitialConnectionRetryCount--; | ||
if (InitialConnectionRetryCount == 0) { throw ex; } | ||
if (InitialConnectionRetryCount == 0) | ||
{ throw ex; } | ||
} | ||
} | ||
|
||
LabResponse labResponse = await LabUserHelper.GetDefaultUserAsync().ConfigureAwait(false); | ||
|
||
// Act | ||
Trace.WriteLine("Starting Playwright automation: web app sign-in & call Graph."); | ||
string email = labResponse.User.Upn; | ||
await UiTestHelpers.FirstLogin_MicrosoftIdFlow_ValidEmailPassword(page, email, labResponse.User.GetOrFetchPassword(), _output); | ||
string email = upn; | ||
await UiTestHelpers.FirstLogin_MicrosoftIdFlow_ValidEmailPassword(page, email, credential, _output); | ||
|
||
// Assert | ||
await Assertions.Expect(page.GetByText("Welcome")).ToBeVisibleAsync(_assertVisibleOptions); | ||
|
@@ -91,7 +120,8 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPassword() | |
{ | ||
// Cleanup the web app process and any child processes | ||
Queue<Process> processes = new(); | ||
if (process != null) { processes.Enqueue(process); } | ||
if (process != null) | ||
{ processes.Enqueue(process); } | ||
UiTestHelpers.KillProcessTrees(processes); | ||
Check warning on line 125 in tests/E2E Tests/WebAppUiTests/TestingWebAppLocally.cs GitHub Actions / Analyse
Check warning on line 125 in tests/E2E Tests/WebAppUiTests/TestingWebAppLocally.cs GitHub Actions / IdWeb GitHub Action Test
|
||
|
||
// Cleanup Playwright | ||
|
Oops, something went wrong.