[openstreetmap/openstreetmap-website] Add rate limiting for changeset comments (PR #4202)

Andy Allan notifications at github.com
Wed Aug 30 10:08:05 UTC 2023


@gravitystorm commented on this pull request.



> +
+      auth_header = basic_authorization_header user.email, "test"
+
+      assert_difference "ChangesetComment.count", Settings.min_changeset_comments_per_hour do
+        1.upto(Settings.min_changeset_comments_per_hour) do |count|
+          post changeset_comment_path(:id => changeset, :text => "Comment #{count}"), :headers => auth_header
+          assert_response :success
+        end
+      end
+
+      assert_no_difference "ChangesetComment.count" do
+        post changeset_comment_path(:id => changeset, :text => "One comment too many"), :headers => auth_header
+        assert_response :too_many_requests
+      end
+    end
+

The tests only scratch the edge of the algorithm! Would be good to have tests covering

* accounts with lots of existing comments
* accounts with reports
* moderator accounts

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4202#pullrequestreview-1602363052
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/4202/review/1602363052 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20230830/6f5d3ea6/attachment.htm>


More information about the rails-dev mailing list