Sha256: b04cea303649e31372e94d7b07d0a4bffd56b03a760a2d31604351bf604cdef3

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 KB

Contents

require 'helper'

class TestExvoAuth < Test::Unit::TestCase
  def setup
    Exvo::Helpers.auth_client_id     = "foo"
    Exvo::Helpers.auth_client_secret = "bar"
  end

  test "consumer sanity" do
    c = ExvoAuth::Autonomous::Consumer.new(:app_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(:app_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(:app_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(:app_id => "baz")
    assert_true c.send(:basement).included_modules.include?(HTTParty)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
exvo_auth-0.16.4 test/test_exvo_auth.rb
exvo_auth-0.16.3 test/test_exvo_auth.rb
exvo_auth-0.16.2 test/test_exvo_auth.rb
exvo_auth-0.16.1 test/test_exvo_auth.rb
exvo_auth-0.16.0 test/test_exvo_auth.rb
exvo_auth-0.15.1 test/test_exvo_auth.rb
exvo_auth-0.15.0 test/test_exvo_auth.rb