You are here

public function OAuth2ServerStorageTest::testCheckUserCredentials in OAuth2 Server 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/OAuth2ServerStorageTest.php \Drupal\Tests\oauth2_server\Functional\OAuth2ServerStorageTest::testCheckUserCredentials()

Check user credentials.

File

tests/src/Functional/OAuth2ServerStorageTest.php, line 250

Class

OAuth2ServerStorageTest
The OAuth2 Server admin test case.

Namespace

Drupal\Tests\oauth2_server\Functional

Code

public function testCheckUserCredentials() {
  $user = $this
    ->drupalCreateUser([
    'use oauth2 server',
  ]);

  // Correct credentials.
  $result = $this->storage
    ->checkUserCredentials($user->name->value, $user->pass_raw);
  $this
    ->assertTrue($result, 'Valid user credentials correctly detected.');

  // Invalid username.
  $result = $this->storage
    ->checkUserCredentials('fakeusername', $user->pass_raw);
  $this
    ->assertFalse($result, 'Invalid username correctly detected.');

  // Invalid password.
  $result = $this->storage
    ->checkUserCredentials($user->name->value, 'fakepass');
  $this
    ->assertFalse($result, 'Invalid password correctly detected');
}