From f1e641633608deea27c06a33941707f896016d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rune=20Moskvil=20Lyng=C3=A5s?= Date: Wed, 28 Apr 2021 11:28:17 +0200 Subject: [PATCH 1/4] Updated webservice url --- test/data/options.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/data/options.json b/test/data/options.json index 2e30e05..aad4acd 100644 --- a/test/data/options.json +++ b/test/data/options.json @@ -1,6 +1,6 @@ { "config": { - "url": "http://ws-test.infotorg.no/xml/ErgoGroup/DetSentraleFolkeregister1_4/2011-09-26/DetSentraleFolkeregister1_4.wsdl", + "url": "http://ws-test.infotorg.no/xml/ErgoGroup/DetSentraleFolkeregister1_4/2015-08-10/DetSentraleFolkeregister1_4.wsdl", "namespaceBrukersesjon": "http://ws.infotorg.no/xml/Admin/Brukersesjon/2006-07-07/Brukersesjon.xsd", "distribusjonskanal": "PTP", "systemnavn": "Systemnavn", From 130af808979e81f74e329f603d9d8cbc9d1016d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rune=20Moskvil=20Lyng=C3=A5s?= Date: Wed, 28 Apr 2021 11:28:42 +0200 Subject: [PATCH 2/4] Added foedselsdato --- test/data/options.json | 1 + 1 file changed, 1 insertion(+) diff --git a/test/data/options.json b/test/data/options.json index aad4acd..0e0cb43 100644 --- a/test/data/options.json +++ b/test/data/options.json @@ -11,6 +11,7 @@ "query": { "saksref": "your-reference", "foedselsnr": "27105500837", + "foedselsdato": "271055", "etternavn": "AMOR", "fornavn": "SIV" } From 58b1b13d51999bb622e3deeff9a04e9e867c3624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rune=20Moskvil=20Lyng=C3=A5s?= Date: Wed, 28 Apr 2021 11:31:04 +0200 Subject: [PATCH 3/4] Require either foedselsnr or foedselsdato --- README.md | 6 ++++-- lib/dsf.js | 4 ++-- test/lib/node-dsf-promise-test.js | 15 ++++++++++++--- test/lib/node-dsf-test.js | 16 +++++++++++++--- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3217fdb..9317db9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ const config = { const method = 'hentDetaljer' // See supported methods const query = { saksref: 'your-reference', - foedselsnr: '26118633333', + foedselsnr: '26118633333', // requires this or foedselsdato + foedselsdato: '261186', // requires this or foedselsnr etternavn: 'Enge', fornavn: 'Jonas' } @@ -64,7 +65,8 @@ const config = { const method = 'hentDetaljer' // See supported methods const query = { saksref: 'your-reference', - foedselsnr: '26118633333', + foedselsnr: '26118633333', // requires this or foedselsdato + foedselsdato: '261186', // requires this or foedselsnr etternavn: 'Enge', fornavn: 'Jonas' } diff --git a/lib/dsf.js b/lib/dsf.js index 30b1b84..7e2d38b 100644 --- a/lib/dsf.js +++ b/lib/dsf.js @@ -35,8 +35,8 @@ module.exports = options => { if (!options.query.saksref) { throw Error('Missing required input: options.query.saksref') } - if (!options.query.foedselsnr) { - throw Error('Missing required input: options.query.foedselsnr') + if (!options.query.foedselsnr && !options.query.foedselsdato) { + throw Error('Missing one of the required inputs: options.query.foedselsnr || options.query.foedselsdato') } if (options.query.etternavn && !options.query.fornavn) { throw Error('Missing required input: options.query.fornavn') diff --git a/test/lib/node-dsf-promise-test.js b/test/lib/node-dsf-promise-test.js index a15b4d0..8df771a 100644 --- a/test/lib/node-dsf-promise-test.js +++ b/test/lib/node-dsf-promise-test.js @@ -100,10 +100,19 @@ test('requires param options.query.saksref to exist', t => { }) }) -test('requires param options.query.foedselsnr to exist', t => { +test('requires param options.query.foedselsnr to exist if options.query.foedselsdato is not supplied', t => { const options = JSON.parse(JSON.stringify(masterOptions)) - const expectedErrorMessage = 'Missing required input: options.query.foedselsnr' - options.query.foedselsnr = false + const expectedErrorMessage = 'Missing one of the required inputs: options.query.foedselsnr || options.query.foedselsdato' + delete options.query.foedselsdato + return dsf(options).catch(error => { + t.deepEqual(error.message, expectedErrorMessage, expectedErrorMessage) + }) +}) + +test('requires param options.query.foedselsdato to exist if options.query.foedselsnr is not supplied', t => { + const options = JSON.parse(JSON.stringify(masterOptions)) + const expectedErrorMessage = 'Missing one of the required inputs: options.query.foedselsnr || options.query.foedselsdato' + delete options.query.foedselsnr return dsf(options).catch(error => { t.deepEqual(error.message, expectedErrorMessage, expectedErrorMessage) }) diff --git a/test/lib/node-dsf-test.js b/test/lib/node-dsf-test.js index 81b795c..83b2692 100644 --- a/test/lib/node-dsf-test.js +++ b/test/lib/node-dsf-test.js @@ -111,10 +111,20 @@ test.cb('requires param options.query.saksref to exist', t => { }) }) -test.cb('requires param options.query.foedselsnr to exist', t => { +test.cb('requires param options.query.foedselsnr to exist if options.query.foedselsdato is not supplied', t => { const options = JSON.parse(JSON.stringify(masterOptions)) - const expectedErrorMessage = 'Missing required input: options.query.foedselsnr' - options.query.foedselsnr = false + const expectedErrorMessage = 'Missing one of the required inputs: options.query.foedselsnr || options.query.foedselsdato' + delete options.query.foedselsdato + dsf(options, (error, data) => { + t.deepEqual(error.message, expectedErrorMessage, expectedErrorMessage) + t.end() + }) +}) + +test.cb('requires param options.query.foedselsdato to exist if options.query.foedselsnr is not supplied', t => { + const options = JSON.parse(JSON.stringify(masterOptions)) + const expectedErrorMessage = 'Missing one of the required inputs: options.query.foedselsnr || options.query.foedselsdato' + delete options.query.foedselsnr dsf(options, (error, data) => { t.deepEqual(error.message, expectedErrorMessage, expectedErrorMessage) t.end() From 2ee247f59dfa7b7b6a35b224f6cf0a6ee26784f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rune=20Moskvil=20Lyng=C3=A5s?= Date: Wed, 28 Apr 2021 15:14:52 +0200 Subject: [PATCH 4/4] Added 'foedselsdato' to test --- tst.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tst.js b/tst.js index 271346d..32292c5 100644 --- a/tst.js +++ b/tst.js @@ -12,7 +12,8 @@ const config = { const method = 'hentDetaljer' const query = { saksref: 'your-reference', - foedselsnr: '01010750160', + foedselsnr: '01010750160', // comment out the one not needed + foedselsdato: "010107", // comment out the one not needed etternavn: 'TOPSTAD', fornavn: 'TOMAS' }