Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed issue #64 w/ tests

  • Loading branch information...
commit d8d1e0bad7f70bed788788f2e538be3008d46654 1 parent 03a82b3
Joe Rozner authored
Showing with 11 additions and 2 deletions.
  1. +2 −2 lib/oauth.js
  2. +9 −0 tests/oauth.js
View
4 lib/oauth.js
@@ -189,11 +189,11 @@ exports.OAuth.prototype._createSignature= function(signatureBase, tokenSecret) {
if( tokenSecret === undefined ) var tokenSecret= "";
else tokenSecret= this._encodeData( tokenSecret );
// consumerSecret is already encoded
- var key= this._consumerSecret + "&" + tokenSecret;
+ var key= this._encodeData(this._consumerSecret) + "&" + this._encodeData(tokenSecret);
var hash= ""
if( this._signatureMethod == "PLAINTEXT" ) {
- hash= this._encodeData(key);
+ hash= key;
}
else {
if( crypto.Hmac ) {
View
9 tests/oauth.js
@@ -32,6 +32,15 @@ vows.describe('OAuth').addBatch({
assert.equal( result, "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal");
}
},
+ 'When generating the signature base string with PLAINTEXT': {
+ topic: new OAuth(null, null, null, null, null, null, "PLAINTEXT"),
+ 'we get the expected result string': function (oa) {
+ var result= oa._getSignature("GET", "http://photos.example.net/photos",
+ "file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=PLAINTEXT&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original",
+ "test");
+ assert.equal( result, "&test");
+ }
+ },
'When normalising a url': {
topic: new OAuth(null, null, null, null, null, null, "HMAC-SHA1"),
'default ports should be stripped': function(oa) {
Please sign in to comment.
Something went wrong with that request. Please try again.