Skip to content

Commit

Permalink
fix: digidLevel should be a string
Browse files Browse the repository at this point in the history
  • Loading branch information
marnixdessing committed Mar 31, 2023
1 parent e2c85d2 commit 1ca1ba0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
26 changes: 26 additions & 0 deletions src/app/code/DigiDLoa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,30 @@ export function loaToNumber(loa: DigidLoa) {
default:
return 0;
}
}


/**
* Given a DigiD LOA, proved a value that can be used to issue
* the Yivi DigiDLevel attribute.
* From the old issue app (https://github.com/GemeenteNijmegen/irma-brp-opladen) we know that
* there are 4 valid values:
* - 10 = Basis
* - 20 = Midden
* - 25 = Substantieel
* - 30 = Hoog
*/
export function loaToString(loa: DigidLoa) {
switch (loa) {
case DigidLoa.Hoog:
return 'Hoog';
case DigidLoa.Substantieel:
return 'Substantieel';
case DigidLoa.Midden:
return 'Midden';
case DigidLoa.Basis:
return 'Basis';
default:
return '';
}
}
4 changes: 2 additions & 2 deletions src/app/code/YiviApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AWS } from '@gemeentenijmegen/utils';
import { aws4Interceptor } from 'aws4-axios';
import axios, { Axios } from 'axios';
import { DigidLoa, loaToNumber } from './DigiDLoa';
import { DigidLoa, loaToString } from './DigiDLoa';

export class YiviApi {

Expand Down Expand Up @@ -154,7 +154,7 @@ export class YiviApi {
cityofbirth: gegevens.Geboorteplaats,
countryofbirth: gegevens.Geboorteland,
bsn: brpData.Persoon.BSN.BSN,
digidlevel: `${loaToNumber(loa)}`,
digidlevel: `${loaToString(loa)}`,
...brpData.Persoon.ageLimits,
},
},
Expand Down
6 changes: 3 additions & 3 deletions test/other/YiviApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { YiviApi } from '../../src/app/code/YiviApi';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import { AWS } from '@gemeentenijmegen/utils';
import { DigidLoa, loaToNumber } from '../../src/app/code/DigiDLoa';
import { DigidLoa, loaToString } from '../../src/app/code/DigiDLoa';
import { TestUtils } from './TestUtils';

const axiosMock = new MockAdapter(axios);
Expand Down Expand Up @@ -89,7 +89,7 @@ test('Check if yivi api adds aws4-singature and irma-authorization header and ri
}

const data = JSON.parse(request.data);
const loa = `${loaToNumber(DigidLoa.Substantieel)}`;
const loa = `${loaToString(DigidLoa.Substantieel)}`;
expect(data?.credentials[1]?.attributes?.digidlevel).toBe(loa);
});

Expand Down Expand Up @@ -118,7 +118,7 @@ test('Mapping BRP data', () => {

// Check request buildup and LOA
expect(yiviRequest.type).toBe('issuing');
expect(yiviRequest.credentials[1].attributes.digidlevel).toBe(`${loaToNumber(DigidLoa.Midden)}`);
expect(yiviRequest.credentials[1].attributes.digidlevel).toBe(loaToString(DigidLoa.Midden));
expect(yiviRequest.credentials[0].credential).toBe('irma-demo.gemeente.address');
expect(yiviRequest.credentials[1].credential).toBe('irma-demo.gemeente.personalData');

Expand Down

0 comments on commit 1ca1ba0

Please sign in to comment.