Class: Booth::Testing::Userland::RegistrationWithPasskey

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

Instance Method Summary collapse

Methods included from Shortcuts

#assert_logged_in, #assert_logged_out, #assert_userland_view, #clear_cookies, #create_and_onboard, #decrypt_session_cookie, #login_with_passkey, #register_new_passkey, #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
# File 'lib/booth/testing/userland/registration_with_passkey.rb', line 7

def call
  before_test&.call

  # Register

  begin
    # Non-headless Chrome may cause Exception if HTTP status is 4xx
    visit_namespaced controller: :registrations, action: :new
  rescue Playwright::Error => e
    raise unless e.message.include?('ERR_HTTP_RESPONSE_CODE_FAILURE')
  end

  return log { 'Skipping self-registration tests' } if page.status_code == 410

  virtual_authenticators.create

  assert_userland_view controller: :registrations, step: :choose_username

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

  visit_namespaced controller: :webauths, action: :new

  assert_userland_view controller: :webauths, step: :register

  click_on :register

  assert_userland_view controller: :webauths, step: :choose_nickname

  fill_in :nickname, with: 'My Yubikey'
  click_on :submit

  assert_userland_view controller: :webauths, step: :confirm
  click_on :test

  # ------------ SIGNIFICANT TEST --------------
  # Registering a Passkey via the Browser works.
  # --------------------------------------------
  assert_userland_view controller: :webauths, step: :completed

  clear_cookies

  # Login

  visit_namespaced controller: :logins, action: :new

  assert_userland_view controller: :logins, step: :enter_username

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

  # --------------------- SIGNIFICANT TEST -------------------------
  # Without actually logging out, a Session is still regarded alive.
  # ----------------------------------------------------------------
  assert_userland_view controller: :logins, step: :remote_session_available

  click_on :skip

  assert_userland_view controller: :logins, step: :enter_webauth

  # --------------------- SIGNIFICANT TEST --------------------------
  # After registration and adding a Passkey, you can use it to login.
  # -----------------------------------------------------------------
  click_on :authenticate

  assert_logged_in username: 'alice'

  # Try to register when already logged in

  visit_namespaced controller: :registrations, action: :new

  assert_userland_view controller: :registrations, step: :already_logged_in

  visit_namespaced controller: :webauths, action: :new

  assert_userland_view controller: :webauths, step: :register

  click_on :register

  assert_userland_view controller: :webauths, step: :register

  # --------------------- SIGNIFICANT TEST ---------------
  # A hardware device cannot be registered multiple times.
  # ------------------------------------------------------
  assert_text 'already registered with the relying party'
end