You are here

public function OAuth2ServerStorageTestCase::testCheckUserCredentials in OAuth2 Server 7

File

tests/oauth2_server.test, line 1068
OAuth2 tests.

Class

OAuth2ServerStorageTestCase
Test \Drupal\oauth2_server\Storage.

Code

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

  // Correct credentials
  $result = $this->storage
    ->checkUserCredentials($user->name, $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, 'fakepass');
  $this
    ->assertFalse($result, 'Invalid password correctly detected');
}