Contents

Authenticate Admin Users With TOTP 2FA

@admin

Scenario: Admins can enable TOTP 2FA

  • Given the following admin exists
    loginpasswordemail
    admintestpasswordadmin@example.com
  • And I am logged in as admin "admin" with password "testpassword"
  • When I follow "Set up two-step verification with an authenticator app"
  • Then I should see "Confirm Password"
  • When I fill in "Admin password" with "testpassword"
  • And I press "Continue"
  • Then I should see "Set Up Two-Step Verification"
  • When I fill in a valid TOTP two-step verification code for admin "admin"
  • And I press "Enable Two-Step Verification"
  • Then I should see "Successfully enabled two-step verification; please make note of your backup codes."
  • And I should see "Finish"
  • When I follow "Finish"
  • Then I should see "Account Settings"

Scenario: Admins cannot enable TOTP 2FA if they provide a wrong password

  • Given the following admin exists
    loginpasswordemail
    admintestpasswordadmin@example.com
  • And I am logged in as admin "admin" with password "testpassword"
  • When I follow "Set up two-step verification with an authenticator app"
  • Then I should see "Confirm Password"
  • When I fill in "Admin password" with "wrongpassword"
  • And I press "Continue"
  • Then I should see "Your password was incorrect."
  • And I should not see "Successfully enabled two-step verification, please make note of your backup codes."
  • And I should not see "Finish"

Scenario: Admins cannot enable TOTP 2FA if they provide a wrong code

  • Given the following admin exists
    loginpasswordemail
    admintestpasswordadmin@example.com
  • And I am logged in as admin "admin" with password "testpassword"
  • When I follow "Set up two-step verification with an authenticator app"
  • Then I should see "Confirm Password"
  • When I fill in "Admin password" with "testpassword"
  • And I press "Continue"
  • Then I should see "Set Up Two-Step Verification"
  • When I fill in "6-digit code" with "000000"
  • And I press "Enable Two-Step Verification"
  • Then I should see "Incorrect verification code. Your code may have expired, or you may need to set up your authenticator app again."
  • And I should not see "Successfully enabled two-step verification, please make note of your backup codes."
  • And I should not see "Finish"

Scenario: Admins can disable TOTP 2FA

  • Given the following admin exists
    loginpasswordemail
    admintestpasswordadmin@example.com
  • And I am logged in as admin "admin" with password "testpassword"
  • And admin "admin" has TOTP 2FA enabled
  • When I follow "Hi, admin!"
  • And I follow "Disable two-step verification"
  • Then I should see "Disable Two-Step Verification"
  • When I fill in "Admin password" with "testpassword"
  • And I press "Disable"
  • Then I should see "Successfully disabled two-step verification."

Scenario: Admins cannot disable TOTP 2FA if they provide a wrong password

  • Given the following admin exists
    loginpasswordemail
    admintestpasswordadmin@example.com
  • And I am logged in as admin "admin" with password "testpassword"
  • And admin "admin" has TOTP 2FA enabled
  • When I follow "Hi, admin!"
  • And I follow "Disable two-step verification"
  • Then I should see "Disable Two-Step Verification"
  • When I fill in "Admin password" with "wrongpassword"
  • And I press "Disable"
  • Then I should see "Your password was incorrect."
  • And I should not see "Successfully disabled two-step verification."

Scenario: Admins can regenerate TOTP backup codes

  • Given the following admin exists
    loginpasswordemail
    admintestpasswordadmin@example.com
  • And I am logged in as admin "admin" with password "testpassword"
  • And admin "admin" has TOTP 2FA enabled
  • When I follow "Hi, admin!"
  • And I follow "Regenerate backup codes"
  • Then I should see "Two-Step Verification Backup Codes"
  • When I follow "Finish"
  • Then I should see "Account Settings"

Scenario: Admins with TOTP 2FA enabled can log in after providing their code

  • Given the following admin exists
    loginpasswordemail
    admintestpasswordadmin@example.com
  • And admin "admin" has TOTP 2FA enabled
  • When I go to the admin login page
  • And I fill in "Admin username" with "admin"
  • And I fill in "Admin password" with "testpassword"
  • And I press "Log In as Admin"
  • Then I should see "Two-Step Verification"
  • When I fill in a valid TOTP two-step verification code for admin "admin"
  • And I press "Log In as Admin"
  • Then I should see "Successfully logged in"

Scenario: Admins with TOTP 2FA enabled can log in after providing their recovery code

  • Given the following admin exists
    loginpasswordemail
    admintestpasswordadmin@example.com
  • And admin "admin" has TOTP 2FA enabled
  • When I go to the admin login page
  • And I fill in "Admin username" with "admin"
  • And I fill in "Admin password" with "testpassword"
  • And I press "Log In as Admin"
  • Then I should see "Two-Step Verification"
  • When I fill in a valid TOTP recovery code for admin "admin"
  • And I press "Log In as Admin"
  • Then I should see "Successfully logged in"

Scenario: Admins with TOTP 2FA enabled cannot log in with a used recovery code

  • Given the following admin exists
    loginpasswordemail
    admintestpasswordadmin@example.com
  • And admin "admin" has TOTP 2FA enabled
  • When I go to the admin login page
  • And I fill in "Admin username" with "admin"
  • And I fill in "Admin password" with "testpassword"
  • And I press "Log In as Admin"
  • Then I should see "Two-Step Verification"
  • When I fill in a valid TOTP recovery code for admin "admin"
  • And I press "Log In as Admin"
  • Then I should see "Successfully logged in"
  • When I log out
  • And I go to the admin login page
  • And I fill in "Admin username" with "admin"
  • And I fill in "Admin password" with "testpassword"
  • And I press "Log In as Admin"
  • And I fill in a used TOTP recovery code
  • And I press "Log In as Admin"
  • Then I should see "Incorrect two-step verification code."
  • And I should not see "Successfully logged in"

Scenario: Admins with TOTP 2FA enabled should not be prompted for their code if they enter invalid credentials

  • Given the following admin exists
    loginpasswordemail
    admintestpasswordadmin@example.com
  • And admin "admin" has TOTP 2FA enabled
  • When I go to the admin login page
  • And I fill in "Admin username" with "admin"
  • And I fill in "Admin password" with "wrongpassword"
  • And I press "Log In as Admin"
  • Then I should not see "Two-Step Verification"
  • And I should see "The password or admin username you entered doesn't match our records."

Scenario: Admins with TOTP 2FA enabled cannot log in after providing a wrong code

  • Given the following admin exists
    loginpasswordemail
    admintestpasswordadmin@example.com
  • And admin "admin" has TOTP 2FA enabled
  • When I go to the admin login page
  • And I fill in "Admin username" with "admin"
  • And I fill in "Admin password" with "testpassword"
  • And I press "Log In as Admin"
  • Then I should see "Two-Step Verification"
  • When I fill in "6-digit verification code" with "000000"
  • And I press "Log In as Admin"
  • Then I should see "Incorrect two-step verification code."
  • And I should not see "Successfully logged in"

Source: features/admins/authenticate_admins_with_totp.feature at commit f09caa86, Otwarchive (GPL license).