diff options
author | Thalia <thalia.e.chan@googlemail.com> | 2023-08-07 10:56:43 +0100 |
---|---|---|
committer | Thalia <thalia.e.chan@googlemail.com> | 2023-08-07 14:14:54 +0100 |
commit | 13f4d6bc83c0f7a5c630b458d356445e9ced68bd (patch) | |
tree | 80837791858ffdcb9f83f9ea8d75c1bdb281767b /tests/phpunit/includes/user/UserTest.php | |
parent | 2cdd28ada76c22bb1bb07e382f9a91584df72cc0 (diff) | |
download | mediawikicore-13f4d6bc83c0f7a5c630b458d356445e9ced68bd.tar.gz mediawikicore-13f4d6bc83c0f7a5c630b458d356445e9ced68bd.zip |
Ensure temporary users are blocked by configured IP blocks
Temporary users are blocked if their IP address is listed in
$wgDnsBlacklistUrls or $wgSoftBlockRanges.
Bug: T343704
Change-Id: Ia3383bd10c3c6c35c586550b68f4af5f4659e815
Diffstat (limited to 'tests/phpunit/includes/user/UserTest.php')
-rw-r--r-- | tests/phpunit/includes/user/UserTest.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index 9e90bcd65b0b..5f554870c38b 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -615,6 +615,17 @@ class UserTest extends MediaWikiIntegrationTestCase { $this->assertInstanceOf( SystemBlock::class, $block ); $this->assertSame( 'wgSoftBlockRanges', $block->getSystemBlockType() ); + // IP is in $wgSoftBlockRanges and user is temporary + $this->enableAutoCreateTempUser(); + $user = ( new TestUser( '*Unregistered 1' ) )->getUser(); + $request = new FauxRequest(); + $request->setIP( '10.20.30.40' ); + $this->setSessionUser( $user, $request ); + $block = $user->getBlock(); + $this->assertTrue( $user->isTemp() ); + $this->assertInstanceOf( SystemBlock::class, $block ); + $this->assertSame( 'wgSoftBlockRanges', $block->getSystemBlockType() ); + // Make sure the block is really soft $request = new FauxRequest(); $request->setIP( '10.20.30.40' ); |