diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-02-19 23:06:09 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-02-19 23:06:09 +0000 |
commit | ab45bd487a935ae9558e814ca06b1e4e71ba554a (patch) | |
tree | 79262724491f5f66975ce57c6a650e483b21a43a /activeresource/test | |
parent | 1537aec18453907db3e67dc366eb51f11f94055d (diff) | |
download | rails-ab45bd487a935ae9558e814ca06b1e4e71ba554a.tar.gz rails-ab45bd487a935ae9558e814ca06b1e4e71ba554a.tar.bz2 rails-ab45bd487a935ae9558e814ca06b1e4e71ba554a.zip |
URI.decode site username/password. Closes #11169 [Ernesto Jimenez]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8900 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/test')
-rw-r--r-- | activeresource/test/authorization_test.rb | 9 | ||||
-rw-r--r-- | activeresource/test/base_test.rb | 7 |
2 files changed, 16 insertions, 0 deletions
diff --git a/activeresource/test/authorization_test.rb b/activeresource/test/authorization_test.rb index 05be7e3ef0..9215227620 100644 --- a/activeresource/test/authorization_test.rb +++ b/activeresource/test/authorization_test.rb @@ -45,6 +45,15 @@ class AuthorizationTest < Test::Unit::TestCase assert_equal ["", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] end + def test_authorization_header_with_decoded_credentials_from_url + @conn = ActiveResource::Connection.new("http://my%40email.com:%31%32%33@localhost") + authorization_header = @conn.send!(:authorization_header) + authorization = authorization_header["Authorization"].to_s.split + + assert_equal "Basic", authorization[0] + assert_equal ["my@email.com", "123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] + end + def test_authorization_header_explicitly_setting_username_and_password @authenticated_conn = ActiveResource::Connection.new("http://@localhost") @authenticated_conn.user = 'david' diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb index 5db6f9113d..c85d40f8fa 100644 --- a/activeresource/test/base_test.rb +++ b/activeresource/test/base_test.rb @@ -103,6 +103,13 @@ class BaseTest < Test::Unit::TestCase assert_nil actor.connection.password end + def test_credentials_from_site_are_decoded + actor = Class.new(ActiveResource::Base) + actor.site = 'http://my%40email.com:%31%32%33@cinema' + assert_equal("my@email.com", actor.user) + assert_equal("123", actor.password) + end + def test_site_reader_uses_superclass_site_until_written # Superclass is Object so returns nil. assert_nil ActiveResource::Base.site |