Class: Booth::Test::Userland::Onboardings::Otp

Inherits:
Object
  • Object
show all
Includes:
MethodObject, Helpers
Defined in:
lib/booth/test/userland/onboardings/otp.rb

Instance Method Summary collapse

Methods included from Helpers

#assert_logged_in, #assert_logged_out, #assert_userland_partial, #create_virtual_authenticator, #extract_otp_secret_key_and_generate_code, #setup_virtual_authenticator_environment, #soft_reset_session

Methods included from MethodObject

included

Instance Method Details

#callObject



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
# File 'lib/booth/test/userland/onboardings/otp.rb', line 14

def call
  # Setup

  credential = ::Booth::Models::Credential.create!(
    username: 'alice',
    password: 'qwrasfyxv',
    scope:,
    mode: :username_password_and_otp,
    allowed_modes: %i[username_password_and_otp username_and_webauth]
  )

  onboarding = ::Booth::Models::Onboarding.create!(
    credential_id: credential.id,
    mode: :first_time
  )

  # Onboarding

  page.visit show_onboarding_path.sub('ID', onboarding.secret_key)

  assert_userland_partial controller: :onboarding, step: :choose_mode

  page.click_on :choose_username_password_and_otp

  assert_userland_partial controller: :onboarding, step: :choose_password

  page.fill_in :password, with: 'qwrasfyxv'
  page.click_on :submit

  assert_userland_partial controller: :onboarding, step: :confirm_password

  page.fill_in :password, with: 'qwrasfyxv'
  page.click_on :submit

  assert_userland_partial controller: :onboarding, step: :register_otp

  page.click_on :confirm

  assert_userland_partial controller: :onboarding, step: :confirm_otp

  page.fill_in :code, with: onboarding.reload.otp_code
  page.click_on :submit

  assert_logged_in credential:
end