From d02d445c9a6462a791a6a0668db86ed21378d669 Mon Sep 17 00:00:00 2001 From: Pierre du Plessis Date: Tue, 15 Feb 2022 20:41:50 +0200 Subject: [PATCH] Remove support for Propel --- CHANGELOG-2.0.md | 1 + DependencyInjection/Configuration.php | 2 +- Propel/AccessToken.php | 28 ---- Propel/AccessTokenManager.php | 20 --- Propel/AccessTokenQuery.php | 20 --- Propel/AuthCode.php | 60 --------- Propel/AuthCodeManager.php | 87 ------------- Propel/AuthCodePeer.php | 20 --- Propel/AuthCodeQuery.php | 20 --- Propel/Client.php | 49 ------- Propel/ClientManager.php | 72 ----------- Propel/ClientPeer.php | 20 --- Propel/ClientQuery.php | 20 --- Propel/RefreshToken.php | 28 ---- Propel/RefreshTokenManager.php | 20 --- Propel/RefreshTokenQuery.php | 20 --- Propel/Token.php | 60 --------- Propel/TokenManager.php | 87 ------------- Propel/TokenPeer.php | 20 --- Propel/TokenQuery.php | 20 --- Resources/config/propel.xml | 29 ----- Resources/config/propel/schema.xml | 58 --------- Resources/doc/configuration_reference.md | 2 +- Resources/doc/custom_db_driver.md | 2 +- Resources/doc/extending_the_model.md | 18 --- Resources/doc/index.md | 55 +------- Resources/doc/the_oauth_event_class.md | 2 +- Tests/Command/CreateClientCommandTest.php | 1 - Tests/Model/TokenTest.php | 3 - Tests/Propel/AuthCodeManagerTest.php | 149 ---------------------- Tests/Propel/AuthCodeTest.php | 62 --------- Tests/Propel/ClientManagerTest.php | 138 -------------------- Tests/Propel/ClientTest.php | 49 ------- Tests/Propel/PropelTestCase.php | 26 ---- Tests/Propel/TokenManagerTest.php | 149 ---------------------- Tests/Propel/TokenTest.php | 67 ---------- Tests/bootstrap.php | 16 --- composer.json | 8 +- phpstan.neon | 3 - phpunit.xml.dist | 7 - 40 files changed, 8 insertions(+), 1510 deletions(-) delete mode 100644 Propel/AccessToken.php delete mode 100644 Propel/AccessTokenManager.php delete mode 100644 Propel/AccessTokenQuery.php delete mode 100644 Propel/AuthCode.php delete mode 100644 Propel/AuthCodeManager.php delete mode 100644 Propel/AuthCodePeer.php delete mode 100644 Propel/AuthCodeQuery.php delete mode 100644 Propel/Client.php delete mode 100644 Propel/ClientManager.php delete mode 100644 Propel/ClientPeer.php delete mode 100644 Propel/ClientQuery.php delete mode 100644 Propel/RefreshToken.php delete mode 100644 Propel/RefreshTokenManager.php delete mode 100644 Propel/RefreshTokenQuery.php delete mode 100644 Propel/Token.php delete mode 100644 Propel/TokenManager.php delete mode 100644 Propel/TokenPeer.php delete mode 100644 Propel/TokenQuery.php delete mode 100644 Resources/config/propel.xml delete mode 100644 Resources/config/propel/schema.xml delete mode 100644 Tests/Propel/AuthCodeManagerTest.php delete mode 100644 Tests/Propel/AuthCodeTest.php delete mode 100644 Tests/Propel/ClientManagerTest.php delete mode 100644 Tests/Propel/ClientTest.php delete mode 100644 Tests/Propel/PropelTestCase.php delete mode 100644 Tests/Propel/TokenManagerTest.php delete mode 100644 Tests/Propel/TokenTest.php diff --git a/CHANGELOG-2.0.md b/CHANGELOG-2.0.md index 61adcaa8..fb9700f0 100644 --- a/CHANGELOG-2.0.md +++ b/CHANGELOG-2.0.md @@ -17,6 +17,7 @@ This changelog references the relevant changes done in 6.0 versions. - `OAuthEvent::PRE_AUTHORIZATION_PROCESS` => `FOS\OAuthServerBundle\Event\PreAuthorizationEvent` - `OAuthEvent::POST_AUTHORIZATION_PROCESS` => `FOS\OAuthServerBundle\Event\PostAuthorizationEvent` * **[BC break]** Removed support for templating engine [[#653](https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/pull/653)] +* **[BC break]** Removed support for Propel [[#689](https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/pull/689)] ### 2.0.0-ALPHA0 (2018-05-01) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index fb13f78c..76e75bd9 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -32,7 +32,7 @@ public function getConfigTreeBuilder() $treeBuilder = new TreeBuilder('fos_oauth_server'); $rootNode = $treeBuilder->getRootNode(); - $supportedDrivers = ['orm', 'mongodb', 'propel', 'custom']; + $supportedDrivers = ['orm', 'mongodb', 'custom']; $rootNode ->validate() diff --git a/Propel/AccessToken.php b/Propel/AccessToken.php deleted file mode 100644 index c3bf0f15..00000000 --- a/Propel/AccessToken.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Model\TokenInterface; - -class AccessToken extends Token implements TokenInterface -{ - /** - * Constructs a new AccessToken class, setting the class_key column to TokenPeer::CLASSKEY_2. - */ - public function __construct() - { - parent::__construct(); - $this->setClassKey(TokenPeer::CLASSKEY_2); - } -} diff --git a/Propel/AccessTokenManager.php b/Propel/AccessTokenManager.php deleted file mode 100644 index 044567a3..00000000 --- a/Propel/AccessTokenManager.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Model\AccessTokenManagerInterface; - -class AccessTokenManager extends TokenManager implements AccessTokenManagerInterface -{ -} diff --git a/Propel/AccessTokenQuery.php b/Propel/AccessTokenQuery.php deleted file mode 100644 index c7c7ac82..00000000 --- a/Propel/AccessTokenQuery.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Propel\om\BaseAccessTokenQuery; - -class AccessTokenQuery extends BaseAccessTokenQuery -{ -} diff --git a/Propel/AuthCode.php b/Propel/AuthCode.php deleted file mode 100644 index 1c80a943..00000000 --- a/Propel/AuthCode.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Model\AuthCodeInterface; -use FOS\OAuthServerBundle\Propel\om\BaseAuthCode; - -class AuthCode extends BaseAuthCode implements AuthCodeInterface -{ - /** - * {@inheritdoc} - */ - public function getData() - { - return $this->getUser(); - } - - /** - * {@inheritdoc} - */ - public function getExpiresIn() - { - if ($this->getExpiresAt()) { - return $this->getExpiresAt() - time(); - } - - return PHP_INT_MAX; - } - - /** - * {@inheritdoc} - */ - public function hasExpired() - { - if ($this->getExpiresAt()) { - return time() > $this->getExpiresAt(); - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function getClientId() - { - return $this->getClient()->getPublicId(); - } -} diff --git a/Propel/AuthCodeManager.php b/Propel/AuthCodeManager.php deleted file mode 100644 index a9b8a7fe..00000000 --- a/Propel/AuthCodeManager.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Model\AuthCodeInterface; -use FOS\OAuthServerBundle\Model\AuthCodeManager as BaseAuthCodeManager; - -class AuthCodeManager extends BaseAuthCodeManager -{ - /** - * @var string - */ - protected $class; - - /** - * @param string $class - */ - public function __construct($class) - { - $this->class = $class; - } - - /** - * {@inheritdoc} - */ - public function getClass() - { - return $this->class; - } - - /** - * {@inheritdoc} - */ - public function findAuthCodeBy(array $criteria) - { - if (!isset($criteria['token'])) { - return; - } - - $queryClass = $this->class.'Query'; - - return $queryClass::create() - ->filterByToken($criteria['token']) - ->findOne() - ; - } - - /** - * {@inheritdoc} - */ - public function updateAuthCode(AuthCodeInterface $authCode) - { - $authCode->save(); - } - - /** - * {@inheritdoc} - */ - public function deleteAuthCode(AuthCodeInterface $authCode) - { - $authCode->delete(); - } - - /** - * {@inheritdoc} - */ - public function deleteExpired() - { - $queryClass = $this->class.'Query'; - - return $queryClass::create() - ->filterByExpiresAt(time(), \Criteria::LESS_THAN) - ->delete() - ; - } -} diff --git a/Propel/AuthCodePeer.php b/Propel/AuthCodePeer.php deleted file mode 100644 index 75abc073..00000000 --- a/Propel/AuthCodePeer.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Propel\om\BaseAuthCodePeer; - -class AuthCodePeer extends BaseAuthCodePeer -{ -} diff --git a/Propel/AuthCodeQuery.php b/Propel/AuthCodeQuery.php deleted file mode 100644 index 363943fd..00000000 --- a/Propel/AuthCodeQuery.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Propel\om\BaseAuthCodeQuery; - -class AuthCodeQuery extends BaseAuthCodeQuery -{ -} diff --git a/Propel/Client.php b/Propel/Client.php deleted file mode 100644 index 652c8413..00000000 --- a/Propel/Client.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Model\ClientInterface; -use FOS\OAuthServerBundle\Propel\om\BaseClient; -use FOS\OAuthServerBundle\Util\Random; -use OAuth2\OAuth2; - -class Client extends BaseClient implements ClientInterface -{ - public function __construct() - { - parent::__construct(); - - $this->setAllowedGrantTypes([ - OAuth2::GRANT_TYPE_AUTH_CODE, - ]); - $this->setRandomId(Random::generateToken()); - $this->setSecret(Random::generateToken()); - } - - /** - * {@inheritdoc} - */ - public function checkSecret($secret) - { - return null === $this->secret || $secret === $this->secret; - } - - /** - * {@inheritdoc} - */ - public function getPublicId() - { - return sprintf('%s_%s', $this->getId(), $this->getRandomId()); - } -} diff --git a/Propel/ClientManager.php b/Propel/ClientManager.php deleted file mode 100644 index 1ff94d8b..00000000 --- a/Propel/ClientManager.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Model\ClientInterface; -use FOS\OAuthServerBundle\Model\ClientManager as BaseClientManager; - -class ClientManager extends BaseClientManager -{ - /** - * @var string - */ - protected $class; - - public function __construct($class) - { - $this->class = $class; - } - - /** - * {@inheritdoc} - */ - public function getClass() - { - return $this->class; - } - - /** - * {@inheritdoc} - */ - public function findClientBy(array $criteria) - { - if (!isset($criteria['id']) || !isset($criteria['randomId'])) { - return; - } - - $queryClass = $this->class.'Query'; - - return $queryClass::create() - ->filterById($criteria['id']) - ->filterByRandomId($criteria['randomId']) - ->findOne() - ; - } - - /** - * {@inheritdoc} - */ - public function updateClient(ClientInterface $client) - { - $client->save(); - } - - /** - * {@inheritdoc} - */ - public function deleteClient(ClientInterface $client) - { - $client->delete(); - } -} diff --git a/Propel/ClientPeer.php b/Propel/ClientPeer.php deleted file mode 100644 index d75980da..00000000 --- a/Propel/ClientPeer.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Propel\om\BaseClientPeer; - -class ClientPeer extends BaseClientPeer -{ -} diff --git a/Propel/ClientQuery.php b/Propel/ClientQuery.php deleted file mode 100644 index 03cdd861..00000000 --- a/Propel/ClientQuery.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Propel\om\BaseClientQuery; - -class ClientQuery extends BaseClientQuery -{ -} diff --git a/Propel/RefreshToken.php b/Propel/RefreshToken.php deleted file mode 100644 index 94c4e504..00000000 --- a/Propel/RefreshToken.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Model\TokenInterface; - -class RefreshToken extends Token implements TokenInterface -{ - /** - * Constructs a new RefreshToken class, setting the class_key column to TokenPeer::CLASSKEY_3. - */ - public function __construct() - { - parent::__construct(); - $this->setClassKey(TokenPeer::CLASSKEY_3); - } -} diff --git a/Propel/RefreshTokenManager.php b/Propel/RefreshTokenManager.php deleted file mode 100644 index bb43a627..00000000 --- a/Propel/RefreshTokenManager.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Model\RefreshTokenManagerInterface; - -class RefreshTokenManager extends TokenManager implements RefreshTokenManagerInterface -{ -} diff --git a/Propel/RefreshTokenQuery.php b/Propel/RefreshTokenQuery.php deleted file mode 100644 index d3577a92..00000000 --- a/Propel/RefreshTokenQuery.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Propel\om\BaseRefreshTokenQuery; - -class RefreshTokenQuery extends BaseRefreshTokenQuery -{ -} diff --git a/Propel/Token.php b/Propel/Token.php deleted file mode 100644 index a8d08d77..00000000 --- a/Propel/Token.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Model\TokenInterface; -use FOS\OAuthServerBundle\Propel\om\BaseToken; - -abstract class Token extends BaseToken implements TokenInterface -{ - /** - * {@inheritdoc} - */ - public function getData() - { - return $this->getUser(); - } - - /** - * {@inheritdoc} - */ - public function getExpiresIn() - { - if ($this->getExpiresAt()) { - return $this->getExpiresAt() - time(); - } - - return PHP_INT_MAX; - } - - /** - * {@inheritdoc} - */ - public function hasExpired() - { - if ($this->getExpiresAt()) { - return time() > $this->getExpiresAt(); - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function getClientId() - { - return $this->getClient()->getPublicId(); - } -} diff --git a/Propel/TokenManager.php b/Propel/TokenManager.php deleted file mode 100644 index f991bf67..00000000 --- a/Propel/TokenManager.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Model\TokenInterface; -use FOS\OAuthServerBundle\Model\TokenManager as BaseTokenManager; - -class TokenManager extends BaseTokenManager -{ - /** - * @var string - */ - protected $class; - - /** - * @param string $class a class name - */ - public function __construct($class) - { - $this->class = $class; - } - - /** - * {@inheritdoc} - */ - public function getClass() - { - return $this->class; - } - - /** - * {@inheritdoc} - */ - public function findTokenBy(array $criteria) - { - if (!isset($criteria['token'])) { - return; - } - - $queryClass = $this->class.'Query'; - - return $queryClass::create() - ->filterByToken($criteria['token']) - ->findOne() - ; - } - - /** - * {@inheritdoc} - */ - public function updateToken(TokenInterface $token) - { - $token->save(); - } - - /** - * {@inheritdoc} - */ - public function deleteToken(TokenInterface $token) - { - $token->delete(); - } - - /** - * {@inheritdoc} - */ - public function deleteExpired() - { - $queryClass = $this->class.'Query'; - - return $queryClass::create() - ->filterByExpiresAt(time(), \Criteria::LESS_THAN) - ->delete() - ; - } -} diff --git a/Propel/TokenPeer.php b/Propel/TokenPeer.php deleted file mode 100644 index bff07a3b..00000000 --- a/Propel/TokenPeer.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Propel\om\BaseTokenPeer; - -class TokenPeer extends BaseTokenPeer -{ -} diff --git a/Propel/TokenQuery.php b/Propel/TokenQuery.php deleted file mode 100644 index c8386885..00000000 --- a/Propel/TokenQuery.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Propel; - -use FOS\OAuthServerBundle\Propel\om\BaseTokenQuery; - -class TokenQuery extends BaseTokenQuery -{ -} diff --git a/Resources/config/propel.xml b/Resources/config/propel.xml deleted file mode 100644 index 9c9de483..00000000 --- a/Resources/config/propel.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - %fos_oauth_server.model.client.class% - - - - %fos_oauth_server.model.access_token.class% - - - - %fos_oauth_server.model.refresh_token.class% - - - - %fos_oauth_server.model.auth_code.class% - - - - - - - - - diff --git a/Resources/config/propel/schema.xml b/Resources/config/propel/schema.xml deleted file mode 100644 index 45f77bfa..00000000 --- a/Resources/config/propel/schema.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
-
diff --git a/Resources/doc/configuration_reference.md b/Resources/doc/configuration_reference.md index 9529fa32..836acc0f 100644 --- a/Resources/doc/configuration_reference.md +++ b/Resources/doc/configuration_reference.md @@ -5,7 +5,7 @@ All available configuration options are listed below with their default values. ``` yaml fos_oauth_server: - db_driver: ~ # Required. Available: mongodb, orm, propel + db_driver: ~ # Required. Available: mongodb, orm client_class: ~ # Required access_token_class: ~ # Required refresh_token_class: ~ # Required diff --git a/Resources/doc/custom_db_driver.md b/Resources/doc/custom_db_driver.md index e8c2e5b0..5539be55 100644 --- a/Resources/doc/custom_db_driver.md +++ b/Resources/doc/custom_db_driver.md @@ -1,7 +1,7 @@ Custom db driver. ================= -The bundle provides drivers for Doctrine ORM, Doctrine MongoDB, and Propel libraries. +The bundle provides drivers for Doctrine ORM and Doctrine MongoDB. Though sometimes you might want to use the bundle with a custom or in-house written storage. For that, the bundle has support for custom storage. Once set, setting manager options in fos_oauth_server.service section becomes mandatory. diff --git a/Resources/doc/extending_the_model.md b/Resources/doc/extending_the_model.md index 2f698c3f..8490eb68 100644 --- a/Resources/doc/extending_the_model.md +++ b/Resources/doc/extending_the_model.md @@ -7,22 +7,4 @@ Thanks to an abstraction layer (see the `Model/` directory), it's really easy to database abstraction layers, but in the same time to extend each layer. In this chapter, you will see how to properly extend the model of the FOSOAuthServerBundle to add your business logic. - -## Propel ## - -If you are using Propel, you just have to copy the [`schema.xml`](https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/blob/master/Resources/config/propel/schema.xml) -to the `app/Resources/FOSOAuthServerBundle/config/propel/` directory of your application. - -Then, tweak it to fit your needs. When you are done, just rebuild your model classes as usual: - - $ php app/console propel:model:build - -To update the dabase, you can rely on the `propel:sql:build` command if you want to rebuild your -whole database (which means loosing data), or rely on the migration commmands: - - $ php app/console propel:migration:generate-diff - $ php app/console propel:migration:migrate - -> **Note:** when you generate a diff with Propel, don't forget to review the generated SQL statements before to execute them (migrate). - [Back to index](index.md) diff --git a/Resources/doc/index.md b/Resources/doc/index.md index 65ac21c4..b31e12c0 100644 --- a/Resources/doc/index.md +++ b/Resources/doc/index.md @@ -237,47 +237,6 @@ class AuthCode extends BaseAuthCode __Note__: If you don't have `auto_mapping` activated in your doctrine configuration you need to add `FOSOAuthServerBundle` to your mappings in `config.yml`. -#### Propel - -A `schema.xml` is provided with this bundle to generate Propel classes. -You have to install the [TypehintableBehavior](https://github.com/willdurand/TypehintableBehavior) before to build your model. - -By using [Composer](http://getcomposer.org), you just have to add the following line in your `composer.json`: - -``` json -{ - "require": { - "willdurand/propel-typehintable-behavior": "*" - } -} -``` - -By using Git submodules: - - $ git submodule add http://github.com/willdurand/TypehintableBehavior.git vendor/willdurand/propel-typehintable-behavior - -By using the Symfony2 vendor management: - -```ini -[TypehintableBehavior] - git=http://github.com/willdurand/TypehintableBehavior.git - target=/willdurand/propel-typehintable-behavior -``` - -Then, register it: - -```ini -# app/config/propel.ini -propel.behavior.typehintable.class = vendor.willdurand.propel-typehintable-behavior.src.TypehintableBehavior -``` - -You now can run the following command to create the model: - - $ php app/console propel:model:build - -> To create SQL, run the command propel:sql:build and insert it or use migration commands if you have an existing schema in your database. - - #### Doctrine ODM classes ``` php - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Tests\Propel; - -use FOS\OAuthServerBundle\Propel\AuthCode; -use FOS\OAuthServerBundle\Propel\AuthCodeManager; -use FOS\OAuthServerBundle\Propel\AuthCodeQuery; - -/** - * @group time-sensitive - * - * Class AuthCodeManagerTest - */ -class AuthCodeManagerTest extends PropelTestCase -{ - const AUTH_CODE_CLASS = 'FOS\OAuthServerBundle\Propel\AuthCode'; - - protected $manager; - - public function setUp(): void - { - parent::setUp(); - - $this->manager = new AuthCodeManager(self::AUTH_CODE_CLASS); - AuthCodeQuery::create()->deleteAll(); - } - - public function testConstruct(): void - { - $this->assertSame(self::AUTH_CODE_CLASS, $this->manager->getClass()); - } - - public function testCreateClass(): void - { - $this->assertInstanceOf(self::AUTH_CODE_CLASS, $this->manager->createAuthCode()); - } - - public function testUpdate(): void - { - $authCode = $this->getMockBuilder('FOS\OAuthServerBundle\Propel\AuthCode') - ->disableOriginalConstructor() - ->getMock() - ; - $authCode - ->expects($this->once()) - ->method('save') - ; - - $this->manager->updateAuthCode($authCode); - } - - public function testDelete(): void - { - $authCode = $this->getMockBuilder('FOS\OAuthServerBundle\Propel\AuthCode') - ->disableOriginalConstructor() - ->getMock() - ; - $authCode - ->expects($this->once()) - ->method('delete') - ; - - $this->manager->deleteAuthCode($authCode); - } - - public function testFindAuthCodeReturnsNullIfNotFound(): void - { - $authCode = $this->manager->findAuthCodeBy(['token' => '12345']); - - $this->assertNull($authCode); - } - - public function testFindAuthCode(): void - { - $authCode = $this->createAuthCode('12345'); - $return = $this->manager->findAuthCodeBy(['token' => '12345']); - - $this->assertNotNull($return); - $this->assertSame($authCode, $return); - } - - public function testFindAuthCodeByToken(): void - { - $authCode = $this->createAuthCode('12345'); - $return = $this->manager->findAuthCodeByToken('12345'); - - $this->assertNotNull($return); - $this->assertSame($authCode, $return); - } - - public function testFindAuthCodeByTokenReturnsNullIfNotFound(): void - { - $return = $this->manager->findAuthCodeByToken('12345'); - - $this->assertNull($return); - } - - public function testFindAuthCodeWithInvalidData(): void - { - $token = $this->manager->findAuthCodeBy(['foo' => '12345']); - $this->assertNull($token); - - $token = $this->manager->findAuthCodeBy([]); - $this->assertNull($token); - - $token = $this->manager->findAuthCodeBy(['token']); - $this->assertNull($token); - } - - public function testDeleteExpired(): void - { - $a1 = $this->createAuthCode('12345', time() + 100); - $a2 = $this->createAuthCode('67890', time() - 100); - - $this->assertSame(2, AuthCodeQuery::create()->count()); - - $nb = $this->manager->deleteExpired(); - - $this->assertSame(1, $nb); - $this->assertTrue($a1->equals(AuthCodeQuery::create()->findOne())); - } - - protected function createAuthCode($token, $expiresAt = false) - { - $authCode = new AuthCode(); - $authCode->setClientId(1); - $authCode->setToken($token); - $authCode->setRedirectUri('foo'); - - if ($expiresAt) { - $authCode->setExpiresAt($expiresAt); - } - - $authCode->save(); - - return $authCode; - } -} diff --git a/Tests/Propel/AuthCodeTest.php b/Tests/Propel/AuthCodeTest.php deleted file mode 100644 index 1a54c55a..00000000 --- a/Tests/Propel/AuthCodeTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Tests\Propel; - -use FOS\OAuthServerBundle\Propel\AuthCode; - -/** - * @group time-sensitive - * - * Class AuthCodeTest - */ -class AuthCodeTest extends PropelTestCase -{ - /** - * @dataProvider getTestHasExpiredData - * - * @param mixed $expiresAt - * @param mixed $expect - */ - public function testHasExpired($expiresAt, $expect): void - { - $token = new AuthCode(); - $token->setExpiresAt($expiresAt); - - $this->assertSame($expect, $token->hasExpired()); - } - - public static function getTestHasExpiredData() - { - return [ - [time() + 60, false], - [time() - 60, true], - [null, false], - ]; - } - - public function testExpiresIn(): void - { - $token = new AuthCode(); - - $this->assertSame(PHP_INT_MAX, $token->getExpiresIn()); - } - - public function testExpiresInWithExpiresAt(): void - { - $token = new AuthCode(); - $token->setExpiresAt(time() + 60); - - $this->assertSame(60, $token->getExpiresIn()); - } -} diff --git a/Tests/Propel/ClientManagerTest.php b/Tests/Propel/ClientManagerTest.php deleted file mode 100644 index 60c44fee..00000000 --- a/Tests/Propel/ClientManagerTest.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Tests\Propel; - -use FOS\OAuthServerBundle\Propel\Client; -use FOS\OAuthServerBundle\Propel\ClientManager; -use FOS\OAuthServerBundle\Propel\ClientQuery; - -class ClientManagerTest extends PropelTestCase -{ - const CLIENT_CLASS = 'FOS\OAuthServerBundle\Propel\Client'; - - protected $manager; - - public function setUp(): void - { - parent::setUp(); - - $this->manager = new ClientManager(self::CLIENT_CLASS); - ClientQuery::create()->deleteAll(); - } - - public function testConstruct(): void - { - $this->assertSame(self::CLIENT_CLASS, $this->manager->getClass()); - } - - public function testCreateClass(): void - { - $this->assertInstanceOf(self::CLIENT_CLASS, $this->manager->createClient()); - } - - public function testUpdate(): void - { - $client = $this->getMockBuilder('FOS\OAuthServerBundle\Propel\Client') - ->disableOriginalConstructor() - ->getMock() - ; - $client - ->expects($this->once()) - ->method('save') - ; - - $this->manager->updateClient($client); - } - - public function testDelete(): void - { - $client = $this->getMockBuilder('FOS\OAuthServerBundle\Propel\Client') - ->disableOriginalConstructor() - ->getMock() - ; - $client - ->expects($this->once()) - ->method('delete') - ; - - $this->manager->deleteClient($client); - } - - public function testFindClientReturnsNullIfNotFound(): void - { - $client = $this->manager->findClientBy(['id' => '1', 'randomId' => '2345']); - - $this->assertNull($client); - } - - public function testFindClientWithInvalidCriteria(): void - { - $client = $this->manager->findClientBy(['randomId' => '2345']); - $this->assertNull($client); - - $client = $this->manager->findClientBy(['id' => '2345']); - $this->assertNull($client); - - $client = $this->manager->findClientBy(['foo' => '2345']); - $this->assertNull($client); - } - - public function testFindClient(): void - { - $client = $this->createClient('2345'); - $return = $this->manager->findClientBy(['id' => '1', 'randomId' => '2345']); - - $this->assertNotNull($return); - $this->assertSame($client, $return); - } - - public function testFindClientByPublicId(): void - { - $client = $this->createClient('12345'); - $return = $this->manager->findClientByPublicId('1_12345'); - - $this->assertNotNull($return); - $this->assertSame($client, $return); - } - - public function testFindClientByPublicIdReturnsNullIfNotFound(): void - { - $return = $this->manager->findClientByPublicId('1_12345'); - - $this->assertNull($return); - } - - public function testFindClientByPublicIdReturnsNullIfInvalidPublicId(): void - { - $return = $this->manager->findClientByPublicId('1'); - $this->assertNull($return); - - $return = $this->manager->findClientByPublicId(''); - $this->assertNull($return); - - // invalid type - // $return = $this->manager->findClientByPublicId(null); - // $this->assertNull($return); - } - - protected function createClient($randomId) - { - $client = new Client(); - $client->setRandomId($randomId); - $client->setRedirectUris(['foo']); - $client->save(); - - return $client; - } -} diff --git a/Tests/Propel/ClientTest.php b/Tests/Propel/ClientTest.php deleted file mode 100644 index c2f3d2b9..00000000 --- a/Tests/Propel/ClientTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Tests\Propel; - -use FOS\OAuthServerBundle\Propel\Client; -use OAuth2\OAuth2; - -class ClientTest extends PropelTestCase -{ - public function testConstructor(): void - { - $client = new Client(); - - $this->assertNotNull($client->getRandomId()); - $this->assertNotNull($client->getSecret()); - - $types = $client->getAllowedGrantTypes(); - $this->assertCount(1, $types); - $this->assertSame(OAuth2::GRANT_TYPE_AUTH_CODE, $types[0]); - } - - public function testCheckSecretWithInvalidArgument(): void - { - $client = new Client(); - - $this->assertFalse($client->checkSecret('foo')); - $this->assertFalse($client->checkSecret('')); - $this->assertFalse($client->checkSecret(null)); - } - - public function testCheckSecret(): void - { - $client = new Client(); - $client->setSecret('foo'); - - $this->assertTrue($client->checkSecret('foo')); - } -} diff --git a/Tests/Propel/PropelTestCase.php b/Tests/Propel/PropelTestCase.php deleted file mode 100644 index 7ad41b66..00000000 --- a/Tests/Propel/PropelTestCase.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Tests\Propel; - -use FOS\OAuthServerBundle\Tests\TestCase; - -class PropelTestCase extends TestCase -{ - public function setUp(): void - { - if (!class_exists('\Propel')) { - $this->markTestSkipped('Propel is not installed.'); - } - } -} diff --git a/Tests/Propel/TokenManagerTest.php b/Tests/Propel/TokenManagerTest.php deleted file mode 100644 index 58b73610..00000000 --- a/Tests/Propel/TokenManagerTest.php +++ /dev/null @@ -1,149 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Tests\Propel; - -use FOS\OAuthServerBundle\Propel\RefreshToken as Token; -use FOS\OAuthServerBundle\Propel\RefreshTokenQuery as TokenQuery; -use FOS\OAuthServerBundle\Propel\TokenManager; - -/** - * @group time-sensitive - * - * Class TokenManagerTest - */ -class TokenManagerTest extends PropelTestCase -{ - const TOKEN_CLASS = 'FOS\OAuthServerBundle\Propel\RefreshToken'; - - protected $manager; - - public function setUp(): void - { - parent::setUp(); - - $this->manager = new TokenManager(self::TOKEN_CLASS); - TokenQuery::create()->deleteAll(); - } - - public function testConstruct(): void - { - $this->assertSame(self::TOKEN_CLASS, $this->manager->getClass()); - } - - public function testCreateClass(): void - { - $this->manager = new TokenManager('Token'); - $this->assertInstanceOf('Token', $this->manager->createToken()); - } - - public function testUpdate(): void - { - $token = $this->getMockBuilder('FOS\OAuthServerBundle\Propel\Token') - ->disableOriginalConstructor() - ->getMock() - ; - $token - ->expects($this->once()) - ->method('save') - ; - - $this->manager->updateToken($token); - } - - public function testDelete(): void - { - $token = $this->getMockBuilder('FOS\OAuthServerBundle\Propel\Token') - ->disableOriginalConstructor() - ->getMock() - ; - $token - ->expects($this->once()) - ->method('delete') - ; - - $this->manager->deleteToken($token); - } - - public function testFindTokenReturnsNullIfNotFound(): void - { - $token = $this->manager->findTokenBy(['token' => '12345']); - - $this->assertNull($token); - } - - public function testFindTokenWithInvalidData(): void - { - $token = $this->manager->findTokenBy(['foo' => '12345']); - $this->assertNull($token); - - $token = $this->manager->findTokenBy([]); - $this->assertNull($token); - - $token = $this->manager->findTokenBy(['token']); - $this->assertNull($token); - } - - public function testFindToken(): void - { - $token = $this->createToken('12345'); - $return = $this->manager->findTokenBy(['token' => '12345']); - - $this->assertNotNull($return); - $this->assertSame($token, $return); - } - - public function testFindTokenByToken(): void - { - $token = $this->createToken('12345'); - $return = $this->manager->findTokenByToken('12345'); - - $this->assertNotNull($return); - $this->assertSame($token, $return); - } - - public function testFindTokenByTokenReturnsNullIfNotFound(): void - { - $return = $this->manager->findTokenByToken('12345'); - - $this->assertNull($return); - } - - public function testDeleteExpired(): void - { - $a1 = $this->createToken('12345', time() + 100); - $a2 = $this->createToken('67890', time() - 100); - - $this->assertSame(2, TokenQuery::create()->count()); - - $nb = $this->manager->deleteExpired(); - - $this->assertSame(1, $nb); - $this->assertTrue($a1->equals(TokenQuery::create()->findOne())); - } - - protected function createToken($tokenString, $expiresAt = false) - { - $token = new Token(); - $token->setClientId(1); - $token->setToken($tokenString); - - if ($expiresAt) { - $token->setExpiresAt($expiresAt); - } - - $token->save(); - - return $token; - } -} diff --git a/Tests/Propel/TokenTest.php b/Tests/Propel/TokenTest.php deleted file mode 100644 index cf1ff30f..00000000 --- a/Tests/Propel/TokenTest.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\OAuthServerBundle\Tests\Propel; - -use FOS\OAuthServerBundle\Propel\Token as AbstractToken; - -/** - * @group time-sensitive - * - * Class TokenTest - */ -class TokenTest extends PropelTestCase -{ - /** - * @dataProvider getTestHasExpiredData - * - * @param mixed $expiresAt - * @param mixed $expect - */ - public function testHasExpired($expiresAt, $expect): void - { - $token = new Token(); - $token->setExpiresAt($expiresAt); - - $this->assertSame($expect, $token->hasExpired()); - } - - public static function getTestHasExpiredData() - { - return [ - [time() + 60, false], - [time() - 60, true], - [null, false], - ]; - } - - public function testExpiresIn(): void - { - $token = new Token(); - - $this->assertSame(PHP_INT_MAX, $token->getExpiresIn()); - } - - public function testExpiresInWithExpiresAt(): void - { - $token = new Token(); - $token->setExpiresAt(time() + 60); - - $this->assertSame(60, $token->getExpiresIn()); - } -} - -// The Token class is abstract (concrete inheritance) -class Token extends AbstractToken -{ -} diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index f32a19c5..c194bf36 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -13,20 +13,4 @@ require_once __DIR__.'/../vendor/autoload.php'; -// require Propel -if (file_exists($file = __DIR__.'/../vendor/propel/propel1/generator/lib/util/PropelQuickBuilder.php')) { - set_include_path(__DIR__.'/../vendor/phing/phing/classes'.PATH_SEPARATOR.get_include_path()); - require_once $file; -} - \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists'); - -// Generate Propel base classes on the fly -if (class_exists('TypehintableBehavior')) { - $class = new \ReflectionClass('TypehintableBehavior'); - $builder = new \PropelQuickBuilder(); - $builder->getConfig()->setBuildProperty('behavior.typehintable.class', $class->getFileName()); - $builder->setSchema(file_get_contents(__DIR__.'/../Resources/config/propel/schema.xml')); - $builder->setClassTargets(['tablemap', 'peer', 'object', 'query', 'peerstub']); - $builder->build(); -} diff --git a/composer.json b/composer.json index ca79a1e7..deb19681 100644 --- a/composer.json +++ b/composer.json @@ -39,20 +39,16 @@ "phpstan/phpstan": "^0.12", "phpstan/phpstan-phpunit": "~0.9", "phpunit/phpunit": "^9.0", - "propel/propel1": "~1.6", "symfony/console": "^4.4 || ^5.1", "symfony/form": "^4.4 || ^5.1", "symfony/phpunit-bridge": "^4.4 || ^5.1", - "symfony/yaml": "^4.4 || ^5.1", - "willdurand/propel-typehintable-behavior": "~1.0" + "symfony/yaml": "^4.4 || ^5.1" }, "suggest": { "doctrine/doctrine-bundle": "*", "doctrine/mongodb-odm-bundle": "*", - "propel/propel-bundle": "If you want to use Propel with Symfony2, then you will have to install the PropelBundle", "symfony/console": "Needed to be able to use commands", - "symfony/form": "Needed to be able to use the AuthorizeFormType", - "willdurand/propel-typehintable-behavior": "The Typehintable behavior is useful to add type hints on generated methods, to be compliant with interfaces" + "symfony/form": "Needed to be able to use the AuthorizeFormType" }, "config": { "sort-packages": true diff --git a/phpstan.neon b/phpstan.neon index c94c6e65..1693ccbd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,9 +6,6 @@ parameters: excludes_analyse: - vendor/ - # Propel stuff seems broken as-is, ignoring for now - - Propel/ - - Tests/Propel/ ignoreErrors: # temporary - '#Parameter \#1 \$httpStatusCode of class OAuth2\\OAuth2ServerException constructor expects string, int given#' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5192b311..0f5a7fdf 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -13,13 +13,6 @@ ./Resources ./Tests ./vendor - ./Propel/AccessToken.php - ./Propel/AccessTokenQuery.php - ./Propel/RefreshToken.php - ./Propel/RefreshTokenQuery.php - ./Propel - ./Propel/map - ./Propel/om