require "test_helper"
class OAuthTest < ActionDispatch::IntegrationTest
- fixtures :users, :gpx_files
- set_fixture_class :gpx_files => Trace
-
include OAuth::Helper
def setup
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
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
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
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
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
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
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