spec/rack/oauth2/access_token/mac/signature_spec.rb in rack-oauth2-0.14.4 vs spec/rack/oauth2/access_token/mac/signature_spec.rb in rack-oauth2-0.14.5

- old
+ new

@@ -1,43 +1,59 @@ require 'spec_helper' describe Rack::OAuth2::AccessToken::MAC::Signature do + # From the example of Webtopay wallet API + # ref) https://www.webtopay.com/wallet/ + context 'when ext is not given' do + subject do + Rack::OAuth2::AccessToken::MAC::Signature.new( + :secret => 'IrdTc8uQodU7PRpLzzLTW6wqZAO6tAMU', + :algorithm => 'hmac-sha-256', + :nonce => 'dj83hs9s', + :ts => 1336363200, + :method => 'GET', + :request_uri => '/wallet/rest/api/v1/payment/123', + :host => 'www.webtopay.com', + :port => 443 + ) + end + its(:calculate) { should == 'OZE9fTk2qiRtL1jb01L8lRxC66PTiAGhMDEmboeVeLs=' } + end - # From the example of MAC spec section 1.2 - # ref) http://tools.ietf.org/pdf/draft-ietf-oauth-v2-http-mac-00.pdf - context 'when body_hash is given' do + # From the example of MAC spec section 1.1 + # ref) http://tools.ietf.org/pdf/draft-ietf-oauth-v2-http-mac-01.pdf + context 'when ext is not given' do subject do Rack::OAuth2::AccessToken::MAC::Signature.new( - :secret => '8yfrufh348h', - :algorithm => 'hmac-sha-1', - :nonce => '273156:di3hvdf8', - :method => 'POST', - :request_uri => '/request', - :host => 'example.com', - :port => 80, - :body_hash => 'k9kbtCIy0CkI3/FEfpS/oIDjk6k=', - :ext => nil + :secret => '489dks293j39', + :algorithm => 'hmac-sha-1', + :nonce => 'dj83hs9s', + :ts => 1336363200, + :method => 'GET', + :request_uri => '/resource/1?b=1&a=2', + :host => 'example.com', + :port => 80 ) end - its(:calculate) { should == 'W7bdMZbv9UWOTadASIQHagZyirA=' } + its(:calculate) { should == '6T3zZzy2Emppni6bzL7kdRxUWL4=' } end # From the example of MAC spec section 3.2 - # ref) http://tools.ietf.org/pdf/draft-ietf-oauth-v2-http-mac-00.pdf - context 'otherwize' do + # ref) http://tools.ietf.org/pdf/draft-ietf-oauth-v2-http-mac-01.pdf + context 'otherwise' do subject do Rack::OAuth2::AccessToken::MAC::Signature.new( :secret => '489dks293j39', :algorithm => 'hmac-sha-1', - :nonce => '264095:dj83hs9s', - :method => 'GET', - :request_uri => '/resource/1?b=1&a=2', + :nonce => '7d8f3e4a', + :ts => 264095, + :method => 'POST', + :request_uri => '/request?b5=%3D%253D&a3=a&c%40=&a2=r%20b&c2&a3=2+q', :host => 'example.com', :port => 80, - :body_hash => nil, - :ext => nil + :ext => 'a,b,c' ) end - its(:calculate) { should == 'SLDJd4mg43cjQfElUs3Qub4L6xE=' } + its(:calculate) { should == '+txL5oOFHGYjrfdNYH5VEzROaBY=' } end end \ No newline at end of file