public function GALoginTotpValidationPluginTest::setupUserTotp in Google Authenticator login 8
Setup the user's Validation plugin.
1 call to GALoginTotpValidationPluginTest::setupUserTotp()
- GALoginTotpValidationPluginTest::setUp in tests/
src/ Functional/ GALoginTotpValidationPluginTest.php
File
- tests/
src/ Functional/ GALoginTotpValidationPluginTest.php, line 80
Class
- GALoginTotpValidationPluginTest
- Class GALoginTotpValidationPluginTest.
Namespace
Drupal\Tests\ga_login\FunctionalCode
public function setupUserTotp() {
$edit = [
'current_pass' => $this->userAccount->passRaw,
];
$this
->drupalPostForm('user/' . $this->userAccount
->id() . '/security/tfa/' . $this->validationPluginId, $edit, 'Confirm');
// Fetch seed.
$result = $this
->xpath('//input[@name="seed"]');
if (empty($result)) {
$this
->fail('Unable to extract seed from page. Aborting test.');
return;
}
$this->seed = $result[0]
->getValue();
$this->validationPlugin
->storeSeed($this->seed);
$edit = [
'code' => $this->validationPlugin->auth->otp
->totp(Encoding::base32DecodeUpper($this->seed)),
];
$this
->drupalPostForm(NULL, $edit, 'Verify and save');
$this
->assertSession()
->linkExists('Disable TFA');
}