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

Fix evidence source in hydration #57

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Changes from all commits
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
8 changes: 6 additions & 2 deletions Dan.Core/Services/EvidenceStatusService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task<EvidenceStatus> GetEvidenceStatusAsync(Accreditation accredita

// Since evidencecodes in stored accreditation does not contain requirements, we need to rehydrate it from availableevidenceservice
// This also validates that the evidence code requested is still available at the ES
var stillAvailable = await TryRehydrateEvidenceCodeAuthorizationRequirements(evidenceCode);
var stillAvailable = await TryRehydrateEvidenceCode(evidenceCode);
if (!stillAvailable)
{
status = EvidenceStatusCode.Unavailable;
Expand Down Expand Up @@ -106,7 +106,7 @@ public async Task DetermineAggregateStatus(List<Accreditation> accreditations, b
}
}

private async Task<bool> TryRehydrateEvidenceCodeAuthorizationRequirements(EvidenceCode evidenceCode)
private async Task<bool> TryRehydrateEvidenceCode(EvidenceCode evidenceCode)
{
var availableEvidenceCodes = await _availableEvidenceCodesService.GetAvailableEvidenceCodes();

Expand All @@ -121,6 +121,10 @@ private async Task<bool> TryRehydrateEvidenceCodeAuthorizationRequirements(Evide

evidenceCode.AuthorizationRequirements = availableEvidenceCode.AuthorizationRequirements;

// In case the evidence code has been move to a new source, we need to update the evidence code EvidenceSource
// to reflect that of the availableEvidenceCode, so that requests are routed correctly
evidenceCode.EvidenceSource = availableEvidenceCode.EvidenceSource;

evidenceCode.AuthorizationRequirements = evidenceCode.AuthorizationRequirements.Where(
x => x.AppliesToServiceContext.Count == 0 || x.AppliesToServiceContext.Contains(_requestContextService.ServiceContext.Name)).ToList();

Expand Down