Skip to content

Commit

Permalink
Cleanup after #9567 LocalTest Party selector (#9638)
Browse files Browse the repository at this point in the history
Co-authored-by: Ivar <[email protected]>
  • Loading branch information
ivarne and ivarne authored Jan 25, 2023
1 parent 7e1bbec commit f93dbb2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public async Task<IActionResult> LocalTestUsersRaw()
return Json(localData);
}

//Debugging endpoint
[AllowAnonymous]
public async Task<IActionResult> LocalTestUsers()
{
Expand All @@ -75,6 +76,7 @@ public async Task<IActionResult> LocalTestUsers()
return Json(constructedAppData);
}

// Debugging endpoint
[AllowAnonymous]
public async Task<IActionResult> LocalTestUsersRoundTrip()
{
Expand Down Expand Up @@ -187,7 +189,7 @@ public async Task<ActionResult> LogInTestUser(StartAppModel startAppModel)
var token = await _authenticationService.GenerateTokenForOrg(app.Id.Split("/")[0]);
var newInstance = await _localApp.Instantiate(app.Id, instance, content, xmlDataId, token);

return Redirect($"{_generalSettings.GetBaseUrl}/{app.Id}/#/instance/{newInstance.Id}");
return Redirect($"/{app.Id}/#/instance/{newInstance.Id}");
}
}

Expand Down Expand Up @@ -305,10 +307,6 @@ private async Task<IEnumerable<SelectListItem>> GetTestUsersForList()
{
var properProfile = await _userProfileService.GetUser(profile.UserId);

var group = new SelectListGroup()
{
Name = properProfile.Party.Person.Name,
};
var userParties = await _partiesService.GetParties(properProfile.UserId);

if (userParties.Count == 1)
Expand All @@ -324,6 +322,10 @@ private async Task<IEnumerable<SelectListItem>> GetTestUsersForList()
else
{
// When a user represents multiple parties, add it to a group, so that it stands out visually
var group = new SelectListGroup()
{
Name = properProfile.Party.Name,
};
foreach (var party in userParties)
{
userItems.Add(new()
Expand Down
7 changes: 4 additions & 3 deletions src/Services/TestData/AppTestDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public TestDataRegister GetTestDataRegister()
{
var org = Orgs.Select(o => (Organization)o).ToDictionary(o => o.OrgNumber);
var party = GetParties();
var person = Persons.Select(p => (Person)p).ToDictionary(p => p.SSN);
var person = Persons.Select(p => (Person)p).Where(p=>!string.IsNullOrEmpty(p.SSN)).ToDictionary(p => p.SSN);
return new TestDataRegister()
{
Org = org,
Expand Down Expand Up @@ -84,7 +84,7 @@ private Dictionary<string, Party> GetOrgPartiesWithChildren()
.ToDictionary(p => p.PartyId.ToString());
}


// Only used for debugging
public static AppTestDataModel FromTestDataModel(TestDataModel localData)
{
int negativePartyId = -1;
Expand Down Expand Up @@ -117,6 +117,8 @@ public static AppTestDataModel FromTestDataModel(TestDataModel localData)
}).ToList(),
Persons = localData.Register.Person.Values.Select(p =>
{
// TODO: Self identified users are not in the persons table, but should be in the AppTestDataModel.Persons
// We need a different way to find persons here, but as this is only for matching old and new model, this is fine.
var party = localData.Register.Party.Values.First(party => party.SSN == p.SSN);
var profile = localData.Profile.User.Values.First(user => user.PartyId == party.PartyId);
var customClaims = localData.Authorization.Claims.TryGetValue(profile.UserId.ToString(), out var v) ? v : new();
Expand All @@ -125,7 +127,6 @@ public static AppTestDataModel FromTestDataModel(TestDataModel localData)

return new AppTestPerson()
{

PartyId = party.PartyId,
AddressCity = p.AddressCity,
AddressHouseLetter = p.AddressHouseLetter,
Expand Down

0 comments on commit f93dbb2

Please sign in to comment.