@everymundo/em-eureka
Advanced tools
Comparing version 1.10.2 to 1.10.3
@@ -40,4 +40,3 @@ /* eslint-disable no-console */ | ||
port, | ||
// eureka: {host:'10.0.1.145', port: 8761, servicePath: '/eureka/apps'}, | ||
eureka: {host:'127.0.0.1', port: 8080, servicePath: '/eureka/v2/apps'}, | ||
eureka: {host:'localhost', port: 8761, servicePath: '/eureka/apps'}, | ||
// dataCenterInfo, | ||
@@ -44,0 +43,0 @@ instanceId: `PRAETORIAN-SERVICE-V1:${port}`, |
/* eslint-disable no-console */ | ||
require('./simple-praetorian'); | ||
require('./bulk-ads-service'); | ||
@@ -39,6 +40,5 @@ const http = require('http'); | ||
port, | ||
// eureka: {host:'10.0.1.145', port: 8761, servicePath: '/eureka/apps'}, | ||
eureka: {host:'127.0.0.1', port: 8080, servicePath: '/eureka/v2/apps'}, | ||
eureka: {host:'localhost', port: 8761, servicePath: '/eureka/apps'}, | ||
// dataCenterInfo, | ||
instanceId: `simple-service-v1:${port}`, | ||
instanceId: 'simple-service-v1:000', | ||
// aws, | ||
@@ -45,0 +45,0 @@ })); |
@@ -178,3 +178,3 @@ 'use strict'; | ||
this.praetorianClient = this.service('praetorian-service-v1'); | ||
this.praetorianClient = this.service('praetorian-service-v2'); | ||
@@ -191,2 +191,5 @@ return this.praetorianClient; | ||
const accessToken = await praetorianHelper.requestAccessTokenToPraetorian(CLIENT_CODE, appTokenId, this.getPraetorianClient()); | ||
if (accessToken instanceof Error) { | ||
return accessToken; | ||
} | ||
const expiresInMs = praetorianHelper.getExpirationTime(accessToken); | ||
@@ -300,2 +303,4 @@ | ||
getOnRequestStartFunction, | ||
parseServers, | ||
parseServicePath, | ||
}; |
@@ -11,3 +11,7 @@ 'use strict'; | ||
const body = JSON.parse(response.body); | ||
console.log(body); | ||
return body.accessToken.toString(); | ||
}).catch((error) => { | ||
console.log(`${error.status}: ${error.message}`); | ||
return new Error(`Praetorian call failed status: ${error.status}, check server logs`); | ||
}); | ||
@@ -14,0 +18,0 @@ |
{ | ||
"name": "@everymundo/em-eureka", | ||
"version": "1.10.2", | ||
"version": "1.10.3", | ||
"description": "wrapper around eureka-js-client for everymundo microservice apps", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -192,2 +192,18 @@ 'require strict'; | ||
}); | ||
context('Token invalid', () => { | ||
beforeEach(() => { | ||
box.stub(praetorianHelper, 'requestAccessTokenToPraetorian').returns(new Error()); | ||
box.stub(eurekaJsClient, 'Eureka').value(FakeEureka); | ||
}); | ||
it('should return an Error', async () => { | ||
setServersCalled = sinon.spy(() => {}); | ||
const { createClient } = cleanrequire('../index'); | ||
const client = createClient({ app: 'invalid', port: 80 }, false); | ||
const appName = 'randomApp'; | ||
const res = await client.app(appName); | ||
expect(res).to.be.an.instanceOf(Error); | ||
}); | ||
}); | ||
}); | ||
@@ -221,2 +237,59 @@ | ||
context('#parseServers', () => { | ||
it('should parse servers from array of service Urls', () => { | ||
const lib = cleanrequire('../index'); | ||
const serviceUrls = { | ||
default: [ | ||
'http://us-west-1a.eureka.test.com:1000/eureka', | ||
'http://us-west-1a.eureka.test.com:1001/eureka', | ||
], | ||
}; | ||
const expected = ['http://us-west-1a.eureka.test.com:1000', 'http://us-west-1a.eureka.test.com:1001']; | ||
const res = lib.parseServers(serviceUrls.default); | ||
expect(res).to.deep.equal(expected); | ||
}); | ||
it('should parse servers from one service Url', () => { | ||
const lib = cleanrequire('../index'); | ||
const serviceUrls = { | ||
default: 'http://us-west-1a.eureka.test.com:1000/eureka', | ||
}; | ||
const expected = 'http://us-west-1a.eureka.test.com:1000'; | ||
const res = lib.parseServers(serviceUrls.default); | ||
expect(res).to.deep.equal(expected); | ||
}); | ||
}); | ||
context('#parseServicePath', () => { | ||
it('should parse servicePath from array of serviceUrl', () => { | ||
const lib = cleanrequire('../index'); | ||
const serviceUrls = { | ||
default: [ | ||
'http://us-west-1a.eureka.test.com:1000/eureka', | ||
], | ||
}; | ||
const expected = '/eureka'; | ||
const res = lib.parseServicePath(serviceUrls.default); | ||
expect(res).to.deep.equal(expected); | ||
}); | ||
it('should parse servicePath from one serviceUrl', () => { | ||
const lib = cleanrequire('../index'); | ||
const serviceUrls = { | ||
default: 'http://us-west-1a.eureka.test.com:1000/eureka', | ||
}; | ||
const expected = '/eureka'; | ||
const res = lib.parseServicePath(serviceUrls.default); | ||
expect(res).to.deep.equal(expected); | ||
}); | ||
}); | ||
context('#getPraetorianClient', () => { | ||
@@ -229,3 +302,3 @@ it('should return call service with the proper name', () => { | ||
const res = eurekaJsClient.Eureka.prototype.getPraetorianClient.call(me); | ||
const expected = {name: 'praetorian-service-v1'}; | ||
const expected = {name: 'praetorian-service-v2'}; | ||
@@ -232,0 +305,0 @@ expect(res).to.deep.equal(expected); |
@@ -49,3 +49,3 @@ 'require strict'; | ||
const praetorianClient = {get: () => {} }; | ||
const expectedError = new Error('Error happened'); | ||
const expectedError = new Error('Praetorian call failed status: 1004, check server logs'); | ||
box.stub(praetorianClient, 'get').callsFake(() => new Promise((resolve, reject) => reject(expectedError))); | ||
@@ -52,0 +52,0 @@ const { requestAccessTokenToPraetorian } = require('../lib/intercept-token.js'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77322
1696
14
5