mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[feature/oauth] Add tests for the new token methods
PHPBB3-11673
This commit is contained in:
parent
9eb4d55e82
commit
17d774af8e
1 changed files with 40 additions and 0 deletions
|
@ -78,6 +78,32 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
|
|||
$this->assertEquals($token, $stored_token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider retrieveAccessToken_data
|
||||
*/
|
||||
public function test_retrieve_access_token_by_session($cache_token, $db_token, $exception)
|
||||
{
|
||||
if ($db_token)
|
||||
{
|
||||
$temp_storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->service_name, $this->token_storage_table);
|
||||
$temp_storage->storeAccessToken($db_token);
|
||||
unset($temp_storage);
|
||||
$token = $db_token;
|
||||
}
|
||||
|
||||
if ($cache_token)
|
||||
{
|
||||
$this->token_storage->storeAccessToken($cache_token);
|
||||
$token = $cache_token;
|
||||
}
|
||||
|
||||
$this->setExpectedException($exception);
|
||||
|
||||
$stored_token = $this->token_storage->retrieve_access_token_by_session();
|
||||
$this->assertEquals($token, $stored_token);
|
||||
}
|
||||
|
||||
|
||||
public function test_storeAccessToken()
|
||||
{
|
||||
$token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param') );
|
||||
|
@ -116,6 +142,20 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
|
|||
$this->assertEquals($expected, $has_access_token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider hasAccessToken_data
|
||||
*/
|
||||
public function test_has_access_token_by_session($token, $expected)
|
||||
{
|
||||
if ($token)
|
||||
{
|
||||
$this->token_storage->storeAccessToken($token);
|
||||
}
|
||||
|
||||
$has_access_token = $this->token_storage->has_access_token_by_session();
|
||||
$this->assertEquals($expected, $has_access_token);
|
||||
}
|
||||
|
||||
public function test_clearToken()
|
||||
{
|
||||
$token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param') );
|
||||
|
|
Loading…
Add table
Reference in a new issue