You are here

class TfaTestSendSetup in Two-factor Authentication (TFA) 7.2

Class TfaTestSendSetup.

Hierarchy

Expanded class hierarchy of TfaTestSendSetup

1 string reference to 'TfaTestSendSetup'
TfaTestCase::testSetup in tests/tfa.test
Test the TfaSetup forms and process in tfa_test.module.

File

tests/includes/tfa_test.send.inc, line 120
Tests for the TfaSendPluginInterface.

View source
class TfaTestSendSetup extends TfaTestSend implements TfaSetupPluginInterface {

  /**
   * {@inheritdoc}
   */
  public function getSetupForm(array $form, array &$form_state) {
    if (empty($form_state['storage']['location'])) {
      $form['location'] = array(
        '#type' => 'textfield',
        '#title' => t('Location to send code'),
        '#required' => TRUE,
      );
      $form['actions']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
      );
    }
    else {

      // Include code entry form.
      $form = $this
        ->getForm($form, $form_state);
    }
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateSetupForm(array $form, array &$form_state) {
    if (!empty($form_state['values']['code']) && !$this
      ->validate($form_state['values']['code'])) {
      $this->errorMessages['code'] = t('Invalid code. Please try again.');
      return FALSE;
    }
    else {
      return TRUE;
    }
  }

  /**
   * {@inheritdoc}
   */
  public function submitSetupForm(array $form, array &$form_state) {
    if (!empty($form_state['values']['location'])) {

      // Code would be sent to $form_state['values']['location'].
      $form_state['storage']['location'] = $form_state['values']['location'];
      return FALSE;
    }
    else {

      // Replace test code.
      variable_set('tfa_test_code', $form_state['storage']['location']);

      // Location would be saved.
      return TRUE;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TfaBasePlugin::$code protected property TFA code.
TfaBasePlugin::$codeLength protected property Code Length.
TfaBasePlugin::$context protected property Context of current TFA process.
TfaBasePlugin::$encryptionKey protected property Encryption key.
TfaBasePlugin::$errorMessages protected property Error messages.
TfaBasePlugin::$isValid protected property Code is valid.
TfaBasePlugin::CRYPT_VERSION constant
TfaBasePlugin::decrypt protected function Decrypt a encrypted string.
TfaBasePlugin::decryptLegacyDataWithMcrypt protected function Decrypt using the deprecated Mcrypt extension.
TfaBasePlugin::decryptLegacyDataWithOpenSSL protected function Use OpenSSL to decrypt data that was originally encrypted with Mcrypt.
TfaBasePlugin::encrypt protected function Encrypt a plaintext string.
TfaBasePlugin::encryptWithMcrypt protected function Encrypt using the deprecated Mcrypt extension.
TfaBasePlugin::generate protected function Generate a random string of characters of length $this->codeLength.
TfaBasePlugin::getErrorMessages public function Get error messages suitable for form_set_error().
TfaBasePlugin::timingSafeEquals private function A timing safe equals comparison.
TfaBasePlugin::validate protected function Validate code.
TfaTestSend::begin public function TFA process begin. Overrides TfaSendPluginInterface::begin
TfaTestSend::floodIsAllowed public function Check resend flood.
TfaTestSend::getForm public function Get TFA process form from plugin. Overrides TfaValidationPluginInterface::getForm
TfaTestSend::ready public function Determine if the plugin can run for the current TFA context. Overrides TfaBasePlugin::ready
TfaTestSend::submitForm public function Submit form. Overrides TfaBasePlugin::submitForm
TfaTestSend::validateForm public function Validate form. Overrides TfaValidationPluginInterface::validateForm
TfaTestSend::__construct public function Constructor. Overrides TfaBasePlugin::__construct
TfaTestSendSetup::getSetupForm public function Get setup form. Overrides TfaSetupPluginInterface::getSetupForm
TfaTestSendSetup::submitSetupForm public function Submit setup form. Overrides TfaSetupPluginInterface::submitSetupForm
TfaTestSendSetup::validateSetupForm public function Validate setup form. Overrides TfaSetupPluginInterface::validateSetupForm