push: die with error if providertokens param is empty

Bug: T267263
Change-Id: Icf98189726602dd8e43e1f9daf19e3f73efb91b0
This commit is contained in:
mbsantos 2020-11-09 17:17:02 +01:00 committed by jgiannelos
parent 2f020163ee
commit 86d45a66ca
2 changed files with 13 additions and 0 deletions

View file

@ -54,6 +54,9 @@ class ApiEchoPushSubscriptionsDelete extends ApiBase {
$tokens = $this->getParameter( 'providertoken' ); $tokens = $this->getParameter( 'providertoken' );
$userId = null; $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 // Restrict deletion to the user's own token(s) if not a push subscription manager
try { try {
$this->checkUserRightsAny( 'manage-all-push-subscriptions' ); $this->checkUserRightsAny( 'manage-all-push-subscriptions' );

View file

@ -88,6 +88,16 @@ class ApiEchoPushSubscriptionsDeleteTest extends ApiTestCase {
$this->assertEquals( 'Success', $result[0]['delete']['result'] ); $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 { private function createTestData(): void {
$subscriptionManager = EchoServices::getInstance()->getPushSubscriptionManager(); $subscriptionManager = EchoServices::getInstance()->getPushSubscriptionManager();
$userId = Utils::getPushUserId( $this->user ); $userId = Utils::getPushUserId( $this->user );