Commit 0d0b1e7d authored by Panagiotis Skarvelis's avatar Panagiotis Skarvelis
Browse files

allow overide of endpoint

parent 186180c2
......@@ -92,4 +92,14 @@ or an error message like:
019285930, 052704062, 076509078
##### * Notes
you have to ask KED for notificationCenter_v_0.95 documentation to get more info about the output and error fields.
\ No newline at end of file
you have to ask KED for notificationCenter_v_0.95 documentation to get more info about the output and error fields.
#### * known issues
KED advertises a wrong endpoint(!) for the `getNncIdentity` service on production WSDL. So, you have to use (override) the endpoint: `https://ked.gsis.gr/esb/notificationCenterElementsService`
You can do that by setting the `endpoint` property on the `overides` object.
```
const overides = {
endpoint: 'https://ked.gsis.gr/esb/notificationCenterElementsService',
}
```
......@@ -33,6 +33,7 @@ export declare type errorRecord = {
* @param {string} auditStoragePath - Path to the audit record storage
*/
export declare type Overides = {
endpoint?: string;
prod?: boolean;
auditInit?: AuditRecord;
auditStoragePath?: string;
......
......@@ -25,17 +25,18 @@ const config_json_1 = __importDefault(require("./config.json"));
* @returns AuditRecord | errorRecord
*/
const getIdentity = (afm, user, pass, overides) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b, _c, _d;
const prod = (_a = overides === null || overides === void 0 ? void 0 : overides.prod) !== null && _a !== void 0 ? _a : false;
const auditInit = (_b = overides === null || overides === void 0 ? void 0 : overides.auditInit) !== null && _b !== void 0 ? _b : {};
const auditStoragePath = (_c = overides === null || overides === void 0 ? void 0 : overides.auditStoragePath) !== null && _c !== void 0 ? _c : "/tmp";
const auditEngine = (_d = overides === null || overides === void 0 ? void 0 : overides.auditEngine) !== null && _d !== void 0 ? _d : new gsis_audit_record_db_1.FileEngine(auditStoragePath);
var _a, _b, _c, _d, _e;
const endpoint = (_a = overides === null || overides === void 0 ? void 0 : overides.endpoint) !== null && _a !== void 0 ? _a : "";
const prod = (_b = overides === null || overides === void 0 ? void 0 : overides.prod) !== null && _b !== void 0 ? _b : false;
const auditInit = (_c = overides === null || overides === void 0 ? void 0 : overides.auditInit) !== null && _c !== void 0 ? _c : {};
const auditStoragePath = (_d = overides === null || overides === void 0 ? void 0 : overides.auditStoragePath) !== null && _d !== void 0 ? _d : "/tmp";
const auditEngine = (_e = overides === null || overides === void 0 ? void 0 : overides.auditEngine) !== null && _e !== void 0 ? _e : new gsis_audit_record_db_1.FileEngine(auditStoragePath);
const wsdl = prod == true ? config_json_1.default.prod.wsdl : config_json_1.default.test.wsdl;
const auditRecord = yield (0, gsis_audit_record_db_1.generateAuditRecord)(auditInit, auditEngine);
if (!auditRecord)
throw new Error('Audit record is not initialized');
try {
const s = new soapClient_js_1.default(wsdl, user, pass, auditRecord);
const s = new soapClient_js_1.default(wsdl, user, pass, auditRecord, endpoint);
const Identity = yield s.getIdentity(afm);
return Object.assign(Object.assign({}, Identity), auditRecord);
}
......
......@@ -7,6 +7,7 @@ import { AuditRecord } from '@digigov-oss/gsis-audit-record-db';
* @param {string} username
* @param {string} password
* @param {AuditRecord} auditRecord
* @param {string} endpoint
*/
declare class Soap {
private _client;
......@@ -14,7 +15,8 @@ declare class Soap {
private _username;
private _password;
private _auditRecord;
constructor(wsdl: string, username: string, password: string, auditRecord: AuditRecord);
private _endpoint;
constructor(wsdl: string, username: string, password: string, auditRecord: AuditRecord, endpoint: string);
init(): Promise<any>;
getIdentity(vat: string): Promise<any>;
}
......
......@@ -31,13 +31,15 @@ catch (error) {
* @param {string} username
* @param {string} password
* @param {AuditRecord} auditRecord
* @param {string} endpoint
*/
class Soap {
constructor(wsdl, username, password, auditRecord) {
constructor(wsdl, username, password, auditRecord, endpoint) {
this._wsdl = wsdl;
this._username = username;
this._password = password;
this._auditRecord = auditRecord;
this._endpoint = endpoint;
}
init() {
return __awaiter(this, void 0, void 0, function* () {
......@@ -47,6 +49,9 @@ class Soap {
'Authorization': 'Basic ' + Buffer.from(`${this._username}:${this._password}`).toString('base64'),
},
});
if (this._endpoint) {
client.setEndpoint(this._endpoint);
}
this._client = client;
return client;
}
......
......@@ -33,6 +33,7 @@ export declare type errorRecord = {
* @param {string} auditStoragePath - Path to the audit record storage
*/
export declare type Overides = {
endpoint?: string;
prod?: boolean;
auditInit?: AuditRecord;
auditStoragePath?: string;
......
......@@ -10,6 +10,7 @@ import config from './config.json';
* @returns AuditRecord | errorRecord
*/
export const getIdentity = async (afm, user, pass, overides) => {
const endpoint = overides?.endpoint ?? "";
const prod = overides?.prod ?? false;
const auditInit = overides?.auditInit ?? {};
const auditStoragePath = overides?.auditStoragePath ?? "/tmp";
......@@ -19,7 +20,7 @@ export const getIdentity = async (afm, user, pass, overides) => {
if (!auditRecord)
throw new Error('Audit record is not initialized');
try {
const s = new soapClient(wsdl, user, pass, auditRecord);
const s = new soapClient(wsdl, user, pass, auditRecord, endpoint);
const Identity = await s.getIdentity(afm);
return { ...Identity, ...auditRecord };
}
......
......@@ -7,6 +7,7 @@ import { AuditRecord } from '@digigov-oss/gsis-audit-record-db';
* @param {string} username
* @param {string} password
* @param {AuditRecord} auditRecord
* @param {string} endpoint
*/
declare class Soap {
private _client;
......@@ -14,7 +15,8 @@ declare class Soap {
private _username;
private _password;
private _auditRecord;
constructor(wsdl: string, username: string, password: string, auditRecord: AuditRecord);
private _endpoint;
constructor(wsdl: string, username: string, password: string, auditRecord: AuditRecord, endpoint: string);
init(): Promise<any>;
getIdentity(vat: string): Promise<any>;
}
......
......@@ -17,6 +17,7 @@ catch (error) {
* @param {string} username
* @param {string} password
* @param {AuditRecord} auditRecord
* @param {string} endpoint
*/
class Soap {
_client;
......@@ -24,11 +25,13 @@ class Soap {
_username;
_password;
_auditRecord;
constructor(wsdl, username, password, auditRecord) {
_endpoint;
constructor(wsdl, username, password, auditRecord, endpoint) {
this._wsdl = wsdl;
this._username = username;
this._password = password;
this._auditRecord = auditRecord;
this._endpoint = endpoint;
}
async init() {
try {
......@@ -37,6 +40,9 @@ class Soap {
'Authorization': 'Basic ' + Buffer.from(`${this._username}:${this._password}`).toString('base64'),
},
});
if (this._endpoint) {
client.setEndpoint(this._endpoint);
}
this._client = client;
return client;
}
......
......@@ -39,6 +39,7 @@ export type errorRecord = {
* @param {string} auditStoragePath - Path to the audit record storage
*/
export type Overides = {
endpoint?:string;
prod?:boolean;
auditInit?: AuditRecord;
auditStoragePath?: string;
......@@ -56,6 +57,7 @@ export type Overides = {
* @returns AuditRecord | errorRecord
*/
export const getIdentity = async (afm:string, user:string, pass:string, overides?:Overides) => {
const endpoint = overides?.endpoint ?? "";
const prod = overides?.prod ?? false;
const auditInit = overides?.auditInit ?? {} as AuditRecord;
const auditStoragePath = overides?.auditStoragePath ?? "/tmp"
......@@ -65,7 +67,7 @@ export const getIdentity = async (afm:string, user:string, pass:string, overides
if (!auditRecord) throw new Error('Audit record is not initialized');
try {
const s = new soapClient(wsdl, user, pass, auditRecord);
const s = new soapClient(wsdl, user, pass, auditRecord,endpoint);
const Identity = await s.getIdentity(afm);
return {...Identity,...auditRecord};
} catch (error) {
......
......@@ -19,6 +19,7 @@ import {AuditRecord} from '@digigov-oss/gsis-audit-record-db';
* @param {string} username
* @param {string} password
* @param {AuditRecord} auditRecord
* @param {string} endpoint
*/
class Soap {
private _client: any;
......@@ -26,13 +27,15 @@ class Soap {
private _username: string;
private _password: string;
private _auditRecord: AuditRecord;
private _endpoint: string;
constructor(wsdl: string, username: string, password: string,auditRecord: AuditRecord) {
constructor(wsdl: string, username: string, password: string,auditRecord: AuditRecord, endpoint: string) {
this._wsdl = wsdl;
this._username = username;
this._password = password;
this._auditRecord = auditRecord;
this._endpoint = endpoint;
}
public async init() {
......@@ -42,7 +45,9 @@ class Soap {
'Authorization': 'Basic ' + Buffer.from(`${this._username}:${this._password}`).toString('base64'),
},
});
if (this._endpoint) {
client.setEndpoint(this._endpoint);
}
this._client = client;
return client;
} catch (e) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment