From 2cf30d10731cbcbffd4734006044bbfcb8dcbf86 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 30 Sep 2021 22:55:49 +0200 Subject: [PATCH] remove test --- .../OAuth2/Grant/AuthorizationCodeTest.php | 76 --------- .../OAuth2/Grant/ClientCredentialsTest.php | 58 ------- tests/Auth/OAuth2/Grant/GrantAbstractTest.php | 84 ---------- tests/Auth/OAuth2/Grant/GrantFactoryTest.php | 77 --------- tests/Auth/OAuth2/Grant/PasswordTest.php | 76 --------- tests/Auth/OAuth2/Grant/RefreshTokenTest.php | 76 --------- .../HttpBasicAuthOptionProviderTest.php | 75 --------- .../PostAuthOptionProviderTest.php | 50 ------ tests/Auth/OAuth2/Token/AccessTokenTest.php | 155 ------------------ 9 files changed, 727 deletions(-) delete mode 100644 tests/Auth/OAuth2/Grant/AuthorizationCodeTest.php delete mode 100644 tests/Auth/OAuth2/Grant/ClientCredentialsTest.php delete mode 100644 tests/Auth/OAuth2/Grant/GrantAbstractTest.php delete mode 100644 tests/Auth/OAuth2/Grant/GrantFactoryTest.php delete mode 100644 tests/Auth/OAuth2/Grant/PasswordTest.php delete mode 100644 tests/Auth/OAuth2/Grant/RefreshTokenTest.php delete mode 100644 tests/Auth/OAuth2/OptionProvider/HttpBasicAuthOptionProviderTest.php delete mode 100644 tests/Auth/OAuth2/OptionProvider/PostAuthOptionProviderTest.php delete mode 100644 tests/Auth/OAuth2/Token/AccessTokenTest.php diff --git a/tests/Auth/OAuth2/Grant/AuthorizationCodeTest.php b/tests/Auth/OAuth2/Grant/AuthorizationCodeTest.php deleted file mode 100644 index ff6fb5984..000000000 --- a/tests/Auth/OAuth2/Grant/AuthorizationCodeTest.php +++ /dev/null @@ -1,76 +0,0 @@ -grant = new AuthorizationCode(); - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\AuthorizationCode - * @group framework - */ - public function testDefault() : void - { - self::assertEquals('authorization_code', $this->grant->__toString()); - self::assertEquals( - [ - 'code' => 'value', - 'option' => '2', - 'test' => 'value2', - ], - $this->grant->prepareRequestParamters( - [ - 'code' => 'value', - ], - [ - 'option' => '2', - 'test' => 'value2', - ] - ) - ); - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\AuthorizationCode - * @group framework - */ - public function testMissingDefaultOption() : void - { - $this->expectException(\Exception::class); - $this->grant->prepareRequestParamters( - [ - 'test' => 'value', - ], - [ - 'option' => '2', - 'test' => 'value2', - ] - ); - } -} diff --git a/tests/Auth/OAuth2/Grant/ClientCredentialsTest.php b/tests/Auth/OAuth2/Grant/ClientCredentialsTest.php deleted file mode 100644 index 5e4d2f6f0..000000000 --- a/tests/Auth/OAuth2/Grant/ClientCredentialsTest.php +++ /dev/null @@ -1,58 +0,0 @@ -grant = new ClientCredentials(); - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\ClientCredentials - * @group framework - */ - public function testDefault() : void - { - self::assertEquals('client_credentials', $this->grant->__toString()); - self::assertEquals( - [ - 'code' => 'value', - 'option' => '2', - 'test' => 'value2', - ], - $this->grant->prepareRequestParamters( - [ - 'code' => 'value', - ], - [ - 'option' => '2', - 'test' => 'value2', - ] - ) - ); - } -} diff --git a/tests/Auth/OAuth2/Grant/GrantAbstractTest.php b/tests/Auth/OAuth2/Grant/GrantAbstractTest.php deleted file mode 100644 index 1c4cdb902..000000000 --- a/tests/Auth/OAuth2/Grant/GrantAbstractTest.php +++ /dev/null @@ -1,84 +0,0 @@ -grant = new class() extends GrantAbstract { - protected function getName() : string - { - return 'TestGrant'; - } - - protected function getRequiredRequestParameters() : array - { - return ['test']; - } - }; - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\GrantAbstract - * @group framework - */ - public function testDefault() : void - { - self::assertEquals('TestGrant', $this->grant->__toString()); - self::assertEquals( - [ - 'test' => 'value2', - 'option' => '2', - ], - $this->grant->prepareRequestParamters( - [ - 'test' => 'value', - ], - [ - 'option' => '2', - 'test' => 'value2', - ] - ) - ); - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\GrantAbstract - * @group framework - */ - public function testMissingDefaultOption() : void - { - $this->expectException(\Exception::class); - $this->grant->prepareRequestParamters( - [ - 'something' => 'value', - ], - [ - 'option' => '2', - ] - ); - } -} diff --git a/tests/Auth/OAuth2/Grant/GrantFactoryTest.php b/tests/Auth/OAuth2/Grant/GrantFactoryTest.php deleted file mode 100644 index 7bc04185c..000000000 --- a/tests/Auth/OAuth2/Grant/GrantFactoryTest.php +++ /dev/null @@ -1,77 +0,0 @@ -factory = new GrantFactory(); - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\GrantFactory - * @group framework - */ - public function testGrantGet() : void - { - $grant = $this->factory->getGrant('AuthorizationCode'); - self::assertInstanceOf(AuthorizationCode::class, $grant); - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\GrantFactory - * @group framework - */ - public function testGrantInputOutput() : void - { - $grant = new class() extends GrantAbstract { - protected function getName() : string - { - return 'TestGrant'; - } - - protected function getRequiredRequestParameters() : array - { - return ['test']; - } - }; - $this->factory->setGrant('test', $grant); - - self::assertInstanceOf(\get_class($grant), $this->factory->getGrant('test')); - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\GrantFactory - * @group framework - */ - public function testInvalidGrantGet() : void - { - $this->expectException(\Exception::class); - $this->factory->getGrant('invalid'); - } -} diff --git a/tests/Auth/OAuth2/Grant/PasswordTest.php b/tests/Auth/OAuth2/Grant/PasswordTest.php deleted file mode 100644 index 7117344a3..000000000 --- a/tests/Auth/OAuth2/Grant/PasswordTest.php +++ /dev/null @@ -1,76 +0,0 @@ -grant = new Password(); - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\Password - * @group framework - */ - public function testDefault() : void - { - self::assertEquals('password', $this->grant->__toString()); - self::assertEquals( - [ - 'username' => 'value', - 'password' => '2', - 'test' => 'value2', - ], - $this->grant->prepareRequestParamters( - [ - 'username' => 'value', - ], - [ - 'password' => '2', - 'test' => 'value2', - ] - ) - ); - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\Password - * @group framework - */ - public function testMissingDefaultOption() : void - { - $this->expectException(\Exception::class); - $this->grant->prepareRequestParamters( - [ - 'username' => 'value', - ], - [ - 'option' => '2', - 'test' => 'value2', - ] - ); - } -} diff --git a/tests/Auth/OAuth2/Grant/RefreshTokenTest.php b/tests/Auth/OAuth2/Grant/RefreshTokenTest.php deleted file mode 100644 index 608000241..000000000 --- a/tests/Auth/OAuth2/Grant/RefreshTokenTest.php +++ /dev/null @@ -1,76 +0,0 @@ -grant = new RefreshToken(); - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\RefreshToken - * @group framework - */ - public function testDefault() : void - { - self::assertEquals('refresh_token', $this->grant->__toString()); - self::assertEquals( - [ - 'refresh_token' => 'value', - 'option' => '2', - 'test' => 'value2', - ], - $this->grant->prepareRequestParamters( - [ - 'refresh_token' => 'value', - ], - [ - 'option' => '2', - 'test' => 'value2', - ] - ) - ); - } - - /** - * @covers phpOMS\Auth\OAuth2\Grant\RefreshToken - * @group framework - */ - public function testMissingDefaultOption() : void - { - $this->expectException(\Exception::class); - $this->grant->prepareRequestParamters( - [ - 'test' => 'value', - ], - [ - 'option' => '2', - 'test' => 'value2', - ] - ); - } -} diff --git a/tests/Auth/OAuth2/OptionProvider/HttpBasicAuthOptionProviderTest.php b/tests/Auth/OAuth2/OptionProvider/HttpBasicAuthOptionProviderTest.php deleted file mode 100644 index 56dde42b6..000000000 --- a/tests/Auth/OAuth2/OptionProvider/HttpBasicAuthOptionProviderTest.php +++ /dev/null @@ -1,75 +0,0 @@ -provider = new HttpBasicAuthOptionProvider(); - } - - /** - * @covers phpOMS\Auth\OAuth2\OptionProvider\HttpBasicAuthOptionProvider - * @group framework - */ - public function testDefault() : void - { - self::assertEquals( - [ - 'headers' => [ - 'content-type' => MimeType::M_POST, - 'Authorization' => 'Basic aWQ6c2VjcmV0', - ], - 'body' => 'para=test¶2=test2', - ], - $this->provider->getAccessTokenOptions(RequestMethod::POST, [ - 'para' => 'test', - 'para2' => 'test2', - 'client_id' => 'id', - 'client_secret' => 'secret', - ] - ) - ); - } - - /** - * @covers phpOMS\Auth\OAuth2\OptionProvider\HttpBasicAuthOptionProvider - * @group framework - */ - public function testInvalidParams() : void - { - self::assertEquals([], - $this->provider->getAccessTokenOptions(RequestMethod::POST, [ - 'para' => 'test', - 'para2' => 'test2', - 'client_id' => 'id', - ] - ) - ); - } -} diff --git a/tests/Auth/OAuth2/OptionProvider/PostAuthOptionProviderTest.php b/tests/Auth/OAuth2/OptionProvider/PostAuthOptionProviderTest.php deleted file mode 100644 index 31584707e..000000000 --- a/tests/Auth/OAuth2/OptionProvider/PostAuthOptionProviderTest.php +++ /dev/null @@ -1,50 +0,0 @@ -provider = new PostAuthOptionProvider(); - } - - /** - * @covers phpOMS\Auth\OAuth2\OptionProvider\PostAuthOptionProvider - * @group framework - */ - public function testDefault() : void - { - self::assertEquals( - [ - 'headers' => ['content-type' => MimeType::M_POST], - 'body' => 'para=test¶2=test2', - ], - $this->provider->getAccessTokenOptions(RequestMethod::POST, ['para' => 'test', 'para2' => 'test2']) - ); - } -} diff --git a/tests/Auth/OAuth2/Token/AccessTokenTest.php b/tests/Auth/OAuth2/Token/AccessTokenTest.php deleted file mode 100644 index e145bf611..000000000 --- a/tests/Auth/OAuth2/Token/AccessTokenTest.php +++ /dev/null @@ -1,155 +0,0 @@ - 'token']); - self::assertEquals('token', $token->getToken()); - self::assertEquals('token', $token->__toString()); - self::assertEquals(-1, $token->getExpires()); - self::assertNull($token->getRefreshToken()); - self::assertNull($token->getResourceOwnerId()); - self::assertFalse($token->hasExpired()); - self::assertEquals([], $token->getValues()); - self::assertEquals(['access_token' => 'token'], $token->jsonSerialize()); - } - - /** - * @covers phpOMS\Auth\OAuth2\Token\AccessToken - * @group framework - */ - public function testExpiresInputOutput() : void - { - $expires = \time(); - $token = new AccessToken(['access_token' => 'token', 'expires' => $expires]); - self::assertEquals($expires, $token->getExpires()); - } - - /** - * @covers phpOMS\Auth\OAuth2\Token\AccessToken - * @group framework - */ - public function testExpiresInInputOutput() : void - { - $expires = \time(); - $token = new AccessToken(['access_token' => 'token', 'expires_in' => 10]); - self::assertFalse($token->hasExpired()); - self::assertTrue($expires < $token->getExpires() && $token->getExpires() < $expires + 20); - } - - /** - * @covers phpOMS\Auth\OAuth2\Token\AccessToken - * @group framework - */ - public function testHasExpired() : void - { - $token = new AccessToken(['access_token' => 'token', 'expires_in' => -5]); - self::assertTrue($token->hasExpired()); - - $expires = \time(); - $token = new AccessToken(['access_token' => 'token', 'expires' => $expires - 5]); - self::assertTrue($token->hasExpired()); - } - - /** - * @covers phpOMS\Auth\OAuth2\Token\AccessToken - * @group framework - */ - public function testResourceOwnerIdInputOutput() : void - { - $token = new AccessToken(['access_token' => 'token', 'resource_owner_id' => 'owner']); - self::assertEquals('owner', $token->getResourceOwnerId()); - } - - /** - * @covers phpOMS\Auth\OAuth2\Token\AccessToken - * @group framework - */ - public function testRefreshTokenInputOutput() : void - { - $token = new AccessToken(['access_token' => 'token', 'refresh_token' => 'refresh']); - self::assertEquals('refresh', $token->getRefreshToken()); - } - - /** - * @covers phpOMS\Auth\OAuth2\Token\AccessToken - * @group framework - */ - public function testValuesInputOutput() : void - { - $token = new AccessToken([ - 'access_token' => 'token', - 'resource_owner_id' => 'owner', - 'expires_in' => 10, - 'refresh_token' => 'refresh', - 'more' => 'values', - ]); - - self::assertEquals( - ['more' => 'values'], - $token->getValues() - ); - } - - /** - * @covers phpOMS\Auth\OAuth2\Token\AccessToken - * @group framework - */ - public function testJsonSeriaize() : void - { - $expires = \time() + 10; - - $token = new AccessToken([ - 'access_token' => 'token', - 'resource_owner_id' => 'owner', - 'expires' => $expires, - 'refresh_token' => 'refresh', - 'more' => 'values', - ]); - - self::assertEquals( - [ - 'access_token' => 'token', - 'resource_owner_id' => 'owner', - 'expires' => $expires, - 'refresh_token' => 'refresh', - 'more' => 'values', - ], - $token->jsonSerialize() - ); - } - - /** - * @covers phpOMS\Auth\OAuth2\Token\AccessToken - * @group framework - */ - public function testMissingAccessToken() : void - { - $this->expectException(\InvalidArgumentException::class); - $token = new AccessToken([]); - } -}