Skip to content

Commit

Permalink
Merge pull request #22 from mamoonraja/fix-kube
Browse files Browse the repository at this point in the history
fix(kube): returm apikey as iam_apikey
  • Loading branch information
germanattanasio committed Nov 7, 2018
2 parents 96b7d1a + 2a21144 commit 4edacc5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ const getCredentialsForStarter = function(serviceLabel, credsFromFile) {
}
else if (process.env[`service_watson_${serviceLabel}`]){
creds = JSON.parse(process.env[`service_watson_${serviceLabel}`]);
if (creds.apikey) {
creds.iam_apikey = creds.apikey;
delete creds.apikey;
}
}
return creds;
}
Expand Down
23 changes: 20 additions & 3 deletions test/test.parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,26 @@ describe('credentials file and Kube', function() {
});


it('should get the credentials for Starter from Kube', function() {
process.env.service_watson_conversation = JSON.stringify(cloudCredentials);
assert.deepEqual(cloudCredentials, vcapServices.getCredentialsForStarter('conversation'));
it('should get the IAM credentials for Starter from Kube', function() {
var kubeCredentials = {
apikey: 'apikey',
url: 'url'
};
var expectedCredentials = {
iam_apikey: 'apikey',
url: 'url'
};
process.env.service_watson_discovery = JSON.stringify(kubeCredentials);
assert.deepEqual(expectedCredentials, vcapServices.getCredentialsForStarter('discovery'));
});

it('should get the CF credentials for Starter from Kube', function() {
var kubeCredentials = {
username: 'username',
password: 'password'
};
process.env.service_watson_discovery = JSON.stringify(kubeCredentials);
assert.deepEqual(kubeCredentials, vcapServices.getCredentialsForStarter('discovery'));
});

it('should get the credentials for Starter from file', function() {
Expand Down

0 comments on commit 4edacc5

Please sign in to comment.