Sha256: da1ad4802b527a6800b768d6b831badb490a628a329d3482cafa3118cb80eb80

Contents?: true

Size: 1.93 KB

Versions: 19

Compression:

Stored size: 1.93 KB

Contents

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.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       => '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 == '6T3zZzy2Emppni6bzL7kdRxUWL4=' }
  end

  # From the example of MAC spec section 3.2
  # 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       => '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,
        :ext         => 'a,b,c'
      )
    end
    its(:calculate) { should == '+txL5oOFHGYjrfdNYH5VEzROaBY=' }
  end

end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
rack-oauth2-1.1.1 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.1.0 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.0.10 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.0.9 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.0.8 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-revibe-1.0.7 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.0.7 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.0.6 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.0.5 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.0.4 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.0.3 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.0.2 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.0.1 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-1.0.0 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-0.14.9 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-0.14.8 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-0.14.7 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-0.14.6 spec/rack/oauth2/access_token/mac/signature_spec.rb
rack-oauth2-0.14.5 spec/rack/oauth2/access_token/mac/signature_spec.rb