diff options
author | jenkins-bot <jenkins-bot@gerrit.wikimedia.org> | 2025-04-07 11:38:35 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2025-04-07 11:38:35 +0000 |
commit | 88aef6c1421f3543c67c8ee923386971d6e4ece6 (patch) | |
tree | 66678dead7bcf6f75d9939e7a5924724dfb6a217 /tests/api-testing/action | |
parent | b53bd618cc8a8fc18f5b1c04b56eb6c4941d1fd1 (diff) | |
parent | 2b65587e4d92e7f27661e8821b14f74ade939cfa (diff) | |
download | mediawikicore-88aef6c1421f3543c67c8ee923386971d6e4ece6.tar.gz mediawikicore-88aef6c1421f3543c67c8ee923386971d6e4ece6.zip |
Merge "block: Fix DBS::acquireTarget() race using GET_LOCK()"
Diffstat (limited to 'tests/api-testing/action')
-rw-r--r-- | tests/api-testing/action/Block.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/api-testing/action/Block.js b/tests/api-testing/action/Block.js new file mode 100644 index 000000000000..8053137494b5 --- /dev/null +++ b/tests/api-testing/action/Block.js @@ -0,0 +1,29 @@ +'use strict'; + +const { action, assert } = require( 'api-testing' ); + +describe( 'Block', () => { + const ip = '::' + Math.floor( Math.random() * 65534 ).toString( 16 ); + it( 'should not allow multiblocks without newblock (T389028)', async () => { + const mindy = await action.mindy(); + const token = await mindy.token(); + const promises = [ + mindy.request( { action: 'block', user: ip, token: token }, 'POST' ), + mindy.request( { action: 'block', user: ip, token: token }, 'POST' ) + ]; + const res = await Promise.all( promises ); + assert.lengthOf( res, 2 ); + assert.equal( res[ 0 ].status, 200 ); + assert.equal( res[ 1 ].status, 200 ); + + const goodIndex = 'block' in res[ 0 ].body ? 0 : 1; + const goodBody = res[ goodIndex ].body; + const badBody = res[ +!goodIndex ].body; + + assert.property( goodBody, 'block' ); + assert.isOk( goodBody.block.id ); + + assert.property( badBody, 'error' ); + assert.equal( badBody.error.code, 'alreadyblocked' ); + } ); +} ); |