require "test_helper"
class OAuthTest < ActionDispatch::IntegrationTest
- fixtures :users
-
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]
- trace = create(:trace, :user => users(:public_user))
+ 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/preferences", :consumer => client, :token => token
assert_response :success
- trace = create(:trace, :user => users(:public_user))
+ trace = create(:trace, :user => client.user)
signed_get "/api/0.6/gpx/#{trace.id}", :consumer => client, :token => token
assert_response :forbidden
assert_nil token.invalidated_at
assert_allowed token, [:allow_write_api, :allow_read_gpx]
- trace = create(:trace, :user => users(:public_user))
+ trace = create(:trace, :user => client.user)
signed_get "/api/0.6/gpx/#{trace.id}", :consumer => client, :token => token
assert_response :success