X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/bf29550db840c97cafffbe1e836750bef6c7942d..e989b1a880f79fd1835a44d16de115a778f890af:/test/functional/node_controller_test.rb diff --git a/test/functional/node_controller_test.rb b/test/functional/node_controller_test.rb index 9e5621f8b..2289953fe 100644 --- a/test/functional/node_controller_test.rb +++ b/test/functional/node_controller_test.rb @@ -6,7 +6,7 @@ class NodeControllerTest < ActionController::TestCase def test_create # cannot read password from fixture as it is stored as MD5 digest - basic_authorization(users(:normal_user).email, "test"); + basic_authorization(users(:normal_user).email, "test") # create a node with random lat/lon lat = rand(100)-50 + rand @@ -30,6 +30,32 @@ class NodeControllerTest < ActionController::TestCase assert_equal true, checknode.visible, "saved node is not visible" end + def test_create_invalid_xml + # Initial setup + basic_authorization(users(:normal_user).email, "test") + # normal user has a changeset open, so we'll use that. + changeset = changesets(:normal_user_first_change) + lat = 3.434 + lon = 3.23 + + # test that the upload is rejected when no lat is supplied + # create a minimal xml file + content("") + put :create + # hope for success + assert_response :bad_request, "node upload did not return bad_request status" + assert_equal 'Cannot parse valid node from xml string . lat missing', @response.body + + # test that the upload is rejected when no lon is supplied + # create a minimal xml file + content("") + put :create + # hope for success + assert_response :bad_request, "node upload did not return bad_request status" + assert_equal 'Cannot parse valid node from xml string . lon missing', @response.body + + end + def test_read # check that a visible node is returned properly get :read, :id => current_nodes(:visible_node).id @@ -194,7 +220,8 @@ class NodeControllerTest < ActionController::TestCase content node_xml put :update, :id => current_nodes(:visible_node).id 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/#{current_nodes(:visible_node).id} has duplicate tags with key #{current_node_tags(:t1).k}.", @response.body end # test whether string injection is possible