mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
push: die with error if providertokens param is empty
Bug: T267263 Change-Id: Icf98189726602dd8e43e1f9daf19e3f73efb91b0
This commit is contained in:
parent
2f020163ee
commit
86d45a66ca
|
@ -54,6 +54,9 @@ class ApiEchoPushSubscriptionsDelete extends ApiBase {
|
|||
$tokens = $this->getParameter( 'providertoken' );
|
||||
$userId = null;
|
||||
|
||||
if ( !$tokens ) {
|
||||
$this->dieWithError( [ 'apierror-paramempty', 'providertoken' ], 'paramempty_providertoken' );
|
||||
}
|
||||
// Restrict deletion to the user's own token(s) if not a push subscription manager
|
||||
try {
|
||||
$this->checkUserRightsAny( 'manage-all-push-subscriptions' );
|
||||
|
|
|
@ -88,6 +88,16 @@ class ApiEchoPushSubscriptionsDeleteTest extends ApiTestCase {
|
|||
$this->assertEquals( 'Success', $result[0]['delete']['result'] );
|
||||
}
|
||||
|
||||
public function testApiDeleteSubscriptionProviderTokenEmpty(): void {
|
||||
$params = [
|
||||
'action' => 'echopushsubscriptions',
|
||||
'command' => 'delete',
|
||||
'providertoken' => ''
|
||||
];
|
||||
$this->expectException( ApiUsageException::class );
|
||||
$result = $this->doApiRequestWithToken( $params, null, $this->user );
|
||||
}
|
||||
|
||||
private function createTestData(): void {
|
||||
$subscriptionManager = EchoServices::getInstance()->getPushSubscriptionManager();
|
||||
$userId = Utils::getPushUserId( $this->user );
|
||||
|
|
Loading…
Reference in a new issue