-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent non admin users changing admin signatures (#17)
- Loading branch information
Showing
2 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,12 @@ public function setUp(): void | |
$this->prepareDatabase([ | ||
'users' => [ | ||
$this->normalUser(), | ||
['id' => 3, 'username' => 'moderator', 'email' => '[email protected]', 'is_email_confirmed' => true] | ||
['id' => 3, 'username' => 'moderator', 'email' => '[email protected]', 'is_email_confirmed' => true], | ||
['id' => 4, 'username' => 'admin2', 'email' => '[email protected]', 'is_email_confirmed' => true], | ||
], | ||
'group_user' => [ | ||
['user_id' => 3, 'group_id' => 4] | ||
['user_id' => 3, 'group_id' => 4], | ||
['user_id' => 4, 'group_id' => 1], | ||
], | ||
'group_permission' => [ | ||
['group_id' => 4, 'permission' => 'user.editSignature'] | ||
|
@@ -92,4 +94,36 @@ public function user_with_permission_can_edit_others_signature() | |
|
||
$this->assertTrue($json['data']['attributes']['canEditSignature']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function user_with_permission_cannot_edit_admin_signature() | ||
{ | ||
$response = $this->send( | ||
$this->request('GET', '/api/users/1', ['authenticatedAs' => 3]) | ||
); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
|
||
$json = json_decode($response->getBody(), true); | ||
|
||
$this->assertFalse($json['data']['attributes']['canEditSignature']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function admin_can_edit_admin_signature() | ||
{ | ||
$response = $this->send( | ||
$this->request('GET', '/api/users/1', ['authenticatedAs' => 4]) | ||
); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
|
||
$json = json_decode($response->getBody(), true); | ||
|
||
$this->assertTrue($json['data']['attributes']['canEditSignature']); | ||
} | ||
} |