From 50a7039f52f84ec5432f9f56af0b03832e7c3c15 Mon Sep 17 00:00:00 2001 From: meltingice Date: Sun, 8 May 2011 23:17:24 -0400 Subject: [PATCH] Added signature test for OAuthEcho --- tests/oauth.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/oauth.js b/tests/oauth.js index 9cb38c92..6a00bfb2 100644 --- a/tests/oauth.js +++ b/tests/oauth.js @@ -1,7 +1,8 @@ var vows = require('vows'), assert = require('assert'), events = require('events'), - OAuth= require('../lib/oauth').OAuth; + OAuth= require('../lib/oauth').OAuth, + OAuthEcho= require('../lib/oauth').OAuthEcho; vows.describe('OAuth').addBatch({ 'When generating the signature base string described in http://oauth.net/core/1.0/#sig_base_example': { @@ -124,6 +125,19 @@ vows.describe('OAuth').addBatch({ assert.equal( oa.authHeader("http://somehost.com:3323/foo/poop?bar=foo", "token", "tokensecret"), 'OAuth oauth_consumer_key="consumerkey",oauth_nonce="ybHPeOEkAUJ3k2wJT9Xb43MjtSgTvKqp",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1272399856",oauth_token="token",oauth_version="1.0",oauth_signature="zeOR0Wsm6EG6XSg0Vw%2FsbpoSib8%3D"'); } }, + 'When get the OAuth Echo authorization header': { + topic: function () { + var realm = "http://foobar.com/"; + var verifyCredentials = "http://api.foobar.com/verify.json"; + var oa = new OAuthEcho(realm, verifyCredentials, "consumerkey", "consumersecret", "1.0A", "HMAC-SHA1"); + oa._getTimestamp= function(){ return "1272399856"; } + oa._getNonce= function(){ return "ybHPeOEkAUJ3k2wJT9Xb43MjtSgTvKqp"; } + return oa; + }, + 'Provide a valid signature when a token and token secret is present': function (oa) { + assert.equal( oa.authHeader("http://somehost.com:3323/foo/poop?bar=foo", "token", "tokensecret"), 'OAuth realm="http://foobar.com/",oauth_consumer_key="consumerkey",oauth_nonce="ybHPeOEkAUJ3k2wJT9Xb43MjtSgTvKqp",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1272399856",oauth_token="token",oauth_version="1.0A",oauth_signature="0rr1LhSxACX2IEWRq3uCb4IwtOs%3D"'); + } + }, 'When non standard ports are used': { topic: function() { var oa= new OAuth(null, null, null, null, null, null, "HMAC-SHA1"),