model = $objectManager->get(Revoker::class); $this->reader = $objectManager->get(Reader::class); $this->issuer = $objectManager->get(Issuer::class); $this->customerRepo = $objectManager->get(CustomerRepositoryInterface::class); $this->userModel = $objectManager->create(UserModel::class); $this->paramsFactory = $objectManager->get(UserTokenParametersInterfaceFactory::class); $this->revokedValidator = $objectManager->get(RevokedValidator::class); $this->revokedRepo = $objectManager->get(RevokedRepositoryInterface::class); } /** * @inheritDoc */ protected function tearDown(): void { parent::tearDown(); if ($this->clearForId) { $this->revokedRepo->saveRevoked(new Revoked($this->clearForType, $this->clearForId, time() - 60)); $this->clearForType = null; $this->clearForId = null; } } /** * Verify that a token can be issued for a customer. * * @return void * @throws \Throwable * @magentoDataFixture Magento/Customer/_files/customer.php */ public function testIssueForCustomer(): void { $customer = $this->customerRepo->get('customer@example.com'); /** @var UserTokenParametersInterface $params */ $params = $this->paramsFactory->create(); $token = $this->issuer->create( new JwtUserContext((int) $customer->getId(), UserContextInterface::USER_TYPE_CUSTOMER), $params ); $this->model->revokeFor( new JwtUserContext( $this->clearForId = (int) $customer->getId(), $this->clearForType = UserContextInterface::USER_TYPE_CUSTOMER ) ); $this->expectException(AuthorizationException::class); $this->revokedValidator->validate($this->reader->read($token)); } }