Skip to content

Commit

Permalink
Do not use deprecated ActiveSupport::Base64. Closes #1554
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Mendonça França authored and rafaelfranca committed Jan 9, 2012
1 parent a949f9e commit 9549a32
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/devise/strategies/authenticatable.rb
Expand Up @@ -105,7 +105,7 @@ def valid_password?
# Helper to decode credentials from HTTP.
def decode_credentials
return [] unless request.authorization && request.authorization =~ /^Basic (.*)/m
ActiveSupport::Base64.decode64($1).split(/:/, 2)
Base64.decode64($1).split(/:/, 2)
end

# Sets the authentication hash and the password from params_auth_hash or http_auth_hash.
Expand Down
8 changes: 4 additions & 4 deletions test/integration/http_authenticatable_test.rb
Expand Up @@ -4,7 +4,7 @@ class HttpAuthenticationTest < ActionController::IntegrationTest
test 'handles unverified requests gets rid of caches but continues signed in' do
swap UsersController, :allow_forgery_protection => true do
create_user
post exhibit_user_url(1), {}, "HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("user@test.com:123456")}"
post exhibit_user_url(1), {}, "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("user@test.com:123456")}"
assert warden.authenticated?(:user)
assert_equal "User is authenticated", response.body
end
Expand Down Expand Up @@ -74,7 +74,7 @@ class HttpAuthenticationTest < ActionController::IntegrationTest
token = "token_containing_so_many_characters_that_the_base64_encoding_will_wrap"
user = create_user
user.update_attribute :authentication_token, token
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("#{token}:x")}"
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("#{token}:x")}"
assert_response :success
assert_match "<email>user@test.com</email>", response.body
assert warden.authenticated?(:user)
Expand All @@ -84,14 +84,14 @@ class HttpAuthenticationTest < ActionController::IntegrationTest

def sign_in_as_new_user_with_http(username="user@test.com", password="123456")
user = create_user
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}"
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("#{username}:#{password}")}"
user
end

# Sign in with oauth2 token. This is just to test that it isn't misinterpreted as basic authentication
def add_oauth2_header
user = create_user
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "OAuth #{ActiveSupport::Base64.encode64("#{user.email}:123456")}"
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "OAuth #{Base64.encode64("#{user.email}:123456")}"
end

end
2 changes: 1 addition & 1 deletion test/integration/token_authenticatable_test.rb
Expand Up @@ -125,7 +125,7 @@ def sign_in_as_new_user_with_token(options = {})
options[:auth_token] ||= user.authentication_token

if options[:http_auth]
header = "Basic #{ActiveSupport::Base64.encode64("#{VALID_AUTHENTICATION_TOKEN}:X")}"
header = "Basic #{Base64.encode64("#{VALID_AUTHENTICATION_TOKEN}:X")}"
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => header
else
visit users_path(options[:auth_token_key].to_sym => options[:auth_token])
Expand Down

0 comments on commit 9549a32

Please sign in to comment.