]> git.openstreetmap.org Git - rails.git/blobdiff - test/integration/user_creation_test.rb
Merge pull request #5676 from tomhughes/spam-score-reports
[rails.git] / test / integration / user_creation_test.rb
index beb05a98a372341b514c4bfdb21e3e7e55d2eb06..5d75c508dd80f3bed6deecaf2f6b8cddd016ac90 100644 (file)
@@ -30,12 +30,11 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => dup_email,
                                        :display_name => display_name,
                                        :pass_crypt => "testtest",
-                                       :pass_crypt_confirmation => "testtest",
-                                       :consider_pd => "1" } }
+                                       :pass_crypt_confirmation => "testtest" } }
         end
       end
     end
@@ -51,14 +50,13 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count", 0) do
       assert_no_difference("ActionMailer::Base.deliveries.size") do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => dup_email,
                                        :display_name => display_name,
                                        :pass_crypt => "testtest",
                                        :pass_crypt_confirmation => "testtest",
-                                       :auth_provider => "auth_provider",
-                                       :auth_uid => "123454321",
-                                       :consider_pd => "1" } }
+                                       :auth_provider => "google",
+                                       :auth_uid => "123454321" } }
         end
       end
     end
@@ -74,7 +72,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => email,
                                        :display_name => dup_display_name,
                                        :pass_crypt => "testtest",
@@ -93,12 +91,11 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => email,
                                        :display_name => display_name,
                                        :pass_crypt => "testtest",
-                                       :pass_crypt_confirmation => "blahblah",
-                                       :consider_pd => "1" } }
+                                       :pass_crypt_confirmation => "blahblah" } }
         end
       end
     end
@@ -113,12 +110,11 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count", 0) do
       assert_no_difference("ActionMailer::Base.deliveries.size") do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => email,
                                        :display_name => dup_display_name,
-                                       :auth_provider => "provider",
-                                       :auth_uid => "123454321",
-                                       :consider_pd => "1" } }
+                                       :auth_provider => "google",
+                                       :auth_uid => "123454321" } }
         end
       end
     end
@@ -134,12 +130,11 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count", 1) do
       assert_difference("ActionMailer::Base.deliveries.size", 1) do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :pass_crypt => "testtest",
-                                       :pass_crypt_confirmation => "testtest",
-                                       :consider_pd => "1" } }
+                                       :pass_crypt_confirmation => "testtest" } }
           assert_redirected_to :controller => :confirmations, :action => :confirm, :display_name => display_name
           follow_redirect!
         end
@@ -171,13 +166,13 @@ class UserCreationTest < ActionDispatch::IntegrationTest
   end
 
   # Check that the user can successfully recover their password
-  def test_lost_password_recovery_success
-    # Open the lost password form
-    # Submit the lost password form
-    # Check the e-mail
-    # Submit the reset password token
-    # Check that the password has changed, and the user can login
-  end
+  def test_lost_password_recovery_success
+  #   Open the lost password form
+  #   Submit the lost password form
+  #   Check the e-mail
+  #   Submit the reset password token
+  #   Check that the password has changed, and the user can login
+  end
 
   def test_user_create_redirect
     new_email = "redirect_tester@osm.org"
@@ -188,12 +183,11 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count") do
       assert_difference("ActionMailer::Base.deliveries.size", 1) do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :pass_crypt => password,
-                                       :pass_crypt_confirmation => password,
-                                       :consider_pd => "1" },
+                                       :pass_crypt_confirmation => password },
                             :referer => referer }
           assert_response(:redirect)
           assert_redirected_to :controller => :confirmations, :action => :confirm, :display_name => display_name
@@ -234,6 +228,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
   def test_user_create_openid_success
     new_email = "newtester-openid@osm.org"
     display_name = "new_tester-openid"
+    openid_url = "http://localhost:1000/new.tester"
     auth_uid = "http://localhost:1123/new.tester"
 
     OmniAuth.config.add_mock(:openid,
@@ -243,18 +238,17 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count") do
       assert_difference("ActionMailer::Base.deliveries.size", 1) do
         perform_enqueued_jobs do
-          post auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
-          assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
+          post auth_path(:provider => "openid", :openid_url => openid_url, :origin => "/user/new")
+          assert_redirected_to auth_success_path(:provider => "openid", :openid_url => openid_url, :origin => "/user/new")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name, :email => new_email,
                                :auth_provider => "openid", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "openid",
-                                       :auth_uid => "http://localhost:1123/new.tester",
-                                       :consider_pd => "1" } }
+                                       :auth_uid => auth_uid } }
         end
       end
     end
@@ -307,7 +301,8 @@ class UserCreationTest < ActionDispatch::IntegrationTest
   end
 
   def test_user_create_openid_redirect
-    auth_uid = "12345654321"
+    openid_url = "http://localhost:1000/new.tester"
+    auth_uid = "http://localhost:1123/new.tester"
     new_email = "redirect_tester_openid@osm.org"
     display_name = "redirect_tester_openid"
 
@@ -318,18 +313,17 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count") do
       assert_difference("ActionMailer::Base.deliveries.size", 1) do
         perform_enqueued_jobs do
-          post auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
-          assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
+          post auth_path(:provider => "openid", :openid_url => openid_url, :origin => "/user/new")
+          assert_redirected_to auth_success_path(:provider => "openid", :openid_url => openid_url, :origin => "/user/new")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name, :email => new_email,
                                :auth_provider => "openid", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "openid",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
+                                       :auth_uid => auth_uid } }
           follow_redirect!
         end
       end
@@ -366,7 +360,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
 
   def test_user_create_google_success
     new_email = "newtester-google@osm.org"
-    verified_email = UsersController.message_hmac(new_email)
+    email_hmac = UsersController.message_hmac(new_email)
     display_name = "new_tester-google"
     auth_uid = "123454321"
 
@@ -382,17 +376,16 @@ class UserCreationTest < ActionDispatch::IntegrationTest
           assert_redirected_to auth_success_path(:provider => "google")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                               :email => new_email, :verified_email => verified_email,
+                               :email => new_email, :email_hmac => email_hmac,
                                :auth_provider => "google", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "google",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" },
-                            :verified_email => verified_email }
+                                       :auth_uid => auth_uid },
+                            :email_hmac => email_hmac }
           assert_redirected_to welcome_path
           follow_redirect!
         end
@@ -420,7 +413,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_redirected_to auth_success_path(:provider => "google")
     follow_redirect!
     assert_redirected_to :controller => :users, :action => "new", :nickname => display_name, :email => dup_user.email,
-                         :verified_email => UsersController.message_hmac(dup_user.email),
+                         :email_hmac => UsersController.message_hmac(dup_user.email),
                          :auth_provider => "google", :auth_uid => auth_uid
     follow_redirect!
 
@@ -452,7 +445,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
 
   def test_user_create_google_redirect
     orig_email = "redirect_tester_google_orig@google.com"
-    verified_email = UsersController.message_hmac(orig_email)
+    email_hmac = UsersController.message_hmac(orig_email)
     new_email =  "redirect_tester_google@osm.org"
     display_name = "redirect_tester_google"
     auth_uid = "123454321"
@@ -469,16 +462,15 @@ class UserCreationTest < ActionDispatch::IntegrationTest
           assert_redirected_to auth_success_path(:provider => "google")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                               :email => orig_email, :verified_email => verified_email,
+                               :email => orig_email, :email_hmac => email_hmac,
                                :auth_provider => "google", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
-                                       :verified_email => verified_email,
+                                       :email_hmac => email_hmac,
                                        :display_name => display_name,
                                        :auth_provider => "google",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
+                                       :auth_uid => auth_uid } }
           assert_response :redirect
           follow_redirect!
         end
@@ -516,7 +508,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
 
   def test_user_create_facebook_success
     new_email = "newtester-facebook@osm.org"
-    verified_email = UsersController.message_hmac(new_email)
+    email_hmac = UsersController.message_hmac(new_email)
     display_name = "new_tester-facebook"
     auth_uid = "123454321"
 
@@ -531,17 +523,16 @@ class UserCreationTest < ActionDispatch::IntegrationTest
           assert_redirected_to auth_success_path(:provider => "facebook")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                               :email => new_email, :verified_email => verified_email,
+                               :email => new_email, :email_hmac => email_hmac,
                                :auth_provider => "facebook", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "facebook",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" },
-                            :verified_email => verified_email }
+                                       :auth_uid => auth_uid },
+                            :email_hmac => email_hmac }
           assert_redirected_to welcome_path
           follow_redirect!
         end
@@ -568,7 +559,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_redirected_to auth_success_path(:provider => "facebook")
     follow_redirect!
     assert_redirected_to :controller => :users, :action => "new", :nickname => display_name, :email => dup_user.email,
-                         :verified_email => UsersController.message_hmac(dup_user.email),
+                         :email_hmac => UsersController.message_hmac(dup_user.email),
                          :auth_provider => "facebook", :auth_uid => auth_uid
     follow_redirect!
 
@@ -600,7 +591,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
 
   def test_user_create_facebook_redirect
     orig_email = "redirect_tester_facebook_orig@osm.org"
-    verified_email = UsersController.message_hmac(orig_email)
+    email_hmac = UsersController.message_hmac(orig_email)
     new_email = "redirect_tester_facebook@osm.org"
     display_name = "redirect_tester_facebook"
     auth_uid = "123454321"
@@ -617,17 +608,16 @@ class UserCreationTest < ActionDispatch::IntegrationTest
           assert_redirected_to auth_success_path(:provider => "facebook")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                               :email => orig_email, :verified_email => verified_email,
+                               :email => orig_email, :email_hmac => email_hmac,
                                :auth_provider => "facebook", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
-                                       :verified_email => verified_email,
+                                       :email_hmac => email_hmac,
                                        :display_name => display_name,
                                        :auth_provider => "facebook",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
+                                       :auth_uid => auth_uid } }
           assert_response :redirect
           follow_redirect!
         end
@@ -665,7 +655,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
 
   def test_user_create_microsoft_success
     new_email = "newtester-microsoft@osm.org"
-    verified_email = UsersController.message_hmac(new_email)
+    email_hmac = UsersController.message_hmac(new_email)
     display_name = "new_tester-microsoft"
     auth_uid = "123454321"
 
@@ -680,16 +670,15 @@ class UserCreationTest < ActionDispatch::IntegrationTest
           assert_redirected_to auth_success_path(:provider => "microsoft")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                               :email => new_email, :verified_email => verified_email,
+                               :email => new_email, :email_hmac => email_hmac,
                                :auth_provider => "microsoft", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "microsoft",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" },
-                            :verified_email => verified_email }
+                                       :auth_uid => auth_uid },
+                            :email_hmac => email_hmac }
           assert_redirected_to welcome_path
           follow_redirect!
         end
@@ -716,7 +705,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_redirected_to auth_success_path(:provider => "microsoft")
     follow_redirect!
     assert_redirected_to :controller => :users, :action => "new", :nickname => display_name, :email => dup_user.email,
-                         :verified_email => UsersController.message_hmac(dup_user.email),
+                         :email_hmac => UsersController.message_hmac(dup_user.email),
                          :auth_provider => "microsoft", :auth_uid => auth_uid
     follow_redirect!
 
@@ -748,7 +737,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
 
   def test_user_create_microsoft_redirect
     orig_email = "redirect_tester_microsoft_orig@osm.org"
-    verified_email = UsersController.message_hmac(orig_email)
+    email_hmac = UsersController.message_hmac(orig_email)
     new_email = "redirect_tester_microsoft@osm.org"
     display_name = "redirect_tester_microsoft"
     auth_uid = "123454321"
@@ -764,17 +753,16 @@ class UserCreationTest < ActionDispatch::IntegrationTest
           assert_redirected_to auth_success_path(:provider => "microsoft")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                               :email => orig_email, :verified_email => verified_email,
+                               :email => orig_email, :email_hmac => email_hmac,
                                :auth_provider => "microsoft", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
-                                       :verified_email => verified_email,
+                                       :email_hmac => email_hmac,
                                        :display_name => display_name,
                                        :auth_provider => "microsoft",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
+                                       :auth_uid => auth_uid } }
           assert_response :redirect
           follow_redirect!
         end
@@ -812,7 +800,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
 
   def test_user_create_github_success
     new_email = "newtester-github@osm.org"
-    verified_email = UsersController.message_hmac(new_email)
+    email_hmac = UsersController.message_hmac(new_email)
     display_name = "new_tester-github"
     password = "testtest"
     auth_uid = "123454321"
@@ -828,11 +816,11 @@ class UserCreationTest < ActionDispatch::IntegrationTest
           assert_redirected_to auth_success_path(:provider => "github")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                               :email => new_email, :verified_email => verified_email,
+                               :email => new_email, :email_hmac => email_hmac,
                                :auth_provider => "github", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "github",
@@ -841,7 +829,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                        :pass_crypt_confirmation => password },
                             :read_ct => 1,
                             :read_tou => 1,
-                            :verified_email => verified_email }
+                            :email_hmac => email_hmac }
           assert_redirected_to welcome_path
           follow_redirect!
         end
@@ -869,7 +857,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_redirected_to auth_success_path(:provider => "github")
     follow_redirect!
     assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                         :email => dup_user.email, :verified_email => UsersController.message_hmac(dup_user.email),
+                         :email => dup_user.email, :email_hmac => UsersController.message_hmac(dup_user.email),
                          :auth_provider => "github", :auth_uid => auth_uid
     follow_redirect!
 
@@ -900,7 +888,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
 
   def test_user_create_github_redirect
     orig_email = "redirect_tester_github_orig@osm.org"
-    verified_email = UsersController.message_hmac(orig_email)
+    email_hmac = UsersController.message_hmac(orig_email)
     new_email = "redirect_tester_github@osm.org"
     display_name = "redirect_tester_github"
     auth_uid = "123454321"
@@ -916,16 +904,15 @@ class UserCreationTest < ActionDispatch::IntegrationTest
           assert_redirected_to auth_success_path(:provider => "github")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                               :email => orig_email, :verified_email => verified_email,
+                               :email => orig_email, :email_hmac => email_hmac,
                                :auth_provider => "github", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
-                                       :verified_email => verified_email,
+                                       :email_hmac => email_hmac,
                                        :display_name => display_name,
                                        :auth_provider => "github",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
+                                       :auth_uid => auth_uid } }
           assert_response :redirect
           follow_redirect!
         end
@@ -963,7 +950,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
 
   def test_user_create_wikipedia_success
     new_email = "newtester-wikipedia@osm.org"
-    verified_email = UsersController.message_hmac(new_email)
+    email_hmac = UsersController.message_hmac(new_email)
     display_name = "new_tester-wikipedia"
     password = "testtest"
     auth_uid = "123454321"
@@ -979,10 +966,10 @@ class UserCreationTest < ActionDispatch::IntegrationTest
           assert_redirected_to auth_success_path(:provider => "wikipedia", :origin => "/user/new")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                               :email => new_email, :verified_email => verified_email,
+                               :email => new_email, :email_hmac => email_hmac,
                                :auth_provider => "wikipedia", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "wikipedia",
@@ -991,7 +978,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                        :pass_crypt_confirmation => password },
                             :read_ct => 1,
                             :read_tou => 1,
-                            :verified_email => verified_email }
+                            :email_hmac => email_hmac }
           assert_redirected_to welcome_path
           follow_redirect!
         end
@@ -1016,7 +1003,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_redirected_to auth_success_path(:provider => "wikipedia", :origin => "/user/new")
     follow_redirect!
     assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                         :email => dup_user.email, :verified_email => UsersController.message_hmac(dup_user.email),
+                         :email => dup_user.email, :email_hmac => UsersController.message_hmac(dup_user.email),
                          :auth_provider => "wikipedia", :auth_uid => auth_uid
     follow_redirect!
 
@@ -1048,7 +1035,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
 
   def test_user_create_wikipedia_redirect
     orig_email = "redirect_tester_wikipedia_orig@osm.org"
-    verified_email = UsersController.message_hmac(orig_email)
+    email_hmac = UsersController.message_hmac(orig_email)
     new_email = "redirect_tester_wikipedia@osm.org"
     display_name = "redirect_tester_wikipedia"
     auth_uid = "123454321"
@@ -1065,17 +1052,16 @@ class UserCreationTest < ActionDispatch::IntegrationTest
           assert_redirected_to auth_success_path(:provider => "wikipedia", :origin => "/user/new")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name,
-                               :email => orig_email, :verified_email => verified_email,
+                               :email => orig_email, :email_hmac => email_hmac,
                                :auth_provider => "wikipedia", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
-                                       :verified_email => verified_email,
+                                       :email_hmac => email_hmac,
                                        :display_name => display_name,
                                        :auth_provider => "wikipedia",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
+                                       :auth_uid => auth_uid } }
           assert_response :redirect
           follow_redirect!
         end