Skip to content

Commit

Permalink
feat(j-s): Block create subpoena on staging and production (#16297)
Browse files Browse the repository at this point in the history
* feat(j-s): Block create subpoena on staging and dev

* Update subpoena.service.ts

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
unakb and kodiakhq[bot] authored Oct 8, 2024
1 parent 9d156e4 commit 1c660fe
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/judicial-system/backend/infra/judicial-system-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const serviceSetup = (): ServiceBuilder<'judicial-system-backend'> =>
SQS_REGION: 'eu-west-1',
BLOCKED_API_INTEGRATION: {
dev: '',
staging: 'COURT,POLICE_CASE',
prod: '',
staging: 'COURT,POLICE_CASE,CREATE_SUBPOENA',
prod: 'CREATE_SUBPOENA',
},
NOVA_ACCEPT_UNAUTHORIZED: {
dev: 'true',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ export const policeModuleConfig = defineConfig({
.split(',')
.includes('POLICE_CASE'),
policeApiKey: env.required('XROAD_POLICE_API_KEY', ''),
policeCreateSubpoenaApiAvailable: !(
env.optional('BLOCKED_API_INTEGRATION') ?? ''
)
.split(',')
.includes('CREATE_SUBPOENA'),
}),
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Inject,
Injectable,
NotFoundException,
NotImplementedException,
ServiceUnavailableException,
} from '@nestjs/common'

Expand Down Expand Up @@ -616,6 +617,12 @@ export class PoliceService {
indictment: string,
user: User,
): Promise<CreateSubpoenaResponse> {
if (!this.config.policeCreateSubpoenaApiAvailable) {
throw new NotImplementedException(
'Police create subpoena API not available in current environment',
)
}

const { courtCaseNumber, dateLogs, prosecutor, policeCaseNumbers, court } =
workingCase
const { nationalId: defendantNationalId } = defendant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Inject,
Injectable,
InternalServerErrorException,
NotImplementedException,
} from '@nestjs/common'
import { InjectConnection, InjectModel } from '@nestjs/sequelize'

Expand Down Expand Up @@ -178,9 +179,16 @@ export class SubpoenaService {

return { delivered: true }
} catch (error) {
this.logger.error('Error delivering subpoena to police', error)

return { delivered: false }
if (error instanceof NotImplementedException) {
this.logger.info(
'Failed to deliver subpoena to police due to lack of implementation',
error,
)
return { delivered: true }
} else {
this.logger.error('Error delivering subpoena to police', error)
return { delivered: false }
}
}
}
}
2 changes: 1 addition & 1 deletion charts/judicial-system/values.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ judicial-system-api:
judicial-system-backend:
enabled: true
env:
BLOCKED_API_INTEGRATION: ''
BLOCKED_API_INTEGRATION: 'CREATE_SUBPOENA'
CLIENT_URL: 'https://rettarvorslugatt.island.is'
CONTENTFUL_ENVIRONMENT: 'master'
CONTENTFUL_HOST: 'cdn.contentful.com'
Expand Down
2 changes: 1 addition & 1 deletion charts/judicial-system/values.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ judicial-system-api:
judicial-system-backend:
enabled: true
env:
BLOCKED_API_INTEGRATION: 'COURT,POLICE_CASE'
BLOCKED_API_INTEGRATION: 'COURT,POLICE_CASE,CREATE_SUBPOENA'
CLIENT_URL: 'https://judicial-system.staging01.devland.is'
CONTENTFUL_ENVIRONMENT: 'test'
CONTENTFUL_HOST: 'cdn.contentful.com'
Expand Down

0 comments on commit 1c660fe

Please sign in to comment.