summaryrefslogtreecommitdiff
path: root/test/integration/browser/password_validation_test.rb
blob: 51fcc5d77715f631acd38ccb83429ee1aedbf8e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'test_helper'

class PasswordValidationTest < BrowserIntegrationTest

  test "password confirmation is validated" do
    username ||= "test_#{SecureRandom.urlsafe_base64}".downcase
    password ||= SecureRandom.base64
    visit '/signup'
    fill_in 'Username', with: username
    fill_in 'Password', with: password
    fill_in 'Password confirmation', with: password + "-typo"
    click_on 'Sign Up'
    assert page.has_content? "does not match."
    assert_equal '/signup', current_path
    assert page.has_selector? ".error #srp_password_confirmation"
  end

  test "password needs to be at least 8 chars long" do
    username ||= "test_#{SecureRandom.urlsafe_base64}".downcase
    password ||= SecureRandom.base64[0,7]
    visit '/signup'
    fill_in 'Username', with: username
    fill_in 'Password', with: password
    fill_in 'Password confirmation', with: password
    click_on 'Sign Up'
    assert page.has_content? "needs to be at least 8 characters long"
    assert_equal '/signup', current_path
    assert page.has_selector? ".error #srp_password"
  end
end