mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
remove test
This commit is contained in:
parent
4d0215580c
commit
2cf30d1073
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Auth\OAuth2\Grant;
|
||||
|
||||
use phpOMS\Auth\OAuth2\Grant\AuthorizationCode;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class AuthorizationCodeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private AuthorizationCode $grant;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->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',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Auth\OAuth2\Grant;
|
||||
|
||||
use phpOMS\Auth\OAuth2\Grant\ClientCredentials;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class ClientCredentialsTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private ClientCredentials $grant;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->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',
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Auth\OAuth2\Grant;
|
||||
|
||||
use phpOMS\Auth\OAuth2\Grant\GrantAbstract;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class GrantAbstractTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private GrantAbstract $grant;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->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',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Auth\OAuth2\Grant;
|
||||
|
||||
use phpOMS\Auth\OAuth2\Grant\AuthorizationCode;
|
||||
use phpOMS\Auth\OAuth2\Grant\GrantAbstract;
|
||||
use phpOMS\Auth\OAuth2\Grant\GrantFactory;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class GrantFactoryTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private GrantFactory $factory;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->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');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Auth\OAuth2\Grant;
|
||||
|
||||
use phpOMS\Auth\OAuth2\Grant\Password;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class PasswordTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private Password $grant;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->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',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Auth\OAuth2\Grant;
|
||||
|
||||
use phpOMS\Auth\OAuth2\Grant\RefreshToken;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class RefreshTokenTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private RefreshToken $grant;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->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',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Auth\OAuth2\OptionProvider;
|
||||
|
||||
use phpOMS\Auth\OAuth2\OptionProvider\HttpBasicAuthOptionProvider;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\System\MimeType;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class HttpBasicAuthOptionProviderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private HttpBasicAuthOptionProvider $provider;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->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',
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Auth\OAuth2\OptionProvider;
|
||||
|
||||
use phpOMS\Auth\OAuth2\OptionProvider\PostAuthOptionProvider;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\System\MimeType;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class PostAuthOptionProviderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private PostAuthOptionProvider $provider;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->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'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Auth\OAuth2\Token;
|
||||
|
||||
use phpOMS\Auth\OAuth2\Token\AccessToken;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class AccessTokenTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @covers phpOMS\Auth\OAuth2\Token\AccessToken
|
||||
* @group framework
|
||||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
$token = new AccessToken(['access_token' => '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([]);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user