You are here

public function TfaTestCase::testLoginPlugins in Two-factor Authentication (TFA) 7.2

Test login plugins.

File

tests/tfa.test, line 257
Drupal test cases for TFA.

Class

TfaTestCase
Tests the functionality of the TFA module.

Code

public function testLoginPlugins() {
  variable_set('tfa_validate_plugin', 'tfa_test_send');

  // Enable login plugin.
  variable_set('tfa_login_plugins', array(
    'tfa_test_login',
  ));
  $account = $this->web_user;
  $edit = array(
    'name' => $account->name,
    'pass' => $account->pass_raw,
  );
  $this
    ->drupalPost('user/login', $edit, 'Log in');
  $this
    ->assertNoLink('Log out', 'Not authenticated');

  // Set TfaTestLogin to allow login.
  variable_set('tfa_test_login_uid', (string) $account->uid);
  $edit = array(
    'name' => $account->name,
    'pass' => $account->pass_raw,
  );
  $this
    ->drupalPost('user/login', $edit, 'Log in');
  $this
    ->assertLink('Log out', 0, 'Authenticated');
  $this
    ->assertNoFieldById('edit-code', '', 'The send code input does not appear');
}