fixed issue #64 w/ tests
This commit is contained in:
		| @ -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 ) { | ||||
|  | ||||
| @ -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) { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user