Skip to content

Commit

Permalink
Updated token references in the HTTP controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
benatespina committed Jun 23, 2017
1 parent 564c960 commit 31f8116
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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']);

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/BenGorUser/UserBundle/Controller/EnableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/BenGorUser/UserBundle/Controller/SignUpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 31f8116

Please sign in to comment.