Skip to content

Commit

Permalink
fix: read analysis-permission read handler
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Jul 1, 2024
1 parent d189ebe commit 1d67fa1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export async function getOneAnalysisPermissionRouteHandler(req: Request, res: Re
.where('analysisPermission.id = :id', { id });

const relationsMap = getRelations(req);

if (relationsMap.analysis) {
applyQueryRelationsParseOutput(query, [
relationsMap.analysis,
Expand All @@ -78,8 +79,9 @@ export async function getOneAnalysisPermissionRouteHandler(req: Request, res: Re
}

if (relationsMap.policy) {
// todo: enable when policy api client is defined
// entity.policy = await authupClient.policy.getOne(entity.policy_id);
if (entity.policy_id) {
entity.policy = await authupClient.policy.getOne(entity.policy_id);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export async function runAnalysisPermissionValidation(

result.data.permission = permission;
result.data.permission_realm_id = permission.realm_id;

// todo: remove this when validation is reworked.
result.relation.permission = permission;
} catch (e) {
if (isClientErrorWithStatusCode(e, 404)) {
throw new BadRequestError(buildHTTPValidationErrorMessage('permission_id'));
Expand All @@ -95,6 +98,9 @@ export async function runAnalysisPermissionValidation(

result.data.policy = policy;
result.data.policy_id = policy.id;

// todo: remove this when validation is reworked.
result.relation.policy = policy;
} catch (e) {
if (isClientErrorWithStatusCode(e, 404)) {
throw new BadRequestError(buildHTTPValidationErrorMessage('permission_id'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ describe('src/controllers/core/analysis-permission', () => {
}

const analysisPermission = await client.analysisPermission.create(attributes);

delete analysisPermission.analysis;
delete analysisPermission.permission;

extendObject(attributes, removeDateProperties(analysisPermission));
});

Expand Down

0 comments on commit 1d67fa1

Please sign in to comment.