-
Notifications
You must be signed in to change notification settings - Fork 4
IBX-12340: Pass the required struct option when registering from invitation #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vidarl
wants to merge
3
commits into
5.0
Choose a base branch
from
IBX-12340_registration_from_invitation_returns_500
base: 5.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
tests/integration/Controller/UserRegisterControllerTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
| * @license For full copyright and license information view LICENSE file distributed with this source code. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Ibexa\Tests\Integration\User\Controller; | ||
|
|
||
| use Ibexa\ContentForms\Form\ActionDispatcher\UserDispatcher; | ||
| use Ibexa\Contracts\User\Invitation\InvitationCreateStruct; | ||
| use Ibexa\Tests\Integration\User\IbexaKernelTestCase; | ||
| use Symfony\Bundle\FrameworkBundle\KernelBrowser; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| /** | ||
| * @covers \Ibexa\Bundle\User\Controller\UserRegisterController::registerFromInvitationAction | ||
| */ | ||
| final class UserRegisterControllerTest extends IbexaKernelTestCase | ||
| { | ||
| private const string INVITEE_EMAIL = 'invitee@ibexa.co'; | ||
|
|
||
| public function testRegisterFromInvitationRespondsWithOk(): void | ||
| { | ||
| self::setAdministratorUser(); | ||
| self::getContainer()->set(UserDispatcher::class, new UserDispatcher()); | ||
|
|
||
| // InvitationService::isValid() compares against the SiteAccess the request resolves to | ||
| // which is the default one, not what SiteAccessServiceInterface::getCurrent() returns here | ||
| $siteAccess = self::getContainer()->getParameter('ibexa.site_access.default'); | ||
| self::assertIsString($siteAccess); | ||
|
|
||
| $invitation = self::getInvitationService()->createInvitation( | ||
| new InvitationCreateStruct(self::INVITEE_EMAIL, $siteAccess) | ||
| ); | ||
|
|
||
| $kernel = self::$kernel; | ||
| self::assertNotNull($kernel); | ||
|
|
||
| $client = new KernelBrowser($kernel); | ||
| $client->request('GET', '/from-invite/register/' . $invitation->getHash()); | ||
|
|
||
| self::assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode()); | ||
| } | ||
|
|
||
| protected function tearDown(): void | ||
| { | ||
| // Database is imported once per run and there is no per-test rollback, so without this the | ||
| // invitation survives into InvitationServiceTest, which asserts absolute findInvitations() | ||
| // counts and fails | ||
| $connection = self::getDoctrineConnection(); | ||
| $connection->executeStatement( | ||
| 'DELETE FROM ibexa_user_invitation_assignment WHERE invitation_id IN ' | ||
| . '(SELECT id FROM ibexa_user_invitation WHERE email = :email)', | ||
| ['email' => self::INVITEE_EMAIL] | ||
| ); | ||
| $connection->delete('ibexa_user_invitation', ['email' => self::INVITEE_EMAIL]); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there API that can be used instead of a vanilla SQL query?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@konradoboza No, there is no removal API — see https://github.com/ibexa/user/blob/5.0/src/lib/Invitation/Persistence/DoctrineGateway.php, so rows are in fact never deleted from the invitation tables at all: accepted, expired and stale invitations all stay forever.
I could add a
deleteInvitation()toPersistence\Handler+DoctrineGatewaybut @bnowak suggested adding DAMA to this package separately, so the need for that api call would be short-lived. What do you prefer?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest I leave the code as is, and that I makes a follow-up PR with DAMA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do that.