Skip to content

Commit

Permalink
Merge pull request #412 from loic425/feature/do-not-store-proxy-on-sh…
Browse files Browse the repository at this point in the history
…ared-storage

Do not store proxy on shared storage
  • Loading branch information
loic425 committed Apr 23, 2022
2 parents 5361def + aab6905 commit f3ec9f6
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function iWantToCreateANewAdministrator(): void
* @When /^I am editing (my) details$/
* @When /^I want to edit (this administrator)$/
*/
public function iWantToEditThisAdministrator(AdminUserInterface|Proxy $adminUser): void
public function iWantToEditThisAdministrator(AdminUserInterface $adminUser): void
{
$this->updatePage->open(['id' => $adminUser->getId()]);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken:
user_refresh_token:
username: sylius
valid: "<(new DateTimeImmutable('+2 hours'))>"
valid: "<(new DateTimeImmutable('+4 hours'))>"
refresh_token: SampleRefreshTokenODllODY4ZTQyOThlNWIyMjA1ZDhmZjE1ZDYyMGMwOTUxOWM2NGFmNGRjNjQ2NDBhMDVlNGZjMmQ0YzgyNDM2Ng

App\Entity\User\AppUser:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public function iAmLoggedInAsAnAdministrator(): void
{
$user = $this->userFactory
->createOne(['email' => 'admin@example.com', 'password' => 'admin'])
->disableAutoRefresh();
;

$user = $this->adminUserRepository->find($user->getId());

$this->securityService->logIn($user->object());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
use App\Factory\AdminUserFactory;
use Behat\Behat\Context\Context;
use Monofony\Bridge\Behat\Service\SharedStorageInterface;
use Sylius\Component\User\Repository\UserRepositoryInterface;

final class AdminUserContext implements Context
{
public function __construct(
private SharedStorageInterface $sharedStorage,
private AdminUserFactory $adminUserFactory,
private UserRepositoryInterface $adminUserRepository,
) {
}

Expand All @@ -31,7 +33,9 @@ public function thereIsAnAdministratorIdentifiedBy(string $email, string $passwo
*/
public function thereIsAnAdministratorWithName(string $username): void
{
$adminUser = $this->adminUserFactory->createOne(['username' => $username])->object();
$adminUser = $this->adminUserFactory->createOne(['username' => $username]);

$adminUser = $this->adminUserRepository->find($adminUser->getId());

$this->sharedStorage->set('administrator', $adminUser);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public function iAmLoggedInAs(string $email): void
public function iAmLoggedInAsACustomer(): void
{
/** @var AppUserInterface $user */
$user = $this->userFactory->createOne(['email' => 'customer@example.com', 'password' => 'password', 'roles' => ['ROLE_USER']])->object();
$user = $this->userFactory->createOne(['email' => 'customer@example.com', 'password' => 'password', 'roles' => ['ROLE_USER']]);

$user = $this->appUserRepository->find($user->getId());

$this->securityService->logIn($user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Monofony\Contracts\Core\Model\User\AppUserInterface;
use Sylius\Component\User\Model\UserInterface;
use Sylius\Component\User\Repository\UserRepositoryInterface;
use Zenstruck\Foundry\Proxy;

class UserContext implements Context
{
Expand Down Expand Up @@ -55,29 +54,19 @@ public function accountWasDeleted(string $email): void
/**
* @Given /^(?:(I) have|(this user) has) already received a resetting password email$/
*/
public function iHaveReceivedResettingPasswordEmail(UserInterface|Proxy $user): void
public function iHaveReceivedResettingPasswordEmail(UserInterface $user): void
{
$this->prepareUserPasswordResetToken($user);
}

private function prepareUserPasswordResetToken(UserInterface|Proxy $user): void
private function prepareUserPasswordResetToken(UserInterface $user): void
{
$token = 'itotallyforgotmypassword';

$user->setPasswordResetToken($token);

if ($user instanceof Proxy) {
// $user->save();
}

$user->setPasswordRequestedAt(new \DateTime());

if ($user instanceof Proxy) {
$user->save();

return;
}

$this->appUserManager->flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Behat\Behat\Context\Context;
use Monofony\Bridge\Behat\Service\SharedStorageInterface;
use Monofony\Contracts\Core\Model\User\AdminUserInterface;
use Zenstruck\Foundry\Proxy;

final class AdminUserContext implements Context
{
Expand All @@ -21,7 +20,7 @@ public function __construct(SharedStorageInterface $sharedStorage)
/**
* @Transform /^(I|my)$/
*/
public function getLoggedAdminUser(): AdminUserInterface|Proxy
public function getLoggedAdminUser(): AdminUserInterface
{
return $this->sharedStorage->get('administrator');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Sylius\Component\Customer\Model\CustomerInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Zenstruck\Foundry\Proxy;

final class CustomerContext implements Context
{
Expand Down Expand Up @@ -49,7 +48,7 @@ public function getOrCreateCustomerByEmail(string $email): object
/**
* @Transform /^(he|his|she|her|their|the customer of my account)$/
*/
public function getLastCustomer(): CustomerInterface|Proxy
public function getLastCustomer(): CustomerInterface
{
return $this->sharedStorage->get('customer');
}
Expand Down

0 comments on commit f3ec9f6

Please sign in to comment.