Fix tests for rails 5.2.1 compatibility
Rails 5.2.1 has changed how the request body is handled internally for a test which means we can no longer cheat by stashing it in the request environment and must instead pass it properly to the request method.
This commit is contained in:
parent
28e011e219
commit
6f2f9221ef
9 changed files with 485 additions and 630 deletions
|
@ -21,8 +21,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
user_en_de = create(:user, :languages => %w[en de])
|
user_en_de = create(:user, :languages => %w[en de])
|
||||||
user_de = create(:user, :languages => %w[de])
|
user_de = create(:user, :languages => %w[de])
|
||||||
[user_en_de, user_de].each do |user|
|
[user_en_de, user_de].each do |user|
|
||||||
amf_content "getpresets", "/1", ["#{user.email}:test", ""]
|
post :amf_read, :body => amf_content("getpresets", "/1", ["#{user.email}:test", ""])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
presets = amf_result("/1")
|
presets = amf_result("/1")
|
||||||
|
@ -50,8 +49,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
node = way.nodes.first
|
node = way.nodes.first
|
||||||
user = way.changeset.user
|
user = way.changeset.user
|
||||||
|
|
||||||
amf_content "getway", "/1", [way.id]
|
post :amf_read, :body => amf_content("getway", "/1", [way.id])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -68,8 +66,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
# check an invisible way
|
# check an invisible way
|
||||||
id = create(:way, :deleted).id
|
id = create(:way, :deleted).id
|
||||||
|
|
||||||
amf_content "getway", "/1", [id]
|
post :amf_read, :body => amf_content("getway", "/1", [id])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -86,8 +83,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
node = way.nodes.first
|
node = way.nodes.first
|
||||||
user = way.changeset.user
|
user = way.changeset.user
|
||||||
|
|
||||||
amf_content "getway", "/1", [way.id]
|
post :amf_read, :body => amf_content("getway", "/1", [way.id])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -108,8 +104,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
create(:way_node, :way => way, :node => node, :sequence_id => 2)
|
create(:way_node, :way => way, :node => node, :sequence_id => 2)
|
||||||
user = way.changeset.user
|
user = way.changeset.user
|
||||||
|
|
||||||
amf_content "getway", "/1", [way.id]
|
post :amf_read, :body => amf_content("getway", "/1", [way.id])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -131,8 +126,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
c = way.nodes[2].id
|
c = way.nodes[2].id
|
||||||
user = way.changeset.user
|
user = way.changeset.user
|
||||||
|
|
||||||
amf_content "getway", "/1", [way.id]
|
post :amf_read, :body => amf_content("getway", "/1", [way.id])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -149,8 +143,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_getway_nonexistent
|
def test_getway_nonexistent
|
||||||
# check chat a non-existent way is not returned
|
# check chat a non-existent way is not returned
|
||||||
amf_content "getway", "/1", [0]
|
post :amf_read, :body => amf_content("getway", "/1", [0])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
way = amf_result("/1")
|
way = amf_result("/1")
|
||||||
|
@ -172,8 +165,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
minlat = node.lat - 0.1
|
minlat = node.lat - 0.1
|
||||||
maxlon = node.lon + 0.1
|
maxlon = node.lon + 0.1
|
||||||
maxlat = node.lat + 0.1
|
maxlat = node.lat + 0.1
|
||||||
amf_content "whichways", "/1", [minlon, minlat, maxlon, maxlat]
|
post :amf_read, :body => amf_content("whichways", "/1", [minlon, minlat, maxlon, maxlat])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
|
|
||||||
|
@ -266,8 +258,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
minlat = node.lat - 0.1
|
minlat = node.lat - 0.1
|
||||||
maxlon = node.lon + 0.1
|
maxlon = node.lon + 0.1
|
||||||
maxlat = node.lat + 0.1
|
maxlat = node.lat + 0.1
|
||||||
amf_content "whichways_deleted", "/1", [minlon, minlat, maxlon, maxlat]
|
post :amf_read, :body => amf_content("whichways_deleted", "/1", [minlon, minlat, maxlon, maxlat])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
|
|
||||||
|
@ -286,8 +277,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_whichways_deleted_toobig
|
def test_whichways_deleted_toobig
|
||||||
bbox = [-0.1, -0.1, 1.1, 1.1]
|
bbox = [-0.1, -0.1, 1.1, 1.1]
|
||||||
amf_content "whichways_deleted", "/1", bbox
|
post :amf_read, :body => amf_content("whichways_deleted", "/1", bbox)
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
|
|
||||||
|
@ -297,8 +287,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_getrelation
|
def test_getrelation
|
||||||
id = create(:relation).id
|
id = create(:relation).id
|
||||||
amf_content "getrelation", "/1", [id]
|
post :amf_read, :body => amf_content("getrelation", "/1", [id])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
rel = amf_result("/1")
|
rel = amf_result("/1")
|
||||||
|
@ -308,8 +297,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_getrelation_invisible
|
def test_getrelation_invisible
|
||||||
id = create(:relation, :deleted).id
|
id = create(:relation, :deleted).id
|
||||||
amf_content "getrelation", "/1", [id]
|
post :amf_read, :body => amf_content("getrelation", "/1", [id])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
rel = amf_result("/1")
|
rel = amf_result("/1")
|
||||||
|
@ -321,8 +309,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_getrelation_nonexistent
|
def test_getrelation_nonexistent
|
||||||
id = 0
|
id = 0
|
||||||
amf_content "getrelation", "/1", [id]
|
post :amf_read, :body => amf_content("getrelation", "/1", [id])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
rel = amf_result("/1")
|
rel = amf_result("/1")
|
||||||
|
@ -343,8 +330,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
# try to get version 1
|
# try to get version 1
|
||||||
{ latest.id => "",
|
{ latest.id => "",
|
||||||
v1.way_id => (v1.timestamp + 1).strftime("%d %b %Y, %H:%M:%S") }.each do |id, t|
|
v1.way_id => (v1.timestamp + 1).strftime("%d %b %Y, %H:%M:%S") }.each do |id, t|
|
||||||
amf_content "getway_old", "/1", [id, t]
|
post :amf_read, :body => amf_content("getway_old", "/1", [id, t])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
returned_way = amf_result("/1")
|
returned_way = amf_result("/1")
|
||||||
|
@ -365,8 +351,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
way_id => "2009-03-25 00:00:00", # <- wrong format
|
way_id => "2009-03-25 00:00:00", # <- wrong format
|
||||||
way_id => "0 Jan 2009 00:00:00", # <- invalid date
|
way_id => "0 Jan 2009 00:00:00", # <- invalid date
|
||||||
-1 => "1 Jan 2009 00:00:00" }.each do |id, t| # <- invalid
|
-1 => "1 Jan 2009 00:00:00" }.each do |id, t| # <- invalid
|
||||||
amf_content "getway_old", "/1", [id, t]
|
post :amf_read, :body => amf_content("getway_old", "/1", [id, t])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
returned_way = amf_result("/1")
|
returned_way = amf_result("/1")
|
||||||
|
@ -386,8 +371,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
[[0, ""],
|
[[0, ""],
|
||||||
[0, "1 Jan 1970, 00:00:00"],
|
[0, "1 Jan 1970, 00:00:00"],
|
||||||
[v1.way_id, (v1.timestamp - 10).strftime("%d %b %Y, %H:%M:%S")]].each do |id, t|
|
[v1.way_id, (v1.timestamp - 10).strftime("%d %b %Y, %H:%M:%S")]].each do |id, t|
|
||||||
amf_content "getway_old", "/1", [id, t]
|
post :amf_read, :body => amf_content("getway_old", "/1", [id, t])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
returned_way = amf_result("/1")
|
returned_way = amf_result("/1")
|
||||||
|
@ -403,8 +387,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
v1 = way.old_ways.find_by(:version => 1)
|
v1 = way.old_ways.find_by(:version => 1)
|
||||||
# try to get deleted version
|
# try to get deleted version
|
||||||
[[v1.way_id, (v1.timestamp + 10).strftime("%d %b %Y, %H:%M:%S")]].each do |id, t|
|
[[v1.way_id, (v1.timestamp + 10).strftime("%d %b %Y, %H:%M:%S")]].each do |id, t|
|
||||||
amf_content "getway_old", "/1", [id, t]
|
post :amf_read, :body => amf_content("getway_old", "/1", [id, t])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
returned_way = amf_result("/1")
|
returned_way = amf_result("/1")
|
||||||
|
@ -420,8 +403,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
oldest = create(:old_way, :current_way => latest, :version => 1, :timestamp => latest.timestamp - 2.minutes)
|
oldest = create(:old_way, :current_way => latest, :version => 1, :timestamp => latest.timestamp - 2.minutes)
|
||||||
create(:old_way, :current_way => latest, :version => 2, :timestamp => latest.timestamp)
|
create(:old_way, :current_way => latest, :version => 2, :timestamp => latest.timestamp)
|
||||||
|
|
||||||
amf_content "getway_history", "/1", [latest.id]
|
post :amf_read, :body => amf_content("getway_history", "/1", [latest.id])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
history = amf_result("/1")
|
history = amf_result("/1")
|
||||||
|
@ -438,8 +420,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_getway_history_nonexistent
|
def test_getway_history_nonexistent
|
||||||
amf_content "getway_history", "/1", [0]
|
post :amf_read, :body => amf_content("getway_history", "/1", [0])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
history = amf_result("/1")
|
history = amf_result("/1")
|
||||||
|
@ -456,8 +437,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
_node_v2 = create(:old_node, :current_node => node, :version => 2, :timestamp => 2.days.ago)
|
_node_v2 = create(:old_node, :current_node => node, :version => 2, :timestamp => 2.days.ago)
|
||||||
node_v3 = create(:old_node, :current_node => node, :version => 3, :timestamp => 1.day.ago)
|
node_v3 = create(:old_node, :current_node => node, :version => 3, :timestamp => 1.day.ago)
|
||||||
|
|
||||||
amf_content "getnode_history", "/1", [node.id]
|
post :amf_read, :body => amf_content("getnode_history", "/1", [node.id])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
history = amf_result("/1")
|
history = amf_result("/1")
|
||||||
|
@ -478,8 +458,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_getnode_history_nonexistent
|
def test_getnode_history_nonexistent
|
||||||
amf_content "getnode_history", "/1", [0]
|
post :amf_read, :body => amf_content("getnode_history", "/1", [0])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
history = amf_result("/1")
|
history = amf_result("/1")
|
||||||
|
@ -491,8 +470,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_findgpx_bad_user
|
def test_findgpx_bad_user
|
||||||
amf_content "findgpx", "/1", [1, "test@example.com:wrong"]
|
post :amf_read, :body => amf_content("findgpx", "/1", [1, "test@example.com:wrong"])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -503,8 +481,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
blocked_user = create(:user)
|
blocked_user = create(:user)
|
||||||
create(:user_block, :user => blocked_user)
|
create(:user_block, :user => blocked_user)
|
||||||
amf_content "findgpx", "/1", [1, "#{blocked_user.email}:test"]
|
post :amf_read, :body => amf_content("findgpx", "/1", [1, "#{blocked_user.email}:test"])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -518,8 +495,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
trace = create(:trace, :visibility => "private", :user => user)
|
trace = create(:trace, :visibility => "private", :user => user)
|
||||||
|
|
||||||
amf_content "findgpx", "/1", [trace.id, "#{user.email}:test"]
|
post :amf_read, :body => amf_content("findgpx", "/1", [trace.id, "#{user.email}:test"])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -538,8 +514,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
def test_findgpx_by_name
|
def test_findgpx_by_name
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
|
|
||||||
amf_content "findgpx", "/1", ["Trace", "#{user.email}:test"]
|
post :amf_read, :body => amf_content("findgpx", "/1", ["Trace", "#{user.email}:test"])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -552,8 +527,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
def test_findrelations_by_id
|
def test_findrelations_by_id
|
||||||
relation = create(:relation, :version => 4)
|
relation = create(:relation, :version => 4)
|
||||||
|
|
||||||
amf_content "findrelations", "/1", [relation.id]
|
post :amf_read, :body => amf_content("findrelations", "/1", [relation.id])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -565,8 +539,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
assert_equal relation.members, result[0][2]
|
assert_equal relation.members, result[0][2]
|
||||||
assert_equal relation.version, result[0][3]
|
assert_equal relation.version, result[0][3]
|
||||||
|
|
||||||
amf_content "findrelations", "/1", [999999]
|
post :amf_read, :body => amf_content("findrelations", "/1", [999999])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -583,8 +556,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
create(:relation_tag, :relation => used_relation, :k => "test", :v => "yes")
|
create(:relation_tag, :relation => used_relation, :k => "test", :v => "yes")
|
||||||
create(:relation_tag, :relation => used_relation, :k => "name", :v => "Test Relation")
|
create(:relation_tag, :relation => used_relation, :k => "name", :v => "Test Relation")
|
||||||
|
|
||||||
amf_content "findrelations", "/1", ["yes"]
|
post :amf_read, :body => amf_content("findrelations", "/1", ["yes"])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1").sort
|
result = amf_result("/1").sort
|
||||||
|
@ -601,8 +573,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
assert_equal used_relation.members, result[1][2]
|
assert_equal used_relation.members, result[1][2]
|
||||||
assert_equal used_relation.version, result[1][3]
|
assert_equal used_relation.version, result[1][3]
|
||||||
|
|
||||||
amf_content "findrelations", "/1", ["no"]
|
post :amf_read, :body => amf_content("findrelations", "/1", ["no"])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1").sort
|
result = amf_result("/1").sort
|
||||||
|
@ -614,8 +585,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
node = create(:node, :with_history, :version => 4)
|
node = create(:node, :with_history, :version => 4)
|
||||||
create(:node_tag, :node => node)
|
create(:node_tag, :node => node)
|
||||||
|
|
||||||
amf_content "getpoi", "/1", [node.id, ""]
|
post :amf_read, :body => amf_content("getpoi", "/1", [node.id, ""])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -629,8 +599,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
assert_equal node.tags, result[5]
|
assert_equal node.tags, result[5]
|
||||||
assert_equal node.version, result[6]
|
assert_equal node.version, result[6]
|
||||||
|
|
||||||
amf_content "getpoi", "/1", [999999, ""]
|
post :amf_read, :body => amf_content("getpoi", "/1", [999999, ""])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -649,8 +618,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
# previous whole second, causing <= comparison to fail
|
# previous whole second, causing <= comparison to fail
|
||||||
timestamp = (node.timestamp + 1.second).xmlschema
|
timestamp = (node.timestamp + 1.second).xmlschema
|
||||||
|
|
||||||
amf_content "getpoi", "/1", [node.node_id, timestamp]
|
post :amf_read, :body => amf_content("getpoi", "/1", [node.node_id, timestamp])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -664,8 +632,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
assert_equal node.tags, result[5]
|
assert_equal node.tags, result[5]
|
||||||
assert_equal current_node.version, result[6]
|
assert_equal current_node.version, result[6]
|
||||||
|
|
||||||
amf_content "getpoi", "/1", [node.node_id, "2000-01-01T00:00:00Z"]
|
post :amf_read, :body => amf_content("getpoi", "/1", [node.node_id, "2000-01-01T00:00:00Z"])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -675,8 +642,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
assert_equal "node", result[1]
|
assert_equal "node", result[1]
|
||||||
assert_equal node.node_id, result[2]
|
assert_equal node.node_id, result[2]
|
||||||
|
|
||||||
amf_content "getpoi", "/1", [999999, Time.now.xmlschema]
|
post :amf_read, :body => amf_content("getpoi", "/1", [999999, Time.now.xmlschema])
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -695,8 +661,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
nd = create(:node)
|
nd = create(:node)
|
||||||
cs_id = nd.changeset.id
|
cs_id = nd.changeset.id
|
||||||
user = nd.changeset.user
|
user = nd.changeset.user
|
||||||
amf_content "putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible]
|
post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -711,8 +676,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
# Now try to update again, with a different lat/lon, using the updated version number
|
# Now try to update again, with a different lat/lon, using the updated version number
|
||||||
lat = nd.lat + 0.1
|
lat = nd.lat + 0.1
|
||||||
lon = nd.lon - 0.1
|
lon = nd.lon - 0.1
|
||||||
amf_content "putpoi", "/2", ["#{user.email}:test", cs_id, nd.version + 1, nd.id, lon, lat, nd.tags, nd.visible]
|
post :amf_write, :body => amf_content("putpoi", "/2", ["#{user.email}:test", cs_id, nd.version + 1, nd.id, lon, lat, nd.tags, nd.visible])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/2")
|
result = amf_result("/2")
|
||||||
|
@ -737,8 +701,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
changeset = create(:changeset)
|
changeset = create(:changeset)
|
||||||
user = changeset.user
|
user = changeset.user
|
||||||
|
|
||||||
amf_content "putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, {}, nil]
|
post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, {}, nil])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -774,8 +737,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
lat = rand(-50..49) + rand
|
lat = rand(-50..49) + rand
|
||||||
lon = rand(-50..49) + rand
|
lon = rand(-50..49) + rand
|
||||||
|
|
||||||
amf_content "putpoi", "/2", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, { "key" => "value", "ping" => "pong" }, nil]
|
post :amf_write, :body => amf_content("putpoi", "/2", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, { "key" => "value", "ping" => "pong" }, nil])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/2")
|
result = amf_result("/2")
|
||||||
|
@ -821,8 +783,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
mostly_invalid = (0..31).to_a.map(&:chr).join
|
mostly_invalid = (0..31).to_a.map(&:chr).join
|
||||||
tags = { "something" => "foo#{mostly_invalid}bar" }
|
tags = { "something" => "foo#{mostly_invalid}bar" }
|
||||||
|
|
||||||
amf_content "putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, tags, nil]
|
post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, tags, nil])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -857,8 +818,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
invalid = "\xc0\xc0"
|
invalid = "\xc0\xc0"
|
||||||
tags = { "something" => "foo#{invalid}bar" }
|
tags = { "something" => "foo#{invalid}bar" }
|
||||||
|
|
||||||
amf_content "putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, tags, nil]
|
post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, tags, nil])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -874,8 +834,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
cs_id = nd.changeset.id
|
cs_id = nd.changeset.id
|
||||||
user = nd.changeset.user
|
user = nd.changeset.user
|
||||||
|
|
||||||
amf_content "putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, false]
|
post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, false])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -897,8 +856,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
cs_id = nd.changeset.id
|
cs_id = nd.changeset.id
|
||||||
user = nd.changeset.user
|
user = nd.changeset.user
|
||||||
|
|
||||||
amf_content "putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, false]
|
post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, false])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -915,8 +873,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
cs_id = changeset.id
|
cs_id = changeset.id
|
||||||
user = changeset.user
|
user = changeset.user
|
||||||
|
|
||||||
amf_content "putpoi", "/1", ["#{user.email}:test", cs_id, 1, 999999, 0, 0, {}, false]
|
post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", cs_id, 1, 999999, 0, 0, {}, false])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -933,8 +890,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
cs_id = nd.changeset.id
|
cs_id = nd.changeset.id
|
||||||
user = nd.changeset.user
|
user = nd.changeset.user
|
||||||
|
|
||||||
amf_content "putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, 200, 100, nd.tags, true]
|
post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, 200, 100, nd.tags, true])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -956,8 +912,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
d = create(:node).id
|
d = create(:node).id
|
||||||
e = create(:node).id
|
e = create(:node).id
|
||||||
|
|
||||||
amf_content "putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [a, b, c], { "test" => "new" }, [], {}]
|
post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [a, b, c], { "test" => "new" }, [], {}])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -978,8 +933,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
assert_equal [a, b, c], new_way.nds
|
assert_equal [a, b, c], new_way.nds
|
||||||
assert_equal({ "test" => "new" }, new_way.tags)
|
assert_equal({ "test" => "new" }, new_way.tags)
|
||||||
|
|
||||||
amf_content "putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [b, d, e, a], { "test" => "newer" }, [], {}]
|
post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [b, d, e, a], { "test" => "newer" }, [], {}])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1000,8 +954,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
assert_equal [b, d, e, a], new_way.nds
|
assert_equal [b, d, e, a], new_way.nds
|
||||||
assert_equal({ "test" => "newer" }, new_way.tags)
|
assert_equal({ "test" => "newer" }, new_way.tags)
|
||||||
|
|
||||||
amf_content "putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [b, -1, d, e], { "test" => "newest" }, [[4.56, 12.34, -1, 0, { "test" => "new" }], [12.34, 4.56, d, 1, { "test" => "ok" }]], { a => 1 }]
|
post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [b, -1, d, e], { "test" => "newest" }, [[4.56, 12.34, -1, 0, { "test" => "new" }], [12.34, 4.56, d, 1, { "test" => "ok" }]], { a => 1 }])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1050,8 +1003,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
user = way.changeset.user
|
user = way.changeset.user
|
||||||
|
|
||||||
assert_not_equal({ "test" => "ok" }, way.tags)
|
assert_not_equal({ "test" => "ok" }, way.tags)
|
||||||
amf_content "putway", "/1", ["#{user.email}:test", cs_id, way.version, way.id, way.nds, { "test" => "ok" }, [], {}]
|
post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, way.version, way.id, way.nds, { "test" => "ok" }, [], {}])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1078,8 +1030,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
d = create(:node).id
|
d = create(:node).id
|
||||||
|
|
||||||
assert_not_equal [a, b, c, d], way.nds
|
assert_not_equal [a, b, c, d], way.nds
|
||||||
amf_content "putway", "/1", ["#{user.email}:test", cs_id, way.version + 1, way.id, [a, b, c, d], way.tags, [], {}]
|
post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, way.version + 1, way.id, [a, b, c, d], way.tags, [], {}])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1099,8 +1050,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
assert_equal [a, b, c, d], new_way.nds
|
assert_equal [a, b, c, d], new_way.nds
|
||||||
assert_equal way.tags, new_way.tags
|
assert_equal way.tags, new_way.tags
|
||||||
|
|
||||||
amf_content "putway", "/1", ["#{user.email}:test", cs_id, way.version + 2, way.id, [a, -1, b, c], way.tags, [[4.56, 12.34, -1, 0, { "test" => "new" }], [12.34, 4.56, b, 1, { "test" => "ok" }]], { d => 1 }]
|
post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, way.version + 2, way.id, [a, -1, b, c], way.tags, [[4.56, 12.34, -1, 0, { "test" => "new" }], [12.34, 4.56, b, 1, { "test" => "ok" }]], { d => 1 }])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1156,8 +1106,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
create(:way_node, :node => b)
|
create(:way_node, :node => b)
|
||||||
c = way.nodes[2]
|
c = way.nodes[2]
|
||||||
|
|
||||||
amf_content "deleteway", "/1", ["#{user.email}:test", cs_id, way.id, way.version, nodes]
|
post :amf_write, :body => amf_content("deleteway", "/1", ["#{user.email}:test", cs_id, way.id, way.version, nodes])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1186,8 +1135,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
cs_id = way.changeset.id
|
cs_id = way.changeset.id
|
||||||
user = way.changeset.user
|
user = way.changeset.user
|
||||||
|
|
||||||
amf_content "deleteway", "/1", ["#{user.email}:test", cs_id, way.id, way.version, nodes]
|
post :amf_write, :body => amf_content("deleteway", "/1", ["#{user.email}:test", cs_id, way.id, way.version, nodes])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1215,8 +1163,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
way = create(:way_with_nodes, :nodes_count => 2)
|
way = create(:way_with_nodes, :nodes_count => 2)
|
||||||
relation = create(:relation)
|
relation = create(:relation)
|
||||||
|
|
||||||
amf_content "putrelation", "/1", ["#{user.email}:test", cs_id, 0, -1, { "test" => "new" }, [["Node", node.id, "node"], ["Way", way.id, "way"], ["Relation", relation.id, "relation"]], true]
|
post :amf_write, :body => amf_content("putrelation", "/1", ["#{user.email}:test", cs_id, 0, -1, { "test" => "new" }, [["Node", node.id, "node"], ["Way", way.id, "way"], ["Relation", relation.id, "relation"]], true])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1244,8 +1191,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
cs_id = relation.changeset.id
|
cs_id = relation.changeset.id
|
||||||
|
|
||||||
assert_not_equal({ "test" => "ok" }, relation.tags)
|
assert_not_equal({ "test" => "ok" }, relation.tags)
|
||||||
amf_content "putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, { "test" => "ok" }, relation.members, true]
|
post :amf_write, :body => amf_content("putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, { "test" => "ok" }, relation.members, true])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1272,8 +1218,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
cs_id = relation.changeset.id
|
cs_id = relation.changeset.id
|
||||||
user = relation.changeset.user
|
user = relation.changeset.user
|
||||||
|
|
||||||
amf_content "putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, relation.tags, relation.members, false]
|
post :amf_write, :body => amf_content("putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, relation.tags, relation.members, false])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1300,8 +1245,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
cs_id = relation.changeset.id
|
cs_id = relation.changeset.id
|
||||||
user = relation.changeset.user
|
user = relation.changeset.user
|
||||||
|
|
||||||
amf_content "putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, relation.tags, relation.members, false]
|
post :amf_write, :body => amf_content("putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, relation.tags, relation.members, false])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1321,8 +1265,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
def test_startchangeset_valid
|
def test_startchangeset_valid
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
|
|
||||||
amf_content "startchangeset", "/1", ["#{user.email}:test", { "source" => "new" }, nil, "new", 1]
|
post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user.email}:test", { "source" => "new" }, nil, "new", 1])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1338,8 +1281,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
old_cs_id = new_cs_id
|
old_cs_id = new_cs_id
|
||||||
|
|
||||||
amf_content "startchangeset", "/1", ["#{user.email}:test", { "source" => "newer" }, old_cs_id, "newer", 1]
|
post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user.email}:test", { "source" => "newer" }, old_cs_id, "newer", 1])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1361,8 +1303,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
old_cs_id = new_cs_id
|
old_cs_id = new_cs_id
|
||||||
|
|
||||||
amf_content "startchangeset", "/1", ["#{user.email}:test", {}, old_cs_id, "", 0]
|
post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user.email}:test", {}, old_cs_id, "", 0])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1382,8 +1323,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
user2 = create(:user)
|
user2 = create(:user)
|
||||||
|
|
||||||
amf_content "startchangeset", "/1", ["#{user.email}:test", { "source" => "new" }, nil, "new", 1]
|
post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user.email}:test", { "source" => "new" }, nil, "new", 1])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1397,8 +1337,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
assert_equal true, cs.is_open?
|
assert_equal true, cs.is_open?
|
||||||
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
|
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
|
||||||
|
|
||||||
amf_content "startchangeset", "/1", ["#{user2.email}:test", {}, cs_id, "delete", 0]
|
post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user2.email}:test", {}, cs_id, "delete", 0])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1419,8 +1358,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
invalid = "\035\022"
|
invalid = "\035\022"
|
||||||
comment = "foo#{invalid}bar"
|
comment = "foo#{invalid}bar"
|
||||||
|
|
||||||
amf_content "startchangeset", "/1", ["#{user.email}:test", {}, nil, comment, 1]
|
post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user.email}:test", {}, nil, comment, 1])
|
||||||
post :amf_write
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
result = amf_result("/1")
|
result = amf_result("/1")
|
||||||
|
@ -1460,7 +1398,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
c.write [-1].pack("N")
|
c.write [-1].pack("N")
|
||||||
c.write AMF.encodevalue(data)
|
c.write AMF.encodevalue(data)
|
||||||
|
|
||||||
@request.env["RAW_POST_DATA"] = c.string
|
c.string
|
||||||
end
|
end
|
||||||
|
|
||||||
# Parses the @response object as an AMF messsage.
|
# Parses the @response object as an AMF messsage.
|
||||||
|
@ -1499,8 +1437,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
# caller's block for assertion testing.
|
# caller's block for assertion testing.
|
||||||
def check_bboxes_are_bad(bboxes)
|
def check_bboxes_are_bad(bboxes)
|
||||||
bboxes.each do |bbox|
|
bboxes.each do |bbox|
|
||||||
amf_content "whichways", "/1", bbox
|
post :amf_read, :body => amf_content("whichways", "/1", bbox)
|
||||||
post :amf_read
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
amf_parse_response
|
amf_parse_response
|
||||||
|
|
||||||
|
|
|
@ -77,18 +77,18 @@ class ChangesetsControllerTest < ActionController::TestCase
|
||||||
def test_create
|
def test_create
|
||||||
basic_authorization create(:user, :data_public => false).email, "test"
|
basic_authorization create(:user, :data_public => false).email, "test"
|
||||||
# Create the first user's changeset
|
# Create the first user's changeset
|
||||||
content "<osm><changeset>" \
|
xml = "<osm><changeset>" \
|
||||||
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
||||||
"</changeset></osm>"
|
"</changeset></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_require_public_data
|
assert_require_public_data
|
||||||
|
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
# Create the first user's changeset
|
# Create the first user's changeset
|
||||||
content "<osm><changeset>" \
|
xml = "<osm><changeset>" \
|
||||||
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
||||||
"</changeset></osm>"
|
"</changeset></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
|
|
||||||
assert_response :success, "Creation of changeset did not return sucess status"
|
assert_response :success, "Creation of changeset did not return sucess status"
|
||||||
newid = @response.body.to_i
|
newid = @response.body.to_i
|
||||||
|
@ -111,14 +111,14 @@ class ChangesetsControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_create_invalid
|
def test_create_invalid
|
||||||
basic_authorization create(:user, :data_public => false).email, "test"
|
basic_authorization create(:user, :data_public => false).email, "test"
|
||||||
content "<osm><changeset></osm>"
|
xml = "<osm><changeset></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_require_public_data
|
assert_require_public_data
|
||||||
|
|
||||||
## Try the public user
|
## Try the public user
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
content "<osm><changeset></osm>"
|
xml = "<osm><changeset></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :bad_request, "creating a invalid changeset should fail"
|
assert_response :bad_request, "creating a invalid changeset should fail"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -325,8 +325,7 @@ class ChangesetsControllerTest < ActionController::TestCase
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset_id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset_id }
|
|
||||||
assert_response :unauthorized,
|
assert_response :unauthorized,
|
||||||
"shouldn't be able to upload a simple valid diff to changeset: #{@response.body}"
|
"shouldn't be able to upload a simple valid diff to changeset: #{@response.body}"
|
||||||
|
|
||||||
|
@ -355,8 +354,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset_id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset_id }
|
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"can't upload a simple valid diff to changeset: #{@response.body}"
|
"can't upload a simple valid diff to changeset: #{@response.body}"
|
||||||
|
|
||||||
|
@ -385,8 +383,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset_id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset_id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload a simple valid diff to changeset: #{@response.body}"
|
"can't upload a simple valid diff to changeset: #{@response.body}"
|
||||||
|
|
||||||
|
@ -430,8 +427,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload a simple valid creation to changeset: #{@response.body}"
|
"can't upload a simple valid creation to changeset: #{@response.body}"
|
||||||
|
|
||||||
|
@ -495,8 +491,7 @@ CHANGESET
|
||||||
end
|
end
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff.to_s
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload a deletion diff to changeset: #{@response.body}"
|
"can't upload a deletion diff to changeset: #{@response.body}"
|
||||||
|
|
||||||
|
@ -523,8 +518,7 @@ CHANGESET
|
||||||
diff = "<osmChange><delete><node id='#{node.id}' version='#{node.version}' changeset='#{changeset.id}'/></delete></osmChange>"
|
diff = "<osmChange><delete><node id='#{node.id}' version='#{node.version}' changeset='#{changeset.id}'/></delete></osmChange>"
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload a deletion diff to changeset: #{@response.body}"
|
"can't upload a deletion diff to changeset: #{@response.body}"
|
||||||
|
|
||||||
|
@ -540,11 +534,11 @@ CHANGESET
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
# create a temporary changeset
|
# create a temporary changeset
|
||||||
content "<osm><changeset>" \
|
xml = "<osm><changeset>" \
|
||||||
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
||||||
"</changeset></osm>"
|
"</changeset></osm>"
|
||||||
assert_difference "Changeset.count", 1 do
|
assert_difference "Changeset.count", 1 do
|
||||||
put :create
|
put :create, :body => xml
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
@ -554,8 +548,7 @@ CHANGESET
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
# create a changeset
|
# create a changeset
|
||||||
content "<osm><changeset/></osm>"
|
put :create, :body => "<osm><changeset/></osm>"
|
||||||
put :create
|
|
||||||
assert_response :success, "Should be able to create a changeset: #{@response.body}"
|
assert_response :success, "Should be able to create a changeset: #{@response.body}"
|
||||||
changeset_id = @response.body.to_i
|
changeset_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -587,8 +580,7 @@ CHANGESET
|
||||||
|
|
||||||
# upload it, which used to cause an error like "PGError: ERROR:
|
# upload it, which used to cause an error like "PGError: ERROR:
|
||||||
# integer out of range" (bug #2152). but shouldn't any more.
|
# integer out of range" (bug #2152). but shouldn't any more.
|
||||||
content diff
|
post :upload, :params => { :id => changeset_id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset_id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload a spatially-large diff to changeset: #{@response.body}"
|
"can't upload a spatially-large diff to changeset: #{@response.body}"
|
||||||
|
|
||||||
|
@ -630,8 +622,7 @@ CHANGESET
|
||||||
end
|
end
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff.to_s
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :precondition_failed,
|
assert_response :precondition_failed,
|
||||||
"shouldn't be able to upload a invalid deletion diff: #{@response.body}"
|
"shouldn't be able to upload a invalid deletion diff: #{@response.body}"
|
||||||
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
|
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
|
||||||
|
@ -674,8 +665,7 @@ CHANGESET
|
||||||
end
|
end
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff.to_s
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't do a conditional delete of in use objects: #{@response.body}"
|
"can't do a conditional delete of in use objects: #{@response.body}"
|
||||||
|
|
||||||
|
@ -728,8 +718,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"shoudln't be able to upload too long a tag to changeset: #{@response.body}"
|
"shoudln't be able to upload too long a tag to changeset: #{@response.body}"
|
||||||
end
|
end
|
||||||
|
@ -771,8 +760,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload a complex diff to changeset: #{@response.body}"
|
"can't upload a complex diff to changeset: #{@response.body}"
|
||||||
|
|
||||||
|
@ -833,8 +821,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :conflict,
|
assert_response :conflict,
|
||||||
"uploading a diff with multiple changesets should have failed"
|
"uploading a diff with multiple changesets should have failed"
|
||||||
|
|
||||||
|
@ -870,8 +857,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload multiple versions of an element in a diff: #{@response.body}"
|
"can't upload multiple versions of an element in a diff: #{@response.body}"
|
||||||
|
|
||||||
|
@ -900,8 +886,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :conflict,
|
assert_response :conflict,
|
||||||
"shouldn't be able to upload the same element twice in a diff: #{@response.body}"
|
"shouldn't be able to upload the same element twice in a diff: #{@response.body}"
|
||||||
end
|
end
|
||||||
|
@ -922,8 +907,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"shouldn't be able to upload an element without version: #{@response.body}"
|
"shouldn't be able to upload an element without version: #{@response.body}"
|
||||||
end
|
end
|
||||||
|
@ -942,8 +926,7 @@ CHANGESET
|
||||||
</ping>
|
</ping>
|
||||||
</osmChange>
|
</osmChange>
|
||||||
CHANGESET
|
CHANGESET
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :bad_request, "Shouldn't be able to upload a diff with the action ping"
|
assert_response :bad_request, "Shouldn't be able to upload a diff with the action ping"
|
||||||
assert_equal @response.body, "Unknown action ping, choices are create, modify, delete"
|
assert_equal @response.body, "Unknown action ping, choices are create, modify, delete"
|
||||||
end
|
end
|
||||||
|
@ -976,8 +959,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload a valid diff with whitespace variations to changeset: #{@response.body}"
|
"can't upload a valid diff with whitespace variations to changeset: #{@response.body}"
|
||||||
|
|
||||||
|
@ -1014,8 +996,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload a valid diff with re-used placeholders to changeset: #{@response.body}"
|
"can't upload a valid diff with re-used placeholders to changeset: #{@response.body}"
|
||||||
|
|
||||||
|
@ -1043,8 +1024,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"shouldn't be able to re-use placeholder IDs"
|
"shouldn't be able to re-use placeholder IDs"
|
||||||
end
|
end
|
||||||
|
@ -1075,8 +1055,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"shouldn't be able to use invalid placeholder IDs"
|
"shouldn't be able to use invalid placeholder IDs"
|
||||||
assert_equal "Placeholder node not found for reference -4 in way -1", @response.body
|
assert_equal "Placeholder node not found for reference -4 in way -1", @response.body
|
||||||
|
@ -1099,8 +1078,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"shouldn't be able to use invalid placeholder IDs"
|
"shouldn't be able to use invalid placeholder IDs"
|
||||||
assert_equal "Placeholder node not found for reference -4 in way #{way.id}", @response.body
|
assert_equal "Placeholder node not found for reference -4 in way #{way.id}", @response.body
|
||||||
|
@ -1132,8 +1110,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"shouldn't be able to use invalid placeholder IDs"
|
"shouldn't be able to use invalid placeholder IDs"
|
||||||
assert_equal "Placeholder Node not found for reference -4 in relation -1.", @response.body
|
assert_equal "Placeholder Node not found for reference -4 in relation -1.", @response.body
|
||||||
|
@ -1156,8 +1133,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"shouldn't be able to use invalid placeholder IDs"
|
"shouldn't be able to use invalid placeholder IDs"
|
||||||
assert_equal "Placeholder Way not found for reference -1 in relation #{relation.id}.", @response.body
|
assert_equal "Placeholder Way not found for reference -1 in relation #{relation.id}.", @response.body
|
||||||
|
@ -1169,10 +1145,10 @@ CHANGESET
|
||||||
def test_upload_node_move
|
def test_upload_node_move
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
content "<osm><changeset>" \
|
xml = "<osm><changeset>" \
|
||||||
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
||||||
"</changeset></osm>"
|
"</changeset></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success
|
assert_response :success
|
||||||
changeset_id = @response.body.to_i
|
changeset_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -1189,8 +1165,7 @@ CHANGESET
|
||||||
diff.root << modify
|
diff.root << modify
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset_id }, :body => diff.to_s
|
||||||
post :upload, :params => { :id => changeset_id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"diff should have uploaded OK"
|
"diff should have uploaded OK"
|
||||||
|
|
||||||
|
@ -1207,10 +1182,10 @@ CHANGESET
|
||||||
def test_upload_way_extend
|
def test_upload_way_extend
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
content "<osm><changeset>" \
|
xml = "<osm><changeset>" \
|
||||||
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
||||||
"</changeset></osm>"
|
"</changeset></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success
|
assert_response :success
|
||||||
changeset_id = @response.body.to_i
|
changeset_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -1229,8 +1204,7 @@ CHANGESET
|
||||||
diff.root << modify
|
diff.root << modify
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset_id }, :body => diff.to_s
|
||||||
post :upload, :params => { :id => changeset_id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"diff should have uploaded OK"
|
"diff should have uploaded OK"
|
||||||
|
|
||||||
|
@ -1254,8 +1228,7 @@ CHANGESET
|
||||||
"<osmChange><modify/></osmChange>",
|
"<osmChange><modify/></osmChange>",
|
||||||
"<osmChange><modify></modify></osmChange>"].each do |diff|
|
"<osmChange><modify></modify></osmChange>"].each do |diff|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset.id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset.id }
|
|
||||||
assert_response(:success, "should be able to upload " \
|
assert_response(:success, "should be able to upload " \
|
||||||
"empty changeset: " + diff)
|
"empty changeset: " + diff)
|
||||||
end
|
end
|
||||||
|
@ -1278,9 +1251,8 @@ CHANGESET
|
||||||
delete << node.to_xml_node
|
delete << node.to_xml_node
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
|
||||||
error_format "xml"
|
error_format "xml"
|
||||||
post :upload, :params => { :id => changeset.id }
|
post :upload, :params => { :id => changeset.id }, :body => diff.to_s
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"failed to return error in XML format"
|
"failed to return error in XML format"
|
||||||
|
|
||||||
|
@ -1300,20 +1272,20 @@ CHANGESET
|
||||||
basic_authorization create(:user, :data_public => false).email, "test"
|
basic_authorization create(:user, :data_public => false).email, "test"
|
||||||
|
|
||||||
# create a temporary changeset
|
# create a temporary changeset
|
||||||
content "<osm><changeset>" \
|
xml = "<osm><changeset>" \
|
||||||
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
||||||
"</changeset></osm>"
|
"</changeset></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
## Now try with a normal user
|
## Now try with a normal user
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
# create a temporary changeset
|
# create a temporary changeset
|
||||||
content "<osm><changeset>" \
|
xml = "<osm><changeset>" \
|
||||||
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
||||||
"</changeset></osm>"
|
"</changeset></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success
|
assert_response :success
|
||||||
changeset_id = @response.body.to_i
|
changeset_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -1334,8 +1306,7 @@ CHANGESET
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset_id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset_id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload multiple versions of an element in a diff: #{@response.body}"
|
"can't upload multiple versions of an element in a diff: #{@response.body}"
|
||||||
|
|
||||||
|
@ -1356,10 +1327,10 @@ CHANGESET
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
# create a temporary changeset
|
# create a temporary changeset
|
||||||
content "<osm><changeset>" \
|
xml = "<osm><changeset>" \
|
||||||
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
||||||
"</changeset></osm>"
|
"</changeset></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success
|
assert_response :success
|
||||||
changeset_id = @response.body.to_i
|
changeset_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -1393,8 +1364,7 @@ CHANGESET
|
||||||
OSMFILE
|
OSMFILE
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset_id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset_id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload a diff from JOSM: #{@response.body}"
|
"can't upload a diff from JOSM: #{@response.body}"
|
||||||
|
|
||||||
|
@ -1418,10 +1388,10 @@ OSMFILE
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
# create a temporary changeset
|
# create a temporary changeset
|
||||||
content "<osm><changeset>" \
|
xml = "<osm><changeset>" \
|
||||||
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
"<tag k='created_by' v='osm test suite checking changesets'/>" \
|
||||||
"</changeset></osm>"
|
"</changeset></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success
|
assert_response :success
|
||||||
changeset_id = @response.body.to_i
|
changeset_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -1449,8 +1419,7 @@ OSMFILE
|
||||||
CHANGESET
|
CHANGESET
|
||||||
|
|
||||||
# upload it
|
# upload it
|
||||||
content diff
|
post :upload, :params => { :id => changeset_id }, :body => diff
|
||||||
post :upload, :params => { :id => changeset_id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"can't upload multiple versions of an element in a diff: #{@response.body}"
|
"can't upload multiple versions of an element in a diff: #{@response.body}"
|
||||||
|
|
||||||
|
@ -1501,15 +1470,15 @@ CHANGESET
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
# create a new changeset
|
# create a new changeset
|
||||||
content "<osm><changeset/></osm>"
|
xml = "<osm><changeset/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success, "Creating of changeset failed."
|
assert_response :success, "Creating of changeset failed."
|
||||||
changeset_id = @response.body.to_i
|
changeset_id = @response.body.to_i
|
||||||
|
|
||||||
# add a single node to it
|
# add a single node to it
|
||||||
with_controller(NodesController.new) do
|
with_controller(NodesController.new) do
|
||||||
content "<osm><node lon='1' lat='2' changeset='#{changeset_id}'/></osm>"
|
xml = "<osm><node lon='1' lat='2' changeset='#{changeset_id}'/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success, "Couldn't create node."
|
assert_response :success, "Couldn't create node."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1523,8 +1492,8 @@ CHANGESET
|
||||||
|
|
||||||
# add another node to it
|
# add another node to it
|
||||||
with_controller(NodesController.new) do
|
with_controller(NodesController.new) do
|
||||||
content "<osm><node lon='2' lat='1' changeset='#{changeset_id}'/></osm>"
|
xml = "<osm><node lon='2' lat='1' changeset='#{changeset_id}'/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success, "Couldn't create second node."
|
assert_response :success, "Couldn't create second node."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1538,8 +1507,8 @@ CHANGESET
|
||||||
|
|
||||||
# add (delete) a way to it, which contains a point at (3,3)
|
# add (delete) a way to it, which contains a point at (3,3)
|
||||||
with_controller(WaysController.new) do
|
with_controller(WaysController.new) do
|
||||||
content update_changeset(way.to_xml, changeset_id)
|
xml = update_changeset(way.to_xml, changeset_id)
|
||||||
put :delete, :params => { :id => way.id }
|
put :delete, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :success, "Couldn't delete a way."
|
assert_response :success, "Couldn't delete a way."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1558,8 +1527,7 @@ CHANGESET
|
||||||
basic_authorization create(:user).display_name, "test"
|
basic_authorization create(:user).display_name, "test"
|
||||||
|
|
||||||
# create a new changeset
|
# create a new changeset
|
||||||
content "<osm><changeset/></osm>"
|
put :create, :body => "<osm><changeset/></osm>"
|
||||||
put :create
|
|
||||||
assert_response :success, "Creating of changeset failed."
|
assert_response :success, "Creating of changeset failed."
|
||||||
changeset_id = @response.body.to_i
|
changeset_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -1580,8 +1548,8 @@ CHANGESET
|
||||||
basic_authorization create(:user).display_name, "test"
|
basic_authorization create(:user).display_name, "test"
|
||||||
|
|
||||||
# create a new changeset
|
# create a new changeset
|
||||||
content "<osm><changeset/></osm>"
|
xml = "<osm><changeset/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success, "Creating of changeset failed."
|
assert_response :success, "Creating of changeset failed."
|
||||||
changeset_id = @response.body.to_i
|
changeset_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -1589,18 +1557,18 @@ CHANGESET
|
||||||
lat = -0.45
|
lat = -0.45
|
||||||
|
|
||||||
# Try and put
|
# Try and put
|
||||||
content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
|
xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
|
||||||
put :expand_bbox, :params => { :id => changeset_id }
|
put :expand_bbox, :params => { :id => changeset_id }, :body => xml
|
||||||
assert_response :method_not_allowed, "shouldn't be able to put a bbox expand"
|
assert_response :method_not_allowed, "shouldn't be able to put a bbox expand"
|
||||||
|
|
||||||
# Try to get the update
|
# Try to get the update
|
||||||
content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
|
xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
|
||||||
get :expand_bbox, :params => { :id => changeset_id }
|
get :expand_bbox, :params => { :id => changeset_id }, :body => xml
|
||||||
assert_response :method_not_allowed, "shouldn't be able to get a bbox expand"
|
assert_response :method_not_allowed, "shouldn't be able to get a bbox expand"
|
||||||
|
|
||||||
# Try to use a hopefully missing changeset
|
# Try to use a hopefully missing changeset
|
||||||
content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
|
xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
|
||||||
post :expand_bbox, :params => { :id => changeset_id + 13245 }
|
post :expand_bbox, :params => { :id => changeset_id + 13245 }, :body => xml
|
||||||
assert_response :not_found, "shouldn't be able to do a bbox expand on a nonexistant changeset"
|
assert_response :not_found, "shouldn't be able to do a bbox expand on a nonexistant changeset"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1734,20 +1702,19 @@ CHANGESET
|
||||||
new_tag["k"] = "tagtesting"
|
new_tag["k"] = "tagtesting"
|
||||||
new_tag["v"] = "valuetesting"
|
new_tag["v"] = "valuetesting"
|
||||||
new_changeset.find("//osm/changeset").first << new_tag
|
new_changeset.find("//osm/changeset").first << new_tag
|
||||||
content new_changeset
|
|
||||||
|
|
||||||
# try without any authorization
|
# try without any authorization
|
||||||
put :update, :params => { :id => private_changeset.id }
|
put :update, :params => { :id => private_changeset.id }, :body => new_changeset.to_s
|
||||||
assert_response :unauthorized
|
assert_response :unauthorized
|
||||||
|
|
||||||
# try with the wrong authorization
|
# try with the wrong authorization
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
put :update, :params => { :id => private_changeset.id }
|
put :update, :params => { :id => private_changeset.id }, :body => new_changeset.to_s
|
||||||
assert_response :conflict
|
assert_response :conflict
|
||||||
|
|
||||||
# now this should get an unauthorized
|
# now this should get an unauthorized
|
||||||
basic_authorization private_user.email, "test"
|
basic_authorization private_user.email, "test"
|
||||||
put :update, :params => { :id => private_changeset.id }
|
put :update, :params => { :id => private_changeset.id }, :body => new_changeset.to_s
|
||||||
assert_require_public_data "user with their data non-public, shouldn't be able to edit their changeset"
|
assert_require_public_data "user with their data non-public, shouldn't be able to edit their changeset"
|
||||||
|
|
||||||
## Now try with the public user
|
## Now try with the public user
|
||||||
|
@ -1757,21 +1724,20 @@ CHANGESET
|
||||||
new_tag["k"] = "tagtesting"
|
new_tag["k"] = "tagtesting"
|
||||||
new_tag["v"] = "valuetesting"
|
new_tag["v"] = "valuetesting"
|
||||||
new_changeset.find("//osm/changeset").first << new_tag
|
new_changeset.find("//osm/changeset").first << new_tag
|
||||||
content new_changeset
|
|
||||||
|
|
||||||
# try without any authorization
|
# try without any authorization
|
||||||
@request.env["HTTP_AUTHORIZATION"] = nil
|
@request.env["HTTP_AUTHORIZATION"] = nil
|
||||||
put :update, :params => { :id => changeset.id }
|
put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
|
||||||
assert_response :unauthorized
|
assert_response :unauthorized
|
||||||
|
|
||||||
# try with the wrong authorization
|
# try with the wrong authorization
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
put :update, :params => { :id => changeset.id }
|
put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
|
||||||
assert_response :conflict
|
assert_response :conflict
|
||||||
|
|
||||||
# now this should work...
|
# now this should work...
|
||||||
basic_authorization user.email, "test"
|
basic_authorization user.email, "test"
|
||||||
put :update, :params => { :id => changeset.id }
|
put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select "osm>changeset[id='#{changeset.id}']", 1
|
assert_select "osm>changeset[id='#{changeset.id}']", 1
|
||||||
|
@ -1792,8 +1758,7 @@ CHANGESET
|
||||||
new_tag["v"] = "testing"
|
new_tag["v"] = "testing"
|
||||||
new_changeset.find("//osm/changeset").first << new_tag
|
new_changeset.find("//osm/changeset").first << new_tag
|
||||||
|
|
||||||
content new_changeset
|
put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
|
||||||
put :update, :params => { :id => changeset.id }
|
|
||||||
assert_response :conflict
|
assert_response :conflict
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1804,8 +1769,8 @@ CHANGESET
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
# open a new changeset
|
# open a new changeset
|
||||||
content "<osm><changeset/></osm>"
|
xml = "<osm><changeset/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success, "can't create a new changeset"
|
assert_response :success, "can't create a new changeset"
|
||||||
cs_id = @response.body.to_i
|
cs_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -1819,8 +1784,8 @@ CHANGESET
|
||||||
|
|
||||||
with_controller(NodesController.new) do
|
with_controller(NodesController.new) do
|
||||||
# create a new node
|
# create a new node
|
||||||
content "<osm><node changeset='#{cs_id}' lat='0.0' lon='0.0'/></osm>"
|
xml = "<osm><node changeset='#{cs_id}' lat='0.0' lon='0.0'/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success, "can't create a new node"
|
assert_response :success, "can't create a new node"
|
||||||
node_id = @response.body.to_i
|
node_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -1835,8 +1800,7 @@ CHANGESET
|
||||||
node_xml["lon"] = rand.to_s
|
node_xml["lon"] = rand.to_s
|
||||||
node_xml["version"] = (i + 1).to_s
|
node_xml["version"] = (i + 1).to_s
|
||||||
|
|
||||||
content node_doc
|
put :update, :params => { :id => node_id }, :body => node_doc.to_s
|
||||||
put :update, :params => { :id => node_id }
|
|
||||||
assert_response :success, "attempt #{i} should have succeeded"
|
assert_response :success, "attempt #{i} should have succeeded"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1845,8 +1809,7 @@ CHANGESET
|
||||||
node_xml["lon"] = rand.to_s
|
node_xml["lon"] = rand.to_s
|
||||||
node_xml["version"] = offset.to_s
|
node_xml["version"] = offset.to_s
|
||||||
|
|
||||||
content node_doc
|
put :update, :params => { :id => node_id }, :body => node_doc.to_s
|
||||||
put :update, :params => { :id => node_id }
|
|
||||||
assert_response :conflict, "final attempt should have failed"
|
assert_response :conflict, "final attempt should have failed"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2230,8 +2193,8 @@ CHANGESET
|
||||||
##
|
##
|
||||||
# call the include method and assert properties of the bbox
|
# call the include method and assert properties of the bbox
|
||||||
def check_after_include(changeset_id, lon, lat, bbox)
|
def check_after_include(changeset_id, lon, lat, bbox)
|
||||||
content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
|
xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
|
||||||
post :expand_bbox, :params => { :id => changeset_id }
|
post :expand_bbox, :params => { :id => changeset_id }, :body => xml
|
||||||
assert_response :success, "Setting include of changeset failed: #{@response.body}"
|
assert_response :success, "Setting include of changeset failed: #{@response.body}"
|
||||||
|
|
||||||
# check exactly one changeset
|
# check exactly one changeset
|
||||||
|
|
|
@ -38,9 +38,9 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
## First try with no auth
|
## First try with no auth
|
||||||
# create a minimal xml file
|
# create a minimal xml file
|
||||||
content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>")
|
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
|
||||||
assert_difference("OldNode.count", 0) do
|
assert_difference("OldNode.count", 0) do
|
||||||
put :create
|
put :create, :body => xml
|
||||||
end
|
end
|
||||||
# hope for unauthorized
|
# hope for unauthorized
|
||||||
assert_response :unauthorized, "node upload did not return unauthorized status"
|
assert_response :unauthorized, "node upload did not return unauthorized status"
|
||||||
|
@ -49,9 +49,9 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
basic_authorization private_user.email, "test"
|
basic_authorization private_user.email, "test"
|
||||||
|
|
||||||
# create a minimal xml file
|
# create a minimal xml file
|
||||||
content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{private_changeset.id}'/></osm>")
|
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{private_changeset.id}'/></osm>"
|
||||||
assert_difference("Node.count", 0) do
|
assert_difference("Node.count", 0) do
|
||||||
put :create
|
put :create, :body => xml
|
||||||
end
|
end
|
||||||
# hope for success
|
# hope for success
|
||||||
assert_require_public_data "node create did not return forbidden status"
|
assert_require_public_data "node create did not return forbidden status"
|
||||||
|
@ -60,8 +60,8 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
basic_authorization user.email, "test"
|
basic_authorization user.email, "test"
|
||||||
|
|
||||||
# create a minimal xml file
|
# create a minimal xml file
|
||||||
content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>")
|
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for success
|
# hope for success
|
||||||
assert_response :success, "node upload did not return success status"
|
assert_response :success, "node upload did not return success status"
|
||||||
|
|
||||||
|
@ -88,46 +88,46 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
lon = 3.23
|
lon = 3.23
|
||||||
|
|
||||||
# test that the upload is rejected when xml is valid, but osm doc isn't
|
# test that the upload is rejected when xml is valid, but osm doc isn't
|
||||||
content("<create/>")
|
xml = "<create/>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :bad_request, "node upload did not return bad_request status"
|
assert_response :bad_request, "node upload did not return bad_request status"
|
||||||
assert_equal "Cannot parse valid node from xml string <create/>. XML doesn't contain an osm/node element.", @response.body
|
assert_equal "Cannot parse valid node from xml string <create/>. XML doesn't contain an osm/node element.", @response.body
|
||||||
|
|
||||||
# test that the upload is rejected when no lat is supplied
|
# test that the upload is rejected when no lat is supplied
|
||||||
# create a minimal xml file
|
# create a minimal xml file
|
||||||
content("<osm><node lon='#{lon}' changeset='#{changeset.id}'/></osm>")
|
xml = "<osm><node lon='#{lon}' changeset='#{changeset.id}'/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for success
|
# hope for success
|
||||||
assert_response :bad_request, "node upload did not return bad_request status"
|
assert_response :bad_request, "node upload did not return bad_request status"
|
||||||
assert_equal "Cannot parse valid node from xml string <node lon=\"3.23\" changeset=\"#{changeset.id}\"/>. lat missing", @response.body
|
assert_equal "Cannot parse valid node from xml string <node lon=\"3.23\" changeset=\"#{changeset.id}\"/>. lat missing", @response.body
|
||||||
|
|
||||||
# test that the upload is rejected when no lon is supplied
|
# test that the upload is rejected when no lon is supplied
|
||||||
# create a minimal xml file
|
# create a minimal xml file
|
||||||
content("<osm><node lat='#{lat}' changeset='#{changeset.id}'/></osm>")
|
xml = "<osm><node lat='#{lat}' changeset='#{changeset.id}'/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for success
|
# hope for success
|
||||||
assert_response :bad_request, "node upload did not return bad_request status"
|
assert_response :bad_request, "node upload did not return bad_request status"
|
||||||
assert_equal "Cannot parse valid node from xml string <node lat=\"3.434\" changeset=\"#{changeset.id}\"/>. lon missing", @response.body
|
assert_equal "Cannot parse valid node from xml string <node lat=\"3.434\" changeset=\"#{changeset.id}\"/>. lon missing", @response.body
|
||||||
|
|
||||||
# test that the upload is rejected when lat is non-numeric
|
# test that the upload is rejected when lat is non-numeric
|
||||||
# create a minimal xml file
|
# create a minimal xml file
|
||||||
content("<osm><node lat='abc' lon='#{lon}' changeset='#{changeset.id}'/></osm>")
|
xml = "<osm><node lat='abc' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for success
|
# hope for success
|
||||||
assert_response :bad_request, "node upload did not return bad_request status"
|
assert_response :bad_request, "node upload did not return bad_request status"
|
||||||
assert_equal "Cannot parse valid node from xml string <node lat=\"abc\" lon=\"#{lon}\" changeset=\"#{changeset.id}\"/>. lat not a number", @response.body
|
assert_equal "Cannot parse valid node from xml string <node lat=\"abc\" lon=\"#{lon}\" changeset=\"#{changeset.id}\"/>. lat not a number", @response.body
|
||||||
|
|
||||||
# test that the upload is rejected when lon is non-numeric
|
# test that the upload is rejected when lon is non-numeric
|
||||||
# create a minimal xml file
|
# create a minimal xml file
|
||||||
content("<osm><node lat='#{lat}' lon='abc' changeset='#{changeset.id}'/></osm>")
|
xml = "<osm><node lat='#{lat}' lon='abc' changeset='#{changeset.id}'/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for success
|
# hope for success
|
||||||
assert_response :bad_request, "node upload did not return bad_request status"
|
assert_response :bad_request, "node upload did not return bad_request status"
|
||||||
assert_equal "Cannot parse valid node from xml string <node lat=\"#{lat}\" lon=\"abc\" changeset=\"#{changeset.id}\"/>. lon not a number", @response.body
|
assert_equal "Cannot parse valid node from xml string <node lat=\"#{lat}\" lon=\"abc\" changeset=\"#{changeset.id}\"/>. lon not a number", @response.body
|
||||||
|
|
||||||
# test that the upload is rejected when we have a tag which is too long
|
# test that the upload is rejected when we have a tag which is too long
|
||||||
content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'><tag k='foo' v='#{'x' * 256}'/></node></osm>")
|
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'><tag k='foo' v='#{'x' * 256}'/></node></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :bad_request, "node upload did not return bad_request status"
|
assert_response :bad_request, "node upload did not return bad_request status"
|
||||||
assert_equal ["NodeTag ", " v: is too long (maximum is 255 characters) (\"#{'x' * 256}\")"], @response.body.split(/[0-9]+,foo:/)
|
assert_equal ["NodeTag ", " v: is too long (maximum is 255 characters) (\"#{'x' * 256}\")"], @response.body.split(/[0-9]+,foo:/)
|
||||||
end
|
end
|
||||||
|
@ -163,23 +163,23 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
basic_authorization private_user.email, "test"
|
basic_authorization private_user.email, "test"
|
||||||
|
|
||||||
# try to delete with an invalid (closed) changeset
|
# try to delete with an invalid (closed) changeset
|
||||||
content update_changeset(private_node.to_xml, private_user_closed_changeset.id)
|
xml = update_changeset(private_node.to_xml, private_user_closed_changeset.id)
|
||||||
delete :delete, :params => { :id => private_node.id }
|
delete :delete, :params => { :id => private_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data("non-public user shouldn't be able to delete node")
|
assert_require_public_data("non-public user shouldn't be able to delete node")
|
||||||
|
|
||||||
# try to delete with an invalid (non-existent) changeset
|
# try to delete with an invalid (non-existent) changeset
|
||||||
content update_changeset(private_node.to_xml, 0)
|
xml = update_changeset(private_node.to_xml, 0)
|
||||||
delete :delete, :params => { :id => private_node.id }
|
delete :delete, :params => { :id => private_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data("shouldn't be able to delete node, when user's data is private")
|
assert_require_public_data("shouldn't be able to delete node, when user's data is private")
|
||||||
|
|
||||||
# valid delete now takes a payload
|
# valid delete now takes a payload
|
||||||
content(private_node.to_xml)
|
xml = private_node.to_xml
|
||||||
delete :delete, :params => { :id => private_node.id }
|
delete :delete, :params => { :id => private_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data("shouldn't be able to delete node when user's data isn't public'")
|
assert_require_public_data("shouldn't be able to delete node when user's data isn't public'")
|
||||||
|
|
||||||
# this won't work since the node is already deleted
|
# this won't work since the node is already deleted
|
||||||
content(private_deleted_node.to_xml)
|
xml = private_deleted_node.to_xml
|
||||||
delete :delete, :params => { :id => private_deleted_node.id }
|
delete :delete, :params => { :id => private_deleted_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data
|
assert_require_public_data
|
||||||
|
|
||||||
# this won't work since the node never existed
|
# this won't work since the node never existed
|
||||||
|
@ -191,16 +191,16 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
private_used_node = create(:node, :changeset => private_user_changeset)
|
private_used_node = create(:node, :changeset => private_user_changeset)
|
||||||
create(:way_node, :node => private_used_node)
|
create(:way_node, :node => private_used_node)
|
||||||
|
|
||||||
content(private_used_node.to_xml)
|
xml = private_used_node.to_xml
|
||||||
delete :delete, :params => { :id => private_used_node.id }
|
delete :delete, :params => { :id => private_used_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data "shouldn't be able to delete a node used in a way (#{@response.body})"
|
assert_require_public_data "shouldn't be able to delete a node used in a way (#{@response.body})"
|
||||||
|
|
||||||
# in a relation...
|
# in a relation...
|
||||||
private_used_node2 = create(:node, :changeset => private_user_changeset)
|
private_used_node2 = create(:node, :changeset => private_user_changeset)
|
||||||
create(:relation_member, :member => private_used_node2)
|
create(:relation_member, :member => private_used_node2)
|
||||||
|
|
||||||
content(private_used_node2.to_xml)
|
xml = private_used_node2.to_xml
|
||||||
delete :delete, :params => { :id => private_used_node2.id }
|
delete :delete, :params => { :id => private_used_node2.id }, :body => xml.to_s
|
||||||
assert_require_public_data "shouldn't be able to delete a node used in a relation (#{@response.body})"
|
assert_require_public_data "shouldn't be able to delete a node used in a relation (#{@response.body})"
|
||||||
|
|
||||||
## now setup for the public data user
|
## now setup for the public data user
|
||||||
|
@ -211,31 +211,31 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
basic_authorization user.email, "test"
|
basic_authorization user.email, "test"
|
||||||
|
|
||||||
# try to delete with an invalid (closed) changeset
|
# try to delete with an invalid (closed) changeset
|
||||||
content update_changeset(node.to_xml, closed_changeset.id)
|
xml = update_changeset(node.to_xml, closed_changeset.id)
|
||||||
delete :delete, :params => { :id => node.id }
|
delete :delete, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :conflict
|
assert_response :conflict
|
||||||
|
|
||||||
# try to delete with an invalid (non-existent) changeset
|
# try to delete with an invalid (non-existent) changeset
|
||||||
content update_changeset(node.to_xml, 0)
|
xml = update_changeset(node.to_xml, 0)
|
||||||
delete :delete, :params => { :id => node.id }
|
delete :delete, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :conflict
|
assert_response :conflict
|
||||||
|
|
||||||
# try to delete a node with a different ID
|
# try to delete a node with a different ID
|
||||||
other_node = create(:node)
|
other_node = create(:node)
|
||||||
content(other_node.to_xml)
|
xml = other_node.to_xml
|
||||||
delete :delete, :params => { :id => node.id }
|
delete :delete, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"should not be able to delete a node with a different ID from the XML"
|
"should not be able to delete a node with a different ID from the XML"
|
||||||
|
|
||||||
# try to delete a node rubbish in the payloads
|
# try to delete a node rubbish in the payloads
|
||||||
content("<delete/>")
|
xml = "<delete/>"
|
||||||
delete :delete, :params => { :id => node.id }
|
delete :delete, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"should not be able to delete a node without a valid XML payload"
|
"should not be able to delete a node without a valid XML payload"
|
||||||
|
|
||||||
# valid delete now takes a payload
|
# valid delete now takes a payload
|
||||||
content(node.to_xml)
|
xml = node.to_xml
|
||||||
delete :delete, :params => { :id => node.id }
|
delete :delete, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# valid delete should return the new version number, which should
|
# valid delete should return the new version number, which should
|
||||||
|
@ -244,8 +244,8 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
"delete request should return a new version number for node"
|
"delete request should return a new version number for node"
|
||||||
|
|
||||||
# deleting the same node twice doesn't work
|
# deleting the same node twice doesn't work
|
||||||
content(node.to_xml)
|
xml = node.to_xml
|
||||||
delete :delete, :params => { :id => node.id }
|
delete :delete, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :gone
|
assert_response :gone
|
||||||
|
|
||||||
# this won't work since the node never existed
|
# this won't work since the node never existed
|
||||||
|
@ -258,8 +258,8 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
way_node = create(:way_node, :node => used_node)
|
way_node = create(:way_node, :node => used_node)
|
||||||
way_node2 = create(:way_node, :node => used_node)
|
way_node2 = create(:way_node, :node => used_node)
|
||||||
|
|
||||||
content(used_node.to_xml)
|
xml = used_node.to_xml
|
||||||
delete :delete, :params => { :id => used_node.id }
|
delete :delete, :params => { :id => used_node.id }, :body => xml.to_s
|
||||||
assert_response :precondition_failed,
|
assert_response :precondition_failed,
|
||||||
"shouldn't be able to delete a node used in a way (#{@response.body})"
|
"shouldn't be able to delete a node used in a way (#{@response.body})"
|
||||||
assert_equal "Precondition failed: Node #{used_node.id} is still used by ways #{way_node.way.id},#{way_node2.way.id}.", @response.body
|
assert_equal "Precondition failed: Node #{used_node.id} is still used by ways #{way_node.way.id},#{way_node2.way.id}.", @response.body
|
||||||
|
@ -269,8 +269,8 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
relation_member = create(:relation_member, :member => used_node2)
|
relation_member = create(:relation_member, :member => used_node2)
|
||||||
relation_member2 = create(:relation_member, :member => used_node2)
|
relation_member2 = create(:relation_member, :member => used_node2)
|
||||||
|
|
||||||
content(used_node2.to_xml)
|
xml = used_node2.to_xml
|
||||||
delete :delete, :params => { :id => used_node2.id }
|
delete :delete, :params => { :id => used_node2.id }, :body => xml.to_s
|
||||||
assert_response :precondition_failed,
|
assert_response :precondition_failed,
|
||||||
"shouldn't be able to delete a node used in a relation (#{@response.body})"
|
"shouldn't be able to delete a node used in a relation (#{@response.body})"
|
||||||
assert_equal "Precondition failed: Node #{used_node2.id} is still used by relations #{relation_member.relation.id},#{relation_member2.relation.id}.", @response.body
|
assert_equal "Precondition failed: Node #{used_node2.id} is still used by relations #{relation_member.relation.id},#{relation_member2.relation.id}.", @response.body
|
||||||
|
@ -288,8 +288,8 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
node = create(:node, :changeset => create(:changeset, :user => user))
|
node = create(:node, :changeset => create(:changeset, :user => user))
|
||||||
|
|
||||||
content node.to_xml
|
xml = node.to_xml
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :unauthorized
|
assert_response :unauthorized
|
||||||
|
|
||||||
## Second test with the private user
|
## Second test with the private user
|
||||||
|
@ -300,50 +300,50 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
## trying to break changesets
|
## trying to break changesets
|
||||||
|
|
||||||
# try and update in someone else's changeset
|
# try and update in someone else's changeset
|
||||||
content update_changeset(private_node.to_xml,
|
xml = update_changeset(private_node.to_xml,
|
||||||
create(:changeset).id)
|
create(:changeset).id)
|
||||||
put :update, :params => { :id => private_node.id }
|
put :update, :params => { :id => private_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data "update with other user's changeset should be forbidden when data isn't public"
|
assert_require_public_data "update with other user's changeset should be forbidden when data isn't public"
|
||||||
|
|
||||||
# try and update in a closed changeset
|
# try and update in a closed changeset
|
||||||
content update_changeset(private_node.to_xml,
|
xml = update_changeset(private_node.to_xml,
|
||||||
create(:changeset, :closed, :user => private_user).id)
|
create(:changeset, :closed, :user => private_user).id)
|
||||||
put :update, :params => { :id => private_node.id }
|
put :update, :params => { :id => private_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data "update with closed changeset should be forbidden, when data isn't public"
|
assert_require_public_data "update with closed changeset should be forbidden, when data isn't public"
|
||||||
|
|
||||||
# try and update in a non-existant changeset
|
# try and update in a non-existant changeset
|
||||||
content update_changeset(private_node.to_xml, 0)
|
xml = update_changeset(private_node.to_xml, 0)
|
||||||
put :update, :params => { :id => private_node.id }
|
put :update, :params => { :id => private_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data "update with changeset=0 should be forbidden, when data isn't public"
|
assert_require_public_data "update with changeset=0 should be forbidden, when data isn't public"
|
||||||
|
|
||||||
## try and submit invalid updates
|
## try and submit invalid updates
|
||||||
content xml_attr_rewrite(private_node.to_xml, "lat", 91.0)
|
xml = xml_attr_rewrite(private_node.to_xml, "lat", 91.0)
|
||||||
put :update, :params => { :id => private_node.id }
|
put :update, :params => { :id => private_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data "node at lat=91 should be forbidden, when data isn't public"
|
assert_require_public_data "node at lat=91 should be forbidden, when data isn't public"
|
||||||
|
|
||||||
content xml_attr_rewrite(private_node.to_xml, "lat", -91.0)
|
xml = xml_attr_rewrite(private_node.to_xml, "lat", -91.0)
|
||||||
put :update, :params => { :id => private_node.id }
|
put :update, :params => { :id => private_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data "node at lat=-91 should be forbidden, when data isn't public"
|
assert_require_public_data "node at lat=-91 should be forbidden, when data isn't public"
|
||||||
|
|
||||||
content xml_attr_rewrite(private_node.to_xml, "lon", 181.0)
|
xml = xml_attr_rewrite(private_node.to_xml, "lon", 181.0)
|
||||||
put :update, :params => { :id => private_node.id }
|
put :update, :params => { :id => private_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data "node at lon=181 should be forbidden, when data isn't public"
|
assert_require_public_data "node at lon=181 should be forbidden, when data isn't public"
|
||||||
|
|
||||||
content xml_attr_rewrite(private_node.to_xml, "lon", -181.0)
|
xml = xml_attr_rewrite(private_node.to_xml, "lon", -181.0)
|
||||||
put :update, :params => { :id => private_node.id }
|
put :update, :params => { :id => private_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data "node at lon=-181 should be forbidden, when data isn't public"
|
assert_require_public_data "node at lon=-181 should be forbidden, when data isn't public"
|
||||||
|
|
||||||
## finally, produce a good request which still won't work
|
## finally, produce a good request which still won't work
|
||||||
content private_node.to_xml
|
xml = private_node.to_xml
|
||||||
put :update, :params => { :id => private_node.id }
|
put :update, :params => { :id => private_node.id }, :body => xml.to_s
|
||||||
assert_require_public_data "should have failed with a forbidden when data isn't public"
|
assert_require_public_data "should have failed with a forbidden when data isn't public"
|
||||||
|
|
||||||
## Finally test with the public user
|
## Finally test with the public user
|
||||||
|
|
||||||
# try and update a node without authorisation
|
# try and update a node without authorisation
|
||||||
# first try to update node without auth
|
# first try to update node without auth
|
||||||
content node.to_xml
|
xml = node.to_xml
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# setup auth
|
# setup auth
|
||||||
|
@ -352,76 +352,76 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
## trying to break changesets
|
## trying to break changesets
|
||||||
|
|
||||||
# try and update in someone else's changeset
|
# try and update in someone else's changeset
|
||||||
content update_changeset(node.to_xml,
|
xml = update_changeset(node.to_xml,
|
||||||
create(:changeset).id)
|
create(:changeset).id)
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :conflict, "update with other user's changeset should be rejected"
|
assert_response :conflict, "update with other user's changeset should be rejected"
|
||||||
|
|
||||||
# try and update in a closed changeset
|
# try and update in a closed changeset
|
||||||
content update_changeset(node.to_xml,
|
xml = update_changeset(node.to_xml,
|
||||||
create(:changeset, :closed, :user => user).id)
|
create(:changeset, :closed, :user => user).id)
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :conflict, "update with closed changeset should be rejected"
|
assert_response :conflict, "update with closed changeset should be rejected"
|
||||||
|
|
||||||
# try and update in a non-existant changeset
|
# try and update in a non-existant changeset
|
||||||
content update_changeset(node.to_xml, 0)
|
xml = update_changeset(node.to_xml, 0)
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :conflict, "update with changeset=0 should be rejected"
|
assert_response :conflict, "update with changeset=0 should be rejected"
|
||||||
|
|
||||||
## try and submit invalid updates
|
## try and submit invalid updates
|
||||||
content xml_attr_rewrite(node.to_xml, "lat", 91.0)
|
xml = xml_attr_rewrite(node.to_xml, "lat", 91.0)
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :bad_request, "node at lat=91 should be rejected"
|
assert_response :bad_request, "node at lat=91 should be rejected"
|
||||||
|
|
||||||
content xml_attr_rewrite(node.to_xml, "lat", -91.0)
|
xml = xml_attr_rewrite(node.to_xml, "lat", -91.0)
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :bad_request, "node at lat=-91 should be rejected"
|
assert_response :bad_request, "node at lat=-91 should be rejected"
|
||||||
|
|
||||||
content xml_attr_rewrite(node.to_xml, "lon", 181.0)
|
xml = xml_attr_rewrite(node.to_xml, "lon", 181.0)
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :bad_request, "node at lon=181 should be rejected"
|
assert_response :bad_request, "node at lon=181 should be rejected"
|
||||||
|
|
||||||
content xml_attr_rewrite(node.to_xml, "lon", -181.0)
|
xml = xml_attr_rewrite(node.to_xml, "lon", -181.0)
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :bad_request, "node at lon=-181 should be rejected"
|
assert_response :bad_request, "node at lon=-181 should be rejected"
|
||||||
|
|
||||||
## next, attack the versioning
|
## next, attack the versioning
|
||||||
current_node_version = node.version
|
current_node_version = node.version
|
||||||
|
|
||||||
# try and submit a version behind
|
# try and submit a version behind
|
||||||
content xml_attr_rewrite(node.to_xml,
|
xml = xml_attr_rewrite(node.to_xml,
|
||||||
"version", current_node_version - 1)
|
"version", current_node_version - 1)
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :conflict, "should have failed on old version number"
|
assert_response :conflict, "should have failed on old version number"
|
||||||
|
|
||||||
# try and submit a version ahead
|
# try and submit a version ahead
|
||||||
content xml_attr_rewrite(node.to_xml,
|
xml = xml_attr_rewrite(node.to_xml,
|
||||||
"version", current_node_version + 1)
|
"version", current_node_version + 1)
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :conflict, "should have failed on skipped version number"
|
assert_response :conflict, "should have failed on skipped version number"
|
||||||
|
|
||||||
# try and submit total crap in the version field
|
# try and submit total crap in the version field
|
||||||
content xml_attr_rewrite(node.to_xml,
|
xml = xml_attr_rewrite(node.to_xml,
|
||||||
"version", "p1r4t3s!")
|
"version", "p1r4t3s!")
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :conflict,
|
assert_response :conflict,
|
||||||
"should not be able to put 'p1r4at3s!' in the version field"
|
"should not be able to put 'p1r4at3s!' in the version field"
|
||||||
|
|
||||||
## try an update with the wrong ID
|
## try an update with the wrong ID
|
||||||
content create(:node).to_xml
|
xml = create(:node).to_xml
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"should not be able to update a node with a different ID from the XML"
|
"should not be able to update a node with a different ID from the XML"
|
||||||
|
|
||||||
## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.
|
## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.
|
||||||
content "<update/>"
|
xml = "<update/>"
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"should not be able to update a node with non-OSM XML doc."
|
"should not be able to update a node with non-OSM XML doc."
|
||||||
|
|
||||||
## finally, produce a good request which should work
|
## finally, produce a good request which should work
|
||||||
content node.to_xml
|
xml = node.to_xml
|
||||||
put :update, :params => { :id => node.id }
|
put :update, :params => { :id => node.id }, :body => xml.to_s
|
||||||
assert_response :success, "a valid update request failed"
|
assert_response :success, "a valid update request failed"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -477,8 +477,7 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
node_xml.find("//osm/node").first << tag_xml
|
node_xml.find("//osm/node").first << tag_xml
|
||||||
|
|
||||||
# try and upload it
|
# try and upload it
|
||||||
content node_xml
|
put :update, :params => { :id => existing_tag.node.id }, :body => node_xml.to_s
|
||||||
put :update, :params => { :id => existing_tag.node.id }
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"adding duplicate tags to a node should fail with 'bad request'"
|
"adding duplicate tags to a node should fail with 'bad request'"
|
||||||
assert_equal "Element node/#{existing_tag.node.id} has duplicate tags with key #{existing_tag.k}", @response.body
|
assert_equal "Element node/#{existing_tag.node.id} has duplicate tags with key #{existing_tag.k}", @response.body
|
||||||
|
@ -496,10 +495,10 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# try and put something into a string that the API might
|
# try and put something into a string that the API might
|
||||||
# use unquoted and therefore allow code injection...
|
# use unquoted and therefore allow code injection...
|
||||||
content "<osm><node lat='0' lon='0' changeset='#{private_changeset.id}'>" \
|
xml = "<osm><node lat='0' lon='0' changeset='#{private_changeset.id}'>" \
|
||||||
'<tag k="#{@user.inspect}" v="0"/>' \
|
'<tag k="#{@user.inspect}" v="0"/>' \
|
||||||
"</node></osm>"
|
"</node></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_require_public_data "Shouldn't be able to create with non-public user"
|
assert_require_public_data "Shouldn't be able to create with non-public user"
|
||||||
|
|
||||||
## Then try with the public data user
|
## Then try with the public data user
|
||||||
|
@ -507,10 +506,10 @@ class NodesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# try and put something into a string that the API might
|
# try and put something into a string that the API might
|
||||||
# use unquoted and therefore allow code injection...
|
# use unquoted and therefore allow code injection...
|
||||||
content "<osm><node lat='0' lon='0' changeset='#{changeset.id}'>" \
|
xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'>" \
|
||||||
'<tag k="#{@user.inspect}" v="0"/>' \
|
'<tag k="#{@user.inspect}" v="0"/>' \
|
||||||
"</node></osm>"
|
"</node></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success
|
assert_response :success
|
||||||
nodeid = @response.body
|
nodeid = @response.body
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,7 @@ class OldNodesControllerTest < ActionController::TestCase
|
||||||
xml_node["lat"] = precision(rand * 180 - 90).to_s
|
xml_node["lat"] = precision(rand * 180 - 90).to_s
|
||||||
xml_node["lon"] = precision(rand * 360 - 180).to_s
|
xml_node["lon"] = precision(rand * 360 - 180).to_s
|
||||||
with_controller(NodesController.new) do
|
with_controller(NodesController.new) do
|
||||||
content xml_doc
|
put :update, :params => { :id => nodeid }, :body => xml_doc.to_s
|
||||||
put :update, :params => { :id => nodeid }
|
|
||||||
assert_response :forbidden, "Should have rejected node update"
|
assert_response :forbidden, "Should have rejected node update"
|
||||||
xml_node["version"] = @response.body.to_s
|
xml_node["version"] = @response.body.to_s
|
||||||
end
|
end
|
||||||
|
@ -75,8 +74,7 @@ class OldNodesControllerTest < ActionController::TestCase
|
||||||
xml_tag["v"] = random_string
|
xml_tag["v"] = random_string
|
||||||
xml_node << xml_tag
|
xml_node << xml_tag
|
||||||
with_controller(NodesController.new) do
|
with_controller(NodesController.new) do
|
||||||
content xml_doc
|
put :update, :params => { :id => nodeid }, :body => xml_doc.to_s
|
||||||
put :update, :params => { :id => nodeid }
|
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"should have rejected node #{nodeid} (#{@response.body}) with forbidden"
|
"should have rejected node #{nodeid} (#{@response.body}) with forbidden"
|
||||||
xml_node["version"] = @response.body.to_s
|
xml_node["version"] = @response.body.to_s
|
||||||
|
@ -109,8 +107,7 @@ class OldNodesControllerTest < ActionController::TestCase
|
||||||
xml_node["lat"] = precision(rand * 180 - 90).to_s
|
xml_node["lat"] = precision(rand * 180 - 90).to_s
|
||||||
xml_node["lon"] = precision(rand * 360 - 180).to_s
|
xml_node["lon"] = precision(rand * 360 - 180).to_s
|
||||||
with_controller(NodesController.new) do
|
with_controller(NodesController.new) do
|
||||||
content xml_doc
|
put :update, :params => { :id => nodeid }, :body => xml_doc.to_s
|
||||||
put :update, :params => { :id => nodeid }
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
xml_node["version"] = @response.body.to_s
|
xml_node["version"] = @response.body.to_s
|
||||||
end
|
end
|
||||||
|
@ -125,8 +122,7 @@ class OldNodesControllerTest < ActionController::TestCase
|
||||||
xml_tag["v"] = random_string
|
xml_tag["v"] = random_string
|
||||||
xml_node << xml_tag
|
xml_node << xml_tag
|
||||||
with_controller(NodesController.new) do
|
with_controller(NodesController.new) do
|
||||||
content xml_doc
|
put :update, :params => { :id => nodeid }, :body => xml_doc.to_s
|
||||||
put :update, :params => { :id => nodeid }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"couldn't update node #{nodeid} (#{@response.body})"
|
"couldn't update node #{nodeid} (#{@response.body})"
|
||||||
xml_node["version"] = @response.body.to_s
|
xml_node["version"] = @response.body.to_s
|
||||||
|
|
|
@ -206,8 +206,8 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
basic_authorization private_user.email, "test"
|
basic_authorization private_user.email, "test"
|
||||||
|
|
||||||
# create an relation without members
|
# create an relation without members
|
||||||
content "<osm><relation changeset='#{private_changeset.id}'><tag k='test' v='yes' /></relation></osm>"
|
xml = "<osm><relation changeset='#{private_changeset.id}'><tag k='test' v='yes' /></relation></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for forbidden, due to user
|
# hope for forbidden, due to user
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"relation upload should have failed with forbidden"
|
"relation upload should have failed with forbidden"
|
||||||
|
@ -215,10 +215,10 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
###
|
###
|
||||||
# create an relation with a node as member
|
# create an relation with a node as member
|
||||||
# This time try with a role attribute in the relation
|
# This time try with a role attribute in the relation
|
||||||
content "<osm><relation changeset='#{private_changeset.id}'>" \
|
xml = "<osm><relation changeset='#{private_changeset.id}'>" \
|
||||||
"<member ref='#{node.id}' type='node' role='some'/>" \
|
"<member ref='#{node.id}' type='node' role='some'/>" \
|
||||||
"<tag k='test' v='yes' /></relation></osm>"
|
"<tag k='test' v='yes' /></relation></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for forbidden due to user
|
# hope for forbidden due to user
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"relation upload did not return forbidden status"
|
"relation upload did not return forbidden status"
|
||||||
|
@ -226,20 +226,20 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
###
|
###
|
||||||
# create an relation with a node as member, this time test that we don't
|
# create an relation with a node as member, this time test that we don't
|
||||||
# need a role attribute to be included
|
# need a role attribute to be included
|
||||||
content "<osm><relation changeset='#{private_changeset.id}'>" \
|
xml = "<osm><relation changeset='#{private_changeset.id}'>" \
|
||||||
"<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
|
"<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for forbidden due to user
|
# hope for forbidden due to user
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"relation upload did not return forbidden status"
|
"relation upload did not return forbidden status"
|
||||||
|
|
||||||
###
|
###
|
||||||
# create an relation with a way and a node as members
|
# create an relation with a way and a node as members
|
||||||
content "<osm><relation changeset='#{private_changeset.id}'>" \
|
xml = "<osm><relation changeset='#{private_changeset.id}'>" \
|
||||||
"<member type='node' ref='#{node.id}' role='some'/>" \
|
"<member type='node' ref='#{node.id}' role='some'/>" \
|
||||||
"<member type='way' ref='#{way.id}' role='other'/>" \
|
"<member type='way' ref='#{way.id}' role='other'/>" \
|
||||||
"<tag k='test' v='yes' /></relation></osm>"
|
"<tag k='test' v='yes' /></relation></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for forbidden, due to user
|
# hope for forbidden, due to user
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"relation upload did not return success status"
|
"relation upload did not return success status"
|
||||||
|
@ -248,8 +248,8 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
basic_authorization user.email, "test"
|
basic_authorization user.email, "test"
|
||||||
|
|
||||||
# create an relation without members
|
# create an relation without members
|
||||||
content "<osm><relation changeset='#{changeset.id}'><tag k='test' v='yes' /></relation></osm>"
|
xml = "<osm><relation changeset='#{changeset.id}'><tag k='test' v='yes' /></relation></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for success
|
# hope for success
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"relation upload did not return success status"
|
"relation upload did not return success status"
|
||||||
|
@ -276,10 +276,10 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
###
|
###
|
||||||
# create an relation with a node as member
|
# create an relation with a node as member
|
||||||
# This time try with a role attribute in the relation
|
# This time try with a role attribute in the relation
|
||||||
content "<osm><relation changeset='#{changeset.id}'>" \
|
xml = "<osm><relation changeset='#{changeset.id}'>" \
|
||||||
"<member ref='#{node.id}' type='node' role='some'/>" \
|
"<member ref='#{node.id}' type='node' role='some'/>" \
|
||||||
"<tag k='test' v='yes' /></relation></osm>"
|
"<tag k='test' v='yes' /></relation></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for success
|
# hope for success
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"relation upload did not return success status"
|
"relation upload did not return success status"
|
||||||
|
@ -307,9 +307,9 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
###
|
###
|
||||||
# create an relation with a node as member, this time test that we don't
|
# create an relation with a node as member, this time test that we don't
|
||||||
# need a role attribute to be included
|
# need a role attribute to be included
|
||||||
content "<osm><relation changeset='#{changeset.id}'>" \
|
xml = "<osm><relation changeset='#{changeset.id}'>" \
|
||||||
"<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
|
"<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for success
|
# hope for success
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"relation upload did not return success status"
|
"relation upload did not return success status"
|
||||||
|
@ -336,11 +336,11 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
###
|
###
|
||||||
# create an relation with a way and a node as members
|
# create an relation with a way and a node as members
|
||||||
content "<osm><relation changeset='#{changeset.id}'>" \
|
xml = "<osm><relation changeset='#{changeset.id}'>" \
|
||||||
"<member type='node' ref='#{node.id}' role='some'/>" \
|
"<member type='node' ref='#{node.id}' role='some'/>" \
|
||||||
"<member type='way' ref='#{way.id}' role='other'/>" \
|
"<member type='way' ref='#{way.id}' role='other'/>" \
|
||||||
"<tag k='test' v='yes' /></relation></osm>"
|
"<tag k='test' v='yes' /></relation></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for success
|
# hope for success
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"relation upload did not return success status"
|
"relation upload did not return success status"
|
||||||
|
@ -443,8 +443,7 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
basic_authorization user.email, "test"
|
basic_authorization user.email, "test"
|
||||||
with_relation(relation.id) do |rel|
|
with_relation(relation.id) do |rel|
|
||||||
update_changeset(rel, changeset.id)
|
update_changeset(rel, changeset.id)
|
||||||
content rel
|
put :update, :params => { :id => other_relation.id }, :body => rel.to_s
|
||||||
put :update, :params => { :id => other_relation.id }
|
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -460,10 +459,10 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
basic_authorization user.email, "test"
|
basic_authorization user.email, "test"
|
||||||
|
|
||||||
# create a relation with non-existing node as member
|
# create a relation with non-existing node as member
|
||||||
content "<osm><relation changeset='#{changeset.id}'>" \
|
xml = "<osm><relation changeset='#{changeset.id}'>" \
|
||||||
"<member type='node' ref='0'/><tag k='test' v='yes' />" \
|
"<member type='node' ref='0'/><tag k='test' v='yes' />" \
|
||||||
"</relation></osm>"
|
"</relation></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# expect failure
|
# expect failure
|
||||||
assert_response :precondition_failed,
|
assert_response :precondition_failed,
|
||||||
"relation upload with invalid node did not return 'precondition failed'"
|
"relation upload with invalid node did not return 'precondition failed'"
|
||||||
|
@ -481,10 +480,10 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
basic_authorization user.email, "test"
|
basic_authorization user.email, "test"
|
||||||
|
|
||||||
# create some xml that should return an error
|
# create some xml that should return an error
|
||||||
content "<osm><relation changeset='#{changeset.id}'>" \
|
xml = "<osm><relation changeset='#{changeset.id}'>" \
|
||||||
"<member type='type' ref='#{node.id}' role=''/>" \
|
"<member type='type' ref='#{node.id}' role=''/>" \
|
||||||
"<tag k='tester' v='yep'/></relation></osm>"
|
"<tag k='tester' v='yep'/></relation></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# expect failure
|
# expect failure
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
assert_match(/Cannot parse valid relation from xml string/, @response.body)
|
assert_match(/Cannot parse valid relation from xml string/, @response.body)
|
||||||
|
@ -520,34 +519,34 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# try to delete without specifying a changeset
|
# try to delete without specifying a changeset
|
||||||
content "<osm><relation id='#{relation.id}'/></osm>"
|
xml = "<osm><relation id='#{relation.id}'/></osm>"
|
||||||
delete :delete, :params => { :id => relation.id }
|
delete :delete, :params => { :id => relation.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# try to delete with an invalid (closed) changeset
|
# try to delete with an invalid (closed) changeset
|
||||||
content update_changeset(relation.to_xml,
|
xml = update_changeset(relation.to_xml,
|
||||||
private_user_closed_changeset.id)
|
private_user_closed_changeset.id)
|
||||||
delete :delete, :params => { :id => relation.id }
|
delete :delete, :params => { :id => relation.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# try to delete with an invalid (non-existent) changeset
|
# try to delete with an invalid (non-existent) changeset
|
||||||
content update_changeset(relation.to_xml, 0)
|
xml = update_changeset(relation.to_xml, 0)
|
||||||
delete :delete, :params => { :id => relation.id }
|
delete :delete, :params => { :id => relation.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# this won't work because the relation is in-use by another relation
|
# this won't work because the relation is in-use by another relation
|
||||||
content(used_relation.to_xml)
|
xml = used_relation.to_xml
|
||||||
delete :delete, :params => { :id => used_relation.id }
|
delete :delete, :params => { :id => used_relation.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# this should work when we provide the appropriate payload...
|
# this should work when we provide the appropriate payload...
|
||||||
content(relation.to_xml)
|
xml = relation.to_xml
|
||||||
delete :delete, :params => { :id => relation.id }
|
delete :delete, :params => { :id => relation.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# this won't work since the relation is already deleted
|
# this won't work since the relation is already deleted
|
||||||
content(deleted_relation.to_xml)
|
xml = deleted_relation.to_xml
|
||||||
delete :delete, :params => { :id => deleted_relation.id }
|
delete :delete, :params => { :id => deleted_relation.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# this won't work since the relation never existed
|
# this won't work since the relation never existed
|
||||||
|
@ -562,43 +561,43 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
|
|
||||||
# try to delete without specifying a changeset
|
# try to delete without specifying a changeset
|
||||||
content "<osm><relation id='#{relation.id}' version='#{relation.version}' /></osm>"
|
xml = "<osm><relation id='#{relation.id}' version='#{relation.version}' /></osm>"
|
||||||
delete :delete, :params => { :id => relation.id }
|
delete :delete, :params => { :id => relation.id }, :body => xml.to_s
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
assert_match(/Changeset id is missing/, @response.body)
|
assert_match(/Changeset id is missing/, @response.body)
|
||||||
|
|
||||||
# try to delete with an invalid (closed) changeset
|
# try to delete with an invalid (closed) changeset
|
||||||
content update_changeset(relation.to_xml,
|
xml = update_changeset(relation.to_xml,
|
||||||
closed_changeset.id)
|
closed_changeset.id)
|
||||||
delete :delete, :params => { :id => relation.id }
|
delete :delete, :params => { :id => relation.id }, :body => xml.to_s
|
||||||
assert_response :conflict
|
assert_response :conflict
|
||||||
|
|
||||||
# try to delete with an invalid (non-existent) changeset
|
# try to delete with an invalid (non-existent) changeset
|
||||||
content update_changeset(relation.to_xml, 0)
|
xml = update_changeset(relation.to_xml, 0)
|
||||||
delete :delete, :params => { :id => relation.id }
|
delete :delete, :params => { :id => relation.id }, :body => xml.to_s
|
||||||
assert_response :conflict
|
assert_response :conflict
|
||||||
|
|
||||||
# this won't work because the relation is in a changeset owned by someone else
|
# this won't work because the relation is in a changeset owned by someone else
|
||||||
content update_changeset(relation.to_xml, create(:changeset).id)
|
xml = update_changeset(relation.to_xml, create(:changeset).id)
|
||||||
delete :delete, :params => { :id => relation.id }
|
delete :delete, :params => { :id => relation.id }, :body => xml.to_s
|
||||||
assert_response :conflict,
|
assert_response :conflict,
|
||||||
"shouldn't be able to delete a relation in a changeset owned by someone else (#{@response.body})"
|
"shouldn't be able to delete a relation in a changeset owned by someone else (#{@response.body})"
|
||||||
|
|
||||||
# this won't work because the relation in the payload is different to that passed
|
# this won't work because the relation in the payload is different to that passed
|
||||||
content update_changeset(relation.to_xml, changeset.id)
|
xml = update_changeset(relation.to_xml, changeset.id)
|
||||||
delete :delete, :params => { :id => create(:relation).id }
|
delete :delete, :params => { :id => create(:relation).id }, :body => xml.to_s
|
||||||
assert_response :bad_request, "shouldn't be able to delete a relation when payload is different to the url"
|
assert_response :bad_request, "shouldn't be able to delete a relation when payload is different to the url"
|
||||||
|
|
||||||
# this won't work because the relation is in-use by another relation
|
# this won't work because the relation is in-use by another relation
|
||||||
content update_changeset(used_relation.to_xml, changeset.id)
|
xml = update_changeset(used_relation.to_xml, changeset.id)
|
||||||
delete :delete, :params => { :id => used_relation.id }
|
delete :delete, :params => { :id => used_relation.id }, :body => xml.to_s
|
||||||
assert_response :precondition_failed,
|
assert_response :precondition_failed,
|
||||||
"shouldn't be able to delete a relation used in a relation (#{@response.body})"
|
"shouldn't be able to delete a relation used in a relation (#{@response.body})"
|
||||||
assert_equal "Precondition failed: The relation #{used_relation.id} is used in relation #{super_relation.id}.", @response.body
|
assert_equal "Precondition failed: The relation #{used_relation.id} is used in relation #{super_relation.id}.", @response.body
|
||||||
|
|
||||||
# this should work when we provide the appropriate payload...
|
# this should work when we provide the appropriate payload...
|
||||||
content update_changeset(multi_tag_relation.to_xml, changeset.id)
|
xml = update_changeset(multi_tag_relation.to_xml, changeset.id)
|
||||||
delete :delete, :params => { :id => multi_tag_relation.id }
|
delete :delete, :params => { :id => multi_tag_relation.id }, :body => xml.to_s
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# valid delete should return the new version number, which should
|
# valid delete should return the new version number, which should
|
||||||
|
@ -607,19 +606,19 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
"delete request should return a new version number for relation"
|
"delete request should return a new version number for relation"
|
||||||
|
|
||||||
# this won't work since the relation is already deleted
|
# this won't work since the relation is already deleted
|
||||||
content update_changeset(deleted_relation.to_xml, changeset.id)
|
xml = update_changeset(deleted_relation.to_xml, changeset.id)
|
||||||
delete :delete, :params => { :id => deleted_relation.id }
|
delete :delete, :params => { :id => deleted_relation.id }, :body => xml.to_s
|
||||||
assert_response :gone
|
assert_response :gone
|
||||||
|
|
||||||
# Public visible relation needs to be deleted
|
# Public visible relation needs to be deleted
|
||||||
content update_changeset(super_relation.to_xml, changeset.id)
|
xml = update_changeset(super_relation.to_xml, changeset.id)
|
||||||
delete :delete, :params => { :id => super_relation.id }
|
delete :delete, :params => { :id => super_relation.id }, :body => xml.to_s
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# this works now because the relation which was using this one
|
# this works now because the relation which was using this one
|
||||||
# has been deleted.
|
# has been deleted.
|
||||||
content update_changeset(used_relation.to_xml, changeset.id)
|
xml = update_changeset(used_relation.to_xml, changeset.id)
|
||||||
delete :delete, :params => { :id => used_relation.id }
|
delete :delete, :params => { :id => used_relation.id }, :body => xml.to_s
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"should be able to delete a relation used in an old relation (#{@response.body})"
|
"should be able to delete a relation used in an old relation (#{@response.body})"
|
||||||
|
|
||||||
|
@ -654,8 +653,7 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
update_changeset(relation_xml, changeset_id)
|
update_changeset(relation_xml, changeset_id)
|
||||||
|
|
||||||
# upload the change
|
# upload the change
|
||||||
content relation_xml
|
put :update, :params => { :id => relation.id }, :body => relation_xml.to_s
|
||||||
put :update, :params => { :id => relation.id }
|
|
||||||
assert_response :success, "can't update relation for tag/bbox test"
|
assert_response :success, "can't update relation for tag/bbox test"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -688,8 +686,7 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
update_changeset(relation_xml, changeset_id)
|
update_changeset(relation_xml, changeset_id)
|
||||||
|
|
||||||
# upload the change
|
# upload the change
|
||||||
content relation_xml
|
put :update, :params => { :id => relation.id }, :body => relation_xml.to_s
|
||||||
put :update, :params => { :id => relation.id }
|
|
||||||
assert_response :success, "can't update relation for add #{element.class}/bbox test: #{@response.body}"
|
assert_response :success, "can't update relation for add #{element.class}/bbox test: #{@response.body}"
|
||||||
|
|
||||||
# get it back and check the ordering
|
# get it back and check the ordering
|
||||||
|
@ -721,8 +718,7 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
update_changeset(relation_xml, changeset_id)
|
update_changeset(relation_xml, changeset_id)
|
||||||
|
|
||||||
# upload the change
|
# upload the change
|
||||||
content relation_xml
|
put :update, :params => { :id => relation.id }, :body => relation_xml.to_s
|
||||||
put :update, :params => { :id => relation.id }
|
|
||||||
assert_response :success, "can't update relation for remove node/bbox test"
|
assert_response :success, "can't update relation for remove node/bbox test"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -752,8 +748,7 @@ class RelationsControllerTest < ActionController::TestCase
|
||||||
OSM
|
OSM
|
||||||
doc = XML::Parser.string(doc_str).parse
|
doc = XML::Parser.string(doc_str).parse
|
||||||
|
|
||||||
content doc
|
put :create, :body => doc.to_s
|
||||||
put :create
|
|
||||||
assert_response :success, "can't create a relation: #{@response.body}"
|
assert_response :success, "can't create a relation: #{@response.body}"
|
||||||
relation_id = @response.body.to_i
|
relation_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -773,8 +768,7 @@ OSM
|
||||||
doc.find("//osm/relation").first["version"] = 1.to_s
|
doc.find("//osm/relation").first["version"] = 1.to_s
|
||||||
|
|
||||||
# upload the next version of the relation
|
# upload the next version of the relation
|
||||||
content doc
|
put :update, :params => { :id => relation_id }, :body => doc.to_s
|
||||||
put :update, :params => { :id => relation_id }
|
|
||||||
assert_response :success, "can't update relation: #{@response.body}"
|
assert_response :success, "can't update relation: #{@response.body}"
|
||||||
assert_equal 2, @response.body.to_i
|
assert_equal 2, @response.body.to_i
|
||||||
|
|
||||||
|
@ -815,15 +809,13 @@ OSM
|
||||||
## First try with the private user
|
## First try with the private user
|
||||||
basic_authorization private_user.email, "test"
|
basic_authorization private_user.email, "test"
|
||||||
|
|
||||||
content doc
|
put :create, :body => doc.to_s
|
||||||
put :create
|
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
## Now try with the public user
|
## Now try with the public user
|
||||||
basic_authorization user.email, "test"
|
basic_authorization user.email, "test"
|
||||||
|
|
||||||
content doc
|
put :create, :body => doc.to_s
|
||||||
put :create
|
|
||||||
assert_response :success, "can't create a relation: #{@response.body}"
|
assert_response :success, "can't create a relation: #{@response.body}"
|
||||||
relation_id = @response.body.to_i
|
relation_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -856,8 +848,7 @@ OSM
|
||||||
doc = XML::Parser.string(doc_str).parse
|
doc = XML::Parser.string(doc_str).parse
|
||||||
basic_authorization user.email, "test"
|
basic_authorization user.email, "test"
|
||||||
|
|
||||||
content doc
|
put :create, :body => doc.to_s
|
||||||
put :create
|
|
||||||
assert_response :success, "can't create a relation: #{@response.body}"
|
assert_response :success, "can't create a relation: #{@response.body}"
|
||||||
relation_id = @response.body.to_i
|
relation_id = @response.body.to_i
|
||||||
|
|
||||||
|
@ -896,8 +887,7 @@ OSM
|
||||||
update_changeset(relation_xml, changeset_id)
|
update_changeset(relation_xml, changeset_id)
|
||||||
|
|
||||||
# upload the change
|
# upload the change
|
||||||
content relation_xml
|
put :update, :params => { :id => relation.id }, :body => relation_xml.to_s
|
||||||
put :update, :params => { :id => relation.id }
|
|
||||||
assert_response :success, "can't update relation for remove all members test"
|
assert_response :success, "can't update relation for remove all members test"
|
||||||
checkrelation = Relation.find(relation.id)
|
checkrelation = Relation.find(relation.id)
|
||||||
assert_not_nil(checkrelation,
|
assert_not_nil(checkrelation,
|
||||||
|
@ -940,8 +930,8 @@ OSM
|
||||||
# create a new changeset for this operation, so we are assured
|
# create a new changeset for this operation, so we are assured
|
||||||
# that the bounding box will be newly-generated.
|
# that the bounding box will be newly-generated.
|
||||||
changeset_id = with_controller(ChangesetsController.new) do
|
changeset_id = with_controller(ChangesetsController.new) do
|
||||||
content "<osm><changeset/></osm>"
|
xml = "<osm><changeset/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :forbidden, "shouldn't be able to create changeset for modify test, as should get forbidden"
|
assert_response :forbidden, "shouldn't be able to create changeset for modify test, as should get forbidden"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -951,8 +941,8 @@ OSM
|
||||||
# create a new changeset for this operation, so we are assured
|
# create a new changeset for this operation, so we are assured
|
||||||
# that the bounding box will be newly-generated.
|
# that the bounding box will be newly-generated.
|
||||||
changeset_id = with_controller(ChangesetsController.new) do
|
changeset_id = with_controller(ChangesetsController.new) do
|
||||||
content "<osm><changeset/></osm>"
|
xml = "<osm><changeset/></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
assert_response :success, "couldn't create changeset for modify test"
|
assert_response :success, "couldn't create changeset for modify test"
|
||||||
@response.body.to_i
|
@response.body.to_i
|
||||||
end
|
end
|
||||||
|
@ -995,8 +985,7 @@ OSM
|
||||||
# the parsed XML doc is retured.
|
# the parsed XML doc is retured.
|
||||||
def with_update(rel)
|
def with_update(rel)
|
||||||
rel_id = rel.find("//osm/relation").first["id"].to_i
|
rel_id = rel.find("//osm/relation").first["id"].to_i
|
||||||
content rel
|
put :update, :params => { :id => rel_id }, :body => rel.to_s
|
||||||
put :update, :params => { :id => rel_id }
|
|
||||||
assert_response :success, "can't update relation: #{@response.body}"
|
assert_response :success, "can't update relation: #{@response.body}"
|
||||||
version = @response.body.to_i
|
version = @response.body.to_i
|
||||||
|
|
||||||
|
@ -1027,8 +1016,7 @@ OSM
|
||||||
change << modify
|
change << modify
|
||||||
modify << doc.import(rel.find("//osm/relation").first)
|
modify << doc.import(rel.find("//osm/relation").first)
|
||||||
|
|
||||||
content doc.to_s
|
post :upload, :params => { :id => cs_id }, :body => doc.to_s
|
||||||
post :upload, :params => { :id => cs_id }
|
|
||||||
assert_response :success, "can't upload diff relation: #{@response.body}"
|
assert_response :success, "can't upload diff relation: #{@response.body}"
|
||||||
version = xml_parse(@response.body).find("//diffResult/relation").first["new_version"].to_i
|
version = xml_parse(@response.body).find("//diffResult/relation").first["new_version"].to_i
|
||||||
end
|
end
|
||||||
|
|
|
@ -929,32 +929,27 @@ class TracesControllerTest < ActionController::TestCase
|
||||||
anon_trace_file = create(:trace, :visibility => "private")
|
anon_trace_file = create(:trace, :visibility => "private")
|
||||||
|
|
||||||
# First with no auth
|
# First with no auth
|
||||||
content public_trace_file.to_xml
|
put :api_update, :params => { :id => public_trace_file.id }, :body => public_trace_file.to_xml.to_s
|
||||||
put :api_update, :params => { :id => public_trace_file.id }
|
|
||||||
assert_response :unauthorized
|
assert_response :unauthorized
|
||||||
|
|
||||||
# Now with some other user, which should fail
|
# Now with some other user, which should fail
|
||||||
basic_authorization create(:user).display_name, "test"
|
basic_authorization create(:user).display_name, "test"
|
||||||
content public_trace_file.to_xml
|
put :api_update, :params => { :id => public_trace_file.id }, :body => public_trace_file.to_xml.to_s
|
||||||
put :api_update, :params => { :id => public_trace_file.id }
|
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# Now with a trace which doesn't exist
|
# Now with a trace which doesn't exist
|
||||||
basic_authorization create(:user).display_name, "test"
|
basic_authorization create(:user).display_name, "test"
|
||||||
content public_trace_file.to_xml
|
put :api_update, :params => { :id => 0 }, :body => public_trace_file.to_xml.to_s
|
||||||
put :api_update, :params => { :id => 0 }
|
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
|
|
||||||
# Now with a trace which did exist but has been deleted
|
# Now with a trace which did exist but has been deleted
|
||||||
basic_authorization deleted_trace_file.user.display_name, "test"
|
basic_authorization deleted_trace_file.user.display_name, "test"
|
||||||
content deleted_trace_file.to_xml
|
put :api_update, :params => { :id => deleted_trace_file.id }, :body => deleted_trace_file.to_xml.to_s
|
||||||
put :api_update, :params => { :id => deleted_trace_file.id }
|
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
|
|
||||||
# Now try an update with the wrong ID
|
# Now try an update with the wrong ID
|
||||||
basic_authorization public_trace_file.user.display_name, "test"
|
basic_authorization public_trace_file.user.display_name, "test"
|
||||||
content anon_trace_file.to_xml
|
put :api_update, :params => { :id => public_trace_file.id }, :body => anon_trace_file.to_xml.to_s
|
||||||
put :api_update, :params => { :id => public_trace_file.id }
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"should not be able to update a trace with a different ID from the XML"
|
"should not be able to update a trace with a different ID from the XML"
|
||||||
|
|
||||||
|
@ -963,8 +958,7 @@ class TracesControllerTest < ActionController::TestCase
|
||||||
t = public_trace_file
|
t = public_trace_file
|
||||||
t.description = "Changed description"
|
t.description = "Changed description"
|
||||||
t.visibility = "private"
|
t.visibility = "private"
|
||||||
content t.to_xml
|
put :api_update, :params => { :id => t.id }, :body => t.to_xml.to_s
|
||||||
put :api_update, :params => { :id => t.id }
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
nt = Trace.find(t.id)
|
nt = Trace.find(t.id)
|
||||||
assert_equal nt.description, t.description
|
assert_equal nt.description, t.description
|
||||||
|
@ -977,8 +971,7 @@ class TracesControllerTest < ActionController::TestCase
|
||||||
trace = tracetag.trace
|
trace = tracetag.trace
|
||||||
basic_authorization trace.user.display_name, "test"
|
basic_authorization trace.user.display_name, "test"
|
||||||
|
|
||||||
content trace.to_xml
|
put :api_update, :params => { :id => trace.id }, :body => trace.to_xml.to_s
|
||||||
put :api_update, :params => { :id => trace.id }
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
updated = Trace.find(trace.id)
|
updated = Trace.find(trace.id)
|
||||||
|
|
|
@ -96,8 +96,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# try a put without auth
|
# try a put without auth
|
||||||
assert_no_difference "UserPreference.count" do
|
assert_no_difference "UserPreference.count" do
|
||||||
content "<osm><preferences><preference k='key' v='new_value'/><preference k='new_key' v='value'/></preferences></osm>"
|
put :update, :body => "<osm><preferences><preference k='key' v='new_value'/><preference k='new_key' v='value'/></preferences></osm>"
|
||||||
put :update
|
|
||||||
end
|
end
|
||||||
assert_response :unauthorized, "should be authenticated"
|
assert_response :unauthorized, "should be authenticated"
|
||||||
assert_equal "value", UserPreference.find([user.id, "key"]).v
|
assert_equal "value", UserPreference.find([user.id, "key"]).v
|
||||||
|
@ -111,8 +110,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# try the put again
|
# try the put again
|
||||||
assert_no_difference "UserPreference.count" do
|
assert_no_difference "UserPreference.count" do
|
||||||
content "<osm><preferences><preference k='key' v='new_value'/><preference k='new_key' v='value'/></preferences></osm>"
|
put :update, :body => "<osm><preferences><preference k='key' v='new_value'/><preference k='new_key' v='value'/></preferences></osm>"
|
||||||
put :update
|
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal "text/plain", @response.content_type
|
assert_equal "text/plain", @response.content_type
|
||||||
|
@ -125,8 +123,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# try a put with duplicate keys
|
# try a put with duplicate keys
|
||||||
assert_no_difference "UserPreference.count" do
|
assert_no_difference "UserPreference.count" do
|
||||||
content "<osm><preferences><preference k='key' v='value'/><preference k='key' v='newer_value'/></preferences></osm>"
|
put :update, :body => "<osm><preferences><preference k='key' v='value'/><preference k='key' v='newer_value'/></preferences></osm>"
|
||||||
put :update
|
|
||||||
end
|
end
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
assert_equal "text/plain", @response.content_type
|
assert_equal "text/plain", @response.content_type
|
||||||
|
@ -135,8 +132,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# try a put with invalid content
|
# try a put with invalid content
|
||||||
assert_no_difference "UserPreference.count" do
|
assert_no_difference "UserPreference.count" do
|
||||||
content "nonsense"
|
put :update, :body => "nonsense"
|
||||||
put :update
|
|
||||||
end
|
end
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
end
|
end
|
||||||
|
@ -149,8 +145,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# try a put without auth
|
# try a put without auth
|
||||||
assert_no_difference "UserPreference.count" do
|
assert_no_difference "UserPreference.count" do
|
||||||
content "new_value"
|
put :update_one, :params => { :preference_key => "new_key" }, :body => "new_value"
|
||||||
put :update_one, :params => { :preference_key => "new_key" }
|
|
||||||
end
|
end
|
||||||
assert_response :unauthorized, "should be authenticated"
|
assert_response :unauthorized, "should be authenticated"
|
||||||
assert_raises ActiveRecord::RecordNotFound do
|
assert_raises ActiveRecord::RecordNotFound do
|
||||||
|
@ -162,8 +157,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# try adding a new preference
|
# try adding a new preference
|
||||||
assert_difference "UserPreference.count", 1 do
|
assert_difference "UserPreference.count", 1 do
|
||||||
content "new_value"
|
put :update_one, :params => { :preference_key => "new_key" }, :body => "new_value"
|
||||||
put :update_one, :params => { :preference_key => "new_key" }
|
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal "text/plain", @response.content_type
|
assert_equal "text/plain", @response.content_type
|
||||||
|
@ -172,8 +166,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# try changing the value of a preference
|
# try changing the value of a preference
|
||||||
assert_no_difference "UserPreference.count" do
|
assert_no_difference "UserPreference.count" do
|
||||||
content "newer_value"
|
put :update_one, :params => { :preference_key => "new_key" }, :body => "newer_value"
|
||||||
put :update_one, :params => { :preference_key => "new_key" }
|
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal "text/plain", @response.content_type
|
assert_equal "text/plain", @response.content_type
|
||||||
|
|
|
@ -127,10 +127,10 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
changeset_id = private_changeset.id
|
changeset_id = private_changeset.id
|
||||||
|
|
||||||
# create a way with pre-existing nodes
|
# create a way with pre-existing nodes
|
||||||
content "<osm><way changeset='#{changeset_id}'>" \
|
xml = "<osm><way changeset='#{changeset_id}'>" \
|
||||||
"<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
|
"<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
|
||||||
"<tag k='test' v='yes' /></way></osm>"
|
"<tag k='test' v='yes' /></way></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for failure
|
# hope for failure
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"way upload did not return forbidden status"
|
"way upload did not return forbidden status"
|
||||||
|
@ -142,10 +142,10 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
changeset_id = changeset.id
|
changeset_id = changeset.id
|
||||||
|
|
||||||
# create a way with pre-existing nodes
|
# create a way with pre-existing nodes
|
||||||
content "<osm><way changeset='#{changeset_id}'>" \
|
xml = "<osm><way changeset='#{changeset_id}'>" \
|
||||||
"<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
|
"<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
|
||||||
"<tag k='test' v='yes' /></way></osm>"
|
"<tag k='test' v='yes' /></way></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# hope for success
|
# hope for success
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"way upload did not return success status"
|
"way upload did not return success status"
|
||||||
|
@ -187,25 +187,25 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# use the first user's open changeset
|
# use the first user's open changeset
|
||||||
# create a way with non-existing node
|
# create a way with non-existing node
|
||||||
content "<osm><way changeset='#{private_open_changeset.id}'>" \
|
xml = "<osm><way changeset='#{private_open_changeset.id}'>" \
|
||||||
"<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
|
"<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# expect failure
|
# expect failure
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"way upload with invalid node using a private user did not return 'forbidden'"
|
"way upload with invalid node using a private user did not return 'forbidden'"
|
||||||
|
|
||||||
# create a way with no nodes
|
# create a way with no nodes
|
||||||
content "<osm><way changeset='#{private_open_changeset.id}'>" \
|
xml = "<osm><way changeset='#{private_open_changeset.id}'>" \
|
||||||
"<tag k='test' v='yes' /></way></osm>"
|
"<tag k='test' v='yes' /></way></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# expect failure
|
# expect failure
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"way upload with no node using a private userdid not return 'forbidden'"
|
"way upload with no node using a private userdid not return 'forbidden'"
|
||||||
|
|
||||||
# create a way inside a closed changeset
|
# create a way inside a closed changeset
|
||||||
content "<osm><way changeset='#{private_closed_changeset.id}'>" \
|
xml = "<osm><way changeset='#{private_closed_changeset.id}'>" \
|
||||||
"<nd ref='#{node.id}'/></way></osm>"
|
"<nd ref='#{node.id}'/></way></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# expect failure
|
# expect failure
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"way upload to closed changeset with a private user did not return 'forbidden'"
|
"way upload to closed changeset with a private user did not return 'forbidden'"
|
||||||
|
@ -215,37 +215,37 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# use the first user's open changeset
|
# use the first user's open changeset
|
||||||
# create a way with non-existing node
|
# create a way with non-existing node
|
||||||
content "<osm><way changeset='#{open_changeset.id}'>" \
|
xml = "<osm><way changeset='#{open_changeset.id}'>" \
|
||||||
"<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
|
"<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# expect failure
|
# expect failure
|
||||||
assert_response :precondition_failed,
|
assert_response :precondition_failed,
|
||||||
"way upload with invalid node did not return 'precondition failed'"
|
"way upload with invalid node did not return 'precondition failed'"
|
||||||
assert_equal "Precondition failed: Way requires the nodes with id in (0), which either do not exist, or are not visible.", @response.body
|
assert_equal "Precondition failed: Way requires the nodes with id in (0), which either do not exist, or are not visible.", @response.body
|
||||||
|
|
||||||
# create a way with no nodes
|
# create a way with no nodes
|
||||||
content "<osm><way changeset='#{open_changeset.id}'>" \
|
xml = "<osm><way changeset='#{open_changeset.id}'>" \
|
||||||
"<tag k='test' v='yes' /></way></osm>"
|
"<tag k='test' v='yes' /></way></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# expect failure
|
# expect failure
|
||||||
assert_response :precondition_failed,
|
assert_response :precondition_failed,
|
||||||
"way upload with no node did not return 'precondition failed'"
|
"way upload with no node did not return 'precondition failed'"
|
||||||
assert_equal "Precondition failed: Cannot create way: data is invalid.", @response.body
|
assert_equal "Precondition failed: Cannot create way: data is invalid.", @response.body
|
||||||
|
|
||||||
# create a way inside a closed changeset
|
# create a way inside a closed changeset
|
||||||
content "<osm><way changeset='#{closed_changeset.id}'>" \
|
xml = "<osm><way changeset='#{closed_changeset.id}'>" \
|
||||||
"<nd ref='#{node.id}'/></way></osm>"
|
"<nd ref='#{node.id}'/></way></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# expect failure
|
# expect failure
|
||||||
assert_response :conflict,
|
assert_response :conflict,
|
||||||
"way upload to closed changeset did not return 'conflict'"
|
"way upload to closed changeset did not return 'conflict'"
|
||||||
|
|
||||||
# create a way with a tag which is too long
|
# create a way with a tag which is too long
|
||||||
content "<osm><way changeset='#{open_changeset.id}'>" \
|
xml = "<osm><way changeset='#{open_changeset.id}'>" \
|
||||||
"<nd ref='#{node.id}'/>" \
|
"<nd ref='#{node.id}'/>" \
|
||||||
"<tag k='foo' v='#{'x' * 256}'/>" \
|
"<tag k='foo' v='#{'x' * 256}'/>" \
|
||||||
"</way></osm>"
|
"</way></osm>"
|
||||||
put :create
|
put :create, :body => xml
|
||||||
# expect failure
|
# expect failure
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"way upload to with too long tag did not return 'bad_request'"
|
"way upload to with too long tag did not return 'bad_request'"
|
||||||
|
@ -284,23 +284,23 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# Now try without having a changeset
|
# Now try without having a changeset
|
||||||
content "<osm><way id='#{private_way.id}'/></osm>"
|
xml = "<osm><way id='#{private_way.id}'/></osm>"
|
||||||
delete :delete, :params => { :id => private_way.id }
|
delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# try to delete with an invalid (closed) changeset
|
# try to delete with an invalid (closed) changeset
|
||||||
content update_changeset(private_way.to_xml, private_closed_changeset.id)
|
xml = update_changeset(private_way.to_xml, private_closed_changeset.id)
|
||||||
delete :delete, :params => { :id => private_way.id }
|
delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# try to delete with an invalid (non-existent) changeset
|
# try to delete with an invalid (non-existent) changeset
|
||||||
content update_changeset(private_way.to_xml, 0)
|
xml = update_changeset(private_way.to_xml, 0)
|
||||||
delete :delete, :params => { :id => private_way.id }
|
delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# Now try with a valid changeset
|
# Now try with a valid changeset
|
||||||
content private_way.to_xml
|
xml = private_way.to_xml
|
||||||
delete :delete, :params => { :id => private_way.id }
|
delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# check the returned value - should be the new version number
|
# check the returned value - should be the new version number
|
||||||
|
@ -310,13 +310,13 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
# "delete request should return a new version number for way"
|
# "delete request should return a new version number for way"
|
||||||
|
|
||||||
# this won't work since the way is already deleted
|
# this won't work since the way is already deleted
|
||||||
content private_deleted_way.to_xml
|
xml = private_deleted_way.to_xml
|
||||||
delete :delete, :params => { :id => private_deleted_way.id }
|
delete :delete, :params => { :id => private_deleted_way.id }, :body => xml.to_s
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# this shouldn't work as the way is used in a relation
|
# this shouldn't work as the way is used in a relation
|
||||||
content private_used_way.to_xml
|
xml = private_used_way.to_xml
|
||||||
delete :delete, :params => { :id => private_used_way.id }
|
delete :delete, :params => { :id => private_used_way.id }, :body => xml.to_s
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"shouldn't be able to delete a way used in a relation (#{@response.body}), when done by a private user"
|
"shouldn't be able to delete a way used in a relation (#{@response.body}), when done by a private user"
|
||||||
|
|
||||||
|
@ -333,23 +333,23 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
|
|
||||||
# Now try without having a changeset
|
# Now try without having a changeset
|
||||||
content "<osm><way id='#{way.id}'/></osm>"
|
xml = "<osm><way id='#{way.id}'/></osm>"
|
||||||
delete :delete, :params => { :id => way.id }
|
delete :delete, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
|
|
||||||
# try to delete with an invalid (closed) changeset
|
# try to delete with an invalid (closed) changeset
|
||||||
content update_changeset(way.to_xml, closed_changeset.id)
|
xml = update_changeset(way.to_xml, closed_changeset.id)
|
||||||
delete :delete, :params => { :id => way.id }
|
delete :delete, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :conflict
|
assert_response :conflict
|
||||||
|
|
||||||
# try to delete with an invalid (non-existent) changeset
|
# try to delete with an invalid (non-existent) changeset
|
||||||
content update_changeset(way.to_xml, 0)
|
xml = update_changeset(way.to_xml, 0)
|
||||||
delete :delete, :params => { :id => way.id }
|
delete :delete, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :conflict
|
assert_response :conflict
|
||||||
|
|
||||||
# Now try with a valid changeset
|
# Now try with a valid changeset
|
||||||
content way.to_xml
|
xml = way.to_xml
|
||||||
delete :delete, :params => { :id => way.id }
|
delete :delete, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
# check the returned value - should be the new version number
|
# check the returned value - should be the new version number
|
||||||
|
@ -359,13 +359,13 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
"delete request should return a new version number for way"
|
"delete request should return a new version number for way"
|
||||||
|
|
||||||
# this won't work since the way is already deleted
|
# this won't work since the way is already deleted
|
||||||
content deleted_way.to_xml
|
xml = deleted_way.to_xml
|
||||||
delete :delete, :params => { :id => deleted_way.id }
|
delete :delete, :params => { :id => deleted_way.id }, :body => xml.to_s
|
||||||
assert_response :gone
|
assert_response :gone
|
||||||
|
|
||||||
# this shouldn't work as the way is used in a relation
|
# this shouldn't work as the way is used in a relation
|
||||||
content used_way.to_xml
|
xml = used_way.to_xml
|
||||||
delete :delete, :params => { :id => used_way.id }
|
delete :delete, :params => { :id => used_way.id }, :body => xml.to_s
|
||||||
assert_response :precondition_failed,
|
assert_response :precondition_failed,
|
||||||
"shouldn't be able to delete a way used in a relation (#{@response.body})"
|
"shouldn't be able to delete a way used in a relation (#{@response.body})"
|
||||||
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
|
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
|
||||||
|
@ -389,8 +389,8 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
## First test with no user credentials
|
## First test with no user credentials
|
||||||
# try and update a way without authorisation
|
# try and update a way without authorisation
|
||||||
content way.to_xml
|
xml = way.to_xml
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :unauthorized
|
assert_response :unauthorized
|
||||||
|
|
||||||
## Second test with the private user
|
## Second test with the private user
|
||||||
|
@ -401,34 +401,34 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
## trying to break changesets
|
## trying to break changesets
|
||||||
|
|
||||||
# try and update in someone else's changeset
|
# try and update in someone else's changeset
|
||||||
content update_changeset(private_way.to_xml,
|
xml = update_changeset(private_way.to_xml,
|
||||||
create(:changeset).id)
|
create(:changeset).id)
|
||||||
put :update, :params => { :id => private_way.id }
|
put :update, :params => { :id => private_way.id }, :body => xml.to_s
|
||||||
assert_require_public_data "update with other user's changeset should be forbidden when date isn't public"
|
assert_require_public_data "update with other user's changeset should be forbidden when date isn't public"
|
||||||
|
|
||||||
# try and update in a closed changeset
|
# try and update in a closed changeset
|
||||||
content update_changeset(private_way.to_xml,
|
xml = update_changeset(private_way.to_xml,
|
||||||
create(:changeset, :closed, :user => private_user).id)
|
create(:changeset, :closed, :user => private_user).id)
|
||||||
put :update, :params => { :id => private_way.id }
|
put :update, :params => { :id => private_way.id }, :body => xml.to_s
|
||||||
assert_require_public_data "update with closed changeset should be forbidden, when data isn't public"
|
assert_require_public_data "update with closed changeset should be forbidden, when data isn't public"
|
||||||
|
|
||||||
# try and update in a non-existant changeset
|
# try and update in a non-existant changeset
|
||||||
content update_changeset(private_way.to_xml, 0)
|
xml = update_changeset(private_way.to_xml, 0)
|
||||||
put :update, :params => { :id => private_way.id }
|
put :update, :params => { :id => private_way.id }, :body => xml.to_s
|
||||||
assert_require_public_data("update with changeset=0 should be forbidden, when data isn't public")
|
assert_require_public_data("update with changeset=0 should be forbidden, when data isn't public")
|
||||||
|
|
||||||
## try and submit invalid updates
|
## try and submit invalid updates
|
||||||
content xml_replace_node(private_way.to_xml, node.id, 9999)
|
xml = xml_replace_node(private_way.to_xml, node.id, 9999)
|
||||||
put :update, :params => { :id => private_way.id }
|
put :update, :params => { :id => private_way.id }, :body => xml.to_s
|
||||||
assert_require_public_data "way with non-existent node should be forbidden, when data isn't public"
|
assert_require_public_data "way with non-existent node should be forbidden, when data isn't public"
|
||||||
|
|
||||||
content xml_replace_node(private_way.to_xml, node.id, create(:node, :deleted).id)
|
xml = xml_replace_node(private_way.to_xml, node.id, create(:node, :deleted).id)
|
||||||
put :update, :params => { :id => private_way.id }
|
put :update, :params => { :id => private_way.id }, :body => xml.to_s
|
||||||
assert_require_public_data "way with deleted node should be forbidden, when data isn't public"
|
assert_require_public_data "way with deleted node should be forbidden, when data isn't public"
|
||||||
|
|
||||||
## finally, produce a good request which will still not work
|
## finally, produce a good request which will still not work
|
||||||
content private_way.to_xml
|
xml = private_way.to_xml
|
||||||
put :update, :params => { :id => private_way.id }
|
put :update, :params => { :id => private_way.id }, :body => xml.to_s
|
||||||
assert_require_public_data "should have failed with a forbidden when data isn't public"
|
assert_require_public_data "should have failed with a forbidden when data isn't public"
|
||||||
|
|
||||||
## Finally test with the public user
|
## Finally test with the public user
|
||||||
|
@ -439,68 +439,68 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
## trying to break changesets
|
## trying to break changesets
|
||||||
|
|
||||||
# try and update in someone else's changeset
|
# try and update in someone else's changeset
|
||||||
content update_changeset(way.to_xml,
|
xml = update_changeset(way.to_xml,
|
||||||
create(:changeset).id)
|
create(:changeset).id)
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :conflict, "update with other user's changeset should be rejected"
|
assert_response :conflict, "update with other user's changeset should be rejected"
|
||||||
|
|
||||||
# try and update in a closed changeset
|
# try and update in a closed changeset
|
||||||
content update_changeset(way.to_xml,
|
xml = update_changeset(way.to_xml,
|
||||||
create(:changeset, :closed, :user => user).id)
|
create(:changeset, :closed, :user => user).id)
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :conflict, "update with closed changeset should be rejected"
|
assert_response :conflict, "update with closed changeset should be rejected"
|
||||||
|
|
||||||
# try and update in a non-existant changeset
|
# try and update in a non-existant changeset
|
||||||
content update_changeset(way.to_xml, 0)
|
xml = update_changeset(way.to_xml, 0)
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :conflict, "update with changeset=0 should be rejected"
|
assert_response :conflict, "update with changeset=0 should be rejected"
|
||||||
|
|
||||||
## try and submit invalid updates
|
## try and submit invalid updates
|
||||||
content xml_replace_node(way.to_xml, node.id, 9999)
|
xml = xml_replace_node(way.to_xml, node.id, 9999)
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :precondition_failed, "way with non-existent node should be rejected"
|
assert_response :precondition_failed, "way with non-existent node should be rejected"
|
||||||
|
|
||||||
content xml_replace_node(way.to_xml, node.id, create(:node, :deleted).id)
|
xml = xml_replace_node(way.to_xml, node.id, create(:node, :deleted).id)
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :precondition_failed, "way with deleted node should be rejected"
|
assert_response :precondition_failed, "way with deleted node should be rejected"
|
||||||
|
|
||||||
## next, attack the versioning
|
## next, attack the versioning
|
||||||
current_way_version = way.version
|
current_way_version = way.version
|
||||||
|
|
||||||
# try and submit a version behind
|
# try and submit a version behind
|
||||||
content xml_attr_rewrite(way.to_xml,
|
xml = xml_attr_rewrite(way.to_xml,
|
||||||
"version", current_way_version - 1)
|
"version", current_way_version - 1)
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :conflict, "should have failed on old version number"
|
assert_response :conflict, "should have failed on old version number"
|
||||||
|
|
||||||
# try and submit a version ahead
|
# try and submit a version ahead
|
||||||
content xml_attr_rewrite(way.to_xml,
|
xml = xml_attr_rewrite(way.to_xml,
|
||||||
"version", current_way_version + 1)
|
"version", current_way_version + 1)
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :conflict, "should have failed on skipped version number"
|
assert_response :conflict, "should have failed on skipped version number"
|
||||||
|
|
||||||
# try and submit total crap in the version field
|
# try and submit total crap in the version field
|
||||||
content xml_attr_rewrite(way.to_xml,
|
xml = xml_attr_rewrite(way.to_xml,
|
||||||
"version", "p1r4t3s!")
|
"version", "p1r4t3s!")
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :conflict,
|
assert_response :conflict,
|
||||||
"should not be able to put 'p1r4at3s!' in the version field"
|
"should not be able to put 'p1r4at3s!' in the version field"
|
||||||
|
|
||||||
## try an update with the wrong ID
|
## try an update with the wrong ID
|
||||||
content create(:way).to_xml
|
xml = create(:way).to_xml
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"should not be able to update a way with a different ID from the XML"
|
"should not be able to update a way with a different ID from the XML"
|
||||||
|
|
||||||
## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.
|
## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.
|
||||||
content "<update/>"
|
xml = "<update/>"
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"should not be able to update a way with non-OSM XML doc."
|
"should not be able to update a way with non-OSM XML doc."
|
||||||
|
|
||||||
## finally, produce a good request which should work
|
## finally, produce a good request which should work
|
||||||
content way.to_xml
|
xml = way.to_xml
|
||||||
put :update, :params => { :id => way.id }
|
put :update, :params => { :id => way.id }, :body => xml.to_s
|
||||||
assert_response :success, "a valid update request failed"
|
assert_response :success, "a valid update request failed"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -530,8 +530,7 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
way_xml.find("//osm/way").first << tag_xml
|
way_xml.find("//osm/way").first << tag_xml
|
||||||
|
|
||||||
# try and upload it
|
# try and upload it
|
||||||
content way_xml
|
put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
|
||||||
put :update, :params => { :id => private_way.id }
|
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"adding a duplicate tag to a way for a non-public should fail with 'forbidden'"
|
"adding a duplicate tag to a way for a non-public should fail with 'forbidden'"
|
||||||
|
|
||||||
|
@ -549,8 +548,7 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
way_xml.find("//osm/way").first << tag_xml
|
way_xml.find("//osm/way").first << tag_xml
|
||||||
|
|
||||||
# try and upload it
|
# try and upload it
|
||||||
content way_xml
|
put :update, :params => { :id => way.id }, :body => way_xml.to_s
|
||||||
put :update, :params => { :id => way.id }
|
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"adding a new tag to a way should succeed"
|
"adding a new tag to a way should succeed"
|
||||||
assert_equal way.version + 1, @response.body.to_i
|
assert_equal way.version + 1, @response.body.to_i
|
||||||
|
@ -580,8 +578,7 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
way_xml.find("//osm/way").first << tag_xml
|
way_xml.find("//osm/way").first << tag_xml
|
||||||
|
|
||||||
# try and upload it
|
# try and upload it
|
||||||
content way_xml
|
put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
|
||||||
put :update, :params => { :id => private_way.id }
|
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"adding a duplicate tag to a way for a non-public should fail with 'forbidden'"
|
"adding a duplicate tag to a way for a non-public should fail with 'forbidden'"
|
||||||
|
|
||||||
|
@ -599,8 +596,7 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
way_xml.find("//osm/way").first << tag_xml
|
way_xml.find("//osm/way").first << tag_xml
|
||||||
|
|
||||||
# try and upload it
|
# try and upload it
|
||||||
content way_xml
|
put :update, :params => { :id => way.id }, :body => way_xml.to_s
|
||||||
put :update, :params => { :id => way.id }
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"adding a duplicate tag to a way should fail with 'bad request'"
|
"adding a duplicate tag to a way should fail with 'bad request'"
|
||||||
assert_equal "Element way/#{way.id} has duplicate tags with key #{existing_tag.k}", @response.body
|
assert_equal "Element way/#{way.id} has duplicate tags with key #{existing_tag.k}", @response.body
|
||||||
|
@ -630,8 +626,7 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
way_xml.find("//osm/way").first << tag_xml.copy(true) << tag_xml
|
way_xml.find("//osm/way").first << tag_xml.copy(true) << tag_xml
|
||||||
|
|
||||||
# try and upload it
|
# try and upload it
|
||||||
content way_xml
|
put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
|
||||||
put :update, :params => { :id => private_way.id }
|
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"adding new duplicate tags to a way using a non-public user should fail with 'forbidden'"
|
"adding new duplicate tags to a way using a non-public user should fail with 'forbidden'"
|
||||||
|
|
||||||
|
@ -651,8 +646,7 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
way_xml.find("//osm/way").first << tag_xml.copy(true) << tag_xml
|
way_xml.find("//osm/way").first << tag_xml.copy(true) << tag_xml
|
||||||
|
|
||||||
# try and upload it
|
# try and upload it
|
||||||
content way_xml
|
put :update, :params => { :id => way.id }, :body => way_xml.to_s
|
||||||
put :update, :params => { :id => way.id }
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"adding new duplicate tags to a way should fail with 'bad request'"
|
"adding new duplicate tags to a way should fail with 'bad request'"
|
||||||
assert_equal "Element way/#{way.id} has duplicate tags with key i_am_a_duplicate", @response.body
|
assert_equal "Element way/#{way.id} has duplicate tags with key i_am_a_duplicate", @response.body
|
||||||
|
@ -679,8 +673,7 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
way_str << "</way></osm>"
|
way_str << "</way></osm>"
|
||||||
|
|
||||||
# try and upload it
|
# try and upload it
|
||||||
content way_str
|
put :create, :body => way_str
|
||||||
put :create
|
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"adding new duplicate tags to a way with a non-public user should fail with 'forbidden'"
|
"adding new duplicate tags to a way with a non-public user should fail with 'forbidden'"
|
||||||
|
|
||||||
|
@ -695,8 +688,7 @@ class WaysControllerTest < ActionController::TestCase
|
||||||
way_str << "</way></osm>"
|
way_str << "</way></osm>"
|
||||||
|
|
||||||
# try and upload it
|
# try and upload it
|
||||||
content way_str
|
put :create, :body => way_str
|
||||||
put :create
|
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"adding new duplicate tags to a way should fail with 'bad request'"
|
"adding new duplicate tags to a way should fail with 'bad request'"
|
||||||
assert_equal "Element way/ has duplicate tags with key addr:housenumber", @response.body
|
assert_equal "Element way/ has duplicate tags with key addr:housenumber", @response.body
|
||||||
|
|
|
@ -94,12 +94,6 @@ module ActiveSupport
|
||||||
@request.env["HTTP_X_ERROR_FORMAT"] = format
|
@request.env["HTTP_X_ERROR_FORMAT"] = format
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
|
||||||
# set the raw body to be sent with a POST request
|
|
||||||
def content(c)
|
|
||||||
@request.env["RAW_POST_DATA"] = c.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Used to check that the error header and the forbidden responses are given
|
# Used to check that the error header and the forbidden responses are given
|
||||||
# when the owner of the changset has their data not marked as public
|
# when the owner of the changset has their data not marked as public
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue