Skip to content

Commit

Permalink
Merge pull request #2994 from dlecocq/oauth-sign-0.9.0
Browse files Browse the repository at this point in the history
Update to oauth-sign 0.9.0
  • Loading branch information
simov authored Aug 3, 2018
2 parents 10987ef + 628ff5e commit 5797963
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"isstream": "~0.1.2",
"json-stringify-safe": "~5.0.1",
"mime-types": "~2.1.17",
"oauth-sign": "~0.8.2",
"oauth-sign": "~0.9.0",
"performance-now": "^2.1.0",
"qs": "~6.5.1",
"safe-buffer": "^5.1.1",
Expand Down
48 changes: 48 additions & 0 deletions tests/test-oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ function getSignature (r) {
// Tests from Twitter documentation https://dev.twitter.com/docs/auth/oauth

var hmacsign = oauth.hmacsign
var hmacsign256 = oauth.hmacsign256
var rsasign = oauth.rsasign
var rsaPrivatePEM = fs.readFileSync(path.join(__dirname, 'ssl', 'test.key'))
var reqsign
var reqsign256
var reqsignRSA
var accsign
var accsign256
var accsignRSA
var upsign
var upsign256
var upsignRSA

tape('reqsign', function (t) {
Expand All @@ -44,6 +48,20 @@ tape('reqsign', function (t) {
t.end()
})

tape('reqsign256', function (t) {
reqsign256 = hmacsign256('POST', 'https://api.twitter.com/oauth/request_token',
{ oauth_callback: 'http://localhost:3005/the_dance/process_callback?service_provider_id=11',
oauth_consumer_key: 'GDdmIQH6jhtmLUypg82g',
oauth_nonce: 'QP70eNmVz8jvdPevU3oJD2AfF7R7odC2XJcn4XlZJqk',
oauth_signature_method: 'HMAC-SHA256',
oauth_timestamp: '1272323042',
oauth_version: '1.0'
}, 'MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98')

t.equal(reqsign256, 'N0KBpiPbuPIMx2B77eIg7tNfGNF81iq3bcO9RO6lH+k=')
t.end()
})

tape('reqsignRSA', function (t) {
reqsignRSA = rsasign('POST', 'https://api.twitter.com/oauth/request_token',
{ oauth_callback: 'http://localhost:3005/the_dance/process_callback?service_provider_id=11',
Expand Down Expand Up @@ -73,6 +91,21 @@ tape('accsign', function (t) {
t.end()
})

tape('accsign256', function (t) {
accsign256 = hmacsign256('POST', 'https://api.twitter.com/oauth/access_token',
{ oauth_consumer_key: 'GDdmIQH6jhtmLUypg82g',
oauth_nonce: '9zWH6qe0qG7Lc1telCn7FhUbLyVdjEaL3MO5uHxn8',
oauth_signature_method: 'HMAC-SHA256',
oauth_token: '8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc',
oauth_timestamp: '1272323047',
oauth_verifier: 'pDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY',
oauth_version: '1.0'
}, 'MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98', 'x6qpRnlEmW9JbQn4PQVVeVG8ZLPEx6A0TOebgwcuA')

t.equal(accsign256, 'y7S9eUhA0tC9/YfRzCPqkg3/bUdYRDpZ93Xi51AvhjQ=')
t.end()
})

tape('accsignRSA', function (t) {
accsignRSA = rsasign('POST', 'https://api.twitter.com/oauth/access_token',
{ oauth_consumer_key: 'GDdmIQH6jhtmLUypg82g',
Expand Down Expand Up @@ -103,6 +136,21 @@ tape('upsign', function (t) {
t.end()
})

tape('upsign256', function (t) {
upsign256 = hmacsign256('POST', 'http://api.twitter.com/1/statuses/update.json',
{ oauth_consumer_key: 'GDdmIQH6jhtmLUypg82g',
oauth_nonce: 'oElnnMTQIZvqvlfXM56aBLAf5noGD0AQR3Fmi7Q6Y',
oauth_signature_method: 'HMAC-SHA256',
oauth_token: '819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw',
oauth_timestamp: '1272325550',
oauth_version: '1.0',
status: 'setting up my twitter 私のさえずりを設定する'
}, 'MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98', 'J6zix3FfA9LofH0awS24M3HcBYXO5nI1iYe8EfBA')

t.equal(upsign256, 'xYhKjozxc3NYef7C26WU+gORdhEURdZRxSDzRttEKH0=')
t.end()
})

tape('upsignRSA', function (t) {
upsignRSA = rsasign('POST', 'http://api.twitter.com/1/statuses/update.json',
{ oauth_consumer_key: 'GDdmIQH6jhtmLUypg82g',
Expand Down

0 comments on commit 5797963

Please sign in to comment.