Sha256: 17fe41b2cbee1cc17a56512d43e4494d069d27186bf8fad4cc00f03079b3d6f4

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'
require 'support/features/feature_helpers'

feature 'visitor has consecutive bad logins' do
  before do
    @user = create(:user)
    Authenticate.configuration.max_consecutive_bad_logins_allowed = 2
  end

  scenario 'less than max bad logins does not lock account' do
    sign_in_with @user.email, 'badpassword'
    sign_in_with @user.email, 'badpassword'
    sign_in_with @user.email, @user.password

    expect_user_to_be_signed_in
  end

  scenario 'exceeds max bad logins and locks account' do
    sign_in_with @user.email, 'badpassword'
    sign_in_with @user.email, 'badpassword'
    sign_in_with @user.email, 'badpassword'

    expect_locked_account
    expect_lockout_time_to_be_displayed
    expect_user_to_be_signed_out
  end

  scenario 'user locks account, waits for lock to expire, logs in successfully' do
    sign_in_with @user.email, 'badpassword'
    sign_in_with @user.email, 'badpassword'
    sign_in_with @user.email, 'badpassword'

    Timecop.travel 50.minutes do
      sign_in_with @user.email, @user.password
      expect_user_to_be_signed_in
    end
  end
end

def expect_locked_account
  expect(page).to have_content 'Your account is locked'
end

def expect_lockout_time_to_be_displayed
  expect(page).to have_content '10 minutes'
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
authenticate-0.7.1 spec/features/brute_force_spec.rb
authenticate-0.7.0 spec/features/brute_force_spec.rb
authenticate-0.6.1 spec/features/brute_force_spec.rb
authenticate-0.6.0 spec/features/brute_force_spec.rb
authenticate-0.5.0 spec/features/brute_force_spec.rb
authenticate-0.4.0 spec/features/brute_force_spec.rb