1
+ require 'spec_helper'
2
+
3
+ describe Rack ::OAuth2 ::AccessToken ::MAC ::Signature do
4
+
5
+ # From the example of MAC spec section 1.2
6
+ # ref) http://tools.ietf.org/pdf/draft-ietf-oauth-v2-http-mac-00.pdf
7
+ context 'when body_hash is given' do
8
+ subject do
9
+ Rack ::OAuth2 ::AccessToken ::MAC ::Signature . new (
10
+ :secret => '8yfrufh348h' ,
11
+ :algorithm => 'hmac-sha-1' ,
12
+ :nonce => '273156:di3hvdf8' ,
13
+ :method => 'POST' ,
14
+ :request_uri => '/request' ,
15
+ :host => 'example.com' ,
16
+ :port => 80 ,
17
+ :body_hash => 'k9kbtCIy0CkI3/FEfpS/oIDjk6k=' ,
18
+ :ext => nil
19
+ )
20
+ end
21
+ its ( :calculate ) { should == 'W7bdMZbv9UWOTadASIQHagZyirA=' }
22
+ end
23
+
24
+ # From the example of MAC spec section 3.2
25
+ # ref) http://tools.ietf.org/pdf/draft-ietf-oauth-v2-http-mac-00.pdf
26
+ context 'otherwize' do
27
+ subject do
28
+ Rack ::OAuth2 ::AccessToken ::MAC ::Signature . new (
29
+ :secret => '489dks293j39' ,
30
+ :algorithm => 'hmac-sha-1' ,
31
+ :nonce => '264095:dj83hs9s' ,
32
+ :method => 'GET' ,
33
+ :request_uri => '/resource/1?b=1&a=2' ,
34
+ :host => 'example.com' ,
35
+ :port => 80 ,
36
+ :body_hash => nil ,
37
+ :ext => nil
38
+ )
39
+ end
40
+ its ( :calculate ) { should == 'SLDJd4mg43cjQfElUs3Qub4L6xE=' }
41
+ end
42
+
43
+ end
0 commit comments