From c828b0a6b867f756bfd08f624fd62945057d5f0d Mon Sep 17 00:00:00 2001 From: Davide Iadeluca Date: Mon, 18 Nov 2024 11:55:07 +0100 Subject: [PATCH] test: write test for email with too long local part --- .../integration/api/users/CreateTest.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/framework/core/tests/integration/api/users/CreateTest.php b/framework/core/tests/integration/api/users/CreateTest.php index 48d1340ad5..98f988ce01 100644 --- a/framework/core/tests/integration/api/users/CreateTest.php +++ b/framework/core/tests/integration/api/users/CreateTest.php @@ -173,6 +173,35 @@ public function admin_can_create_user_with_longest_possible_local_part_email() $this->assertEquals($email, $user->email); } + /** + * @test + */ + public function admin_cannot_create_user_with_invalid_local_part_email() + { + $email = str_repeat('a', 65) . '@machine.local'; + + $response = $this->send( + $this->request( + 'POST', + '/api/users', + [ + 'authenticatedAs' => 1, + 'json' => [ + 'data' => [ + 'attributes' => [ + 'username' => 'test', + 'password' => 'too-obscure', + 'email' => $email, + ], + ] + ], + ] + ) + ); + + $this->assertEquals(422, $response->getStatusCode()); + } + /** * @test */