-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: share service request wrapper instance with token managers (#36)
this will allow users to configure all requests, rather than just the service requests this was causing a bug where users could not use the SDK behind a corporate proxy
- Loading branch information
Showing
5 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
const util = require('util'); | ||
const BaseService = require('../../lib/base_service').BaseService; | ||
|
||
function TestService(options) { | ||
BaseService.call(this, options); | ||
} | ||
|
||
util.inherits(TestService, BaseService); | ||
|
||
TestService.prototype.name = 'test'; | ||
TestService.prototype.version = 'v1'; | ||
|
||
TestService.URL = 'https://gateway.watsonplatform.net/test/api'; | ||
|
||
/* | ||
* Test the way the BaseService interacts with other modules | ||
*/ | ||
describe('Base service - token manager - integration', function() { | ||
it('should propagate request properties to token managers', function() { | ||
const hostname = 'jabba.the.hutt'; | ||
const port = 'mos eisley'; | ||
|
||
const instance = new TestService({ | ||
iam_apikey: 'r2-d2', | ||
proxy: { | ||
hostname, | ||
port, | ||
}, | ||
}); | ||
|
||
expect(instance.tokenManager).toBeDefined(); | ||
|
||
const axiosOptions = instance.tokenManager.requestWrapperInstance.axiosInstance.defaults; | ||
expect(axiosOptions.proxy.hostname).toBe(hostname); | ||
expect(axiosOptions.proxy.port).toBe(port); | ||
}); | ||
}); |