Skip to content

Commit bbe757a

Browse files
authored
Bugfix - AccessMgmt - ClientDelegation - ReturnModel (#494)
* Update DelegationService.cs More info in exceptions * Fixed bug in Get - new return model
1 parent e4985e2 commit bbe757a

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/apps/Altinn.AccessManagement/src/Altinn.AccessManagement/Controllers/SystemUserClientDelegationController.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ IAssignmentRepository assignmentRepository
4545
/// </summary>
4646
/// <param name="party">The party the authenticated user is performing client administration on behalf of</param>
4747
/// <param name="request">Request Dto</param>
48+
/// <returns><seealso cref="ExtConnection"/>List of connections</returns>
4849
[HttpPost]
4950
[Authorize(Policy = AuthzConstants.POLICY_CLIENTDELEGATION_WRITE)]
5051
public async Task<ActionResult> PostClientDelegation([FromQuery] Guid party, [FromBody] CreateSystemDelegationRequestDto request)
@@ -56,13 +57,14 @@ public async Task<ActionResult> PostClientDelegation([FromQuery] Guid party, [Fr
5657
}
5758

5859
var delegations = await delegationService.CreateClientDelegation(request, userId, party);
59-
var result = new List<ExtDelegation>();
60+
var result = new List<ExtConnection>();
6061

6162
foreach (var delegation in delegations)
6263
{
63-
result.Add(await delegationRepository.GetExtended(delegation.Id));
64+
result.Add(await connectionRepository.GetExtended(delegation.Id));
6465
}
6566

67+
// Remark: Kan ikke garantere at det KUN er delegeringer som er opprettet i denne handlingen som blir returnert.
6668
return Ok(result);
6769
}
6870

@@ -175,7 +177,7 @@ public async Task<ActionResult> DeleteClientAssignment([FromQuery] Guid party, [
175177
/// </summary>
176178
/// <param name="party">The party the authenticated user is performing client administration on behalf of</param>
177179
/// <param name="systemUser">The system user the authenticated user is delegating access to</param>
178-
/// <returns></returns>
180+
/// <returns><seealso cref="ExtConnection"/>List of connections</returns>
179181
[HttpGet]
180182
[Authorize(Policy = AuthzConstants.POLICY_CLIENTDELEGATION_READ)]
181183
public async Task<ActionResult> GetClientDelegations([FromQuery] Guid party, [FromQuery] Guid systemUser)
@@ -186,10 +188,10 @@ public async Task<ActionResult> GetClientDelegations([FromQuery] Guid party, [Fr
186188
return Unauthorized();
187189
}
188190

189-
var filter = delegationRepository.CreateFilterBuilder();
190-
filter.Equal(t => t.ToId, systemUser);
191-
filter.Equal(t => t.FacilitatorId, party);
192-
var res = await delegationRepository.GetExtended(filter);
191+
var f = connectionRepository.CreateFilterBuilder();
192+
f.Equal(t => t.ToId, systemUser);
193+
f.Equal(t => t.FacilitatorId, party);
194+
var res = await connectionRepository.GetExtended(f);
193195

194196
return Ok(res);
195197
}

src/apps/Altinn.AccessManagement/src/Altinn.AccessMgmt.Persistence/Services/DelegationService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,21 +186,21 @@ [ ] Check i Resource is Delegable
186186
public async Task<IEnumerable<Delegation>> CreateClientDelegation(CreateSystemDelegationRequestDto request, Guid userId, Guid facilitatorPartyId)
187187
{
188188
// Find user : Fredrik
189-
var user = (await entityRepository.Get(userId)) ?? throw new Exception(string.Format("Party not found '{0}'", userId));
189+
var user = (await entityRepository.Get(userId)) ?? throw new Exception(string.Format("Party not found '{0}' for user", userId));
190190

191191
// Find Facilitator : Regnskapsfolk
192-
var facilitator = (await entityRepository.Get(facilitatorPartyId)) ?? throw new Exception(string.Format("Party not found '{0}'", facilitatorPartyId));
192+
var facilitator = (await entityRepository.Get(facilitatorPartyId)) ?? throw new Exception(string.Format("Party not found '{0}' for facilitator", facilitatorPartyId));
193193

194194
// Find admin role : Tilgangstyrer eller KlientAdmin
195195

196196
// Find Agent Role : AGENT
197197
var agentRole = await GetRole(request.AgentRole) ?? throw new Exception(string.Format("Role not found '{0}'", request.AgentRole));
198198

199199
// Find Agent
200-
var agent = await GetOrCreateEntity(request.AgentId, request.AgentName, request.AgentId.ToString(), "Systembruker", "System") ?? throw new Exception(string.Format("Could not find or create '{0}'", request.AgentId));
200+
var agent = await GetOrCreateEntity(request.AgentId, request.AgentName, request.AgentId.ToString(), "Systembruker", "System") ?? throw new Exception(string.Format("Could not find or create party '{0}' for agent", request.AgentId));
201201

202202
// Find ClientId : Bakeriet
203-
var client = (await entityRepository.Get(request.ClientId)) ?? throw new Exception(string.Format("Party not found '{0}'", request.ClientId));
203+
var client = (await entityRepository.Get(request.ClientId)) ?? throw new Exception(string.Format("Party not found '{0}' for client", request.ClientId));
204204

205205
// Find or Create Agent Assignment : Regnskapsfolk - AGENT - SystemBruker01
206206
var agentAssignment = await GetOrCreateAssignment(facilitator, agent, agentRole) ?? throw new Exception(string.Format("Could not find or create assignment '{0}' - {1} - {2}", facilitator.Name, agentRole.Code, agent.Name));

0 commit comments

Comments
 (0)