public function GALoginHotpValidationPluginTest::setupUserHotp in Google Authenticator login 8
Setup the user's Validation plugin.
1 call to GALoginHotpValidationPluginTest::setupUserHotp()
- GALoginHotpValidationPluginTest::setUp in tests/
src/ Functional/ GALoginHotpValidationPluginTest.php
File
- tests/
src/ Functional/ GALoginHotpValidationPluginTest.php, line 80
Class
- GALoginHotpValidationPluginTest
- Class GALoginHotpValidationPluginTest.
Namespace
Drupal\Tests\ga_login\FunctionalCode
public function setupUserHotp() {
$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
->hotp(Encoding::base32DecodeUpper($this->seed), $this->validationPlugin
->getHotpCounter()),
];
$this
->drupalPostForm(NULL, $edit, 'Verify and save');
$this
->assertSession()
->linkExists('Disable TFA');
}