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

feat(air-discount-scheme): Add myflug + add more logs to ads #16655

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion apps/air-discount-scheme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ There are certain precondition to be eligible for a discount. They are:
The API is used by airlines to verify the discount code validity and get basic
booking info about the user.

The airlines that have access to this api are `Icelandair`, `Ernir` and
The airlines that have access to this api are `Icelandair`, `Ernir`, `Myflug` and
`Norlandair`. Historically some flights were booked for `Norlandair` through
`Icelandair`, those flights are marked with the `Icelandair` airline but have a
cooperation field with `Norlandair`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const serviceSetup = (): ServiceBuilder<'air-discount-scheme-backend'> =>
.namespace('air-discount-scheme')
.secrets({
ICELANDAIR_API_KEY: '/k8s/air-discount-scheme/backend/ICELANDAIR_API_KEY',
MYFLUG_API_KEY: '/k8s/air-discount-scheme/backend/MYFLUG_API_KEY',
ERNIR_API_KEY: '/k8s/air-discount-scheme/backend/ERNIR_API_KEY',
NORLANDAIR_API_KEY: '/k8s/air-discount-scheme/backend/NORLANDAIR_API_KEY',
NATIONAL_REGISTRY_PASSWORD:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const getRandomFlightLeg = (flightId, flightDate, pairing) => {
created: flightDate,
modified: flightDate,
financial_state: 'AWAITING_DEBIT',
airline: ['ernir', 'norlandair', 'icelandair'][
Math.floor(Math.random() * 3)
airline: ['ernir', 'norlandair', 'icelandair', 'myflug'][
Math.floor(Math.random() * 4)
thordurhhh marked this conversation as resolved.
Show resolved Hide resolved
],
cooperation: null,
financial_state_updated: flightDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ describe('AuthGuard', () => {
expect(isValid).toBe(true)
})

it('Api key should work for Myflug', async () => {
const request: any = {
headers: {
authorization: `bearer ${airlineApiKeys.myflug}`,
},
}

const isValid = authGuard.hasValidApiKey(request)

expect(isValid).toBe(true)
})

it('Api key should not work with empty authorization header', async () => {
const request: any = {
headers: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,15 @@ export class NationalRegistryService {
}

async getRelations(authUser: AuthUser): Promise<Array<string>> {
return this.personApi.getCustodyChildren(authUser)
try {
return this.personApi.getCustodyChildren(authUser)
} catch (e) {
this.logger.info('getRelations custodychildren not successful', {
category: 'ads-backend',
e,
})
throw e
}
thordurhhh marked this conversation as resolved.
Show resolved Hide resolved
}

async getCustodians(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const devConfig = {
[Airlines.icelandair]: Airlines.icelandair,
[Airlines.ernir]: Airlines.ernir,
[Airlines.norlandair]: Airlines.norlandair,
[Airlines.myflug]: Airlines.myflug,
},
redis: {
urls: [
Expand Down Expand Up @@ -41,6 +42,7 @@ const prodConfig = {
[Airlines.icelandair]: process.env.ICELANDAIR_API_KEY,
[Airlines.ernir]: process.env.ERNIR_API_KEY,
[Airlines.norlandair]: process.env.NORLANDAIR_API_KEY,
[Airlines.myflug]: process.env.MYFLUG_API_KEY,
thordurhhh marked this conversation as resolved.
Show resolved Hide resolved
},
redis: {
urls: [process.env.REDIS_URL_NODE_01!],
Expand Down
4 changes: 4 additions & 0 deletions apps/air-discount-scheme/web/screens/Admin/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export const airlineOptions = [
label: 'Icelandair',
value: Airlines.icelandair,
},
{
label: 'Mýflug',
value: Airlines.myflug,
},
{
label: 'Norlandair',
value: Airlines.norlandair,
Expand Down
1 change: 1 addition & 0 deletions charts/islandis/values.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ air-discount-scheme-backend:
ERNIR_API_KEY: '/k8s/air-discount-scheme/backend/ERNIR_API_KEY'
ICELANDAIR_API_KEY: '/k8s/air-discount-scheme/backend/ICELANDAIR_API_KEY'
IDENTITY_SERVER_CLIENT_SECRET: '/k8s/air-discount-scheme-backend/VEGAGERDIN_IDS_CLIENTS_ADS_SECRET'
MYFLUG_API_KEY: '/k8s/air-discount-scheme/backend/MYFLUG_API_KEY'
NATIONAL_REGISTRY_PASSWORD: '/k8s/air-discount-scheme/backend/NATIONAL_REGISTRY_PASSWORD'
NATIONAL_REGISTRY_URL: '/k8s/air-discount-scheme/backend/NATIONAL_REGISTRY_URL'
NATIONAL_REGISTRY_USERNAME: '/k8s/air-discount-scheme/backend/NATIONAL_REGISTRY_USERNAME'
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 @@ -177,6 +177,7 @@ air-discount-scheme-backend:
ERNIR_API_KEY: '/k8s/air-discount-scheme/backend/ERNIR_API_KEY'
ICELANDAIR_API_KEY: '/k8s/air-discount-scheme/backend/ICELANDAIR_API_KEY'
IDENTITY_SERVER_CLIENT_SECRET: '/k8s/air-discount-scheme-backend/VEGAGERDIN_IDS_CLIENTS_ADS_SECRET'
MYFLUG_API_KEY: '/k8s/air-discount-scheme/backend/MYFLUG_API_KEY'
NATIONAL_REGISTRY_PASSWORD: '/k8s/air-discount-scheme/backend/NATIONAL_REGISTRY_PASSWORD'
NATIONAL_REGISTRY_URL: '/k8s/air-discount-scheme/backend/NATIONAL_REGISTRY_URL'
NATIONAL_REGISTRY_USERNAME: '/k8s/air-discount-scheme/backend/NATIONAL_REGISTRY_USERNAME'
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 @@ -185,6 +185,7 @@ air-discount-scheme-backend:
ERNIR_API_KEY: '/k8s/air-discount-scheme/backend/ERNIR_API_KEY'
ICELANDAIR_API_KEY: '/k8s/air-discount-scheme/backend/ICELANDAIR_API_KEY'
IDENTITY_SERVER_CLIENT_SECRET: '/k8s/air-discount-scheme-backend/VEGAGERDIN_IDS_CLIENTS_ADS_SECRET'
MYFLUG_API_KEY: '/k8s/air-discount-scheme/backend/MYFLUG_API_KEY'
NATIONAL_REGISTRY_PASSWORD: '/k8s/air-discount-scheme/backend/NATIONAL_REGISTRY_PASSWORD'
NATIONAL_REGISTRY_URL: '/k8s/air-discount-scheme/backend/NATIONAL_REGISTRY_URL'
NATIONAL_REGISTRY_USERNAME: '/k8s/air-discount-scheme/backend/NATIONAL_REGISTRY_USERNAME'
Expand Down
1 change: 1 addition & 0 deletions libs/air-discount-scheme/consts/src/lib/flight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export const Airlines = {
ernir: 'ernir',
icelandair: 'icelandair',
norlandair: 'norlandair',
myflug: 'myflug',
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export const airlineOptions = [
label: 'Icelandair',
value: Airlines.icelandair,
},
{
label: 'Mýflug',
value: Airlines.myflug,
},
{
label: 'Norlandair',
value: Airlines.norlandair,
Expand Down
4 changes: 4 additions & 0 deletions libs/service-portal/air-discount/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export const messages = defineMessages({
id: 'sp.air-discount:copy-code',
defaultMessage: 'Afrita kóða',
},
codeGenFailed: {
id: 'sp.air-discount:code-generation-fail',
defaultMessage: 'Ekki tókst að útbúa kóða',
},
copied: {
id: 'sp.air-discount:copied',
defaultMessage: 'Afritað',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ export const AirDiscountOverview = () => {
? undefined
: item.discountCode
? item.discountCode
: '0'
: formatMessage(m.codeGenFailed)
}
cta={{
label: formatMessage(m.copyCode),
onClick: () => copy(item.discountCode),
centered: true,
icon: isCopied ? 'checkmark' : 'copy',
hide: item.user.fund?.credit === 0,
hide: item.user.fund?.credit === 0 || !item.discountCode,
}}
/>
)
Expand Down
Loading