Sha256: cd6aed9e46a3afc44aaa34e3660bc1fb1d8a94de74a9a6231ddeffe876c66286

Contents?: true

Size: 885 Bytes

Versions: 21

Compression:

Stored size: 885 Bytes

Contents

require 'rest-core/test'

describe RC::Oauth2Header do
  env  = {RC::REQUEST_HEADERS => {}}
  auth = RC::Oauth2Header.new(RC::Dry.new)

  would 'do nothing if no access token' do
    auth.call(env){ |res| res.should.eq(env) }
  end

  would 'Bearer token' do
    auth.call(env.merge('access_token_type' => 'Bearer',
                        'access_token'      => 'token')){ |res|
      res[RC::REQUEST_HEADERS].should.eq 'Authorization' => 'Bearer token'
    }
  end

  would 'MAC token' do # http://tools.ietf.org/html/rfc6749#section-7.1
    auth.call(env.merge('access_token_type' => 'MAC',
                        'access_token'      =>
                          {'id'  => 'h480djs93hd8',
                           'mac' => 'kDZvddkndxv='})){ |res|
      res[RC::REQUEST_HEADERS].should.eq \
        'Authorization' => 'MAC id="h480djs93hd8", mac="kDZvddkndxv="'
    }
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rest-core-4.0.1 test/test_oauth2_header.rb
rest-core-4.0.0 test/test_oauth2_header.rb
rest-core-3.6.0 test/test_oauth2_header.rb
rest-core-3.5.92 test/test_oauth2_header.rb
rest-core-3.5.91 test/test_oauth2_header.rb
rest-core-3.5.9 test/test_oauth2_header.rb
rest-core-3.5.8 test/test_oauth2_header.rb
rest-core-3.5.7 test/test_oauth2_header.rb
rest-core-3.5.6 test/test_oauth2_header.rb
rest-core-3.5.5 test/test_oauth2_header.rb
rest-core-3.5.4 test/test_oauth2_header.rb
rest-core-3.5.3 test/test_oauth2_header.rb
rest-core-3.5.2 test/test_oauth2_header.rb
rest-core-3.5.1 test/test_oauth2_header.rb
rest-core-3.5.0 test/test_oauth2_header.rb
rest-core-3.4.1 test/test_oauth2_header.rb
rest-core-3.4.0 test/test_oauth2_header.rb
rest-core-3.3.3 test/test_oauth2_header.rb
rest-core-3.3.2 test/test_oauth2_header.rb
rest-core-3.3.1 test/test_oauth2_header.rb