Skip to content

Commit

Permalink
Merge branch 'main' into j-s/service-announcement-defenders
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Nov 8, 2024
2 parents db83d4b + e485d7e commit ae44420
Show file tree
Hide file tree
Showing 68 changed files with 1,008 additions and 934 deletions.
2 changes: 2 additions & 0 deletions apps/application-system/api/infra/application-system-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ export const serviceSetup = (services: {
'/k8s/api/ALTHINGI_OMBUDSMAN_XROAD_USERNAME',
ALTHINGI_OMBUDSMAN_XROAD_PASSWORD:
'/k8s/api/ALTHINGI_OMBUDSMAN_XROAD_PASSWORD',
NATIONAL_REGISTRY_B2C_CLIENT_SECRET:
'/k8s/api/NATIONAL_REGISTRY_B2C_CLIENT_SECRET',
})
.db()
.migrations()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class TemplateApiApplicationService extends BaseTemplateApiApplicationSer
super()
}

async saveAttachmentToApplicaton(
async saveAttachmentToApplication(
application: ApplicationWithAttachments,
fileName: string,
buffer: Buffer,
Expand Down
1 change: 0 additions & 1 deletion apps/auth-admin-web/specs/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import { render } from '@testing-library/react'
import 'whatwg-fetch'
import Index from '../pages/index'
jest.mock('next/router', () => ({
useRouter: () => ({ push: () => jest.fn() }),
Expand Down
9 changes: 9 additions & 0 deletions apps/services/auth/delegation-api/infra/delegation-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,17 @@ export const serviceSetup = (services: {
prod: 'https://api.syslumenn.is/api',
},
SYSLUMENN_TIMEOUT: '3000',
ZENDESK_CONTACT_FORM_SUBDOMAIN: {
prod: 'digitaliceland',
staging: 'digitaliceland',
dev: 'digitaliceland',
},
})
.secrets({
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL',
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN',
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE:
'/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE',
IDENTITY_SERVER_CLIENT_SECRET:
'/k8s/services-auth/IDENTITY_SERVER_CLIENT_SECRET',
NATIONAL_REGISTRY_IDS_CLIENT_SECRET:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,17 @@ export const serviceSetup =
prod: 'https://api.syslumenn.is/api',
},
SYSLUMENN_TIMEOUT: '3000',
ZENDESK_CONTACT_FORM_SUBDOMAIN: {
prod: 'digitaliceland',
staging: 'digitaliceland',
dev: 'digitaliceland',
},
})
.secrets({
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL',
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN',
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE:
'/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE',
IDENTITY_SERVER_CLIENT_SECRET:
'/k8s/services-auth/IDENTITY_SERVER_CLIENT_SECRET',
SYSLUMENN_USERNAME: '/k8s/services-auth/SYSLUMENN_USERNAME',
Expand Down
9 changes: 9 additions & 0 deletions apps/services/auth/public-api/infra/auth-public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,17 @@ export const serviceSetup = (): ServiceBuilder<'services-auth-public-api'> => {
prod: 'https://api.syslumenn.is/api',
},
SYSLUMENN_TIMEOUT: '3000',
ZENDESK_CONTACT_FORM_SUBDOMAIN: {
prod: 'digitaliceland',
staging: 'digitaliceland',
dev: 'digitaliceland',
},
})
.secrets({
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL',
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN',
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE:
'/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE',
IDENTITY_SERVER_CLIENT_SECRET:
'/k8s/services-auth/IDENTITY_SERVER_CLIENT_SECRET',
NATIONAL_REGISTRY_IDS_CLIENT_SECRET:
Expand Down
12 changes: 12 additions & 0 deletions charts/identity-server/values.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ services-auth-delegation-api:
XROAD_RSK_PROCURING_REDIS_NODES: '["clustercfg.general-redis-cluster-group.5fzau3.euw1.cache.amazonaws.com:6379"]'
XROAD_TLS_BASE_PATH: 'https://securityserver.dev01.devland.is'
XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.dev01.devland.is/r1/IS-DEV'
ZENDESK_CONTACT_FORM_SUBDOMAIN: 'digitaliceland'
grantNamespaces:
- 'nginx-ingress-internal'
- 'islandis'
Expand Down Expand Up @@ -389,6 +390,9 @@ services-auth-delegation-api:
NATIONAL_REGISTRY_IDS_CLIENT_SECRET: '/k8s/xroad/client/NATIONAL-REGISTRY/IDENTITYSERVER_SECRET'
SYSLUMENN_PASSWORD: '/k8s/services-auth/SYSLUMENN_PASSWORD'
SYSLUMENN_USERNAME: '/k8s/services-auth/SYSLUMENN_USERNAME'
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL'
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN'
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE: '/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE'
securityContext:
allowPrivilegeEscalation: false
privileged: false
Expand Down Expand Up @@ -611,6 +615,7 @@ services-auth-personal-representative:
XROAD_RSK_PROCURING_REDIS_NODES: '["clustercfg.general-redis-cluster-group.5fzau3.euw1.cache.amazonaws.com:6379"]'
XROAD_TLS_BASE_PATH: 'https://securityserver.dev01.devland.is'
XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.dev01.devland.is/r1/IS-DEV'
ZENDESK_CONTACT_FORM_SUBDOMAIN: 'digitaliceland'
grantNamespaces: []
grantNamespacesEnabled: false
healthCheck:
Expand Down Expand Up @@ -662,6 +667,9 @@ services-auth-personal-representative:
IDENTITY_SERVER_CLIENT_SECRET: '/k8s/services-auth/IDENTITY_SERVER_CLIENT_SECRET'
SYSLUMENN_PASSWORD: '/k8s/services-auth/SYSLUMENN_PASSWORD'
SYSLUMENN_USERNAME: '/k8s/services-auth/SYSLUMENN_USERNAME'
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL'
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN'
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE: '/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE'
securityContext:
allowPrivilegeEscalation: false
privileged: false
Expand Down Expand Up @@ -762,6 +770,7 @@ services-auth-public-api:
XROAD_TJODSKRA_MEMBER_CODE: '10001'
XROAD_TLS_BASE_PATH: 'https://securityserver.dev01.devland.is'
XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.dev01.devland.is/r1/IS-DEV'
ZENDESK_CONTACT_FORM_SUBDOMAIN: 'digitaliceland'
grantNamespaces:
- 'nginx-ingress-external'
- 'nginx-ingress-internal'
Expand Down Expand Up @@ -821,6 +830,9 @@ services-auth-public-api:
NATIONAL_REGISTRY_IDS_CLIENT_SECRET: '/k8s/xroad/client/NATIONAL-REGISTRY/IDENTITYSERVER_SECRET'
SYSLUMENN_PASSWORD: '/k8s/services-auth/SYSLUMENN_PASSWORD'
SYSLUMENN_USERNAME: '/k8s/services-auth/SYSLUMENN_USERNAME'
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL'
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN'
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE: '/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE'
securityContext:
allowPrivilegeEscalation: false
privileged: false
12 changes: 12 additions & 0 deletions charts/identity-server/values.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ services-auth-delegation-api:
XROAD_RSK_PROCURING_REDIS_NODES: '["clustercfg.general-redis-cluster-group.dnugi2.euw1.cache.amazonaws.com:6379"]'
XROAD_TLS_BASE_PATH: 'https://securityserver.island.is'
XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.island.is/r1/IS'
ZENDESK_CONTACT_FORM_SUBDOMAIN: 'digitaliceland'
grantNamespaces:
- 'nginx-ingress-internal'
- 'islandis'
Expand Down Expand Up @@ -386,6 +387,9 @@ services-auth-delegation-api:
NATIONAL_REGISTRY_IDS_CLIENT_SECRET: '/k8s/xroad/client/NATIONAL-REGISTRY/IDENTITYSERVER_SECRET'
SYSLUMENN_PASSWORD: '/k8s/services-auth/SYSLUMENN_PASSWORD'
SYSLUMENN_USERNAME: '/k8s/services-auth/SYSLUMENN_USERNAME'
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL'
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN'
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE: '/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE'
securityContext:
allowPrivilegeEscalation: false
privileged: false
Expand Down Expand Up @@ -608,6 +612,7 @@ services-auth-personal-representative:
XROAD_RSK_PROCURING_REDIS_NODES: '["clustercfg.general-redis-cluster-group.dnugi2.euw1.cache.amazonaws.com:6379"]'
XROAD_TLS_BASE_PATH: 'https://securityserver.island.is'
XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.island.is/r1/IS'
ZENDESK_CONTACT_FORM_SUBDOMAIN: 'digitaliceland'
grantNamespaces: []
grantNamespacesEnabled: false
healthCheck:
Expand Down Expand Up @@ -659,6 +664,9 @@ services-auth-personal-representative:
IDENTITY_SERVER_CLIENT_SECRET: '/k8s/services-auth/IDENTITY_SERVER_CLIENT_SECRET'
SYSLUMENN_PASSWORD: '/k8s/services-auth/SYSLUMENN_PASSWORD'
SYSLUMENN_USERNAME: '/k8s/services-auth/SYSLUMENN_USERNAME'
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL'
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN'
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE: '/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE'
securityContext:
allowPrivilegeEscalation: false
privileged: false
Expand Down Expand Up @@ -759,6 +767,7 @@ services-auth-public-api:
XROAD_TJODSKRA_MEMBER_CODE: '6503760649'
XROAD_TLS_BASE_PATH: 'https://securityserver.island.is'
XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.island.is/r1/IS'
ZENDESK_CONTACT_FORM_SUBDOMAIN: 'digitaliceland'
grantNamespaces:
- 'nginx-ingress-external'
- 'nginx-ingress-internal'
Expand Down Expand Up @@ -818,6 +827,9 @@ services-auth-public-api:
NATIONAL_REGISTRY_IDS_CLIENT_SECRET: '/k8s/xroad/client/NATIONAL-REGISTRY/IDENTITYSERVER_SECRET'
SYSLUMENN_PASSWORD: '/k8s/services-auth/SYSLUMENN_PASSWORD'
SYSLUMENN_USERNAME: '/k8s/services-auth/SYSLUMENN_USERNAME'
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL'
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN'
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE: '/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE'
securityContext:
allowPrivilegeEscalation: false
privileged: false
12 changes: 12 additions & 0 deletions charts/identity-server/values.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ services-auth-delegation-api:
XROAD_RSK_PROCURING_REDIS_NODES: '["clustercfg.general-redis-cluster-group.ab9ckb.euw1.cache.amazonaws.com:6379"]'
XROAD_TLS_BASE_PATH: 'https://securityserver.staging01.devland.is'
XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.staging01.devland.is/r1/IS-TEST'
ZENDESK_CONTACT_FORM_SUBDOMAIN: 'digitaliceland'
grantNamespaces:
- 'nginx-ingress-internal'
- 'islandis'
Expand Down Expand Up @@ -389,6 +390,9 @@ services-auth-delegation-api:
NATIONAL_REGISTRY_IDS_CLIENT_SECRET: '/k8s/xroad/client/NATIONAL-REGISTRY/IDENTITYSERVER_SECRET'
SYSLUMENN_PASSWORD: '/k8s/services-auth/SYSLUMENN_PASSWORD'
SYSLUMENN_USERNAME: '/k8s/services-auth/SYSLUMENN_USERNAME'
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL'
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN'
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE: '/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE'
securityContext:
allowPrivilegeEscalation: false
privileged: false
Expand Down Expand Up @@ -611,6 +615,7 @@ services-auth-personal-representative:
XROAD_RSK_PROCURING_REDIS_NODES: '["clustercfg.general-redis-cluster-group.ab9ckb.euw1.cache.amazonaws.com:6379"]'
XROAD_TLS_BASE_PATH: 'https://securityserver.staging01.devland.is'
XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.staging01.devland.is/r1/IS-TEST'
ZENDESK_CONTACT_FORM_SUBDOMAIN: 'digitaliceland'
grantNamespaces: []
grantNamespacesEnabled: false
healthCheck:
Expand Down Expand Up @@ -662,6 +667,9 @@ services-auth-personal-representative:
IDENTITY_SERVER_CLIENT_SECRET: '/k8s/services-auth/IDENTITY_SERVER_CLIENT_SECRET'
SYSLUMENN_PASSWORD: '/k8s/services-auth/SYSLUMENN_PASSWORD'
SYSLUMENN_USERNAME: '/k8s/services-auth/SYSLUMENN_USERNAME'
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL'
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN'
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE: '/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE'
securityContext:
allowPrivilegeEscalation: false
privileged: false
Expand Down Expand Up @@ -762,6 +770,7 @@ services-auth-public-api:
XROAD_TJODSKRA_MEMBER_CODE: '6503760649'
XROAD_TLS_BASE_PATH: 'https://securityserver.staging01.devland.is'
XROAD_TLS_BASE_PATH_WITH_ENV: 'https://securityserver.staging01.devland.is/r1/IS-TEST'
ZENDESK_CONTACT_FORM_SUBDOMAIN: 'digitaliceland'
grantNamespaces:
- 'nginx-ingress-external'
- 'nginx-ingress-internal'
Expand Down Expand Up @@ -821,6 +830,9 @@ services-auth-public-api:
NATIONAL_REGISTRY_IDS_CLIENT_SECRET: '/k8s/xroad/client/NATIONAL-REGISTRY/IDENTITYSERVER_SECRET'
SYSLUMENN_PASSWORD: '/k8s/services-auth/SYSLUMENN_PASSWORD'
SYSLUMENN_USERNAME: '/k8s/services-auth/SYSLUMENN_USERNAME'
ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL'
ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN'
ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE: '/k8s/services-auth/ZENDESK_WEBHOOK_SECRET_GENERAL_MANDATE'
securityContext:
allowPrivilegeEscalation: false
privileged: false
1 change: 1 addition & 0 deletions charts/islandis/values.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ application-system-api:
IDENTITY_SERVER_CLIENT_SECRET: '/k8s/application-system/api/IDENTITY_SERVER_CLIENT_SECRET'
ISLYKILL_SERVICE_BASEPATH: '/k8s/api/ISLYKILL_SERVICE_BASEPATH'
ISLYKILL_SERVICE_PASSPHRASE: '/k8s/api/ISLYKILL_SERVICE_PASSPHRASE'
NATIONAL_REGISTRY_B2C_CLIENT_SECRET: '/k8s/api/NATIONAL_REGISTRY_B2C_CLIENT_SECRET'
NOVA_PASSWORD: '/k8s/application-system/api/NOVA_PASSWORD'
NOVA_URL: '/k8s/application-system-api/NOVA_URL'
SYSLUMENN_HOST: '/k8s/application-system-api/SYSLUMENN_HOST'
Expand Down
1 change: 1 addition & 0 deletions charts/islandis/values.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ application-system-api:
IDENTITY_SERVER_CLIENT_SECRET: '/k8s/application-system/api/IDENTITY_SERVER_CLIENT_SECRET'
ISLYKILL_SERVICE_BASEPATH: '/k8s/api/ISLYKILL_SERVICE_BASEPATH'
ISLYKILL_SERVICE_PASSPHRASE: '/k8s/api/ISLYKILL_SERVICE_PASSPHRASE'
NATIONAL_REGISTRY_B2C_CLIENT_SECRET: '/k8s/api/NATIONAL_REGISTRY_B2C_CLIENT_SECRET'
NOVA_PASSWORD: '/k8s/application-system/api/NOVA_PASSWORD'
NOVA_URL: '/k8s/application-system-api/NOVA_URL'
SYSLUMENN_HOST: '/k8s/application-system-api/SYSLUMENN_HOST'
Expand Down
1 change: 1 addition & 0 deletions charts/islandis/values.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ application-system-api:
IDENTITY_SERVER_CLIENT_SECRET: '/k8s/application-system/api/IDENTITY_SERVER_CLIENT_SECRET'
ISLYKILL_SERVICE_BASEPATH: '/k8s/api/ISLYKILL_SERVICE_BASEPATH'
ISLYKILL_SERVICE_PASSPHRASE: '/k8s/api/ISLYKILL_SERVICE_PASSPHRASE'
NATIONAL_REGISTRY_B2C_CLIENT_SECRET: '/k8s/api/NATIONAL_REGISTRY_B2C_CLIENT_SECRET'
NOVA_PASSWORD: '/k8s/application-system/api/NOVA_PASSWORD'
NOVA_URL: '/k8s/application-system-api/NOVA_URL'
SYSLUMENN_HOST: '/k8s/application-system-api/SYSLUMENN_HOST'
Expand Down
4 changes: 2 additions & 2 deletions libs/api/domains/education/src/lib/education.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { FeatureFlagModule } from '@island.is/nest/feature-flags'
import { XRoadConfig, MMSApi } from '@island.is/clients/mms'
import { FriggResolver, InnaResolver, MainResolver } from './graphql'
import { EducationService } from './education.service'
import { S3Service } from './s3.service'
import { InnaClientModule } from '@island.is/clients/inna'
import { NationalRegistryV3ClientModule } from '@island.is/clients/national-registry-v3'
import { FriggClientModule } from '@island.is/clients/mms/frigg'
import { AwsModule } from '@island.is/nest/aws'

export interface Config {
fileDownloadBucket: string
Expand All @@ -23,7 +23,6 @@ export class EducationModule {
FriggResolver,
InnaResolver,
MainResolver,
S3Service,
EducationService,
{
provide: 'CONFIG',
Expand All @@ -39,6 +38,7 @@ export class EducationModule {
FeatureFlagModule,
NationalRegistryV3ClientModule,
FriggClientModule,
AwsModule,
],
exports: [],
}
Expand Down
29 changes: 23 additions & 6 deletions libs/api/domains/education/src/lib/education.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import {
ExamResult,
Student,
} from './education.type'
import { S3Service } from './s3.service'
import { getYearInterval } from './education.utils'
import { NationalRegistryV3ClientService } from '@island.is/clients/national-registry-v3'
import { isDefined } from '@island.is/shared/utils'
import { S3Service } from '@island.is/nest/aws'
import { LOGGER_PROVIDER, type Logger } from '@island.is/logging'

@Injectable()
export class EducationService {
Expand All @@ -30,6 +31,7 @@ export class EducationService {
@Inject('CONFIG')
private readonly config: Config,
private readonly nationalRegistryApi: NationalRegistryV3ClientService,
@Inject(LOGGER_PROVIDER) protected readonly logger: Logger,
) {}

async getLicenses(
Expand All @@ -53,11 +55,26 @@ export class EducationService {
nationalId,
licenseId,
)

return this.s3Service.uploadFileFromStream(responseStream, {
fileName: uuid(),
bucket: this.config.fileDownloadBucket,
})
try {
const fileLocation = await this.s3Service.uploadFile(
responseStream.body,
{ bucket: this.config.fileDownloadBucket, key: uuid() },
{
ContentType:
responseStream.headers?.get('content-type') || 'application/pdf',
},
)

// Presigned URL expires in 65 seconds to allow for download initiation
const PRESIGNED_URL_EXPIRY = 65
return await this.s3Service.getPresignedUrl(
fileLocation,
PRESIGNED_URL_EXPIRY,
)
} catch (error) {
this.logger.error(`Failed to process PDF license:`, { error, licenseId })
return null
}
}

async getFamily(nationalId: string): Promise<Array<Student>> {
Expand Down
4 changes: 2 additions & 2 deletions libs/api/domains/education/src/lib/education.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
ADULT_STUDENT1,
} from './__mock-data__/my-family'
import { MMSApi } from '@island.is/clients/mms'
import { S3Service } from './s3.service'
import {
NationalRegistryV3ClientConfig,
NationalRegistryV3ClientModule,
Expand All @@ -24,6 +23,7 @@ import {
import { Student } from './education.type'
import { ConfigModule } from '@nestjs/config'
import { XRoadConfig } from '@island.is/nest/config'
import { AwsModule } from '@island.is/nest/aws'

const config = {
fileDownloadBucket: '',
Expand All @@ -39,13 +39,13 @@ describe('EducationService', () => {
imports: [
LoggingModule,
NationalRegistryV3ClientModule,
AwsModule,
ConfigModule.forRoot({
isGlobal: true,
load: [XRoadConfig, NationalRegistryV3ClientConfig],
}),
],
providers: [
S3Service,
{
provide: MMSApi,
useValue: new MMSApi(config.xroad),
Expand Down
Loading

0 comments on commit ae44420

Please sign in to comment.