Sha256: ee083e3a8a6aa85f1eceeadceec78247ac4eda37f7b91e9c48b915c670f4e507

Contents?: true

Size: 888 Bytes

Versions: 4

Compression:

Stored size: 888 Bytes

Contents

require 'rest-core/test'

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

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

  should '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

  should '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

4 entries across 4 versions & 1 rubygems

Version Path
rest-core-3.2.0 test/test_oauth2_header.rb
rest-core-3.1.1 test/test_oauth2_header.rb
rest-core-3.1.0 test/test_oauth2_header.rb
rest-core-3.0.0 test/test_oauth2_header.rb