aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api/ApiBlockTest.php
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2025-03-12 09:51:46 +1100
committerTim Starling <tstarling@wikimedia.org>2025-03-12 11:29:45 +1100
commit8bba7dd4e2918e9f5996c6f561a7ed0236e143e2 (patch)
tree6209f1196351f180708dca8110e5b39af17130e5 /tests/phpunit/includes/api/ApiBlockTest.php
parentb90d4c32a36de5ffab50562084a55e0ecd3aee04 (diff)
downloadmediawikicore-8bba7dd4e2918e9f5996c6f561a7ed0236e143e2.tar.gz
mediawikicore-8bba7dd4e2918e9f5996c6f561a7ed0236e143e2.zip
block: Fix failure to sanitize a range blocked with ApiBlock
Bug: T388097 Change-Id: I89baf1b190cf9adefba9a232f57c957a2345f8e5
Diffstat (limited to 'tests/phpunit/includes/api/ApiBlockTest.php')
-rw-r--r--tests/phpunit/includes/api/ApiBlockTest.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/phpunit/includes/api/ApiBlockTest.php b/tests/phpunit/includes/api/ApiBlockTest.php
index 7f15985a9c6f..3c4334d5fd2e 100644
--- a/tests/phpunit/includes/api/ApiBlockTest.php
+++ b/tests/phpunit/includes/api/ApiBlockTest.php
@@ -348,6 +348,22 @@ class ApiBlockTest extends ApiTestCase {
$this->doBlock();
}
+ public function testNonNormalizedRangeBlock() {
+ $params = [
+ 'action' => 'block',
+ 'user' => '128.0.0.1/16',
+ 'reason' => 'Some reason',
+ ];
+ $res = $this->doApiRequestWithToken( $params );
+ $this->assertSame( '128.0.0.0/16', $res[0]['block']['user'] );
+ $this->newSelectQueryBuilder()
+ ->select( 'bt_address' )
+ ->from( 'block_target' )
+ ->join( 'block', null, 'bl_target=bt_id' )
+ ->where( [ 'bl_id' => $res[0]['block']['id'] ] )
+ ->assertFieldValue( '128.0.0.0/16' );
+ }
+
public function testBlockByIdReturns() {
// See T189073 and Ifdced735b694b85116cb0e43dadbfa8e4cdb8cab for context
$userId = $this->mUser->getId();