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" }
13 { :path => "/api/0.6/permissions.json", :method => :get },
14 { :controller => "api/permissions", :action => "show", :format => "json" }
18 def test_permissions_anonymous
20 assert_response :success
21 assert_select "osm > permissions", :count => 1 do
22 assert_select "permission", :count => 0
26 get permissions_path(:format => "json")
27 assert_response :success
28 assert_equal "application/json", @response.media_type
30 js = ActiveSupport::JSON.decode(@response.body)
32 assert_equal 0, js["permissions"].count
35 def test_permissions_oauth2
37 auth_header = bearer_authorization_header(user, :scopes => %w[read_prefs write_api])
38 get permissions_path, :headers => auth_header
39 assert_response :success
40 assert_select "osm > permissions", :count => 1 do
41 assert_select "permission", :count => 2
42 assert_select "permission[name='allow_read_prefs']", :count => 1
43 assert_select "permission[name='allow_write_api']", :count => 1
44 assert_select "permission[name='allow_read_gpx']", :count => 0