You are here

public function TfaRecoveryCodePluginTest::setUp in Two-factor Authentication (TFA) 8

Overrides TfaTestBase::setUp

File

tests/src/Functional/TfaRecoveryCodePluginTest.php, line 64

Class

TfaRecoveryCodePluginTest
Class TfaRecoveryCodeSetupPluginTest.

Namespace

Drupal\Tests\tfa\Functional

Code

public function setUp() : void {
  parent::setUp();
  $config = $this
    ->config('tfa.settings');
  $config
    ->set('enabled', TRUE)
    ->set('default_validation_plugin', $this->validationPluginId)
    ->set('allowed_validation_plugins', [
    $this->validationPluginId => $this->validationPluginId,
  ])
    ->set('encryption', $this->encryptionProfile
    ->id())
    ->set('required_roles', [
    'authenticated' => 'authenticated',
  ])
    ->set('validation_plugin_settings', [
    $this->validationPluginId => [
      'recovery_codes_amount' => 10,
    ],
  ])
    ->save();
  $permissions = [
    'setup own tfa',
    'disable own tfa',
  ];
  $this->userAccount = $this
    ->createUser($permissions);
  $this->tfaSetupManager = \Drupal::service('plugin.manager.tfa.setup');
  $this->setupPlugin = $this->tfaSetupManager
    ->createInstance($this->validationPluginId . '_setup', [
    'uid' => $this->userAccount
      ->id(),
  ]);
  $this->tfaValidationManager = \Drupal::service('plugin.manager.tfa.validation');
  $this->validationPlugin = $this->tfaValidationManager
    ->createInstance($this->validationPluginId, [
    'uid' => $this->userAccount
      ->id(),
  ]);
}