From e87401016adee1704c8573fe9b70ee00855aecf7 Mon Sep 17 00:00:00 2001 From: David Wheatley Date: Sun, 1 Aug 2021 00:36:31 +0100 Subject: [PATCH] Update tests for deactivation --- tests/integration/api/users/UpdateTest.php | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/tests/integration/api/users/UpdateTest.php b/tests/integration/api/users/UpdateTest.php index 2681c50d3e..b2391be084 100644 --- a/tests/integration/api/users/UpdateTest.php +++ b/tests/integration/api/users/UpdateTest.php @@ -251,6 +251,26 @@ public function users_cant_activate_themselves() $this->assertEquals(403, $response->getStatusCode()); } + /** + * @test + */ + public function users_cant_deactivate_themselves() + { + $response = $this->send( + $this->request('PATCH', '/api/users/2', [ + 'authenticatedAs' => 2, + 'json' => [ + 'data' => [ + 'attributes' => [ + 'isEmailConfirmed' => false + ], + ] + ], + ]) + ); + $this->assertEquals(403, $response->getStatusCode()); + } + /** * @test * @@ -354,6 +374,26 @@ public function users_cant_activate_others_without_permission() $this->assertEquals(403, $response->getStatusCode()); } + /** + * @test + */ + public function users_cant_deactivate_others_without_permission() + { + $response = $this->send( + $this->request('PATCH', '/api/users/2', [ + 'authenticatedAs' => 2, + 'json' => [ + 'data' => [ + 'attributes' => [ + 'isEmailConfirmed' => false + ], + ] + ], + ]) + ); + $this->assertEquals(403, $response->getStatusCode()); + } + /** * @test * @@ -574,6 +614,27 @@ public function users_cant_activate_others_even_with_permissions() $this->assertEquals(403, $response->getStatusCode()); } + /** + * @test + */ + public function users_cant_deactivate_others_even_with_permissions() + { + $this->giveNormalUsersEditPerms(); + $response = $this->send( + $this->request('PATCH', '/api/users/2', [ + 'authenticatedAs' => 2, + 'json' => [ + 'data' => [ + 'attributes' => [ + 'isEmailConfirmed' => false + ], + ] + ], + ]) + ); + $this->assertEquals(403, $response->getStatusCode()); + } + /** * @test */ @@ -636,6 +697,26 @@ public function admins_can_activate_others() $this->assertEquals(200, $response->getStatusCode()); } + /** + * @test + */ + public function admins_can_deactivate_others() + { + $response = $this->send( + $this->request('PATCH', '/api/users/2', [ + 'authenticatedAs' => 1, + 'json' => [ + 'data' => [ + 'attributes' => [ + 'isEmailConfirmed' => false + ], + ] + ], + ]) + ); + $this->assertEquals(200, $response->getStatusCode()); + } + /** * @test */