File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -43,13 +43,15 @@ export interface UserOptions {
4343 iam_access_token ?: string ;
4444 iam_apikey ?: string ;
4545 iam_url ?: string ;
46+ allow_unauthorized ?: boolean ;
4647}
4748
4849export interface BaseServiceOptions extends UserOptions {
4950 headers : HeaderOptions ;
5051 url : string ;
5152 jar ?: request . CookieJar ;
5253 qs : any ;
54+ rejectUnauthorized ?: boolean ;
5355}
5456
5557export interface Credentials {
@@ -149,6 +151,9 @@ export class BaseService {
149151 } else {
150152 this . tokenManager = null ;
151153 }
154+ // rejectUnauthorized should only be false if allow_unauthorized is true
155+ // used to disable ssl checking for icp
156+ this . _options . rejectUnauthorized = ! options . allow_unauthorized ;
152157 }
153158
154159 /**
Original file line number Diff line number Diff line change @@ -264,4 +264,30 @@ describe('BaseService', function() {
264264 assert . equal ( instance . tokenManager , null ) ;
265265 assert ( authHeader . startsWith ( 'Basic' ) ) ;
266266 } ) ;
267+
268+ it ( 'should set rejectUnauthorized to `false` if allow_unauthorized is `true`' , function ( ) {
269+ const instance = new TestService ( {
270+ username : 'apikey' ,
271+ password : 'icp-1234' ,
272+ allow_unauthorized : true ,
273+ } ) ;
274+ assert . equal ( instance . _options . rejectUnauthorized , false ) ;
275+ } ) ;
276+
277+ it ( 'should set rejectUnauthorized to `true` if allow_unauthorized is `false`' , function ( ) {
278+ const instance = new TestService ( {
279+ username : 'apikey' ,
280+ password : 'icp-1234' ,
281+ allow_unauthorized : false ,
282+ } ) ;
283+ assert ( instance . _options . rejectUnauthorized ) ;
284+ } ) ;
285+
286+ it ( 'should set rejectUnauthorized to `true` if allow_unauthorized is not set' , function ( ) {
287+ const instance = new TestService ( {
288+ username : 'apikey' ,
289+ password : 'icp-1234' ,
290+ } ) ;
291+ assert ( instance . _options . rejectUnauthorized ) ;
292+ } ) ;
267293} ) ;
You can’t perform that action at this time.
0 commit comments