mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-30 02:33:14 +05:30
Change code challenge and verifier to be constants in test
This commit is contained in:
parent
ce2662ece7
commit
b78c012796
@ -34,25 +34,13 @@ class AuthCodeGrantTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
protected $cryptStub;
|
protected $cryptStub;
|
||||||
|
|
||||||
/**
|
const CODE_VERIFIER = 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk';
|
||||||
* @var string Valid generated Code verifier.
|
|
||||||
*/
|
|
||||||
protected $codeVerifier;
|
|
||||||
|
|
||||||
/**
|
const CODE_CHALLENGE = 'E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM';
|
||||||
* @var string Valid generated code challenge using a proper code verifier.
|
|
||||||
*/
|
|
||||||
protected $codeChallenge;
|
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->cryptStub = new CryptTraitStub;
|
$this->cryptStub = new CryptTraitStub;
|
||||||
|
|
||||||
// [RFC 7636] Appendix B. Example for the S256 code_challenge_method
|
|
||||||
// $this->codeVerifier = 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk';
|
|
||||||
$this->codeVerifier = strtr(rtrim(base64_encode(random_bytes(32)), '='), '+/', '-_');
|
|
||||||
// $this->codeChallenge = 'E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM';
|
|
||||||
$this->codeChallenge = strtr(rtrim(base64_encode(hash('sha256', $this->codeVerifier, true)), '='), '+/', '-_');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIdentifier()
|
public function testGetIdentifier()
|
||||||
@ -201,7 +189,7 @@ class AuthCodeGrantTest extends TestCase
|
|||||||
'response_type' => 'code',
|
'response_type' => 'code',
|
||||||
'client_id' => 'foo',
|
'client_id' => 'foo',
|
||||||
'redirect_uri' => 'http://foo/bar',
|
'redirect_uri' => 'http://foo/bar',
|
||||||
'code_challenge' => $this->codeChallenge,
|
'code_challenge' => self::CODE_CHALLENGE,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -702,7 +690,7 @@ class AuthCodeGrantTest extends TestCase
|
|||||||
'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
'client_id' => 'foo',
|
'client_id' => 'foo',
|
||||||
'redirect_uri' => 'http://foo/bar',
|
'redirect_uri' => 'http://foo/bar',
|
||||||
'code_verifier' => $this->codeVerifier,
|
'code_verifier' => self::CODE_VERIFIER,
|
||||||
'code' => $this->cryptStub->doEncrypt(
|
'code' => $this->cryptStub->doEncrypt(
|
||||||
json_encode(
|
json_encode(
|
||||||
[
|
[
|
||||||
@ -712,7 +700,7 @@ class AuthCodeGrantTest extends TestCase
|
|||||||
'user_id' => 123,
|
'user_id' => 123,
|
||||||
'scopes' => ['foo'],
|
'scopes' => ['foo'],
|
||||||
'redirect_uri' => 'http://foo/bar',
|
'redirect_uri' => 'http://foo/bar',
|
||||||
'code_challenge' => $this->codeVerifier,
|
'code_challenge' => self::CODE_VERIFIER,
|
||||||
'code_challenge_method' => 'plain',
|
'code_challenge_method' => 'plain',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -773,7 +761,7 @@ class AuthCodeGrantTest extends TestCase
|
|||||||
'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
'client_id' => 'foo',
|
'client_id' => 'foo',
|
||||||
'redirect_uri' => 'http://foo/bar',
|
'redirect_uri' => 'http://foo/bar',
|
||||||
'code_verifier' => $this->codeVerifier,
|
'code_verifier' => self::CODE_VERIFIER,
|
||||||
'code' => $this->cryptStub->doEncrypt(
|
'code' => $this->cryptStub->doEncrypt(
|
||||||
json_encode(
|
json_encode(
|
||||||
[
|
[
|
||||||
@ -783,7 +771,7 @@ class AuthCodeGrantTest extends TestCase
|
|||||||
'user_id' => 123,
|
'user_id' => 123,
|
||||||
'scopes' => ['foo'],
|
'scopes' => ['foo'],
|
||||||
'redirect_uri' => 'http://foo/bar',
|
'redirect_uri' => 'http://foo/bar',
|
||||||
'code_challenge' => $this->codeChallenge,
|
'code_challenge' => self::CODE_CHALLENGE,
|
||||||
'code_challenge_method' => 'S256',
|
'code_challenge_method' => 'S256',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -1216,7 +1204,7 @@ class AuthCodeGrantTest extends TestCase
|
|||||||
'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
'client_id' => 'foo',
|
'client_id' => 'foo',
|
||||||
'redirect_uri' => 'http://foo/bar',
|
'redirect_uri' => 'http://foo/bar',
|
||||||
'code_verifier' => $this->codeVerifier,
|
'code_verifier' => self::CODE_VERIFIER,
|
||||||
'code' => $this->cryptStub->doEncrypt(
|
'code' => $this->cryptStub->doEncrypt(
|
||||||
json_encode(
|
json_encode(
|
||||||
[
|
[
|
||||||
@ -1370,7 +1358,7 @@ class AuthCodeGrantTest extends TestCase
|
|||||||
'user_id' => 123,
|
'user_id' => 123,
|
||||||
'scopes' => ['foo'],
|
'scopes' => ['foo'],
|
||||||
'redirect_uri' => 'http://foo/bar',
|
'redirect_uri' => 'http://foo/bar',
|
||||||
'code_challenge' => $this->codeChallenge,
|
'code_challenge' => self::CODE_CHALLENGE,
|
||||||
'code_challenge_method' => 'S256',
|
'code_challenge_method' => 'S256',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user