assert_response :gone
# check chat a non-existent way is not returned
- get api_way_path(:id => 0)
+ get api_way_path(0)
assert_response :not_found
end
assert_response :bad_request
# check error when no parameter value provided
- get ways_path, :params => { :ways => "" }
+ get ways_path(:ways => "")
assert_response :bad_request
# test a working call
- get ways_path, :params => { :ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}" }
+ get ways_path(:ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}")
assert_response :success
assert_select "osm" do
assert_select "way", :count => 4
end
# test a working call with json format
- get ways_path, :params => { :ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}", :format => "json" }
+ get ways_path(:ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}", :format => "json")
js = ActiveSupport::JSON.decode(@response.body)
assert_not_nil js
assert_equal 1, (js["elements"].count { |a| a["id"] == way4.id && a["visible"].nil? })
# check error when a non-existent way is included
- get ways_path, :params => { :ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id},0" }
+ get ways_path(:ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id},0")
assert_response :not_found
end
changeset = create(:changeset, :user => user)
## First check that it fails when creating a way using a non-public user
- auth_header = basic_authorization_header private_user.email, "test"
+ auth_header = bearer_authorization_header private_user
# use the first user's open changeset
changeset_id = private_changeset.id
"way upload did not return forbidden status"
## Now use a public user
- auth_header = basic_authorization_header user.email, "test"
+ auth_header = bearer_authorization_header user
# use the first user's open changeset
changeset_id = changeset.id
closed_changeset = create(:changeset, :closed, :user => user)
## First test with a private user to make sure that they are not authorized
- auth_header = basic_authorization_header private_user.email, "test"
+ auth_header = bearer_authorization_header private_user
# use the first user's open changeset
# create a way with non-existing node
"way upload to closed changeset with a private user did not return 'forbidden'"
## Now test with a public user
- auth_header = basic_authorization_header user.email, "test"
+ auth_header = bearer_authorization_header user
# use the first user's open changeset
# create a way with non-existing node
assert_response :unauthorized
# now set auth using the private user
- auth_header = basic_authorization_header private_user.email, "test"
+ auth_header = bearer_authorization_header private_user
# this shouldn't work as with the 0.6 api we need pay load to delete
delete api_way_path(private_way), :headers => auth_header
"shouldn't be able to delete a way used in a relation (#{@response.body}), when done by a private user"
# this won't work since the way never existed
- delete api_way_path(:id => 0), :headers => auth_header
+ delete api_way_path(0), :headers => auth_header
assert_response :forbidden
### Now check with a public user
# now set auth
- auth_header = basic_authorization_header user.email, "test"
+ auth_header = bearer_authorization_header user
# this shouldn't work as with the 0.6 api we need pay load to delete
delete api_way_path(way), :headers => auth_header
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
# this won't work since the way never existed
- delete api_way_path(:id => 0), :params => xml.to_s, :headers => auth_header
+ delete api_way_path(0), :params => xml.to_s, :headers => auth_header
assert_response :not_found
end
## Second test with the private user
# setup auth
- auth_header = basic_authorization_header private_user.email, "test"
+ auth_header = bearer_authorization_header private_user
## trying to break changesets
## Finally test with the public user
# setup auth
- auth_header = basic_authorization_header user.email, "test"
+ auth_header = bearer_authorization_header user
## trying to break changesets
## Try with the non-public user
# setup auth
- auth_header = basic_authorization_header private_user.email, "test"
+ auth_header = bearer_authorization_header private_user
# add an identical tag to the way
tag_xml = XML::Node.new("tag")
## Now try with the public user
# setup auth
- auth_header = basic_authorization_header user.email, "test"
+ auth_header = bearer_authorization_header user
# add an identical tag to the way
tag_xml = XML::Node.new("tag")
## Try with the non-public user
# setup auth
- auth_header = basic_authorization_header private_user.email, "test"
+ auth_header = bearer_authorization_header private_user
# add an identical tag to the way
tag_xml = XML::Node.new("tag")
## Now try with the public user
# setup auth
- auth_header = basic_authorization_header user.email, "test"
+ auth_header = bearer_authorization_header user
# add an identical tag to the way
tag_xml = XML::Node.new("tag")
## First test with the non-public user so should be rejected
# setup auth
- auth_header = basic_authorization_header private_user.email, "test"
+ auth_header = bearer_authorization_header private_user
# create duplicate tag
tag_xml = XML::Node.new("tag")
## Now test with the public user
# setup auth
- auth_header = basic_authorization_header user.email, "test"
+ auth_header = bearer_authorization_header user
# create duplicate tag
tag_xml = XML::Node.new("tag")
## First make sure that you can't with a non-public user
# setup auth
- auth_header = basic_authorization_header private_user.email, "test"
+ auth_header = bearer_authorization_header private_user
# add the tag into the existing xml
way_str = "<osm><way changeset='#{private_changeset.id}'>"
## Now do it with a public user
# setup auth
- auth_header = basic_authorization_header user.email, "test"
+ auth_header = bearer_authorization_header user
# add the tag into the existing xml
way_str = "<osm><way changeset='#{changeset.id}'>"
:num_changes => Settings.initial_changes_per_hour - 1)
# create authentication header
- auth_header = basic_authorization_header user.email, "test"
+ auth_header = bearer_authorization_header user
# try creating a way
xml = "<osm><way changeset='#{changeset.id}'>" \
end
# create authentication header
- auth_header = basic_authorization_header user.email, "test"
+ auth_header = bearer_authorization_header user
# try creating a way
xml = "<osm><way changeset='#{changeset.id}'>" \