Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit 2cfabdb

Browse files
author
Chris Wiechmann
committed
Options logger was missing #76
1 parent da4ac7b commit 2cfabdb

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-axway-api-management/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async function getPlugin(pluginConfig, options) {
3434
}
3535
pluginConfig.apimanager = await parseAPIManagerConfig(pluginConfig, options);
3636
if(pluginConfig.validateConfig==true) {
37-
var isValid = await checkAPIManagers(pluginConfig.apimanager, options.logger);
37+
var isValid = await checkAPIManagers(pluginConfig.apimanager, options);
3838
if(!isValid) {
3939
throw new Error(`Error checking configured API-Manager(s). ${JSON.stringify(pluginConfig.apimanager)}`);
4040
} else {

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-axway-api-management/src/utils.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ function getManagerConfig(apiManagerConfig, groupId, region) {
167167
}
168168
}
169169

170-
async function checkAPIManagers(apiManagerConfig, logger) {
170+
async function checkAPIManagers(apiManagerConfig, options) {
171171
var finalResult = true;
172172
for (const [key, config] of Object.entries(apiManagerConfig)) {
173173
if(key == "perGroupAndRegion") continue;
174174
try {
175175
var data = `username=${config.username}&password=${config.password}`;
176-
var options = {
176+
var reqOptions = {
177177
path: `/api/portal/v1.3/login`,
178178
method: 'POST',
179179
headers: {
@@ -182,37 +182,37 @@ async function checkAPIManagers(apiManagerConfig, logger) {
182182
},
183183
agent: new https.Agent({ rejectUnauthorized: false })
184184
};
185-
const result = await sendRequest(config.url, options, data, 303)
185+
const result = await sendRequest(config.url, reqOptions, data, 303)
186186
.then(response => {
187187
return response;
188188
})
189189
.catch(err => {
190190
throw new Error(`Cannot login to API-Manager: '${config.url}'. Got error: ${err}`);
191191
});
192192
const session = _getSession(result.headers);
193-
var options = {
193+
var reqOptions = {
194194
path: `/api/portal/v1.3/currentuser`,
195195
headers: {
196196
'Cookie': `APIMANAGERSESSION=${session}`
197197
},
198198
agent: new https.Agent({ rejectUnauthorized: false })
199199
};
200-
const currentUser = await sendRequest(config.url, options)
200+
const currentUser = await sendRequest(config.url, reqOptions)
201201
.then(response => {
202202
return response;
203203
})
204204
.catch(err => {
205205
throw new Error(`Cant get current user: ${err}`);
206206
});
207207
if(currentUser.body.role!='admin') {
208-
logger.error(`User: ${currentUser.body.loginName} has no admin role on API-Manager: ${config.url}.`);
208+
options.logger.error(`User: ${currentUser.body.loginName} has no admin role on API-Manager: ${config.url}.`);
209209
config.isValid = false;
210210
finalResult = false;
211211
} else {
212212
config.isValid = true;
213213
}
214214
} catch (ex) {
215-
logger.error(ex);
215+
options.logger.error(ex);
216216
throw ex;
217217
}
218218
}

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-axway-api-management/test/testManagerConfigs.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ const simple = require('simple-mock');
44
const nock = require('nock');
55

66
describe('Test API-Manager configuration variations', () => {
7-
var logger = {
7+
var options = { logger: {
88
info: simple.mock(),
99
trace: simple.mock(),
10-
error: simple.mock()
11-
}
10+
error: simple.mock(),
11+
debug: simple.mock()
12+
} };
1213

1314
describe('Test API-Manager parsing', () => {
1415
it('should succeed with a single API-Manager configured', async () => {
16+
debugger;
1517
var pluginConfig = {
1618
apimanager: {
1719
url: "http://my.api-manager.com:8075",
@@ -24,7 +26,7 @@ describe('Test API-Manager configuration variations', () => {
2426
username: "user", password: "password"
2527
}
2628
}
27-
var configuredManagers = await parseAPIManagerConfig(pluginConfig, logger);
29+
var configuredManagers = await parseAPIManagerConfig(pluginConfig, options);
2830
expect(configuredManagers).to.deep.equal(expectedManagers);
2931
});
3032

@@ -41,7 +43,7 @@ describe('Test API-Manager configuration variations', () => {
4143
username: "user", password: "password"
4244
}
4345
}
44-
var configuredManagers = await parseAPIManagerConfig(pluginConfig, logger);
46+
var configuredManagers = await parseAPIManagerConfig(pluginConfig, options);
4547
expect(configuredManagers).to.deep.equal(expectedManagers);
4648
});
4749

@@ -63,7 +65,7 @@ describe('Test API-Manager configuration variations', () => {
6365
username: "user", password: "password"
6466
}
6567
}
66-
var configuredManagers = await parseAPIManagerConfig(pluginConfig, logger);
68+
var configuredManagers = await parseAPIManagerConfig(pluginConfig, options);
6769
expect(configuredManagers).to.deep.equal(expectedManagers);
6870
});
6971

@@ -89,7 +91,7 @@ describe('Test API-Manager configuration variations', () => {
8991
username: "user", password: "password"
9092
}
9193
}
92-
var configuredManagers = await parseAPIManagerConfig(pluginConfig, logger);
94+
var configuredManagers = await parseAPIManagerConfig(pluginConfig, options);
9395
expect(configuredManagers).to.deep.equal(expectedManagers);
9496
});
9597

@@ -111,7 +113,7 @@ describe('Test API-Manager configuration variations', () => {
111113
username: "user", password: "password"
112114
}
113115
}
114-
var configuredManagers = await parseAPIManagerConfig(pluginConfig, logger);
116+
var configuredManagers = await parseAPIManagerConfig(pluginConfig, options);
115117
expect(configuredManagers).to.deep.equal(expectedManagers);
116118
});
117119
});
@@ -131,7 +133,7 @@ describe('Test API-Manager configuration variations', () => {
131133
username: "user", password: "password"
132134
}
133135
}
134-
var result = await checkAPIManagers(configuredManagers, logger);
136+
var result = await checkAPIManagers(configuredManagers, options);
135137
expect(result).to.equal(true);
136138
expect(configuredManagers.default.isValid).to.equal(true);
137139
});
@@ -149,7 +151,7 @@ describe('Test API-Manager configuration variations', () => {
149151
username: "user", password: "password"
150152
}
151153
}
152-
var result = await checkAPIManagers(configuredManagers, logger);
154+
var result = await checkAPIManagers(configuredManagers, options);
153155
expect(result).to.equal(false);
154156
expect(configuredManagers.default.isValid).to.equal(false);
155157
});
@@ -175,7 +177,7 @@ describe('Test API-Manager configuration variations', () => {
175177
username: "user", password: "password"
176178
},
177179
}
178-
var result = await checkAPIManagers(configuredManagers, logger);
180+
var result = await checkAPIManagers(configuredManagers, options);
179181
expect(result).to.equal(true);
180182
expect(configuredManagers.default.isValid).to.equal(true);
181183
expect(configuredManagers.default.isValid).to.equal(true);
@@ -202,7 +204,7 @@ describe('Test API-Manager configuration variations', () => {
202204
username: "user", password: "password"
203205
},
204206
}
205-
var result = await checkAPIManagers(configuredManagers, logger);
207+
var result = await checkAPIManagers(configuredManagers, options);
206208
expect(result).to.equal(false);
207209
expect(configuredManagers.default.isValid).to.equal(true);
208210
expect(configuredManagers['group-a'].isValid).to.equal(false);

0 commit comments

Comments
 (0)