@@ -907,4 +907,47 @@ describe('assistant-v1', function() {
907907 assert . equal ( req . method , 'POST' ) ;
908908 } ) ;
909909 } ) ;
910+
911+ describe ( 'credentials()' , function ( ) {
912+ it ( 'should load its credentials from bluemix (conversation)' , function ( ) {
913+ process . env . VCAP_SERVICES = JSON . stringify ( {
914+ conversation : [
915+ {
916+ credentials : {
917+ url : 'https://gateway.watsonplatform.net/assistant/api' ,
918+ username : 'hyphenated-user' ,
919+ password : 'hpyhenated-pass' ,
920+ } ,
921+ } ,
922+ ] ,
923+ } ) ;
924+ const assistant = new watson . AssistantV1 ( {
925+ version : '2018-02-16' ,
926+ } ) ;
927+ assert ( assistant ) ;
928+ assert . equal ( assistant . getCredentials ( ) . username , 'hyphenated-user' ) ;
929+ } ) ;
930+
931+ it ( 'should load its credentials from environment (conversation)' , function ( ) {
932+ process . env . CONVERSATION_USERNAME = 'user' ;
933+ process . env . CONVERSATION_PASSWORD = 'password' ;
934+ process . env . CONVERSATION_URL = 'https://gateway.watsonplatform.net/assistant/api' ;
935+ const assistant = new watson . AssistantV1 ( {
936+ version : '2018-02-16' ,
937+ } ) ;
938+ assert ( assistant ) ;
939+ assert . equal ( assistant . getCredentials ( ) . username , 'user' ) ;
940+ } ) ;
941+
942+ it ( 'should load its credentials from environment (assistant)' , function ( ) {
943+ process . env . ASSISTANT_USERNAME = 'user' ;
944+ process . env . ASSISTANT_PASSWORD = 'password' ;
945+ process . env . ASSISTANT_URL = 'https://gateway.watsonplatform.net/assistant/api' ;
946+ const assistant = new watson . AssistantV1 ( {
947+ version : '2018-02-16' ,
948+ } ) ;
949+ assert ( assistant ) ;
950+ assert . equal ( assistant . getCredentials ( ) . username , 'user' ) ;
951+ } ) ;
952+ } ) ;
910953} ) ;
0 commit comments