Dereckson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/318149

Change subject: Tests for throttle rules
......................................................................

Tests for throttle rules

Change d0b37a87 introduced a parameter typo to a rule. In the past,
we got several times issues with ip/IP (now both cases are accepted).

This test checks the parameters of the throttle rules' arrays to avoid
future occurrences of the issue.

Change-Id: I1f7a07441f78c45e1469e7de0c89e96be5995f08
---
A tests/ThrottleTest.php
1 file changed, 29 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/49/318149/1

diff --git a/tests/ThrottleTest.php b/tests/ThrottleTest.php
new file mode 100644
index 0000000..a96c896
--- /dev/null
+++ b/tests/ThrottleTest.php
@@ -0,0 +1,29 @@
+<?php
+
+require_once __DIR__ . '/../wmf-config/throttle.php';
+
+class ThrottleTest extends PHPUnit_Framework_TestCase {
+
+       public function testThrottlingExceptionsKeys () {
+               global $wmgThrottlingExceptions;
+
+               $validParameters = 
self::getThrottlingExceptionsValidParameters();
+
+               foreach ( $wmgThrottlingExceptions as $rule ) {
+                       foreach ( $rule as $key => $value ) {
+                                       $this->assertContains(
+                                               $key, $validParameters,
+                                               "Invalid parameter in a 
throttle rule detected: $key"
+                                       );
+                       }
+               }
+       }
+
+       protected static function getThrottlingExceptionsValidParameters () {
+               return [
+                       'from', 'to',
+                       'IP', 'ip', 'range',
+                       'dbname', 'value',
+               ];
+       }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/318149
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1f7a07441f78c45e1469e7de0c89e96be5995f08
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Dereckson <dereck...@espace-win.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to