Skip to content

Commit

Permalink
add unauthorized api test
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Jan 31, 2024
1 parent 6e52663 commit 0a4dcf4
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/integration/api/CreatePollTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,45 @@ public function authorized_user_can_create_global_poll_on_api(int $userId)

$this->assertTrue($json['data']['attributes']['isGlobal']);
}

/**
* @dataProvider unauthorizedUserProvider
*
* @test
*/
public function unauthorized_user_cannot_create_global_poll_on_api(int $userId)
{
$response = $this->send(
$this->request(
'POST',
'/api/fof/polls',
[
'authenticatedAs' => $userId,
'json' => [
'data' => [
'attributes' => [
'question' => 'Add a global poll',
'publicPoll' => false,
'hideVotes' => false,
'allowChangeVote' => true,
'allowMultipleVotes' => false,
'maxVotes' => 0,
'endDate' => false,
'options' => [
[
'answer' => 'Yes',
],
[
'answer' => 'No',
],
],
],
],
],
]
)
);

$this->assertEquals(403, $response->getStatusCode());
}
}

0 comments on commit 0a4dcf4

Please sign in to comment.