From 9549a32500301c0a60a41bc31311b6198a8f0670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 9 Jan 2012 18:08:27 -0300 Subject: [PATCH 1/9] Do not use deprecated ActiveSupport::Base64. Closes #1554 --- lib/devise/strategies/authenticatable.rb | 2 +- test/integration/http_authenticatable_test.rb | 8 ++++---- test/integration/token_authenticatable_test.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/devise/strategies/authenticatable.rb b/lib/devise/strategies/authenticatable.rb index b1062e3a..9108e727 100644 --- a/lib/devise/strategies/authenticatable.rb +++ b/lib/devise/strategies/authenticatable.rb @@ -105,7 +105,7 @@ module Devise # 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. diff --git a/test/integration/http_authenticatable_test.rb b/test/integration/http_authenticatable_test.rb index c42abb93..408483d2 100644 --- a/test/integration/http_authenticatable_test.rb +++ b/test/integration/http_authenticatable_test.rb @@ -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 @@ -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 "user@test.com", response.body assert warden.authenticated?(:user) @@ -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 diff --git a/test/integration/token_authenticatable_test.rb b/test/integration/token_authenticatable_test.rb index a6e54f4c..f2ccc8ac 100644 --- a/test/integration/token_authenticatable_test.rb +++ b/test/integration/token_authenticatable_test.rb @@ -125,7 +125,7 @@ class TokenAuthenticationTest < ActionController::IntegrationTest 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]) From edb0aac0915a109d4e07c3a625042830305c1b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 9 Jan 2012 18:08:39 -0300 Subject: [PATCH 2/9] Whitespaces :scissors: --- lib/devise/strategies/authenticatable.rb | 2 +- test/integration/token_authenticatable_test.rb | 4 ++-- test/integration/trackable_test.rb | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/devise/strategies/authenticatable.rb b/lib/devise/strategies/authenticatable.rb index 9108e727..e23bf0eb 100644 --- a/lib/devise/strategies/authenticatable.rb +++ b/lib/devise/strategies/authenticatable.rb @@ -156,4 +156,4 @@ module Devise end end end -end \ No newline at end of file +end diff --git a/test/integration/token_authenticatable_test.rb b/test/integration/token_authenticatable_test.rb index f2ccc8ac..084cfc7a 100644 --- a/test/integration/token_authenticatable_test.rb +++ b/test/integration/token_authenticatable_test.rb @@ -112,7 +112,7 @@ class TokenAuthenticationTest < ActionController::IntegrationTest assert_not_equal user1, user2 visit users_path(Devise.token_authentication_key.to_s + '[$ne]' => user1.authentication_token) - assert_nil warden.user(:user) + assert_nil warden.user(:user) end end @@ -145,4 +145,4 @@ class TokenAuthenticationTest < ActionController::IntegrationTest sign_in_as_new_user_with_token(:user => user) end -end \ No newline at end of file +end diff --git a/test/integration/trackable_test.rb b/test/integration/trackable_test.rb index d3aef96b..d02a1d7d 100644 --- a/test/integration/trackable_test.rb +++ b/test/integration/trackable_test.rb @@ -36,10 +36,10 @@ class TrackableHooksTest < ActionController::IntegrationTest assert_equal "127.0.0.1", user.current_sign_in_ip assert_equal "127.0.0.1", user.last_sign_in_ip end - + test "current remote ip returns original ip behind a non transparent proxy" do user = create_user - + arbitrary_ip = '192.168.1.69' sign_in_as_user do header 'HTTP_X_FORWARDED_FOR', arbitrary_ip @@ -72,7 +72,7 @@ class TrackableHooksTest < ActionController::IntegrationTest assert_nil user.last_sign_in_at end end - + test "do not track if devise.skip_trackable is set" do user = create_user sign_in_as_user do @@ -81,7 +81,7 @@ class TrackableHooksTest < ActionController::IntegrationTest user.reload assert_equal 0, user.sign_in_count visit destroy_user_session_path - + sign_in_as_user do header 'devise.skip_trackable', false end From 93d4bb83616bdc08469d8981b6b79fa46711a9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 9 Jan 2012 22:59:13 -0300 Subject: [PATCH 3/9] Add travis-ci specific gemfiles --- .travis.yml | 3 +++ gemfiles/Gemfile.rails-3.1.x | 33 +++++++++++++++++++++++++++++++++ gemfiles/Gemfile.rails-3.2.x | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 gemfiles/Gemfile.rails-3.1.x create mode 100644 gemfiles/Gemfile.rails-3.2.x diff --git a/.travis.yml b/.travis.yml index f94ce30a..27a187d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ rvm: - 1.9.3 - ree - rbx-18mode +gemfile: + - gemfiles/Gemfile.rails-3.1.x + - gemfiles/Gemfile.rails-3.2.x notifications: recipients: - jose.valim@plataformatec.com.br diff --git a/gemfiles/Gemfile.rails-3.1.x b/gemfiles/Gemfile.rails-3.1.x new file mode 100644 index 00000000..d7da201a --- /dev/null +++ b/gemfiles/Gemfile.rails-3.1.x @@ -0,0 +1,33 @@ +gemspec + +gem "rails", "~> 3.1.0" +gem "omniauth", "~> 1.0.0" +gem "omniauth-oauth2", "~> 1.0.0" +gem "rdoc" + +group :test do + gem "omniauth-facebook" + gem "omniauth-openid", "~> 1.0.1" + gem "webrat", "0.7.2", :require => false + gem "mocha", :require => false + + platforms :mri_18 do + gem "ruby-debug", ">= 0.10.3" + end +end + +platforms :jruby do + gem "activerecord-jdbc-adapter" + gem "activerecord-jdbcsqlite3-adapter" + gem "jruby-openssl" +end + +platforms :ruby do + gem "sqlite3-ruby" + + group :mongoid do + gem "mongo", "~> 1.3.0" + gem "mongoid", "~> 2.0" + gem "bson_ext", "~> 1.3.0" + end +end diff --git a/gemfiles/Gemfile.rails-3.2.x b/gemfiles/Gemfile.rails-3.2.x new file mode 100644 index 00000000..9bf8ffca --- /dev/null +++ b/gemfiles/Gemfile.rails-3.2.x @@ -0,0 +1,35 @@ +source "http://rubygems.org" + +gemspec + +gem "rails", ">= 3.2.0.rc", "< 4.0" +gem "omniauth", "~> 1.0.0" +gem "omniauth-oauth2", "~> 1.0.0" +gem "rdoc" + +group :test do + gem "omniauth-facebook" + gem "omniauth-openid", "~> 1.0.1" + gem "webrat", "0.7.2", :require => false + gem "mocha", :require => false + + platforms :mri_18 do + gem "ruby-debug", ">= 0.10.3" + end +end + +platforms :jruby do + gem "activerecord-jdbc-adapter" + gem "activerecord-jdbcsqlite3-adapter" + gem "jruby-openssl" +end + +platforms :ruby do + gem "sqlite3-ruby" + + group :mongoid do + gem "mongo", "~> 1.3.0" + gem "mongoid", "~> 2.0" + gem "bson_ext", "~> 1.3.0" + end +end From e954254abb29baf93107574d901fedd71e17393d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 9 Jan 2012 23:18:03 -0300 Subject: [PATCH 4/9] Fix gemfiles --- gemfiles/Gemfile.rails-3.1.x | 4 +++- gemfiles/Gemfile.rails-3.2.x | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gemfiles/Gemfile.rails-3.1.x b/gemfiles/Gemfile.rails-3.1.x index d7da201a..b88f6884 100644 --- a/gemfiles/Gemfile.rails-3.1.x +++ b/gemfiles/Gemfile.rails-3.1.x @@ -1,4 +1,6 @@ -gemspec +source "http://rubygems.org" + +gem "devise", :path => ".." gem "rails", "~> 3.1.0" gem "omniauth", "~> 1.0.0" diff --git a/gemfiles/Gemfile.rails-3.2.x b/gemfiles/Gemfile.rails-3.2.x index 9bf8ffca..1829a160 100644 --- a/gemfiles/Gemfile.rails-3.2.x +++ b/gemfiles/Gemfile.rails-3.2.x @@ -1,6 +1,6 @@ source "http://rubygems.org" -gemspec +gem "devise", :path => ".." gem "rails", ">= 3.2.0.rc", "< 4.0" gem "omniauth", "~> 1.0.0" From cfdabf874a5b00cf14e0fb9b94697447a6600b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 9 Jan 2012 23:47:35 -0300 Subject: [PATCH 5/9] Change gemspec to avoid subshells and remove unneeded files More informations at http://tenderlovemaking.com/2011/12/05/profiling-rails-startup-with-dtrace/ --- devise.gemspec | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/devise.gemspec b/devise.gemspec index beb2a929..74b38906 100644 --- a/devise.gemspec +++ b/devise.gemspec @@ -14,13 +14,12 @@ Gem::Specification.new do |s| s.rubyforge_project = "devise" - s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.files = Dir["CHANGELOG.rdoc", "MIT-LICENSE", "README.rdoc", "app/**/*", "config/**/*", "lib/**/*"] + s.test_files = Dir["test/**/*"] s.require_paths = ["lib"] s.add_dependency("warden", "~> 1.1") s.add_dependency("orm_adapter", "~> 0.0.3") s.add_dependency("bcrypt-ruby", "~> 3.0") s.add_dependency("railties", "~> 3.1") -end \ No newline at end of file +end From ead414d0a7651683e11be0c9302b1aa36d435253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 10 Jan 2012 10:52:14 -0300 Subject: [PATCH 6/9] Use global Gemfile in travis-ci --- .travis.yml | 2 +- Gemfile | 2 +- Gemfile.lock | 74 ++++++++++++++++++------------------ gemfiles/Gemfile.rails-3.2.x | 35 ----------------- 4 files changed, 38 insertions(+), 75 deletions(-) delete mode 100644 gemfiles/Gemfile.rails-3.2.x diff --git a/.travis.yml b/.travis.yml index 27a187d7..3bf12d45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ rvm: - rbx-18mode gemfile: - gemfiles/Gemfile.rails-3.1.x - - gemfiles/Gemfile.rails-3.2.x + - Gemfile notifications: recipients: - jose.valim@plataformatec.com.br diff --git a/Gemfile b/Gemfile index db1e06c0..9bf8ffca 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "http://rubygems.org" gemspec -gem "rails", "~> 3.1.0" +gem "rails", ">= 3.2.0.rc", "< 4.0" gem "omniauth", "~> 1.0.0" gem "omniauth-oauth2", "~> 1.0.0" gem "rdoc" diff --git a/Gemfile.lock b/Gemfile.lock index f21bc541..c1e70864 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,36 +10,35 @@ PATH GEM remote: http://rubygems.org/ specs: - actionmailer (3.1.3) - actionpack (= 3.1.3) + actionmailer (3.2.0.rc2) + actionpack (= 3.2.0.rc2) mail (~> 2.3.0) - actionpack (3.1.3) - activemodel (= 3.1.3) - activesupport (= 3.1.3) + actionpack (3.2.0.rc2) + activemodel (= 3.2.0.rc2) + activesupport (= 3.2.0.rc2) builder (~> 3.0.0) erubis (~> 2.7.0) - i18n (~> 0.6) - rack (~> 1.3.5) + journey (~> 1.0.0.rc1) + rack (~> 1.4.0) rack-cache (~> 1.1) - rack-mount (~> 0.8.2) rack-test (~> 0.6.1) - sprockets (~> 2.0.3) - activemodel (3.1.3) - activesupport (= 3.1.3) + sprockets (~> 2.1.2) + activemodel (3.2.0.rc2) + activesupport (= 3.2.0.rc2) builder (~> 3.0.0) - i18n (~> 0.6) - activerecord (3.1.3) - activemodel (= 3.1.3) - activesupport (= 3.1.3) - arel (~> 2.2.1) + activerecord (3.2.0.rc2) + activemodel (= 3.2.0.rc2) + activesupport (= 3.2.0.rc2) + arel (~> 3.0.0.rc1) tzinfo (~> 0.3.29) - activeresource (3.1.3) - activemodel (= 3.1.3) - activesupport (= 3.1.3) - activesupport (3.1.3) + activeresource (3.2.0.rc2) + activemodel (= 3.2.0.rc2) + activesupport (= 3.2.0.rc2) + activesupport (3.2.0.rc2) + i18n (~> 0.6) multi_json (~> 1.0) addressable (2.2.6) - arel (2.2.1) + arel (3.0.0.rc1) bcrypt-ruby (3.0.1) bson (1.5.1) bson_ext (1.3.1) @@ -53,7 +52,8 @@ GEM hashie (1.2.0) hike (1.2.1) i18n (0.6.0) - json (1.6.3) + journey (1.0.0.rc4) + json (1.6.4) linecache (0.46) rbx-require-relative (> 0.0.4) mail (2.3.0) @@ -89,11 +89,9 @@ GEM rack-openid (~> 1.3.1) orm_adapter (0.0.5) polyglot (0.3.3) - rack (1.3.5) + rack (1.4.0) rack-cache (1.1) rack (>= 0.4) - rack-mount (0.8.3) - rack (>= 1.0.0) rack-openid (1.3.1) rack (>= 1.1.0) ruby-openid (>= 2.1.8) @@ -101,24 +99,24 @@ GEM rack rack-test (0.6.1) rack (>= 1.0) - rails (3.1.3) - actionmailer (= 3.1.3) - actionpack (= 3.1.3) - activerecord (= 3.1.3) - activeresource (= 3.1.3) - activesupport (= 3.1.3) + rails (3.2.0.rc2) + actionmailer (= 3.2.0.rc2) + actionpack (= 3.2.0.rc2) + activerecord (= 3.2.0.rc2) + activeresource (= 3.2.0.rc2) + activesupport (= 3.2.0.rc2) bundler (~> 1.0) - railties (= 3.1.3) - railties (3.1.3) - actionpack (= 3.1.3) - activesupport (= 3.1.3) + railties (= 3.2.0.rc2) + railties (3.2.0.rc2) + actionpack (= 3.2.0.rc2) + activesupport (= 3.2.0.rc2) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) rake (0.9.2.2) rbx-require-relative (0.0.5) - rdoc (3.11) + rdoc (3.12) json (~> 1.4) ruby-debug (0.10.4) columnize (>= 0.1) @@ -126,7 +124,7 @@ GEM ruby-debug-base (0.10.4) linecache (>= 0.3) ruby-openid (2.1.8) - sprockets (2.0.3) + sprockets (2.1.2) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) @@ -162,7 +160,7 @@ DEPENDENCIES omniauth-facebook omniauth-oauth2 (~> 1.0.0) omniauth-openid (~> 1.0.1) - rails (~> 3.1.0) + rails (>= 3.2.0.rc, < 4.0) rdoc ruby-debug (>= 0.10.3) sqlite3-ruby diff --git a/gemfiles/Gemfile.rails-3.2.x b/gemfiles/Gemfile.rails-3.2.x deleted file mode 100644 index 1829a160..00000000 --- a/gemfiles/Gemfile.rails-3.2.x +++ /dev/null @@ -1,35 +0,0 @@ -source "http://rubygems.org" - -gem "devise", :path => ".." - -gem "rails", ">= 3.2.0.rc", "< 4.0" -gem "omniauth", "~> 1.0.0" -gem "omniauth-oauth2", "~> 1.0.0" -gem "rdoc" - -group :test do - gem "omniauth-facebook" - gem "omniauth-openid", "~> 1.0.1" - gem "webrat", "0.7.2", :require => false - gem "mocha", :require => false - - platforms :mri_18 do - gem "ruby-debug", ">= 0.10.3" - end -end - -platforms :jruby do - gem "activerecord-jdbc-adapter" - gem "activerecord-jdbcsqlite3-adapter" - gem "jruby-openssl" -end - -platforms :ruby do - gem "sqlite3-ruby" - - group :mongoid do - gem "mongo", "~> 1.3.0" - gem "mongoid", "~> 2.0" - gem "bson_ext", "~> 1.3.0" - end -end From d699b802540430e4d0749ca46e285c28eb4d3dac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 10 Jan 2012 11:43:15 -0300 Subject: [PATCH 7/9] Do not use a local network ip as HTTP_X_FORWARDED_FOR header If HTTP_X_FORWARDED_FOR is a local network IP the HTTP_CLIENT_IP need to be set --- test/integration/trackable_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/trackable_test.rb b/test/integration/trackable_test.rb index d02a1d7d..df492784 100644 --- a/test/integration/trackable_test.rb +++ b/test/integration/trackable_test.rb @@ -40,7 +40,7 @@ class TrackableHooksTest < ActionController::IntegrationTest test "current remote ip returns original ip behind a non transparent proxy" do user = create_user - arbitrary_ip = '192.168.1.69' + arbitrary_ip = '200.121.1.69' sign_in_as_user do header 'HTTP_X_FORWARDED_FOR', arbitrary_ip end From cf5fbb9d6531543d2c6aeb845ab7e0874019a296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 10 Jan 2012 11:59:20 -0300 Subject: [PATCH 8/9] Fix order specific test --- test/integration/authenticatable_test.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/integration/authenticatable_test.rb b/test/integration/authenticatable_test.rb index b471674f..8e4fee02 100644 --- a/test/integration/authenticatable_test.rb +++ b/test/integration/authenticatable_test.rb @@ -407,7 +407,10 @@ class AuthenticationOthersTest < ActionController::IntegrationTest test 'sign in stub in xml format' do get new_user_session_path(:format => 'xml') - assert_equal "\n\n \n \n\n", response.body + assert_match '', response.body + assert_match /.*<\/user>/m, response.body + assert_match '', response.body + assert_match '', response.body end test 'sign in stub in json format' do From cbf483143fddf2dd2eddbfe331edd1b02d15d0a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 10 Jan 2012 11:59:59 -0300 Subject: [PATCH 9/9] Remove rubinius from travis-ci matrix --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3bf12d45..97c4ae83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ rvm: - 1.9.2 - 1.9.3 - ree - - rbx-18mode gemfile: - gemfiles/Gemfile.rails-3.1.x - Gemfile