4 class NodesControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/api/0.6/node/create", :method => :put },
10 { :controller => "api/nodes", :action => "create" }
13 { :path => "/api/0.6/node/1", :method => :get },
14 { :controller => "api/nodes", :action => "show", :id => "1" }
17 { :path => "/api/0.6/node/1.json", :method => :get },
18 { :controller => "api/nodes", :action => "show", :id => "1", :format => "json" }
21 { :path => "/api/0.6/node/1", :method => :put },
22 { :controller => "api/nodes", :action => "update", :id => "1" }
25 { :path => "/api/0.6/node/1", :method => :delete },
26 { :controller => "api/nodes", :action => "delete", :id => "1" }
29 { :path => "/api/0.6/nodes", :method => :get },
30 { :controller => "api/nodes", :action => "index" }
33 { :path => "/api/0.6/nodes.json", :method => :get },
34 { :controller => "api/nodes", :action => "index", :format => "json" }
39 private_user = create(:user, :data_public => false)
40 private_changeset = create(:changeset, :user => private_user)
42 changeset = create(:changeset, :user => user)
44 # create a node with random lat/lon
45 lat = rand(-50..50) + rand
46 lon = rand(-50..50) + rand
48 ## First try with no auth
49 # create a minimal xml file
50 xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
51 assert_difference("OldNode.count", 0) do
52 put node_create_path, :params => xml
54 # hope for unauthorized
55 assert_response :unauthorized, "node upload did not return unauthorized status"
57 ## Now try with the user which doesn't have their data public
58 auth_header = basic_authorization_header private_user.email, "test"
60 # create a minimal xml file
61 xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{private_changeset.id}'/></osm>"
62 assert_difference("Node.count", 0) do
63 put node_create_path, :params => xml, :headers => auth_header
66 assert_require_public_data "node create did not return forbidden status"
68 ## Now try with the user that has the public data
69 auth_header = basic_authorization_header user.email, "test"
71 # create a minimal xml file
72 xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
73 put node_create_path, :params => xml, :headers => auth_header
75 assert_response :success, "node upload did not return success status"
77 # read id of created node and search for it
78 nodeid = @response.body
79 checknode = Node.find(nodeid)
80 assert_not_nil checknode, "uploaded node not found in data base after upload"
82 assert_in_delta lat * 10000000, checknode.latitude, 1, "saved node does not match requested latitude"
83 assert_in_delta lon * 10000000, checknode.longitude, 1, "saved node does not match requested longitude"
84 assert_equal changeset.id, checknode.changeset_id, "saved node does not belong to changeset that it was created in"
85 assert checknode.visible, "saved node is not visible"
88 def test_create_invalid_xml
89 ## Only test public user here, as test_create should cover what's the forbidden
90 ## that would occur here
93 changeset = create(:changeset, :user => user)
95 auth_header = basic_authorization_header user.email, "test"
99 # test that the upload is rejected when xml is valid, but osm doc isn't
101 put node_create_path, :params => xml, :headers => auth_header
102 assert_response :bad_request, "node upload did not return bad_request status"
103 assert_equal "Cannot parse valid node from xml string <create/>. XML doesn't contain an osm/node element.", @response.body
105 # test that the upload is rejected when no lat is supplied
106 # create a minimal xml file
107 xml = "<osm><node lon='#{lon}' changeset='#{changeset.id}'/></osm>"
108 put node_create_path, :params => xml, :headers => auth_header
110 assert_response :bad_request, "node upload did not return bad_request status"
111 assert_equal "Cannot parse valid node from xml string <node lon=\"3.23\" changeset=\"#{changeset.id}\"/>. lat missing", @response.body
113 # test that the upload is rejected when no lon is supplied
114 # create a minimal xml file
115 xml = "<osm><node lat='#{lat}' changeset='#{changeset.id}'/></osm>"
116 put node_create_path, :params => xml, :headers => auth_header
118 assert_response :bad_request, "node upload did not return bad_request status"
119 assert_equal "Cannot parse valid node from xml string <node lat=\"3.434\" changeset=\"#{changeset.id}\"/>. lon missing", @response.body
121 # test that the upload is rejected when lat is non-numeric
122 # create a minimal xml file
123 xml = "<osm><node lat='abc' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
124 put node_create_path, :params => xml, :headers => auth_header
126 assert_response :bad_request, "node upload did not return bad_request status"
127 assert_equal "Cannot parse valid node from xml string <node lat=\"abc\" lon=\"#{lon}\" changeset=\"#{changeset.id}\"/>. lat not a number", @response.body
129 # test that the upload is rejected when lon is non-numeric
130 # create a minimal xml file
131 xml = "<osm><node lat='#{lat}' lon='abc' changeset='#{changeset.id}'/></osm>"
132 put node_create_path, :params => xml, :headers => auth_header
134 assert_response :bad_request, "node upload did not return bad_request status"
135 assert_equal "Cannot parse valid node from xml string <node lat=\"#{lat}\" lon=\"abc\" changeset=\"#{changeset.id}\"/>. lon not a number", @response.body
137 # test that the upload is rejected when we have a tag which is too long
138 xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'><tag k='foo' v='#{'x' * 256}'/></node></osm>"
139 put node_create_path, :params => xml, :headers => auth_header
140 assert_response :bad_request, "node upload did not return bad_request status"
141 assert_match(/ v: is too long \(maximum is 255 characters\) /, @response.body)
145 # check that a visible node is returned properly
146 get api_node_path(create(:node))
147 assert_response :success
149 # check that an deleted node is not returned
150 get api_node_path(create(:node, :deleted))
151 assert_response :gone
153 # check chat a non-existent node is not returned
155 assert_response :not_found
158 # Ensure the lat/lon is formatted as a decimal e.g. not 4.0e-05
159 def test_lat_lon_xml_format
160 node = create(:node, :latitude => (0.00004 * OldNode::SCALE).to_i, :longitude => (0.00008 * OldNode::SCALE).to_i)
162 get api_node_path(node)
163 assert_match(/lat="0.0000400"/, response.body)
164 assert_match(/lon="0.0000800"/, response.body)
167 # this tests deletion restrictions - basic deletion is tested in the unit
170 private_user = create(:user, :data_public => false)
171 private_user_changeset = create(:changeset, :user => private_user)
172 private_user_closed_changeset = create(:changeset, :closed, :user => private_user)
173 private_node = create(:node, :changeset => private_user_changeset)
174 private_deleted_node = create(:node, :deleted, :changeset => private_user_changeset)
176 ## first try to delete node without auth
177 delete api_node_path(private_node)
178 assert_response :unauthorized
180 ## now set auth for the non-data public user
181 auth_header = basic_authorization_header private_user.email, "test"
183 # try to delete with an invalid (closed) changeset
184 xml = update_changeset(xml_for_node(private_node), private_user_closed_changeset.id)
185 delete api_node_path(private_node), :params => xml.to_s, :headers => auth_header
186 assert_require_public_data("non-public user shouldn't be able to delete node")
188 # try to delete with an invalid (non-existent) changeset
189 xml = update_changeset(xml_for_node(private_node), 0)
190 delete api_node_path(private_node), :params => xml.to_s, :headers => auth_header
191 assert_require_public_data("shouldn't be able to delete node, when user's data is private")
193 # valid delete now takes a payload
194 xml = xml_for_node(private_node)
195 delete api_node_path(private_node), :params => xml.to_s, :headers => auth_header
196 assert_require_public_data("shouldn't be able to delete node when user's data isn't public'")
198 # this won't work since the node is already deleted
199 xml = xml_for_node(private_deleted_node)
200 delete api_node_path(private_deleted_node), :params => xml.to_s, :headers => auth_header
201 assert_require_public_data
203 # this won't work since the node never existed
204 delete api_node_path(0), :headers => auth_header
205 assert_require_public_data
207 ## these test whether nodes which are in-use can be deleted:
209 private_used_node = create(:node, :changeset => private_user_changeset)
210 create(:way_node, :node => private_used_node)
212 xml = xml_for_node(private_used_node)
213 delete api_node_path(private_used_node), :params => xml.to_s, :headers => auth_header
214 assert_require_public_data "shouldn't be able to delete a node used in a way (#{@response.body})"
217 private_used_node2 = create(:node, :changeset => private_user_changeset)
218 create(:relation_member, :member => private_used_node2)
220 xml = xml_for_node(private_used_node2)
221 delete api_node_path(private_used_node2), :params => xml.to_s, :headers => auth_header
222 assert_require_public_data "shouldn't be able to delete a node used in a relation (#{@response.body})"
224 ## now setup for the public data user
225 user = create(:user, :data_public => true)
226 changeset = create(:changeset, :user => user)
227 closed_changeset = create(:changeset, :closed, :user => user)
228 node = create(:node, :changeset => changeset)
229 auth_header = basic_authorization_header user.email, "test"
231 # try to delete with an invalid (closed) changeset
232 xml = update_changeset(xml_for_node(node), closed_changeset.id)
233 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
234 assert_response :conflict
236 # try to delete with an invalid (non-existent) changeset
237 xml = update_changeset(xml_for_node(node), 0)
238 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
239 assert_response :conflict
241 # try to delete a node with a different ID
242 other_node = create(:node)
243 xml = xml_for_node(other_node)
244 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
245 assert_response :bad_request,
246 "should not be able to delete a node with a different ID from the XML"
248 # try to delete a node rubbish in the payloads
250 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
251 assert_response :bad_request,
252 "should not be able to delete a node without a valid XML payload"
254 # valid delete now takes a payload
255 xml = xml_for_node(node)
256 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
257 assert_response :success
259 # valid delete should return the new version number, which should
260 # be greater than the old version number
261 assert_operator @response.body.to_i, :>, node.version, "delete request should return a new version number for node"
263 # deleting the same node twice doesn't work
264 xml = xml_for_node(node)
265 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
266 assert_response :gone
268 # this won't work since the node never existed
269 delete api_node_path(0), :headers => auth_header
270 assert_response :not_found
272 ## these test whether nodes which are in-use can be deleted:
274 used_node = create(:node, :changeset => create(:changeset, :user => user))
275 way_node = create(:way_node, :node => used_node)
276 way_node2 = create(:way_node, :node => used_node)
278 xml = xml_for_node(used_node)
279 delete api_node_path(used_node), :params => xml.to_s, :headers => auth_header
280 assert_response :precondition_failed,
281 "shouldn't be able to delete a node used in a way (#{@response.body})"
282 assert_equal "Precondition failed: Node #{used_node.id} is still used by ways #{way_node.way.id},#{way_node2.way.id}.", @response.body
285 used_node2 = create(:node, :changeset => create(:changeset, :user => user))
286 relation_member = create(:relation_member, :member => used_node2)
287 relation_member2 = create(:relation_member, :member => used_node2)
289 xml = xml_for_node(used_node2)
290 delete api_node_path(used_node2), :params => xml.to_s, :headers => auth_header
291 assert_response :precondition_failed,
292 "shouldn't be able to delete a node used in a relation (#{@response.body})"
293 assert_equal "Precondition failed: Node #{used_node2.id} is still used by relations #{relation_member.relation.id},#{relation_member2.relation.id}.", @response.body
297 # tests whether the API works and prevents incorrect use while trying
300 invalid_attr_values = [["lat", 91.0], ["lat", -91.0], ["lon", 181.0], ["lon", -181.0]]
302 ## First test with no user credentials
303 # try and update a node without authorisation
304 # first try to delete node without auth
305 private_user = create(:user, :data_public => false)
306 private_node = create(:node, :changeset => create(:changeset, :user => private_user))
308 node = create(:node, :changeset => create(:changeset, :user => user))
310 xml = xml_for_node(node)
311 put api_node_path(node), :params => xml.to_s
312 assert_response :unauthorized
314 ## Second test with the private user
317 auth_header = basic_authorization_header private_user.email, "test"
319 ## trying to break changesets
321 # try and update in someone else's changeset
322 xml = update_changeset(xml_for_node(private_node),
323 create(:changeset).id)
324 put api_node_path(private_node), :params => xml.to_s, :headers => auth_header
325 assert_require_public_data "update with other user's changeset should be forbidden when data isn't public"
327 # try and update in a closed changeset
328 xml = update_changeset(xml_for_node(private_node),
329 create(:changeset, :closed, :user => private_user).id)
330 put api_node_path(private_node), :params => xml.to_s, :headers => auth_header
331 assert_require_public_data "update with closed changeset should be forbidden, when data isn't public"
333 # try and update in a non-existant changeset
334 xml = update_changeset(xml_for_node(private_node), 0)
335 put api_node_path(private_node), :params => xml.to_s, :headers => auth_header
336 assert_require_public_data "update with changeset=0 should be forbidden, when data isn't public"
338 ## try and submit invalid updates
339 invalid_attr_values.each do |name, value|
340 xml = xml_attr_rewrite(xml_for_node(private_node), name, value)
341 put api_node_path(private_node), :params => xml.to_s, :headers => auth_header
342 assert_require_public_data "node at #{name}=#{value} should be forbidden, when data isn't public"
345 ## finally, produce a good request which still won't work
346 xml = xml_for_node(private_node)
347 put api_node_path(private_node), :params => xml.to_s, :headers => auth_header
348 assert_require_public_data "should have failed with a forbidden when data isn't public"
350 ## Finally test with the public user
352 # try and update a node without authorisation
353 # first try to update node without auth
354 xml = xml_for_node(node)
355 put api_node_path(node), :params => xml.to_s, :headers => auth_header
356 assert_response :forbidden
359 auth_header = basic_authorization_header user.email, "test"
361 ## trying to break changesets
363 # try and update in someone else's changeset
364 xml = update_changeset(xml_for_node(node),
365 create(:changeset).id)
366 put api_node_path(node), :params => xml.to_s, :headers => auth_header
367 assert_response :conflict, "update with other user's changeset should be rejected"
369 # try and update in a closed changeset
370 xml = update_changeset(xml_for_node(node),
371 create(:changeset, :closed, :user => user).id)
372 put api_node_path(node), :params => xml.to_s, :headers => auth_header
373 assert_response :conflict, "update with closed changeset should be rejected"
375 # try and update in a non-existant changeset
376 xml = update_changeset(xml_for_node(node), 0)
377 put api_node_path(node), :params => xml.to_s, :headers => auth_header
378 assert_response :conflict, "update with changeset=0 should be rejected"
380 ## try and submit invalid updates
381 invalid_attr_values.each do |name, value|
382 xml = xml_attr_rewrite(xml_for_node(node), name, value)
383 put api_node_path(node), :params => xml.to_s, :headers => auth_header
384 assert_response :bad_request, "node at #{name}=#{value} should be rejected"
387 ## next, attack the versioning
388 current_node_version = node.version
390 # try and submit a version behind
391 xml = xml_attr_rewrite(xml_for_node(node),
392 "version", current_node_version - 1)
393 put api_node_path(node), :params => xml.to_s, :headers => auth_header
394 assert_response :conflict, "should have failed on old version number"
396 # try and submit a version ahead
397 xml = xml_attr_rewrite(xml_for_node(node),
398 "version", current_node_version + 1)
399 put api_node_path(node), :params => xml.to_s, :headers => auth_header
400 assert_response :conflict, "should have failed on skipped version number"
402 # try and submit total crap in the version field
403 xml = xml_attr_rewrite(xml_for_node(node),
404 "version", "p1r4t3s!")
405 put api_node_path(node), :params => xml.to_s, :headers => auth_header
406 assert_response :conflict,
407 "should not be able to put 'p1r4at3s!' in the version field"
409 ## try an update with the wrong ID
410 xml = xml_for_node(create(:node))
411 put api_node_path(node), :params => xml.to_s, :headers => auth_header
412 assert_response :bad_request,
413 "should not be able to update a node with a different ID from the XML"
415 ## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.
417 put api_node_path(node), :params => xml.to_s, :headers => auth_header
418 assert_response :bad_request,
419 "should not be able to update a node with non-OSM XML doc."
421 ## finally, produce a good request which should work
422 xml = xml_for_node(node)
423 put api_node_path(node), :params => xml.to_s, :headers => auth_header
424 assert_response :success, "a valid update request failed"
428 # test fetching multiple nodes
430 node1 = create(:node)
431 node2 = create(:node, :deleted)
432 node3 = create(:node)
433 node4 = create(:node, :with_history, :version => 2)
434 node5 = create(:node, :deleted, :with_history, :version => 2)
436 # check error when no parameter provided
438 assert_response :bad_request
440 # check error when no parameter value provided
441 get nodes_path(:nodes => "")
442 assert_response :bad_request
444 # test a working call
445 get nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id}")
446 assert_response :success
447 assert_select "osm" do
448 assert_select "node", :count => 5
449 assert_select "node[id='#{node1.id}'][visible='true']", :count => 1
450 assert_select "node[id='#{node2.id}'][visible='false']", :count => 1
451 assert_select "node[id='#{node3.id}'][visible='true']", :count => 1
452 assert_select "node[id='#{node4.id}'][visible='true']", :count => 1
453 assert_select "node[id='#{node5.id}'][visible='false']", :count => 1
456 # test a working call with json format
457 get nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id}", :format => "json")
459 js = ActiveSupport::JSON.decode(@response.body)
461 assert_equal 5, js["elements"].count
462 assert_equal 5, (js["elements"].count { |a| a["type"] == "node" })
463 assert_equal 1, (js["elements"].count { |a| a["id"] == node1.id && a["visible"].nil? })
464 assert_equal 1, (js["elements"].count { |a| a["id"] == node2.id && a["visible"] == false })
465 assert_equal 1, (js["elements"].count { |a| a["id"] == node3.id && a["visible"].nil? })
466 assert_equal 1, (js["elements"].count { |a| a["id"] == node4.id && a["visible"].nil? })
467 assert_equal 1, (js["elements"].count { |a| a["id"] == node5.id && a["visible"] == false })
469 # check error when a non-existent node is included
470 get nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id},0")
471 assert_response :not_found
475 # test adding tags to a node
476 def test_duplicate_tags
477 existing_tag = create(:node_tag)
478 assert existing_tag.node.changeset.user.data_public
480 auth_header = basic_authorization_header existing_tag.node.changeset.user.email, "test"
482 # add an identical tag to the node
483 tag_xml = XML::Node.new("tag")
484 tag_xml["k"] = existing_tag.k
485 tag_xml["v"] = existing_tag.v
487 # add the tag into the existing xml
488 node_xml = xml_for_node(existing_tag.node)
489 node_xml.find("//osm/node").first << tag_xml
492 put api_node_path(existing_tag.node), :params => node_xml.to_s, :headers => auth_header
493 assert_response :bad_request,
494 "adding duplicate tags to a node should fail with 'bad request'"
495 assert_equal "Element node/#{existing_tag.node.id} has duplicate tags with key #{existing_tag.k}", @response.body
498 # test whether string injection is possible
499 def test_string_injection
500 private_user = create(:user, :data_public => false)
501 private_changeset = create(:changeset, :user => private_user)
503 changeset = create(:changeset, :user => user)
505 ## First try with the non-data public user
506 auth_header = basic_authorization_header private_user.email, "test"
508 # try and put something into a string that the API might
509 # use unquoted and therefore allow code injection...
510 xml = "<osm><node lat='0' lon='0' changeset='#{private_changeset.id}'>" \
511 "<tag k='\#{@user.inspect}' v='0'/>" \
513 put node_create_path, :params => xml, :headers => auth_header
514 assert_require_public_data "Shouldn't be able to create with non-public user"
516 ## Then try with the public data user
517 auth_header = basic_authorization_header user.email, "test"
519 # try and put something into a string that the API might
520 # use unquoted and therefore allow code injection...
521 xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'>" \
522 "<tag k='\#{@user.inspect}' v='0'/>" \
524 put node_create_path, :params => xml, :headers => auth_header
525 assert_response :success
526 nodeid = @response.body
528 # find the node in the database
529 checknode = Node.find(nodeid)
530 assert_not_nil checknode, "node not found in data base after upload"
532 # and grab it using the api
533 get api_node_path(nodeid)
534 assert_response :success
535 apinode = Node.from_xml(@response.body)
536 assert_not_nil apinode, "downloaded node is nil, but shouldn't be"
538 # check the tags are not corrupted
539 assert_equal checknode.tags, apinode.tags
540 assert_includes apinode.tags, "\#{@user.inspect}"
544 # test initial rate limit
545 def test_initial_rate_limit
549 # create a changeset that puts us near the initial rate limit
550 changeset = create(:changeset, :user => user,
551 :created_at => Time.now.utc - 5.minutes,
552 :num_changes => Settings.initial_changes_per_hour - 1)
554 # create authentication header
555 auth_header = basic_authorization_header user.email, "test"
557 # try creating a node
558 xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'/></osm>"
559 put node_create_path, :params => xml, :headers => auth_header
560 assert_response :success, "node create did not return success status"
562 # get the id of the node we created
563 nodeid = @response.body
565 # try updating the node, which should be rate limited
566 xml = "<osm><node id='#{nodeid}' version='1' lat='1' lon='1' changeset='#{changeset.id}'/></osm>"
567 put api_node_path(nodeid), :params => xml, :headers => auth_header
568 assert_response :too_many_requests, "node update did not hit rate limit"
570 # try deleting the node, which should be rate limited
571 xml = "<osm><node id='#{nodeid}' version='2' lat='1' lon='1' changeset='#{changeset.id}'/></osm>"
572 delete api_node_path(nodeid), :params => xml, :headers => auth_header
573 assert_response :too_many_requests, "node delete did not hit rate limit"
575 # try creating a node, which should be rate limited
576 xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'/></osm>"
577 put node_create_path, :params => xml, :headers => auth_header
578 assert_response :too_many_requests, "node create did not hit rate limit"
582 # test maximum rate limit
583 def test_maximum_rate_limit
587 # create a changeset to establish our initial edit time
588 changeset = create(:changeset, :user => user,
589 :created_at => Time.now.utc - 28.days)
591 # create changeset to put us near the maximum rate limit
592 total_changes = Settings.max_changes_per_hour - 1
593 while total_changes.positive?
594 changes = [total_changes, Changeset::MAX_ELEMENTS].min
595 changeset = create(:changeset, :user => user,
596 :created_at => Time.now.utc - 5.minutes,
597 :num_changes => changes)
598 total_changes -= changes
601 # create authentication header
602 auth_header = basic_authorization_header user.email, "test"
604 # try creating a node
605 xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'/></osm>"
606 put node_create_path, :params => xml, :headers => auth_header
607 assert_response :success, "node create did not return success status"
609 # get the id of the node we created
610 nodeid = @response.body
612 # try updating the node, which should be rate limited
613 xml = "<osm><node id='#{nodeid}' version='1' lat='1' lon='1' changeset='#{changeset.id}'/></osm>"
614 put api_node_path(nodeid), :params => xml, :headers => auth_header
615 assert_response :too_many_requests, "node update did not hit rate limit"
617 # try deleting the node, which should be rate limited
618 xml = "<osm><node id='#{nodeid}' version='2' lat='1' lon='1' changeset='#{changeset.id}'/></osm>"
619 delete api_node_path(nodeid), :params => xml, :headers => auth_header
620 assert_response :too_many_requests, "node delete did not hit rate limit"
622 # try creating a node, which should be rate limited
623 xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'/></osm>"
624 put node_create_path, :params => xml, :headers => auth_header
625 assert_response :too_many_requests, "node create did not hit rate limit"
631 # update the changeset_id of a node element
632 def update_changeset(xml, changeset_id)
633 xml_attr_rewrite(xml, "changeset", changeset_id)
637 # update an attribute in the node element
638 def xml_attr_rewrite(xml, name, value)
639 xml.find("//osm/node").first[name] = value.to_s