jenkins-bot has submitted this change and it was merged.

Change subject: Test for throttle rules: detect keys typo
......................................................................


Test for throttle rules: detect keys typo

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, 33 insertions(+), 0 deletions(-)

Approvals:
  Hashar: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/ThrottleTest.php b/tests/ThrottleTest.php
new file mode 100644
index 0000000..5cb0042
--- /dev/null
+++ b/tests/ThrottleTest.php
@@ -0,0 +1,33 @@
+<?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', // temporary — we can now get rid of this case 
tolerance
+                       'ip',
+                       'range',
+                       'dbname',
+                       'value',
+               ];
+       }
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1f7a07441f78c45e1469e7de0c89e96be5995f08
Gerrit-PatchSet: 3
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Dereckson <dereck...@espace-win.org>
Gerrit-Reviewer: Dereckson <dereck...@espace-win.org>
Gerrit-Reviewer: Hashar <has...@free.fr>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to