Class: Booth::Testing::Userland::SudoWebauth

Inherits:
IncorporationTestCase show all
Defined in:
lib/booth/testing/userland/sudo_webauth.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
# File 'lib/booth/testing/userland/sudo_webauth.rb', line 7

def call
  before_test&.call

  create_and_onboard(username: 'alice')
  virtual_authenticators.create
  register_new_passkey(username: 'alice')

  # Visit webauths index with fresh sudo
  visit_namespaced controller: :webauths, action: :index
  assert_userland_view controller: :webauths, step: :index

  # Time travel to expire sudo (default interaction_timeout is 20 minutes)
  travel 21.minutes

  # Visit webauths index again - should require sudo
  visit_namespaced controller: :webauths, action: :index
  assert_userland_view controller: :webauths, step: :sudo

  # Re-authenticate with hardware key to restore sudo
  click_on :authenticate

  # After successful sudo, user sees the index again
  assert_userland_view controller: :webauths, step: :index
end