Skip to content

Commit

Permalink
auth: use utf8 for hmac
Browse files Browse the repository at this point in the history
* Thanks to nodejs/node#5499 (comment) … it seems that crypto.….update() needs to take an encoding parameter.
* Add a test case for non-utf8 text in upload

Fixes: IBM-Cloud#34
  • Loading branch information
srl295 committed Aug 9, 2016
1 parent 9a9d9ac commit 407d1b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/gp-hmac.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ GaasHmac.prototype.apply = function(obj, authorizations) {
//var hmacBuffer = new Buffer(hmacText, this.ENC);

var hmacHash = crypto.createHmac(this.HMAC_SHA1_ALGORITHM, this.secretBuffer )
.update(hmacText)
.update(hmacText, 'utf8')
.digest('base64');
//if(this.VERBOSE) console.log('hmacHash = ' + hmacHash );
var hmacHeader = this.AUTH_SCHEME + ' ' + this.user + ':' + hmacHash;
Expand Down
3 changes: 2 additions & 1 deletion test/client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,8 @@ describe('gaasClient.bundle()', function() {
Q.ninvoke(proj, "create", {sourceLanguage: gaasTest.SOURCES[0], targetLanguages: [gaasTest.SOURCES[0],gaasTest.CYRILLIC]})
.then(function(resp) {
Q.ninvoke(proj, "uploadResourceStrings", {languageId: gaasTest.SOURCES[0], strings: {
hello: 'Hello, World!'
hello: 'Hello, World!',
"msgError": "—"
}})
.then(function(resp){ done(); }, done);
}, done);
Expand Down

0 comments on commit 407d1b3

Please sign in to comment.