4 class PermissionsControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/api/0.6/permissions", :method => :get },
10 { :controller => "api/permissions", :action => "show" }
14 def test_permissions_anonymous
16 assert_response :success
17 assert_select "osm > permissions", :count => 1 do
18 assert_select "permission", :count => 0
22 def test_permissions_basic_auth
23 auth_header = basic_authorization_header create(:user).email, "test"
24 get permissions_path, :headers => auth_header
25 assert_response :success
26 assert_select "osm > permissions", :count => 1 do
27 assert_select "permission", :count => ClientApplication.all_permissions.size
28 ClientApplication.all_permissions.each do |p|
29 assert_select "permission[name='#{p}']", :count => 1
34 def test_permissions_oauth
35 token = create(:access_token,
36 :allow_read_prefs => true,
37 :allow_write_api => true,
38 :allow_read_gpx => false)
39 signed_get permissions_path, :oauth => { :token => token }
40 assert_response :success
41 assert_select "osm > permissions", :count => 1 do
42 assert_select "permission", :count => 2
43 assert_select "permission[name='allow_read_prefs']", :count => 1
44 assert_select "permission[name='allow_write_api']", :count => 1
45 assert_select "permission[name='allow_read_gpx']", :count => 0