Skip to content

Commit

Permalink
Merge pull request #17 from BRP-API/chore/sync-met-source-repo_50819ae
Browse files Browse the repository at this point in the history
sync met 'BRP-API/brp-shared-dotnet' repo
  • Loading branch information
MelvLee authored Aug 22, 2024
2 parents 12b132c + b5b275d commit 48a2825
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 44 deletions.
23 changes: 10 additions & 13 deletions features/step_definitions/als-stepdefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ const { executeSqlStatements } = require('./postgresqlHelpers');
const { addDefaultAutorisatieSettings,
handleRequest } = require('./requestHelpers');

const apiEndpointPrefixMap = new Map([
['bewoningen', 'bewoning'],
['personen', 'brp'],
['reisdocumenten', 'reisdocumenten'],
['verblijfplaatshistorie', 'brphistorie'],
// niet bestaande endpoints
['ingezetenen', 'brp'],
['paspoorten', 'reisdocumenten'],
['verblijfhistorie', 'brphistorie']
]);

When(/^([a-zA-Z-]*) wordt gezocht met de volgende parameters$/, async function (endpoint, dataTable) {
if(this.context.afnemerID === undefined) {
this.context.afnemerID = this.context.oAuth.clients[0].afnemerID;
Expand All @@ -40,13 +29,21 @@ When(/^([a-zA-Z-]*) wordt gezocht met de volgende parameters$/, async function (

await executeSqlStatements(this.context.sql, this.context.sqlData, global.pool);

await handleRequest(this.context, `${apiEndpointPrefixMap.get(endpoint)}/${endpoint}`, dataTable);
const relativeUrl = this.context.apiEndpointPrefixMap.has(endpoint)
? `${this.context.apiEndpointPrefixMap.get(endpoint)}/${endpoint}`
: '';

await handleRequest(this.context, relativeUrl, dataTable);
});

When(/^([a-zA-Z-]*) wordt gezocht met een '(\w*)' aanroep$/, async function (endpoint, httpMethod) {
if(this.context.afnemerID === undefined) {
this.context.afnemerID = this.context.oAuth.clients[0].afnemerID;
}

await handleRequest(this.context, `${apiEndpointPrefixMap.get(endpoint)}/${endpoint}`, undefined, httpMethod);
const relativeUrl = this.context.apiEndpointPrefixMap.has(endpoint)
? `${this.context.apiEndpointPrefixMap.get(endpoint)}/${endpoint}`
: '';

await handleRequest(this.context, relativeUrl, undefined, httpMethod);
});
28 changes: 0 additions & 28 deletions features/step_definitions/stepdefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,10 @@ Before(function({ pickle }) {
const array = fs.readFileSync(this.context.logFileToAssert).toString().split("\n");
this.context.nrOfLogLines = array.length;
}
});

Before({tags: '@api'}, function() {
global.logger.debug('api scope. set baseUrl to apiUrl');
this.context.baseUrl = this.context.apiUrl;
});

Before({tags: '@proxy'}, function() {
global.logger.debug('proxy scope. set baseUrl to proxyUrl');
this.context.baseUrl = this.context.proxyUrl;
});

Before({tags: '@mock'}, function() {
global.logger.debug('mock scope. set baseUrl to mockUrl');
this.context.baseUrl = this.context.mockUrl;
});

Before({tags: '@input-validatie'}, function() {
global.logger.debug('input-validatie scope. set baseUrl to autzUrl');
this.context.baseUrl = this.context.autzUrl;
});

Before({tags: '@autorisatie'}, function() {
global.logger.debug('autorisatie scope. set baseUrl to autzUrl');
this.context.baseUrl = this.context.autzUrl;
});

Before({tags: '@protocollering'}, function() {
global.logger.debug('protocollering scope. set baseUrl to autzUrl');
this.context.baseUrl = this.context.autzUrl;
});

After(async function({ pickle }) {
if(pickle.tags.map((t) => t.name).includes('@stap-documentatie')) {
return;
Expand Down
18 changes: 15 additions & 3 deletions features/step_definitions/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,21 @@ class World {
constructor(parameters) {
this.context = parameters;

this.context.autzUrl = 'http://localhost:8080/haalcentraal/api'
this.context.apiUrl = 'http://localhost:8000/haalcentraal/api'
this.context.proxyUrl = 'http://localhost:5002/haalcentraal/api'
this.context.apiUrl = 'http://localhost:8080/haalcentraal/api'

// wanneer een endpoint prefix mapping voorkomt, wordt bij de constructie van de endpoint url de prefix voor de resource naam gezet
// bijv. voor de personen resource wordt de endpoint url <apiUrl>/brp/personen
// als er geen endpoint prefix mapping voorkomt, wordt de apiUrl gebruikt als endpoint url
this.context.apiEndpointPrefixMap = new Map([
['bewoningen', 'bewoning'],
['personen', 'brp'],
['reisdocumenten', 'reisdocumenten'],
['verblijfplaatshistorie', 'brphistorie'],
// niet bestaande endpoints
['ingezetenen', 'brp'],
['paspoorten', 'reisdocumenten'],
['verblijfhistorie', 'brphistorie']
]);

this.context.gezagDataPath = './test-data/GezagMock/test-data.json';
this.context.logFileToAssert = './test-data/logs/brp-proxy.json';
Expand Down

0 comments on commit 48a2825

Please sign in to comment.