Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create test for hybrid flow sample #800

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
minor cleanup
JoshLozensky committed Oct 31, 2024
commit c0de050b50622889dba324e178e156352c47a1ab
11 changes: 8 additions & 3 deletions UiTests/HybridFlowUiTest/HybridFlowTest.cs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ public class HybridFlowTest : IClassFixture<InstallPlaywrightBrowserFixture>
private const string TraceFileClassName = "OpenIDConnect-HybridFlow";
private const uint NumProcessRetries = 3;
private const string SampleSlnFileName = "2-5-HybridFlow.sln";
private const string SampleExeFileName = "\\2-5-HybridFlow.exe";
private const string SampleExeFileName = "2-5-HybridFlow.exe";
private readonly LocatorAssertionsToBeVisibleOptions _assertVisibleOptions = new() { Timeout = 25000 };
private readonly string _sampleAppPath = "2-WebApp-graph-user" + Path.DirectorySeparatorChar + "2-5-HybridFlow" + Path.DirectorySeparatorChar.ToString();
private readonly string _testAppsettingsPath = "UiTests" + Path.DirectorySeparatorChar + "HybridFlowUiTest" + Path.DirectorySeparatorChar.ToString() + TC.AppSetttingsDotJson;
@@ -52,7 +52,7 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds
// Arrange Playwright setup, to see the browser UI set Headless = false.
const string TraceFileName = TraceFileClassName + "_LoginLogout";
using IPlaywright playwright = await Playwright.CreateAsync();
IBrowser browser = await playwright.Chromium.LaunchAsync(new() { Headless = false });
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 });
IPage page = await context.NewPageAsync();
@@ -65,7 +65,12 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds

// Start the web app and api processes.
// The delay before starting client prevents transient devbox issue where the client fails to load the first time after rebuilding
var clientProcessOptions = new ProcessStartOptions(_testAssemblyLocation, _sampleAppPath, SampleExeFileName, clientEnvVars);
var clientProcessOptions = new ProcessStartOptions(
_testAssemblyLocation,
_sampleAppPath,
Path.DirectorySeparatorChar.ToString() + SampleExeFileName,
clientEnvVars
);

bool areProcessesRunning = UiTestHelpers.StartAndVerifyProcessesAreRunning([clientProcessOptions], out processes, NumProcessRetries);


Unchanged files with check annotations Beta

options.Cookie.IsEssential = true;
});
var initialScopes = builder.Configuration.GetSection("DownstreamApi:Scopes")

Check warning on line 14 in 2-WebApp-graph-user/2-5-HybridFlow/Program.cs

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 14 in 2-WebApp-graph-user/2-5-HybridFlow/Program.cs

GitHub Actions / build

Dereference of a possibly null reference.
.Value
.Split(' ');
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>

Check warning on line 54 in 2-WebApp-graph-user/2-5-HybridFlow/Program.cs

GitHub Actions / build

Suggest using top level route registrations instead of UseEndpoints (https://aka.ms/aspnet/analyzers)

Check warning on line 54 in 2-WebApp-graph-user/2-5-HybridFlow/Program.cs

GitHub Actions / build

Suggest using top level route registrations instead of UseEndpoints (https://aka.ms/aspnet/analyzers)
{
endpoints.MapControllerRoute(
name: "default",
(function () {
const scopes =
@{
var apiScopes = Configuration["DownstreamApi:Scopes"].Split(' ');

Check warning on line 138 in 2-WebApp-graph-user/2-5-HybridFlow/Views/Shared/_Layout.cshtml

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 138 in 2-WebApp-graph-user/2-5-HybridFlow/Views/Shared/_Layout.cshtml

GitHub Actions / build

Dereference of a possibly null reference.
@Html.Raw("[");
foreach(var scope in apiScopes) {
catch (MsalUiRequiredException ex)
{
_tokenAcquisition.ReplyForbiddenWithWwwAuthenticateHeader(_graphScopes, ex);
throw ex;

Check warning on line 255 in 4-WebApp-your-API/4-3-AnyOrg/TodoListService/Controllers/TodoListController.cs

GitHub Actions / build

Re-throwing caught exception changes stack information (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2200)

Check warning on line 255 in 4-WebApp-your-API/4-3-AnyOrg/TodoListService/Controllers/TodoListController.cs

GitHub Actions / build

Re-throwing caught exception changes stack information (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2200)
}
}
try
{
// Request to get groups and directory roles that the user is a direct member of.
var memberPage = await graphClient.Me.GetMemberGroups.PostAsync(new GetMemberGroupsPostRequestBody() { SecurityEnabledOnly = false});

Check warning on line 137 in 5-WebApp-AuthZ/5-2-Groups/Services/GraphHelper.cs

GitHub Actions / build

'GetMemberGroupsRequestBuilder.PostAsync(GetMemberGroupsPostRequestBody, Action<RequestConfiguration<DefaultQueryParameters>>?, CancellationToken)' is obsolete: 'This method is obsolete. Use PostAsGetMemberGroupsPostResponse instead.'
allgroups = memberPage.Value.ToList<string>();
if (allgroups?.Count > 0)