File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,8 @@ function createServiceAPI(serviceName) {
64
64
65
65
// Get credentials from Bluemix
66
66
if ( options . use_vcap_services !== false ) {
67
- var credentials = vcapServices . getCredentials ( serviceName ) ;
67
+ var vcap_services_name = vrv3 ? 'watson_vision_combined' : serviceName ;
68
+ var credentials = vcapServices . getCredentials ( vcap_services_name ) ;
68
69
if ( credentials . username && credentials . password ) {
69
70
credentials . api_key = encodeBase64 ( credentials ) ;
70
71
}
Original file line number Diff line number Diff line change @@ -86,6 +86,41 @@ describe('visual_recognition', function() {
86
86
assert ( ( err instanceof Error ) && / p a r a m e t e r / . test ( err ) , 'Expected error to mention "parameter" but got "' + ( err && err . message || err ) + '"' ) ;
87
87
} ;
88
88
89
+ describe ( 'credentials' , function ( ) {
90
+ var env ;
91
+ before ( function ( ) {
92
+ env = process . env ;
93
+ process . env = {
94
+ VCAP_SERVICES : JSON . stringify ( {
95
+ "watson_vision_combined" : [
96
+ {
97
+ "name" : "Visual Recognition-mj" ,
98
+ "label" : "watson_vision_combined" ,
99
+ "plan" : "free" ,
100
+ "credentials" : {
101
+ "url" : "https://gateway-a.watsonplatform.net/visual-recognition/api" ,
102
+ "note" : "It may take up to 5 minutes for this key to become active" ,
103
+ "api_key" : "foo"
104
+ }
105
+ }
106
+ ]
107
+ } )
108
+ } ;
109
+ } ) ;
110
+ after ( function ( ) {
111
+ process . env = env ;
112
+ } ) ;
113
+
114
+ it ( 'should read credentials from cf/bluemix environment properties' , function ( ) {
115
+ var instance = watson . visual_recognition ( {
116
+ version : 'v3' ,
117
+ version_date : '2016-05-20'
118
+ } ) ;
119
+ assert ( instance . _options . qs . api_key , 'foo' ) ;
120
+ } ) ;
121
+ } ) ;
122
+
123
+
89
124
describe ( 'version_date' , function ( ) {
90
125
it ( 'should check no version_date provided' , function ( done ) {
91
126
try {
You can’t perform that action at this time.
0 commit comments