4 class NodesControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/api/0.6/nodes", :method => :get },
10 { :controller => "api/nodes", :action => "index" }
13 { :path => "/api/0.6/nodes.json", :method => :get },
14 { :controller => "api/nodes", :action => "index", :format => "json" }
17 { :path => "/api/0.6/node/create", :method => :put },
18 { :controller => "api/nodes", :action => "create" }
21 { :path => "/api/0.6/node/1", :method => :get },
22 { :controller => "api/nodes", :action => "show", :id => "1" }
25 { :path => "/api/0.6/node/1.json", :method => :get },
26 { :controller => "api/nodes", :action => "show", :id => "1", :format => "json" }
29 { :path => "/api/0.6/node/1", :method => :put },
30 { :controller => "api/nodes", :action => "update", :id => "1" }
33 { :path => "/api/0.6/node/1", :method => :delete },
34 { :controller => "api/nodes", :action => "delete", :id => "1" }
39 # test fetching multiple nodes
42 node2 = create(:node, :deleted)
44 node4 = create(:node, :with_history, :version => 2)
45 node5 = create(:node, :deleted, :with_history, :version => 2)
47 # check error when no parameter provided
49 assert_response :bad_request
51 # check error when no parameter value provided
52 get api_nodes_path(:nodes => "")
53 assert_response :bad_request
56 get api_nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id}")
57 assert_response :success
58 assert_select "osm" do
59 assert_select "node", :count => 5
60 assert_select "node[id='#{node1.id}'][visible='true']", :count => 1
61 assert_select "node[id='#{node2.id}'][visible='false']", :count => 1
62 assert_select "node[id='#{node3.id}'][visible='true']", :count => 1
63 assert_select "node[id='#{node4.id}'][visible='true']", :count => 1
64 assert_select "node[id='#{node5.id}'][visible='false']", :count => 1
67 # test a working call with json format
68 get api_nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id}", :format => "json")
70 js = ActiveSupport::JSON.decode(@response.body)
72 assert_equal 5, js["elements"].count
73 assert_equal 5, (js["elements"].count { |a| a["type"] == "node" })
74 assert_equal 1, (js["elements"].count { |a| a["id"] == node1.id && a["visible"].nil? })
75 assert_equal 1, (js["elements"].count { |a| a["id"] == node2.id && a["visible"] == false })
76 assert_equal 1, (js["elements"].count { |a| a["id"] == node3.id && a["visible"].nil? })
77 assert_equal 1, (js["elements"].count { |a| a["id"] == node4.id && a["visible"].nil? })
78 assert_equal 1, (js["elements"].count { |a| a["id"] == node5.id && a["visible"] == false })
80 # check error when a non-existent node is included
81 get api_nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id},0")
82 assert_response :not_found
86 private_user = create(:user, :data_public => false)
87 private_changeset = create(:changeset, :user => private_user)
89 changeset = create(:changeset, :user => user)
91 # create a node with random lat/lon
92 lat = rand(-50..50) + rand
93 lon = rand(-50..50) + rand
95 ## First try with no auth
96 # create a minimal xml file
97 xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
98 assert_difference("OldNode.count", 0) do
99 put node_create_path, :params => xml
101 # hope for unauthorized
102 assert_response :unauthorized, "node upload did not return unauthorized status"
104 ## Now try with the user which doesn't have their data public
105 auth_header = bearer_authorization_header private_user
107 # create a minimal xml file
108 xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{private_changeset.id}'/></osm>"
109 assert_difference("Node.count", 0) do
110 put node_create_path, :params => xml, :headers => auth_header
113 assert_require_public_data "node create did not return forbidden status"
115 ## Now try with the user that has the public data
116 auth_header = bearer_authorization_header user
118 # create a minimal xml file
119 xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
120 put node_create_path, :params => xml, :headers => auth_header
122 assert_response :success, "node upload did not return success status"
124 # read id of created node and search for it
125 nodeid = @response.body
126 checknode = Node.find(nodeid)
127 assert_not_nil checknode, "uploaded node not found in data base after upload"
129 assert_in_delta lat * 10000000, checknode.latitude, 1, "saved node does not match requested latitude"
130 assert_in_delta lon * 10000000, checknode.longitude, 1, "saved node does not match requested longitude"
131 assert_equal changeset.id, checknode.changeset_id, "saved node does not belong to changeset that it was created in"
132 assert checknode.visible, "saved node is not visible"
135 def test_create_invalid_xml
136 ## Only test public user here, as test_create should cover what's the forbidden
137 ## that would occur here
140 changeset = create(:changeset, :user => user)
142 auth_header = bearer_authorization_header user
146 # test that the upload is rejected when xml is valid, but osm doc isn't
148 put node_create_path, :params => xml, :headers => auth_header
149 assert_response :bad_request, "node upload did not return bad_request status"
150 assert_equal "Cannot parse valid node from xml string <create/>. XML doesn't contain an osm/node element.", @response.body
152 # test that the upload is rejected when no lat is supplied
153 # create a minimal xml file
154 xml = "<osm><node lon='#{lon}' changeset='#{changeset.id}'/></osm>"
155 put node_create_path, :params => xml, :headers => auth_header
157 assert_response :bad_request, "node upload did not return bad_request status"
158 assert_equal "Cannot parse valid node from xml string <node lon=\"3.23\" changeset=\"#{changeset.id}\"/>. lat missing", @response.body
160 # test that the upload is rejected when no lon is supplied
161 # create a minimal xml file
162 xml = "<osm><node lat='#{lat}' changeset='#{changeset.id}'/></osm>"
163 put node_create_path, :params => xml, :headers => auth_header
165 assert_response :bad_request, "node upload did not return bad_request status"
166 assert_equal "Cannot parse valid node from xml string <node lat=\"3.434\" changeset=\"#{changeset.id}\"/>. lon missing", @response.body
168 # test that the upload is rejected when lat is non-numeric
169 # create a minimal xml file
170 xml = "<osm><node lat='abc' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
171 put node_create_path, :params => xml, :headers => auth_header
173 assert_response :bad_request, "node upload did not return bad_request status"
174 assert_equal "Cannot parse valid node from xml string <node lat=\"abc\" lon=\"#{lon}\" changeset=\"#{changeset.id}\"/>. lat not a number", @response.body
176 # test that the upload is rejected when lon is non-numeric
177 # create a minimal xml file
178 xml = "<osm><node lat='#{lat}' lon='abc' changeset='#{changeset.id}'/></osm>"
179 put node_create_path, :params => xml, :headers => auth_header
181 assert_response :bad_request, "node upload did not return bad_request status"
182 assert_equal "Cannot parse valid node from xml string <node lat=\"#{lat}\" lon=\"abc\" changeset=\"#{changeset.id}\"/>. lon not a number", @response.body
184 # test that the upload is rejected when we have a tag which is too long
185 xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'><tag k='foo' v='#{'x' * 256}'/></node></osm>"
186 put node_create_path, :params => xml, :headers => auth_header
187 assert_response :bad_request, "node upload did not return bad_request status"
188 assert_match(/ v: is too long \(maximum is 255 characters\) /, @response.body)
192 # check that a visible node is returned properly
193 get api_node_path(create(:node))
194 assert_response :success
196 # check that an deleted node is not returned
197 get api_node_path(create(:node, :deleted))
198 assert_response :gone
200 # check chat a non-existent node is not returned
202 assert_response :not_found
205 # Ensure the lat/lon is formatted as a decimal e.g. not 4.0e-05
206 def test_lat_lon_xml_format
207 node = create(:node, :latitude => (0.00004 * OldNode::SCALE).to_i, :longitude => (0.00008 * OldNode::SCALE).to_i)
209 get api_node_path(node)
210 assert_match(/lat="0.0000400"/, response.body)
211 assert_match(/lon="0.0000800"/, response.body)
214 # this tests deletion restrictions - basic deletion is tested in the unit
217 private_user = create(:user, :data_public => false)
218 private_user_changeset = create(:changeset, :user => private_user)
219 private_user_closed_changeset = create(:changeset, :closed, :user => private_user)
220 private_node = create(:node, :changeset => private_user_changeset)
221 private_deleted_node = create(:node, :deleted, :changeset => private_user_changeset)
223 ## first try to delete node without auth
224 delete api_node_path(private_node)
225 assert_response :unauthorized
227 ## now set auth for the non-data public user
228 auth_header = bearer_authorization_header private_user
230 # try to delete with an invalid (closed) changeset
231 xml = update_changeset(xml_for_node(private_node), private_user_closed_changeset.id)
232 delete api_node_path(private_node), :params => xml.to_s, :headers => auth_header
233 assert_require_public_data("non-public user shouldn't be able to delete node")
235 # try to delete with an invalid (non-existent) changeset
236 xml = update_changeset(xml_for_node(private_node), 0)
237 delete api_node_path(private_node), :params => xml.to_s, :headers => auth_header
238 assert_require_public_data("shouldn't be able to delete node, when user's data is private")
240 # valid delete now takes a payload
241 xml = xml_for_node(private_node)
242 delete api_node_path(private_node), :params => xml.to_s, :headers => auth_header
243 assert_require_public_data("shouldn't be able to delete node when user's data isn't public'")
245 # this won't work since the node is already deleted
246 xml = xml_for_node(private_deleted_node)
247 delete api_node_path(private_deleted_node), :params => xml.to_s, :headers => auth_header
248 assert_require_public_data
250 # this won't work since the node never existed
251 delete api_node_path(0), :headers => auth_header
252 assert_require_public_data
254 ## these test whether nodes which are in-use can be deleted:
256 private_used_node = create(:node, :changeset => private_user_changeset)
257 create(:way_node, :node => private_used_node)
259 xml = xml_for_node(private_used_node)
260 delete api_node_path(private_used_node), :params => xml.to_s, :headers => auth_header
261 assert_require_public_data "shouldn't be able to delete a node used in a way (#{@response.body})"
264 private_used_node2 = create(:node, :changeset => private_user_changeset)
265 create(:relation_member, :member => private_used_node2)
267 xml = xml_for_node(private_used_node2)
268 delete api_node_path(private_used_node2), :params => xml.to_s, :headers => auth_header
269 assert_require_public_data "shouldn't be able to delete a node used in a relation (#{@response.body})"
271 ## now setup for the public data user
272 user = create(:user, :data_public => true)
273 changeset = create(:changeset, :user => user)
274 closed_changeset = create(:changeset, :closed, :user => user)
275 node = create(:node, :changeset => changeset)
276 auth_header = bearer_authorization_header user
278 # try to delete with an invalid (closed) changeset
279 xml = update_changeset(xml_for_node(node), closed_changeset.id)
280 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
281 assert_response :conflict
283 # try to delete with an invalid (non-existent) changeset
284 xml = update_changeset(xml_for_node(node), 0)
285 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
286 assert_response :conflict
288 # try to delete a node with a different ID
289 other_node = create(:node)
290 xml = xml_for_node(other_node)
291 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
292 assert_response :bad_request,
293 "should not be able to delete a node with a different ID from the XML"
295 # try to delete a node rubbish in the payloads
297 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
298 assert_response :bad_request,
299 "should not be able to delete a node without a valid XML payload"
301 # valid delete now takes a payload
302 xml = xml_for_node(node)
303 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
304 assert_response :success
306 # valid delete should return the new version number, which should
307 # be greater than the old version number
308 assert_operator @response.body.to_i, :>, node.version, "delete request should return a new version number for node"
310 # deleting the same node twice doesn't work
311 xml = xml_for_node(node)
312 delete api_node_path(node), :params => xml.to_s, :headers => auth_header
313 assert_response :gone
315 # this won't work since the node never existed
316 delete api_node_path(0), :headers => auth_header
317 assert_response :not_found
319 ## these test whether nodes which are in-use can be deleted:
321 used_node = create(:node, :changeset => create(:changeset, :user => user))
322 way_node = create(:way_node, :node => used_node)
323 way_node2 = create(:way_node, :node => used_node)
325 xml = xml_for_node(used_node)
326 delete api_node_path(used_node), :params => xml.to_s, :headers => auth_header
327 assert_response :precondition_failed,
328 "shouldn't be able to delete a node used in a way (#{@response.body})"
329 assert_equal "Precondition failed: Node #{used_node.id} is still used by ways #{way_node.way.id},#{way_node2.way.id}.", @response.body
332 used_node2 = create(:node, :changeset => create(:changeset, :user => user))
333 relation_member = create(:relation_member, :member => used_node2)
334 relation_member2 = create(:relation_member, :member => used_node2)
336 xml = xml_for_node(used_node2)
337 delete api_node_path(used_node2), :params => xml.to_s, :headers => auth_header
338 assert_response :precondition_failed,
339 "shouldn't be able to delete a node used in a relation (#{@response.body})"
340 assert_equal "Precondition failed: Node #{used_node2.id} is still used by relations #{relation_member.relation.id},#{relation_member2.relation.id}.", @response.body
344 # tests whether the API works and prevents incorrect use while trying
347 invalid_attr_values = [["lat", 91.0], ["lat", -91.0], ["lon", 181.0], ["lon", -181.0]]
349 ## First test with no user credentials
350 # try and update a node without authorisation
351 # first try to delete node without auth
352 private_user = create(:user, :data_public => false)
353 private_node = create(:node, :changeset => create(:changeset, :user => private_user))
355 node = create(:node, :changeset => create(:changeset, :user => user))
357 xml = xml_for_node(node)
358 put api_node_path(node), :params => xml.to_s
359 assert_response :unauthorized
361 ## Second test with the private user
364 auth_header = bearer_authorization_header private_user
366 ## trying to break changesets
368 # try and update in someone else's changeset
369 xml = update_changeset(xml_for_node(private_node),
370 create(:changeset).id)
371 put api_node_path(private_node), :params => xml.to_s, :headers => auth_header
372 assert_require_public_data "update with other user's changeset should be forbidden when data isn't public"
374 # try and update in a closed changeset
375 xml = update_changeset(xml_for_node(private_node),
376 create(:changeset, :closed, :user => private_user).id)
377 put api_node_path(private_node), :params => xml.to_s, :headers => auth_header
378 assert_require_public_data "update with closed changeset should be forbidden, when data isn't public"
380 # try and update in a non-existant changeset
381 xml = update_changeset(xml_for_node(private_node), 0)
382 put api_node_path(private_node), :params => xml.to_s, :headers => auth_header
383 assert_require_public_data "update with changeset=0 should be forbidden, when data isn't public"
385 ## try and submit invalid updates
386 invalid_attr_values.each do |name, value|
387 xml = xml_attr_rewrite(xml_for_node(private_node), name, value)
388 put api_node_path(private_node), :params => xml.to_s, :headers => auth_header
389 assert_require_public_data "node at #{name}=#{value} should be forbidden, when data isn't public"
392 ## finally, produce a good request which still won't work
393 xml = xml_for_node(private_node)
394 put api_node_path(private_node), :params => xml.to_s, :headers => auth_header
395 assert_require_public_data "should have failed with a forbidden when data isn't public"
397 ## Finally test with the public user
399 # try and update a node without authorisation
400 # first try to update node without auth
401 xml = xml_for_node(node)
402 put api_node_path(node), :params => xml.to_s, :headers => auth_header
403 assert_response :forbidden
406 auth_header = bearer_authorization_header user
408 ## trying to break changesets
410 # try and update in someone else's changeset
411 xml = update_changeset(xml_for_node(node),
412 create(:changeset).id)
413 put api_node_path(node), :params => xml.to_s, :headers => auth_header
414 assert_response :conflict, "update with other user's changeset should be rejected"
416 # try and update in a closed changeset
417 xml = update_changeset(xml_for_node(node),
418 create(:changeset, :closed, :user => user).id)
419 put api_node_path(node), :params => xml.to_s, :headers => auth_header
420 assert_response :conflict, "update with closed changeset should be rejected"
422 # try and update in a non-existant changeset
423 xml = update_changeset(xml_for_node(node), 0)
424 put api_node_path(node), :params => xml.to_s, :headers => auth_header
425 assert_response :conflict, "update with changeset=0 should be rejected"
427 ## try and submit invalid updates
428 invalid_attr_values.each do |name, value|
429 xml = xml_attr_rewrite(xml_for_node(node), name, value)
430 put api_node_path(node), :params => xml.to_s, :headers => auth_header
431 assert_response :bad_request, "node at #{name}=#{value} should be rejected"
434 ## next, attack the versioning
435 current_node_version = node.version
437 # try and submit a version behind
438 xml = xml_attr_rewrite(xml_for_node(node),
439 "version", current_node_version - 1)
440 put api_node_path(node), :params => xml.to_s, :headers => auth_header
441 assert_response :conflict, "should have failed on old version number"
443 # try and submit a version ahead
444 xml = xml_attr_rewrite(xml_for_node(node),
445 "version", current_node_version + 1)
446 put api_node_path(node), :params => xml.to_s, :headers => auth_header
447 assert_response :conflict, "should have failed on skipped version number"
449 # try and submit total crap in the version field
450 xml = xml_attr_rewrite(xml_for_node(node),
451 "version", "p1r4t3s!")
452 put api_node_path(node), :params => xml.to_s, :headers => auth_header
453 assert_response :conflict,
454 "should not be able to put 'p1r4at3s!' in the version field"
456 ## try an update with the wrong ID
457 xml = xml_for_node(create(:node))
458 put api_node_path(node), :params => xml.to_s, :headers => auth_header
459 assert_response :bad_request,
460 "should not be able to update a node with a different ID from the XML"
462 ## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.
464 put api_node_path(node), :params => xml.to_s, :headers => auth_header
465 assert_response :bad_request,
466 "should not be able to update a node with non-OSM XML doc."
468 ## finally, produce a good request which should work
469 xml = xml_for_node(node)
470 put api_node_path(node), :params => xml.to_s, :headers => auth_header
471 assert_response :success, "a valid update request failed"
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 = bearer_authorization_header existing_tag.node.changeset.user
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 = bearer_authorization_header private_user
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 = bearer_authorization_header user
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 = bearer_authorization_header user
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 = bearer_authorization_header user
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