mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/oauth] Token storage test set_user_id()
PHPBB3-11673
This commit is contained in:
parent
229d4f2fd6
commit
e2ea641cc4
1 changed files with 20 additions and 6 deletions
|
@ -88,12 +88,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
|
||||||
$this->assertEquals( 'param', $extraParams['extra'] );
|
$this->assertEquals( 'param', $extraParams['extra'] );
|
||||||
$this->assertEquals( 'access', $this->token_storage->retrieveAccessToken()->getAccessToken() );
|
$this->assertEquals( 'access', $this->token_storage->retrieveAccessToken()->getAccessToken() );
|
||||||
|
|
||||||
// Test that the token is stored in the database
|
$row = $this->get_token_row_by_session_id($this->session_id);
|
||||||
$sql = 'SELECT oauth_token FROM phpbb_oauth_tokens
|
|
||||||
WHERE session_id = \'' . $this->session_id . '\'';
|
|
||||||
$result = $this->db->sql_query($sql);
|
|
||||||
$row = $this->db->sql_fetchrow($result);
|
|
||||||
$this->db->sql_freeresult($result);
|
|
||||||
|
|
||||||
// The token is serialized before stored in the database
|
// The token is serialized before stored in the database
|
||||||
$this->assertEquals(serialize($token), $row['oauth_token']);
|
$this->assertEquals(serialize($token), $row['oauth_token']);
|
||||||
|
@ -111,6 +106,25 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
|
||||||
|
|
||||||
public function test_set_user_id()
|
public function test_set_user_id()
|
||||||
{
|
{
|
||||||
|
$token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param') );
|
||||||
|
$this->token_storage->storeAccessToken($token);
|
||||||
|
|
||||||
|
$new_user_id = ANONYMOUS + 1;
|
||||||
|
$this->token_storage->set_user_id($new_user_id);
|
||||||
|
|
||||||
|
$row = $this->get_token_row_by_session_id($this->session_id);
|
||||||
|
$this->assertEquals($new_user_id, $row['user_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function get_token_row_by_session_id($session_id)
|
||||||
|
{
|
||||||
|
// Test that the token is stored in the database
|
||||||
|
$sql = 'SELECT * FROM phpbb_oauth_tokens
|
||||||
|
WHERE session_id = \'' . $session_id . '\'';
|
||||||
|
$result = $this->db->sql_query($sql);
|
||||||
|
$row = $this->db->sql_fetchrow($result);
|
||||||
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
|
return $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue