Module: Booth::Testing::Userland::SessionsManageBehavior

Includes:
Logging
Included in:
SessionsRevokeAllOthers, SessionsRevokeOne
Defined in:
lib/booth/testing/userland/sessions_manage_behavior.rb

Instance Method Summary collapse

Instance Method Details

#run(button_name:, template:) ⇒ Object



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
# File 'lib/booth/testing/userland/sessions_manage_behavior.rb', line 9

def run(button_name:, template:)
  before_test&.call

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

  using_session(:"second_browser_#{button_name}") do
    virtual_authenticators.clone_from_other_session
    (username: 'alice')

    visit_namespaced controller: :sessions, action: :index

    assert_userland_view controller: :sessions, step: :index
    click_on button_name

    # ----------------- SIGNIFICANT TEST -------------------
    # Revoking another sessions keeps the current one alive.
    # ------------------------------------------------------
    assert_logged_in username: 'alice'
  end

  visit current_path

  # ----------- SIGNIFICANT TEST ---------------
  # A revoked session is not logged in any more.
  # --------------------------------------------
  assert_logged_out

  # Login on first device again and revoke all others
  virtual_authenticators.refresh_from_other_session
  (username: 'alice')

  visit_namespaced controller: :sessions, action: :index

  assert_userland_view controller: :sessions, step: :index
  travel 21.minutes
  visit_namespaced controller: :sessions, action: :index

  assert_userland_view controller: :sessions, step: :index
  click_on button_name

  assert_userland_view controller: :sessions, step: template
  click_on :authenticate

  assert_userland_view controller: :sessions, step: :index

  using_session(:"second_browser_#{button_name}") do
    visit_namespaced controller: :sessions, action: :index

    # ----------- SIGNIFICANT TEST ---------------
    # A revoked session is not logged in any more.
    # --------------------------------------------
    assert_logged_out
  end
end