Skip to content

Commit

Permalink
Fixes backend endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
gudjong committed Nov 29, 2024
1 parent b193e65 commit 7bd92e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ import { UpdateFilesDto } from './dto/updateFile.dto'
import { CurrentCaseFile } from './guards/caseFile.decorator'
import { CaseFileExistsGuard } from './guards/caseFileExists.guard'
import { ViewCaseFileGuard } from './guards/viewCaseFile.guard'
import { WriteCaseFileGuard } from './guards/writeCaseFile.guard'
import { DeleteFileResponse } from './models/deleteFile.response'
import { CaseFile } from './models/file.model'
import { PresignedPost } from './models/presignedPost.model'
Expand Down Expand Up @@ -107,7 +106,7 @@ export class FileController {
return this.fileService.createPresignedPost(theCase, createPresignedPost)
}

@UseGuards(RolesGuard, CaseExistsGuard, CaseWriteGuard, WriteCaseFileGuard)
@UseGuards(RolesGuard, CaseExistsGuard, CaseWriteGuard)
@RolesRules(
prosecutorRule,
prosecutorRepresentativeRule,
Expand Down Expand Up @@ -135,13 +134,7 @@ export class FileController {
return this.fileService.createCaseFile(theCase, createFile, user)
}

@UseGuards(
RolesGuard,
CaseExistsGuard,
DefendantExistsGuard,
CaseWriteGuard,
WriteCaseFileGuard,
)
@UseGuards(RolesGuard, CaseExistsGuard, DefendantExistsGuard, CaseWriteGuard)
@RolesRules(publicProsecutorStaffRule)
@Post('defendant/:defendantId/file')
@ApiCreatedResponse({
Expand All @@ -168,13 +161,12 @@ export class FileController {
CaseExistsGuard,
CivilClaimantExistsGuard,
CaseWriteGuard,
WriteCaseFileGuard,
)
@RolesRules(publicProsecutorStaffRule)
@Post('defendant/:defendantId/file')
@RolesRules() // This endpoint is not used by any role at the moment
@Post('civilClaimant/:civilClaimantId/file')
@ApiCreatedResponse({
type: CaseFile,
description: 'Creates a new case file connected to a defendant',
description: 'Creates a new case file connected to a civil claimant',
})
async createCivilClaimantCaseFile(
@Param('caseId') caseId: string,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { RolesGuard } from '@island.is/judicial-system/auth'

import { CaseExistsGuard, CaseWriteGuard } from '../../../case'
import { FileController } from '../../file.controller'
import { WriteCaseFileGuard } from '../../guards/writeCaseFile.guard'

describe('FileController - Create case file guards', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -18,7 +17,7 @@ describe('FileController - Create case file guards', () => {
})

it('should have three guards', () => {
expect(guards).toHaveLength(4)
expect(guards).toHaveLength(3)
})

describe('RolesGuard', () => {
Expand Down Expand Up @@ -56,16 +55,4 @@ describe('FileController - Create case file guards', () => {
expect(guard).toBeInstanceOf(CaseWriteGuard)
})
})

describe('CaseWriteGuard', () => {
let guard: CanActivate

beforeEach(() => {
guard = new guards[3]()
})

it('should have CaseWriteGuard as guard 4', () => {
expect(guard).toBeInstanceOf(WriteCaseFileGuard)
})
})
})

0 comments on commit 7bd92e8

Please sign in to comment.