Sha256: 078a6c71b3faf6e89cbc8b20d980a0bc3bbfa9eca0efd6bb9cce656e7aa00d58

Contents?: true

Size: 1.48 KB

Versions: 25

Compression:

Stored size: 1.48 KB

Contents

require 'helper'

class TestExvoAuth < Test::Unit::TestCase
  def setup
    ExvoAuth::Config.client_id     = "foo"
    ExvoAuth::Config.client_secret = "bar"
  end
  
  test "consumer sanity" do
    c = ExvoAuth::Autonomous::Consumer.new(:provider_id => "baz")
    authorization = { "access_token" => "qux", "url" => "https://foo/api" }
    auth = stub(:get => { "authorization" => authorization })
    c.expects(:auth).returns(auth)
    
    assert_equal authorization, c.send(:authorization)
    assert_equal authorization, c.send(:authorization) # second time from cache, without touching httparty
  end

  test "provider sanity" do
    p = ExvoAuth::Autonomous::Provider.new(:consumer_id => "baz", :access_token => "qux")
    auth = stub(:get => {"scope" => "qux quux"})
    p.expects(:auth).returns(auth)
    
    assert_equal ["qux", "quux"], p.scopes
    assert_equal ["qux", "quux"], p.scopes # second time from cache, without touching httparty
  end
  
  test "integration of httparty interface with auth" do
    c = ExvoAuth::Autonomous::Consumer.new(:provider_id => "baz")
    basement = mock("basement")
    basement.expects(:base_uri)
    basement.expects(:basic_auth)
    basement.expects(:get).with("/bar").returns(true)
    c.expects(:basement).at_least_once.returns(basement)
    assert_true c.get("/bar")
  end
  
  test "basement includes httparty" do
    c = ExvoAuth::Autonomous::Consumer.new(:provider_id => "baz")
    assert_true c.send(:basement).included_modules.include?(HTTParty)
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
exvo-auth-0.9.8 test/test_exvo_auth.rb
exvo-auth-0.9.7 test/test_exvo_auth.rb
exvo-auth-0.9.6 test/test_exvo_auth.rb
exvo-auth-0.9.5 test/test_exvo_auth.rb
exvo-auth-0.9.4 test/test_exvo_auth.rb
exvo-auth-0.9.3 test/test_exvo_auth.rb
exvo-auth-0.9.2 test/test_exvo_auth.rb
exvo-auth-0.9.0 test/test_exvo_auth.rb
exvo-auth-0.8.2 test/test_exvo_auth.rb
exvo-auth-0.8.0 test/test_exvo_auth.rb
exvo-auth-0.7.16 test/test_exvo_auth.rb
exvo-auth-0.7.15 test/test_exvo_auth.rb
exvo-auth-0.7.14 test/test_exvo_auth.rb
exvo-auth-0.7.13 test/test_exvo_auth.rb
exvo-auth-0.7.12 test/test_exvo_auth.rb
exvo-auth-0.7.11 test/test_exvo_auth.rb
exvo-auth-0.7.10 test/test_exvo_auth.rb
exvo-auth-0.7.9 test/test_exvo_auth.rb
exvo-auth-0.7.8 test/test_exvo_auth.rb
exvo-auth-0.7.7 test/test_exvo_auth.rb