Commit e194ecf0 authored by Project Update Bot's avatar Project Update Bot Committed by Joao Ventura
Browse files

Issue #3299305 by Project Update Bot, jcnventura: Automated Drupal 10 compatibility fixes

parent b69385a1
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -49,9 +49,10 @@ class TfaLoginTest extends TfaTestBase {
    $edit = [
      'tfa_required_roles[' . $web_user_roles[0] . ']' => TRUE,
    ];
    $this->drupalPostForm('admin/config/people/tfa', $edit, 'Save configuration');
    $this->drupalGet('admin/config/people/tfa');
    $this->submitForm($edit, 'Save configuration');
    $assert_session->statusCodeEquals(200);
    $this->assertText('The configuration options have been saved.');
    $this->assertSession()->pageTextContains('The configuration options have been saved.');

    // Check that tfa is presented.
    $this->drupalLogout();
@@ -59,7 +60,8 @@ class TfaLoginTest extends TfaTestBase {
      'name' => $this->webUser->getAccountName(),
      'pass' => $this->webUser->passRaw,
    ];
    $this->drupalPostForm('user/login', $edit, 'Log in');
    $this->drupalGet('user/login');
    $this->submitForm($edit, 'Log in');
    $assert_session->statusCodeEquals(200);
    $assert_session->addressMatches('/\/tfa\/' . $this->webUser->id() . '/');

@@ -73,9 +75,10 @@ class TfaLoginTest extends TfaTestBase {
      $edit['tfa_required_roles[' . $role_id . ']'] = FALSE;
    }
    $edit['tfa_required_roles[authenticated]'] = FALSE;
    $this->drupalPostForm('admin/config/people/tfa', $edit, 'Save configuration');
    $this->drupalGet('admin/config/people/tfa');
    $this->submitForm($edit, 'Save configuration');
    $assert_session->statusCodeEquals(200);
    $this->assertText('The configuration options have been saved.');
    $this->assertSession()->pageTextContains('The configuration options have been saved.');
    // Enable tfa for a single user.
    $this->drupalLogin($this->webUser);
    $this->drupalGet('user/' . $this->webUser->id() . '/security/tfa');
@@ -104,7 +107,8 @@ class TfaLoginTest extends TfaTestBase {
      'name' => $this->webUser->getAccountName(),
      'pass' => $this->webUser->passRaw,
    ];
    $this->drupalPostForm('user/login', $edit, 'Log in');
    $this->drupalGet('user/login');
    $this->submitForm($edit, 'Log in');
    $assert_session->statusCodeEquals(200);
    $assert_session->addressMatches('/\/tfa\/' . $this->webUser->id() . '/');
  }
+6 −4
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ class TfaRecoveryCodePluginTest extends TfaTestBase {

    // Make sure codes were saved to the account.
    $codes = $this->validationPlugin->getCodes();
    $assert->assert(!empty($codes), 'No codes saved to the account data.');
    $this->assertTrue(!empty($codes), 'No codes saved to the account data.');

    // Now the user should be able to see their existing codes. Let's test that.
    $assert->linkExists('Show codes');
@@ -155,7 +155,8 @@ class TfaRecoveryCodePluginTest extends TfaTestBase {
      'name' => $this->userAccount->getAccountName(),
      'pass' => $this->userAccount->passRaw,
    ];
    $this->drupalPostForm('user/login', $edit, 'Log in');
    $this->drupalGet('user/login');
    $this->submitForm($edit, 'Log in');
    $assert->statusCodeEquals(200);
    $assert->pageTextContains('Enter one of your recovery codes');

@@ -170,7 +171,7 @@ class TfaRecoveryCodePluginTest extends TfaTestBase {
    $this->submitForm($edit, 'Verify');
    $assert->statusCodeEquals(200);
    $assert->pageTextContains($this->userAccount->getDisplayName());
    $assert->assert($this->userAccount->isAuthenticated(), 'User is logged in.');
    $this->assertTrue($this->userAccount->isAuthenticated(), 'User is logged in.');

    // Try replay attack with a valid code that has already been used.
    $this->drupalLogout();
@@ -178,7 +179,8 @@ class TfaRecoveryCodePluginTest extends TfaTestBase {
      'name' => $this->userAccount->getAccountName(),
      'pass' => $this->userAccount->passRaw,
    ];
    $this->drupalPostForm('user/login', $edit, 'Log in');
    $this->drupalGet('user/login');
    $this->submitForm($edit, 'Log in');
    $assert->statusCodeEquals(200);
    $assert->pageTextContains('Enter one of your recovery codes');

+1 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ abstract class TfaTestBase extends BrowserTestBase {
    $select_field_id = 'edit-tfa-validate';
    $option_field = $assert->optionExists($select_field_id, $validation_plugin_id);
    $result = $option_field->hasAttribute('selected');
    $assert->assert($result, "Option {$validation_plugin_id} for field {$select_field_id} is selected.");
    $this->assertTrue($result, "Option {$validation_plugin_id} for field {$select_field_id} is selected.");
  }

}
+2 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\Tests\tfa\Unit\Plugin\TfaValidation;

use Prophecy\PhpUnit\ProphecyTrait;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\Core\DependencyInjection\ContainerBuilder;
@@ -19,6 +20,7 @@ use Drupal\user\UserDataInterface;
 * @group tfa
 */
class TfaRecoveryCodeTest extends UnitTestCase {
  use ProphecyTrait;

  /**
   * Mocked user data service.
+2 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\Tests\tfa\Unit;

use Prophecy\PhpUnit\ProphecyTrait;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\Tests\UnitTestCase;
@@ -19,6 +20,7 @@ use Symfony\Component\HttpFoundation\Request;
 * @group tfa
 */
class TfaContextTest extends UnitTestCase {
  use ProphecyTrait;

  /**
   * Validation plugin manager.