Skip to content
Snippets Groups Projects
Commit e6a44136 authored by Sebastien's avatar Sebastien
Browse files

Merge branch...

Merge branch 'tuleap-106-registration-fail-if-email-is-not-a-valid-email-the-email-doesn-t-fulfill-the-rfc-2282' into 'main'

Fix registration redirects to error page when invalid email submitted

See merge request !24
parents b1ae0bba 9c793e6e
No related branches found
No related tags found
1 merge request!24Fix registration redirects to error page when invalid email submitted
...@@ -8,6 +8,7 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; ...@@ -8,6 +8,7 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\LegacyPasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\LegacyPasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
/** /**
* @ORM\Entity(repositoryClass=UserRepository::class) * @ORM\Entity(repositoryClass=UserRepository::class)
...@@ -25,6 +26,7 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface ...@@ -25,6 +26,7 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
/** /**
* @ORM\Column(type="string", length=255) * @ORM\Column(type="string", length=255)
* @Assert\Email(message = "The email {{ value }} is not a valid email.")
*/ */
private $email; private $email;
......
...@@ -18,7 +18,6 @@ class RegistrationControllerTest extends WebTestCase ...@@ -18,7 +18,6 @@ class RegistrationControllerTest extends WebTestCase
$this->registerUser($userEmail, $client); $this->registerUser($userEmail, $client);
$this->assertUserIsRedirectedToTheEmailNotificationPage($client); $this->assertUserIsRedirectedToTheEmailNotificationPage($client);
} }
...@@ -101,6 +100,17 @@ class RegistrationControllerTest extends WebTestCase ...@@ -101,6 +100,17 @@ class RegistrationControllerTest extends WebTestCase
$this->assertResponseRedirects('/my_capsules', 302); $this->assertResponseRedirects('/my_capsules', 302);
} }
public function testSubmittingTheRegisterFormWithAnInvalidEmailAddressShouldDisplayAFeedbackError(): void
{
$userEmail = 'invalidEmailAddress';
$client = static::createClient();
$crawler = $this->registerUser($userEmail, $client);
$html = $crawler->outerHtml();
$this->assertStringContainsString("is not a valid email", $html);
}
/** /**
* @param string $userEmail The registered user email * @param string $userEmail The registered user email
* @return RawMessage The email message sent to the user * @return RawMessage The email message sent to the user
...@@ -136,7 +146,7 @@ class RegistrationControllerTest extends WebTestCase ...@@ -136,7 +146,7 @@ class RegistrationControllerTest extends WebTestCase
$this->assertResponseIsSuccessful('/register_mail_sent'); $this->assertResponseIsSuccessful('/register_mail_sent');
} }
private function registerUser(string $userEmail, KernelBrowser &$client): void private function registerUser(string $userEmail, KernelBrowser &$client): ?Crawler
{ {
$crawler = $client->request('GET', '/register'); $crawler = $client->request('GET', '/register');
...@@ -147,7 +157,6 @@ class RegistrationControllerTest extends WebTestCase ...@@ -147,7 +157,6 @@ class RegistrationControllerTest extends WebTestCase
$submit = $crawler->selectButton('Register'); $submit = $crawler->selectButton('Register');
$form = $submit->form(); $form = $submit->form();
$form['registration_form[firstName]'] = 'new User FirstName'; $form['registration_form[firstName]'] = 'new User FirstName';
$form['registration_form[lastName]'] = 'new User LastName'; $form['registration_form[lastName]'] = 'new User LastName';
$form['registration_form[email]'] = $userEmail; $form['registration_form[email]'] = $userEmail;
...@@ -155,7 +164,7 @@ class RegistrationControllerTest extends WebTestCase ...@@ -155,7 +164,7 @@ class RegistrationControllerTest extends WebTestCase
$form['registration_form[plainPassword][second]'] = 'password'; $form['registration_form[plainPassword][second]'] = 'password';
$form['registration_form[agreeTerms]'] = 1; $form['registration_form[agreeTerms]'] = 1;
$client->submit($form); return $client->submit($form);
} }
private function clickOnEmailMessageLink(RawMessage $emailMessage, KernelBrowser $client): void private function clickOnEmailMessageLink(RawMessage $emailMessage, KernelBrowser $client): void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment