Skip to content

Commit

Permalink
Fix LocalTest in "http" modus when no app is running (#8253)
Browse files Browse the repository at this point in the history
#8023 introduced an exception instead of a nice error message when
the user forgets to start an app on port 5005 when in "http" mode.
  • Loading branch information
ivarne authored Mar 16, 2022
1 parent 6a4bd7d commit d418fbb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task<IActionResult> Index()
model.AppPath = _localPlatformSettings.AppRepositoryBasePath;
model.StaticTestDataPath = _localPlatformSettings.LocalTestingStaticTestDataPath;
model.LocalAppUrl = _localPlatformSettings.LocalAppUrl;
var defaultAuthLevel = _localPlatformSettings.LocalAppMode == "http" ? await GetAppAuthLevel(model.TestApps.First().Value) : 2;
var defaultAuthLevel = _localPlatformSettings.LocalAppMode == "http" ? await GetAppAuthLevel(model.TestApps) : 2;
model.AuthenticationLevels = GetAuthenticationLevels(defaultAuthLevel);

if (!model.TestApps?.Any() ?? true)
Expand Down Expand Up @@ -224,9 +224,10 @@ private async Task<IEnumerable<SelectListItem>> GetTestUsersForList()

return userItems;
}
private async Task<int> GetAppAuthLevel(string appId)
private async Task<int> GetAppAuthLevel(IEnumerable<SelectListItem> testApps)
{
try {
var appId = testApps.Single().Value;
var policyString = await _localApp.GetXACMLPolicy(appId);
var document = new XmlDocument();
document.LoadXml(policyString);
Expand All @@ -237,7 +238,7 @@ private async Task<int> GetAppAuthLevel(string appId)
}
catch(Exception)
{
// Return default auth level if app auth level can't be found.
// Return default auth level if Single app auth level can't be found.
return 2;
}
}
Expand Down

0 comments on commit d418fbb

Please sign in to comment.