Class: Booth::Testing::Userland::RegistrationWithoutPasskey

Inherits:
IncorporationTestCase show all
Defined in:
lib/booth/testing/userland/registration_without_passkey.rb

Instance Method Summary collapse

Methods included from Shortcuts

#assert_logged_in, #assert_logged_out, #assert_userland_view, #create_and_onboard, #login_with_passkey, #register_new_passkey, #soft_reset_session, #virtual_authenticators, #visit_namespaced

Instance Method Details

#callObject



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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/booth/testing/userland/registration_without_passkey.rb', line 7

def call
  before_test&.call

  # Register normally

  visit_namespaced controller: :registrations, action: :new

  # Chrome Page
  return 'Skipping self-registration tests' if page.has_text?('HTTP ERROR 410')

  assert_userland_view controller: :registrations, step: :choose_username

  fill_in :username, with: 'alice'
  click_on :submit

  # Propagate login to other device

  code = nil
  using_session(:other_device) do
    # Login

    visit_namespaced controller: :logins, action: :new

    assert_userland_view controller: :logins, step: :enter_username

    fill_in :username, with: 'alice'
    click_on :submit

    assert_userland_view controller: :logins, step: :remote_session_available

    code = find('[data-booth="code"]').text
  end

  # Redeem remote code

  visit_namespaced controller: :remote_logins, action: :show

  # ------------- SIGNIFICANT TEST -----------------
  # After registering you are immediately logged in.
  # ------------------------------------------------

  assert_userland_view controller: :remote_logins, step: :remote_login

  fill_in :code, with: code
  click_on :submit

  assert_userland_view controller: :remote_logins, step: :remote_solved

  using_session(:other_device) do
    visit_namespaced controller: :webauths, action: :index

    # -------------------------- SIGNIFICANT TEST ---------------------------
    # You can remote-login even though you don't have any Authenticators yet.
    # -----------------------------------------------------------------------
    assert_userland_view controller: :webauths, step: :index
  end

  # Try to Login without having any Authenticators

  soft_reset_session

  visit_namespaced controller: :logins, action: :new

  assert_userland_view controller: :logins, step: :enter_username

  fill_in :username, with: 'alice'
  click_on :submit

  assert_userland_view controller: :logins, step: :remote_session_available

  click_on :skip

  # ------------------ SIGNIFICANT TEST --------------------
  # If you didn't register any Passkeys, you are locked out.
  # --------------------------------------------------------
  assert_userland_view controller: :logins, step: :no_authenticators

  visit_namespaced controller: :registrations, action: :new

  assert_userland_view controller: :registrations, step: :choose_username

  fill_in :username, with: 'alice'
  click_on :submit

  assert_userland_view controller: :registrations, step: :choose_username

  # ---------------- SIGNIFICANT TEST -------------------
  # You cannot register a username that is already taken.
  # -----------------------------------------------------
  assert_text 'username already exists'
end