]> git.openstreetmap.org Git - rails.git/blobdiff - test/integration/oauth_test.rb
Merge remote-tracking branch 'openstreetmap/pull/1553'
[rails.git] / test / integration / oauth_test.rb
index ceee95892f966d672a4508e11d0a18692cf2c361..9eedd1ff49b2df3782b6da68d6d131a9a664112f 100644 (file)
@@ -1,9 +1,6 @@
 require "test_helper"
 
 class OAuthTest < ActionDispatch::IntegrationTest
-  fixtures :users, :gpx_files
-  set_fixture_class :gpx_files => Trace
-
   include OAuth::Helper
 
   def setup
@@ -11,7 +8,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
   end
 
   def test_oauth10_web_app
-    client = create(:client_application, :callback_url => "http://some.web.app.example.org/callback", :user => users(:public_user), :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
+    client = create(:client_application, :callback_url => "http://some.web.app.example.org/callback", :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
 
     post_via_redirect "/login", :username => client.user.email, :password => "test"
     assert_response :success
@@ -22,7 +19,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
   end
 
   def test_oauth10_desktop_app
-    client = create(:client_application, :user => users(:public_user), :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
+    client = create(:client_application, :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
 
     post_via_redirect "/login", :username => client.user.email, :password => "test"
     assert_response :success
@@ -32,7 +29,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
   end
 
   def test_oauth10a_web_app
-    client = create(:client_application, :callback_url => "http://some.web.app.example.org/callback", :user => users(:public_user), :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
+    client = create(:client_application, :callback_url => "http://some.web.app.example.org/callback", :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
 
     post_via_redirect "/login", :username => client.user.email, :password => "test"
     assert_response :success
@@ -43,7 +40,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
   end
 
   def test_oauth10a_desktop_app
-    client = create(:client_application, :user => users(:public_user), :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
+    client = create(:client_application, :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
 
     post_via_redirect "/login", :username => client.user.email, :password => "test"
     assert_response :success
@@ -168,7 +165,8 @@ class OAuthTest < ActionDispatch::IntegrationTest
     assert_nil token.invalidated_at
     assert_allowed token, [:allow_write_api, :allow_read_gpx]
 
-    signed_get "/api/0.6/gpx/2", :consumer => client, :token => token
+    trace = create(:trace, :user => client.user)
+    signed_get "/api/0.6/gpx/#{trace.id}", :consumer => client, :token => token
     assert_response :success
 
     signed_get "/api/0.6/user/details", :consumer => client, :token => token
@@ -230,7 +228,8 @@ class OAuthTest < ActionDispatch::IntegrationTest
     signed_get "/api/0.6/user/preferences", :consumer => client, :token => token
     assert_response :success
 
-    signed_get "/api/0.6/gpx/2", :consumer => client, :token => token
+    trace = create(:trace, :user => client.user)
+    signed_get "/api/0.6/gpx/#{trace.id}", :consumer => client, :token => token
     assert_response :forbidden
 
     post "/oauth/revoke", :token => token.token
@@ -278,7 +277,8 @@ class OAuthTest < ActionDispatch::IntegrationTest
     assert_nil token.invalidated_at
     assert_allowed token, [:allow_write_api, :allow_read_gpx]
 
-    signed_get "/api/0.6/gpx/2", :consumer => client, :token => token
+    trace = create(:trace, :user => client.user)
+    signed_get "/api/0.6/gpx/#{trace.id}", :consumer => client, :token => token
     assert_response :success
 
     signed_get "/api/0.6/user/details", :consumer => client, :token => token