From 31f8116c91f31d9e1e53a2311c1f7da8f2ac1f4e Mon Sep 17 00:00:00 2001 From: benatespina Date: Fri, 23 Jun 2017 16:50:27 +0200 Subject: [PATCH] Updated token references in the HTTP controllers --- CHANGELOG.md | 4 ++++ .../Controller/Api/ChangePasswordControllerSpec.php | 6 +++--- .../Controller/Api/EnableControllerSpec.php | 4 ++-- .../Controller/Api/SignUpControllerSpec.php | 11 ++++------- .../Controller/ChangePasswordControllerSpec.php | 8 ++++---- .../UserBundle/Controller/EnableControllerSpec.php | 4 ++-- .../UserBundle/Controller/SignUpControllerSpec.php | 8 ++++---- .../Controller/Api/ChangePasswordController.php | 2 +- .../UserBundle/Controller/Api/EnableController.php | 2 +- .../UserBundle/Controller/Api/SignUpController.php | 2 +- .../Controller/ChangePasswordController.php | 2 +- .../UserBundle/Controller/EnableController.php | 2 +- .../UserBundle/Controller/SignUpController.php | 2 +- 13 files changed, 29 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 225f484..90ab432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ This changelog references the relevant changes done between versions. To get the diff for a specific change, go to https://github.com/BenGorUser/UserBundle/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/BenGorUser/UserBundle/compare/v0.7.0...v0.8.0 +## v0.8.4 +* Updated token references in the HTTP controllers. Be careful, this changes introduce BC breaks in order +that the `SymfonyRoutingBundle`'s version is less than v1.1.0, so please check it out. + ## v0.8.3 * Removed country from translation files. diff --git a/spec/BenGorUser/UserBundle/Controller/Api/ChangePasswordControllerSpec.php b/spec/BenGorUser/UserBundle/Controller/Api/ChangePasswordControllerSpec.php index d223b42..455640d 100644 --- a/spec/BenGorUser/UserBundle/Controller/Api/ChangePasswordControllerSpec.php +++ b/spec/BenGorUser/UserBundle/Controller/Api/ChangePasswordControllerSpec.php @@ -119,7 +119,7 @@ function it_by_request_remember_password_action( FormFactoryInterface $formFactory ) { $request->query = $bag; - $bag->get('remember-password-token')->shouldBeCalled()->willReturn('remember-password-token'); + $bag->get('token')->shouldBeCalled()->willReturn('remember-password-token'); $rememberPasswordTokenQuery = new UserOfRememberPasswordTokenQuery('remember-password-token'); $userDto = [ 'email' => 'bengor@user.com', @@ -163,7 +163,7 @@ function it_does_not_change_password_by_request_remember_password_action( FormError $error ) { $request->query = $bag; - $bag->get('remember-password-token')->shouldBeCalled()->willReturn('remember-password-token'); + $bag->get('token')->shouldBeCalled()->willReturn('remember-password-token'); $rememberPasswordTokenQuery = new UserOfRememberPasswordTokenQuery('remember-password-token'); $userDto = [ 'email' => 'bengor@user.com', @@ -203,7 +203,7 @@ function it_does_not_change_password_because_token_does_not_exist( UserOfRememberPasswordTokenHandler $handler ) { $request->query = $bag; - $bag->get('remember-password-token')->shouldBeCalled()->willReturn('remember-password-token'); + $bag->get('token')->shouldBeCalled()->willReturn('remember-password-token'); $rememberPasswordTokenQuery = new UserOfRememberPasswordTokenQuery('remember-password-token'); $container->get('bengor_user.user.by_remember_password_token_query')->shouldBeCalled()->willReturn($handler); $handler->__invoke($rememberPasswordTokenQuery)->shouldBeCalled()->willThrow(UserDoesNotExistException::class); diff --git a/spec/BenGorUser/UserBundle/Controller/Api/EnableControllerSpec.php b/spec/BenGorUser/UserBundle/Controller/Api/EnableControllerSpec.php index 234bef1..60eb229 100644 --- a/spec/BenGorUser/UserBundle/Controller/Api/EnableControllerSpec.php +++ b/spec/BenGorUser/UserBundle/Controller/Api/EnableControllerSpec.php @@ -48,7 +48,7 @@ function it_extends_controller() function it_does_not_enable_because_confirmation_token_is_not_provided(Request $request, ParameterBagInterface $bag) { $request->query = $bag; - $bag->get('confirmation-token')->shouldBeCalled()->willReturn(null); + $bag->get('token')->shouldBeCalled()->willReturn(null); $this->enableAction($request, 'user')->shouldReturnAnInstanceOf(JsonResponse::class); } @@ -60,7 +60,7 @@ function it_enable_action( UserCommandBus $commandBus ) { $request->query = $bag; - $bag->get('confirmation-token')->shouldBeCalled()->willReturn('confirmation-token'); + $bag->get('token')->shouldBeCalled()->willReturn('confirmation-token'); $container->get('bengor_user.user.command_bus')->shouldBeCalled()->willReturn($commandBus); $commandBus->handle(Argument::type(EnableUserCommand::class))->shouldBeCalled(); diff --git a/spec/BenGorUser/UserBundle/Controller/Api/SignUpControllerSpec.php b/spec/BenGorUser/UserBundle/Controller/Api/SignUpControllerSpec.php index d86514f..55847e5 100644 --- a/spec/BenGorUser/UserBundle/Controller/Api/SignUpControllerSpec.php +++ b/spec/BenGorUser/UserBundle/Controller/Api/SignUpControllerSpec.php @@ -34,7 +34,6 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Security\Core\User\UserProviderInterface; /** * Spec file of SignUpController class. @@ -65,10 +64,8 @@ function it_default_action( Request $request, ContainerInterface $container, FormInterface $form, - FormInterface $formChild, FormFactoryInterface $formFactory, - JWTEncoderInterface $encoder, - UserProviderInterface $userProvider + JWTEncoderInterface $encoder ) { $container->getParameter('bengor_user.user_default_roles')->shouldBeCalled()->willReturn(['ROLE_USER']); @@ -138,7 +135,7 @@ function it_by_invitation_action( FormBuilderInterface $formBuilder, JWTEncoderInterface $encoder ) { - $bag->get('invitation-token')->willReturn('invitation-token'); + $bag->get('token')->willReturn('invitation-token'); $request->query = $bag; $invitationTokenQuery = new UserOfInvitationTokenQuery('invitation-token'); @@ -192,7 +189,7 @@ function it_does_not_sign_up_by_invitation_action( FormBuilderInterface $formBuilder, FormError $error ) { - $bag->get('invitation-token')->willReturn('invitation-token'); + $bag->get('token')->willReturn('invitation-token'); $request->query = $bag; $invitationTokenQuery = new UserOfInvitationTokenQuery('invitation-token'); @@ -237,7 +234,7 @@ function it_does_not_render_because_invitation_token_does_not_exist( ContainerInterface $container, UserOfInvitationTokenHandler $handler ) { - $bag->get('invitation-token')->willReturn('invitation-token'); + $bag->get('token')->willReturn('invitation-token'); $request->query = $bag; $invitationTokenQuery = new UserOfInvitationTokenQuery('invitation-token'); diff --git a/spec/BenGorUser/UserBundle/Controller/ChangePasswordControllerSpec.php b/spec/BenGorUser/UserBundle/Controller/ChangePasswordControllerSpec.php index 851b53d..be3a1a8 100644 --- a/spec/BenGorUser/UserBundle/Controller/ChangePasswordControllerSpec.php +++ b/spec/BenGorUser/UserBundle/Controller/ChangePasswordControllerSpec.php @@ -164,7 +164,7 @@ function it_renders_by_request_remember_password_action( FormFactoryInterface $formFactory ) { $request->query = $bag; - $bag->get('remember-password-token')->shouldBeCalled()->willReturn('remember-password-token'); + $bag->get('token')->shouldBeCalled()->willReturn('remember-password-token'); $rememberPasswordTokenQuery = new UserOfRememberPasswordTokenQuery('remember-password-token'); $userDto = [ 'email' => 'bengor@user.com', @@ -215,7 +215,7 @@ function it_by_request_remember_password_action( Translator $translator ) { $request->query = $bag; - $bag->get('remember-password-token')->shouldBeCalled()->willReturn('remember-password-token'); + $bag->get('token')->shouldBeCalled()->willReturn('remember-password-token'); $rememberPasswordTokenQuery = new UserOfRememberPasswordTokenQuery('remember-password-token'); $userDto = [ 'email' => 'bengor@user.com', @@ -273,7 +273,7 @@ function it_does_not_change_password_by_request_remember_password_action( UserInterface $user ) { $request->query = $bag; - $bag->get('remember-password-token')->shouldBeCalled()->willReturn('remember-password-token'); + $bag->get('token')->shouldBeCalled()->willReturn('remember-password-token'); $rememberPasswordTokenQuery = new UserOfRememberPasswordTokenQuery('remember-password-token'); $userDto = [ 'email' => 'bengor@user.com', @@ -318,7 +318,7 @@ function it_does_not_change_password_because_token_does_not_exist( UserOfRememberPasswordTokenHandler $handler ) { $request->query = $bag; - $bag->get('remember-password-token')->shouldBeCalled()->willReturn('remember-password-token'); + $bag->get('token')->shouldBeCalled()->willReturn('remember-password-token'); $rememberPasswordTokenQuery = new UserOfRememberPasswordTokenQuery('remember-password-token'); $container->get('bengor_user.user.by_remember_password_token_query')->shouldBeCalled()->willReturn($handler); $handler->__invoke($rememberPasswordTokenQuery)->shouldBeCalled()->willThrow(UserDoesNotExistException::class); diff --git a/spec/BenGorUser/UserBundle/Controller/EnableControllerSpec.php b/spec/BenGorUser/UserBundle/Controller/EnableControllerSpec.php index b617933..2b39558 100644 --- a/spec/BenGorUser/UserBundle/Controller/EnableControllerSpec.php +++ b/spec/BenGorUser/UserBundle/Controller/EnableControllerSpec.php @@ -53,7 +53,7 @@ function it_extends_controller() function it_does_not_enable_because_confirmation_token_is_not_provided(Request $request, ParameterBagInterface $bag) { $request->query = $bag; - $bag->get('confirmation-token')->shouldBeCalled()->willReturn(null); + $bag->get('token')->shouldBeCalled()->willReturn(null); $this->shouldThrow(NotFoundHttpException::class)->duringEnableAction( $request, 'user', 'bengor_user_user_homepage' @@ -71,7 +71,7 @@ function it_enable_action( Translator $translator ) { $request->query = $bag; - $bag->get('confirmation-token')->shouldBeCalled()->willReturn('confirmation-token'); + $bag->get('token')->shouldBeCalled()->willReturn('confirmation-token'); $container->get('bengor_user.user.command_bus')->shouldBeCalled()->willReturn($commandBus); $commandBus->handle(Argument::type(EnableUserCommand::class))->shouldBeCalled(); diff --git a/spec/BenGorUser/UserBundle/Controller/SignUpControllerSpec.php b/spec/BenGorUser/UserBundle/Controller/SignUpControllerSpec.php index f7e6c3f..5b66f66 100644 --- a/spec/BenGorUser/UserBundle/Controller/SignUpControllerSpec.php +++ b/spec/BenGorUser/UserBundle/Controller/SignUpControllerSpec.php @@ -183,7 +183,7 @@ function it_renders_by_invitation_action( FormInterface $form, FormFactoryInterface $formFactory ) { - $bag->get('invitation-token')->willReturn('invitation-token'); + $bag->get('token')->willReturn('invitation-token'); $request->query = $bag; $invitationTokenQuery = new UserOfInvitationTokenQuery('invitation-token'); @@ -237,7 +237,7 @@ function it_by_invitation_action( FormFactoryInterface $formFactory, FormLoginAuthenticator $formLoginAuthenticator ) { - $bag->get('invitation-token')->willReturn('invitation-token'); + $bag->get('token')->willReturn('invitation-token'); $request->query = $bag; $invitationTokenQuery = new UserOfInvitationTokenQuery('invitation-token'); @@ -298,7 +298,7 @@ function it_does_not_sign_up_by_invitation_action( UserOfInvitationTokenHandler $handler, UserSymfonyDataTransformer $dataTransformer ) { - $bag->get('invitation-token')->willReturn('invitation-token'); + $bag->get('token')->willReturn('invitation-token'); $request->query = $bag; $invitationTokenQuery = new UserOfInvitationTokenQuery('invitation-token'); @@ -342,7 +342,7 @@ function it_does_not_render_because_invitation_token_does_not_exist( ContainerInterface $container, UserOfInvitationTokenHandler $handler ) { - $bag->get('invitation-token')->willReturn('invitation-token'); + $bag->get('token')->willReturn('invitation-token'); $request->query = $bag; $invitationTokenQuery = new UserOfInvitationTokenQuery('invitation-token'); diff --git a/src/BenGorUser/UserBundle/Controller/Api/ChangePasswordController.php b/src/BenGorUser/UserBundle/Controller/Api/ChangePasswordController.php index 6ebff0c..418fd04 100644 --- a/src/BenGorUser/UserBundle/Controller/Api/ChangePasswordController.php +++ b/src/BenGorUser/UserBundle/Controller/Api/ChangePasswordController.php @@ -59,7 +59,7 @@ public function defaultAction(Request $request, $userClass) */ public function byRequestRememberPasswordAction(Request $request, $userClass) { - $rememberPasswordToken = $request->query->get('remember-password-token'); + $rememberPasswordToken = $request->query->get('token'); try { // we need to know if the remember password token given exists in // database, in case that it isn't, it throws 404. diff --git a/src/BenGorUser/UserBundle/Controller/Api/EnableController.php b/src/BenGorUser/UserBundle/Controller/Api/EnableController.php index 0a86b62..d648b09 100644 --- a/src/BenGorUser/UserBundle/Controller/Api/EnableController.php +++ b/src/BenGorUser/UserBundle/Controller/Api/EnableController.php @@ -35,7 +35,7 @@ class EnableController extends Controller */ public function enableAction(Request $request, $userClass) { - $confirmationToken = $request->query->get('confirmation-token'); + $confirmationToken = $request->query->get('token'); if (null === $confirmationToken) { return new JsonResponse(null, 404); } diff --git a/src/BenGorUser/UserBundle/Controller/Api/SignUpController.php b/src/BenGorUser/UserBundle/Controller/Api/SignUpController.php index ec704cb..62f6df9 100644 --- a/src/BenGorUser/UserBundle/Controller/Api/SignUpController.php +++ b/src/BenGorUser/UserBundle/Controller/Api/SignUpController.php @@ -92,7 +92,7 @@ public function defaultAction(Request $request, $userClass, $formType) */ public function byInvitationAction(Request $request, $userClass) { - $invitationToken = $request->query->get('invitation-token'); + $invitationToken = $request->query->get('token'); try { // we need to know if the invitation token given exists in // database, in case that it isn't, it throws 404. diff --git a/src/BenGorUser/UserBundle/Controller/ChangePasswordController.php b/src/BenGorUser/UserBundle/Controller/ChangePasswordController.php index 0af8ebb..369745e 100644 --- a/src/BenGorUser/UserBundle/Controller/ChangePasswordController.php +++ b/src/BenGorUser/UserBundle/Controller/ChangePasswordController.php @@ -74,7 +74,7 @@ public function defaultAction(Request $request, $userClass, $successRoute = null */ public function byRequestRememberPasswordAction(Request $request, $userClass, $successRoute = null) { - $rememberPasswordToken = $request->query->get('remember-password-token'); + $rememberPasswordToken = $request->query->get('token'); try { // we need to know if the remember password token given exists in // database, in case that it isn't, it throws 404. diff --git a/src/BenGorUser/UserBundle/Controller/EnableController.php b/src/BenGorUser/UserBundle/Controller/EnableController.php index 9986ed5..8dc394f 100644 --- a/src/BenGorUser/UserBundle/Controller/EnableController.php +++ b/src/BenGorUser/UserBundle/Controller/EnableController.php @@ -35,7 +35,7 @@ class EnableController extends Controller */ public function enableAction(Request $request, $userClass, $successRoute) { - $confirmationToken = $request->query->get('confirmation-token'); + $confirmationToken = $request->query->get('token'); if (null === $confirmationToken) { throw $this->createNotFoundException(); } diff --git a/src/BenGorUser/UserBundle/Controller/SignUpController.php b/src/BenGorUser/UserBundle/Controller/SignUpController.php index 5896522..4196289 100644 --- a/src/BenGorUser/UserBundle/Controller/SignUpController.php +++ b/src/BenGorUser/UserBundle/Controller/SignUpController.php @@ -85,7 +85,7 @@ public function defaultAction(Request $request, $userClass, $firewall, $formType */ public function byInvitationAction(Request $request, $userClass, $firewall) { - $invitationToken = $request->query->get('invitation-token'); + $invitationToken = $request->query->get('token'); try { // we need to know if the invitation token given exists in // database, in case that it isn't, it throws 404.