mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-06 04:28:41 +00:00
Merge branch 'develop' of https://github.com/Orange-Management/phpOMS into develop
This commit is contained in:
commit
33db2fd2da
|
|
@ -23,7 +23,7 @@ class AuthorizationCodeTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
private AuthorizationCode $grant;
|
private AuthorizationCode $grant;
|
||||||
|
|
||||||
public function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
$this->grant = new AuthorizationCode();
|
$this->grant = new AuthorizationCode();
|
||||||
}
|
}
|
||||||
|
|
@ -33,17 +33,17 @@ class AuthorizationCodeTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals('authorization_code', $this->grant->__toString());
|
self::assertEquals('authorization_code', $this->grant->__toString());
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[
|
[
|
||||||
'code' => 'value',
|
'code' => 'value',
|
||||||
'option' => '2',
|
'option' => '2',
|
||||||
'test' => 'value2',
|
'test' => 'value2',
|
||||||
],
|
],
|
||||||
$this->grant->prepareRequestParamters(
|
$this->grant->prepareRequestParamters(
|
||||||
[
|
[
|
||||||
'code' => 'value'
|
'code' => 'value',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'option' => '2',
|
'option' => '2',
|
||||||
'test' => 'value2'
|
'test' => 'value2',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -54,11 +54,11 @@ class AuthorizationCodeTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->expectException(\Exception::class);
|
$this->expectException(\Exception::class);
|
||||||
$this->grant->prepareRequestParamters(
|
$this->grant->prepareRequestParamters(
|
||||||
[
|
[
|
||||||
'test' => 'value'
|
'test' => 'value',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'option' => '2',
|
'option' => '2',
|
||||||
'test' => 'value2'
|
'test' => 'value2',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class ClientCredentialsTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
private ClientCredentials $grant;
|
private ClientCredentials $grant;
|
||||||
|
|
||||||
public function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
$this->grant = new ClientCredentials();
|
$this->grant = new ClientCredentials();
|
||||||
}
|
}
|
||||||
|
|
@ -33,17 +33,17 @@ class ClientCredentialsTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals('client_credentials', $this->grant->__toString());
|
self::assertEquals('client_credentials', $this->grant->__toString());
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[
|
[
|
||||||
'code' => 'value',
|
'code' => 'value',
|
||||||
'option' => '2',
|
'option' => '2',
|
||||||
'test' => 'value2',
|
'test' => 'value2',
|
||||||
],
|
],
|
||||||
$this->grant->prepareRequestParamters(
|
$this->grant->prepareRequestParamters(
|
||||||
[
|
[
|
||||||
'code' => 'value'
|
'code' => 'value',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'option' => '2',
|
'option' => '2',
|
||||||
'test' => 'value2'
|
'test' => 'value2',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ class GrantAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
private GrantAbstract $grant;
|
private GrantAbstract $grant;
|
||||||
|
|
||||||
public function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
$this->grant = new class extends GrantAbstract {
|
$this->grant = new class() extends GrantAbstract {
|
||||||
protected function getName() : string
|
protected function getName() : string
|
||||||
{
|
{
|
||||||
return 'TestGrant';
|
return 'TestGrant';
|
||||||
|
|
@ -43,16 +43,16 @@ class GrantAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals('TestGrant', $this->grant->__toString());
|
self::assertEquals('TestGrant', $this->grant->__toString());
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[
|
[
|
||||||
'test' => 'value2',
|
'test' => 'value2',
|
||||||
'option' => '2'
|
'option' => '2',
|
||||||
],
|
],
|
||||||
$this->grant->prepareRequestParamters(
|
$this->grant->prepareRequestParamters(
|
||||||
[
|
[
|
||||||
'test' => 'value'
|
'test' => 'value',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'option' => '2',
|
'option' => '2',
|
||||||
'test' => 'value2'
|
'test' => 'value2',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -63,7 +63,7 @@ class GrantAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->expectException(\Exception::class);
|
$this->expectException(\Exception::class);
|
||||||
$this->grant->prepareRequestParamters(
|
$this->grant->prepareRequestParamters(
|
||||||
[
|
[
|
||||||
'something' => 'value'
|
'something' => 'value',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'option' => '2',
|
'option' => '2',
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ declare(strict_types=1);
|
||||||
namespace phpOMS\tests\Auth\OAuth2\Grant;
|
namespace phpOMS\tests\Auth\OAuth2\Grant;
|
||||||
|
|
||||||
use phpOMS\Auth\OAuth2\Grant\AuthorizationCode;
|
use phpOMS\Auth\OAuth2\Grant\AuthorizationCode;
|
||||||
use phpOMS\Auth\OAuth2\Grant\GrantFactory;
|
|
||||||
use phpOMS\Auth\OAuth2\Grant\GrantAbstract;
|
use phpOMS\Auth\OAuth2\Grant\GrantAbstract;
|
||||||
|
use phpOMS\Auth\OAuth2\Grant\GrantFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
|
@ -25,7 +25,7 @@ class GrantFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
private GrantFactory $factory;
|
private GrantFactory $factory;
|
||||||
|
|
||||||
public function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
$this->factory = new GrantFactory();
|
$this->factory = new GrantFactory();
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +38,7 @@ class GrantFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testGrantInputOutput() : void
|
public function testGrantInputOutput() : void
|
||||||
{
|
{
|
||||||
$grant = new class extends GrantAbstract {
|
$grant = new class() extends GrantAbstract {
|
||||||
protected function getName() : string
|
protected function getName() : string
|
||||||
{
|
{
|
||||||
return 'TestGrant';
|
return 'TestGrant';
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class PasswordTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
private Password $grant;
|
private Password $grant;
|
||||||
|
|
||||||
public function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
$this->grant = new Password();
|
$this->grant = new Password();
|
||||||
}
|
}
|
||||||
|
|
@ -35,15 +35,15 @@ class PasswordTest extends \PHPUnit\Framework\TestCase
|
||||||
[
|
[
|
||||||
'username' => 'value',
|
'username' => 'value',
|
||||||
'password' => '2',
|
'password' => '2',
|
||||||
'test' => 'value2',
|
'test' => 'value2',
|
||||||
],
|
],
|
||||||
$this->grant->prepareRequestParamters(
|
$this->grant->prepareRequestParamters(
|
||||||
[
|
[
|
||||||
'username' => 'value'
|
'username' => 'value',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'password' => '2',
|
'password' => '2',
|
||||||
'test' => 'value2'
|
'test' => 'value2',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -54,11 +54,11 @@ class PasswordTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->expectException(\Exception::class);
|
$this->expectException(\Exception::class);
|
||||||
$this->grant->prepareRequestParamters(
|
$this->grant->prepareRequestParamters(
|
||||||
[
|
[
|
||||||
'username' => 'value'
|
'username' => 'value',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'option' => '2',
|
'option' => '2',
|
||||||
'test' => 'value2'
|
'test' => 'value2',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class RefreshTokenTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
private RefreshToken $grant;
|
private RefreshToken $grant;
|
||||||
|
|
||||||
public function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
$this->grant = new RefreshToken();
|
$this->grant = new RefreshToken();
|
||||||
}
|
}
|
||||||
|
|
@ -34,16 +34,16 @@ class RefreshTokenTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[
|
[
|
||||||
'refresh_token' => 'value',
|
'refresh_token' => 'value',
|
||||||
'option' => '2',
|
'option' => '2',
|
||||||
'test' => 'value2',
|
'test' => 'value2',
|
||||||
],
|
],
|
||||||
$this->grant->prepareRequestParamters(
|
$this->grant->prepareRequestParamters(
|
||||||
[
|
[
|
||||||
'refresh_token' => 'value'
|
'refresh_token' => 'value',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'option' => '2',
|
'option' => '2',
|
||||||
'test' => 'value2'
|
'test' => 'value2',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -54,11 +54,11 @@ class RefreshTokenTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->expectException(\Exception::class);
|
$this->expectException(\Exception::class);
|
||||||
$this->grant->prepareRequestParamters(
|
$this->grant->prepareRequestParamters(
|
||||||
[
|
[
|
||||||
'test' => 'value'
|
'test' => 'value',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'option' => '2',
|
'option' => '2',
|
||||||
'test' => 'value2'
|
'test' => 'value2',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class HttpBasicAuthOptionProviderTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
private HttpBasicAuthOptionProvider $provider;
|
private HttpBasicAuthOptionProvider $provider;
|
||||||
|
|
||||||
public function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
$this->provider = new HttpBasicAuthOptionProvider();
|
$this->provider = new HttpBasicAuthOptionProvider();
|
||||||
}
|
}
|
||||||
|
|
@ -35,16 +35,16 @@ class HttpBasicAuthOptionProviderTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[
|
[
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'content-type' => MimeType::M_POST,
|
'content-type' => MimeType::M_POST,
|
||||||
'Authorization' => 'Basic aWQ6c2VjcmV0'
|
'Authorization' => 'Basic aWQ6c2VjcmV0',
|
||||||
],
|
],
|
||||||
'body' => 'para=test¶2=test2',
|
'body' => 'para=test¶2=test2',
|
||||||
],
|
],
|
||||||
$this->provider->getAccessTokenOptions(RequestMethod::POST, [
|
$this->provider->getAccessTokenOptions(RequestMethod::POST, [
|
||||||
'para' => 'test',
|
'para' => 'test',
|
||||||
'para2' => 'test2',
|
'para2' => 'test2',
|
||||||
'client_id' => 'id',
|
'client_id' => 'id',
|
||||||
'client_secret' => 'secret'
|
'client_secret' => 'secret',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -54,8 +54,8 @@ class HttpBasicAuthOptionProviderTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
self::assertEquals([],
|
self::assertEquals([],
|
||||||
$this->provider->getAccessTokenOptions(RequestMethod::POST, [
|
$this->provider->getAccessTokenOptions(RequestMethod::POST, [
|
||||||
'para' => 'test',
|
'para' => 'test',
|
||||||
'para2' => 'test2',
|
'para2' => 'test2',
|
||||||
'client_id' => 'id',
|
'client_id' => 'id',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class PostAuthOptionProviderTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
private PostAuthOptionProvider $provider;
|
private PostAuthOptionProvider $provider;
|
||||||
|
|
||||||
public function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
$this->provider = new PostAuthOptionProvider();
|
$this->provider = new PostAuthOptionProvider();
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,7 @@ class PostAuthOptionProviderTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[
|
[
|
||||||
'headers' => ['content-type' => MimeType::M_POST],
|
'headers' => ['content-type' => MimeType::M_POST],
|
||||||
'body' => 'para=test¶2=test2',
|
'body' => 'para=test¶2=test2',
|
||||||
],
|
],
|
||||||
$this->provider->getAccessTokenOptions(RequestMethod::POST, ['para' => 'test', 'para2' => 'test2'])
|
$this->provider->getAccessTokenOptions(RequestMethod::POST, ['para' => 'test', 'para2' => 'test2'])
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ class AccessTokenTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals('token', $token->getToken());
|
self::assertEquals('token', $token->getToken());
|
||||||
self::assertEquals('token', $token->__toString());
|
self::assertEquals('token', $token->__toString());
|
||||||
self::assertEquals(-1, $token->getExpires());
|
self::assertEquals(-1, $token->getExpires());
|
||||||
self::assertEquals(null, $token->getRefreshToken());
|
self::assertNull($token->getRefreshToken());
|
||||||
self::assertEquals(null, $token->getResourceOwnerId());
|
self::assertNull($token->getResourceOwnerId());
|
||||||
self::assertEquals(false, $token->hasExpired());
|
self::assertFalse($token->hasExpired());
|
||||||
self::assertEquals([], $token->getValues());
|
self::assertEquals([], $token->getValues());
|
||||||
self::assertEquals(['access_token' => 'token'], $token->jsonSerialize());
|
self::assertEquals(['access_token' => 'token'], $token->jsonSerialize());
|
||||||
}
|
}
|
||||||
|
|
@ -74,11 +74,11 @@ class AccessTokenTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testValuesInputOutput() : void
|
public function testValuesInputOutput() : void
|
||||||
{
|
{
|
||||||
$token = new AccessToken([
|
$token = new AccessToken([
|
||||||
'access_token' => 'token',
|
'access_token' => 'token',
|
||||||
'resource_owner_id' => 'owner',
|
'resource_owner_id' => 'owner',
|
||||||
'expires_in' => 10,
|
'expires_in' => 10,
|
||||||
'refresh_token' => 'refresh',
|
'refresh_token' => 'refresh',
|
||||||
'more' => 'values'
|
'more' => 'values',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
|
|
@ -92,20 +92,20 @@ class AccessTokenTest extends \PHPUnit\Framework\TestCase
|
||||||
$expires = \time() + 10;
|
$expires = \time() + 10;
|
||||||
|
|
||||||
$token = new AccessToken([
|
$token = new AccessToken([
|
||||||
'access_token' => 'token',
|
'access_token' => 'token',
|
||||||
'resource_owner_id' => 'owner',
|
'resource_owner_id' => 'owner',
|
||||||
'expires' => $expires,
|
'expires' => $expires,
|
||||||
'refresh_token' => 'refresh',
|
'refresh_token' => 'refresh',
|
||||||
'more' => 'values'
|
'more' => 'values',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[
|
[
|
||||||
'access_token' => 'token',
|
'access_token' => 'token',
|
||||||
'resource_owner_id' => 'owner',
|
'resource_owner_id' => 'owner',
|
||||||
'expires' => $expires,
|
'expires' => $expires,
|
||||||
'refresh_token' => 'refresh',
|
'refresh_token' => 'refresh',
|
||||||
'more' => 'values'
|
'more' => 'values',
|
||||||
],
|
],
|
||||||
$token->jsonSerialize()
|
$token->jsonSerialize()
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user