test/test_fake_authentication.rb in fakeweb-1.2.3 vs test/test_fake_authentication.rb in fakeweb-1.2.4

- old
+ new

@@ -1,50 +1,50 @@ require File.join(File.dirname(__FILE__), "test_helper") class TestFakeAuthentication < Test::Unit::TestCase def setup - FakeWeb.register_uri('http://user:pass@mock/auth.txt', :string => 'authorized') - FakeWeb.register_uri('http://user2:pass@mock/auth.txt', :string => 'wrong user') - FakeWeb.register_uri('http://mock/auth.txt', :string => 'unauthorized') + FakeWeb.register_uri(:get, 'http://user:pass@mock/auth.txt', :body => 'authorized') + FakeWeb.register_uri(:get, 'http://user2:pass@mock/auth.txt', :body => 'wrong user') + FakeWeb.register_uri(:get, 'http://mock/auth.txt', :body => 'unauthorized') end def test_register_uri_with_authentication - FakeWeb.register_uri('http://user:pass@mock/test_example.txt', :string => "example") - assert FakeWeb.registered_uri?('http://user:pass@mock/test_example.txt') + FakeWeb.register_uri(:get, 'http://user:pass@mock/test_example.txt', :body => "example") + assert FakeWeb.registered_uri?(:get, 'http://user:pass@mock/test_example.txt') end def test_register_uri_with_authentication_doesnt_trigger_without - FakeWeb.register_uri('http://user:pass@mock/test_example.txt', :string => "example") - assert !FakeWeb.registered_uri?('http://mock/test_example.txt') + FakeWeb.register_uri(:get, 'http://user:pass@mock/test_example.txt', :body => "example") + assert !FakeWeb.registered_uri?(:get, 'http://mock/test_example.txt') end def test_register_uri_with_authentication_doesnt_trigger_with_incorrect_credentials - FakeWeb.register_uri('http://user:pass@mock/test_example.txt', :string => "example") - assert !FakeWeb.registered_uri?('http://user:wrong@mock/test_example.txt') + FakeWeb.register_uri(:get, 'http://user:pass@mock/test_example.txt', :body => "example") + assert !FakeWeb.registered_uri?(:get, 'http://user:wrong@mock/test_example.txt') end def test_unauthenticated_request http = Net::HTTP.new('mock', 80) req = Net::HTTP::Get.new('/auth.txt') - assert_equal http.request(req).body, 'unauthorized' + assert_equal 'unauthorized', http.request(req).body end def test_authenticated_request http = Net::HTTP.new('mock',80) req = Net::HTTP::Get.new('/auth.txt') req.basic_auth 'user', 'pass' - assert_equal http.request(req).body, 'authorized' + assert_equal 'authorized', http.request(req).body end def test_incorrectly_authenticated_request http = Net::HTTP.new('mock',80) req = Net::HTTP::Get.new('/auth.txt') req.basic_auth 'user2', 'pass' - assert_equal http.request(req).body, 'wrong user' + assert_equal 'wrong user', http.request(req).body end def test_basic_auth_support_is_transparent_to_oauth - FakeWeb.register_uri(:get, "http://sp.example.com/protected", :string => "secret") + FakeWeb.register_uri(:get, "http://sp.example.com/protected", :body => "secret") # from http://oauth.net/core/1.0/#auth_header auth_header = <<-HEADER OAuth realm="http://sp.example.com/", oauth_consumer_key="0685bd9184jfhq22",