admin_password_auth_spec.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Desktop > Admin Password Auth', app: :desktop_view, authenticated_as: false, type: :system do
  4. before do
  5. Setting.set('user_show_password_login', false)
  6. Setting.set('auth_github', true)
  7. end
  8. it 'Shows the regular password login after admin password auth request was sent' do
  9. visit '/login', skip_waiting: true
  10. expect(page).to have_no_field 'login'
  11. expect(page).to have_no_field 'password'
  12. click_on 'Request the password login here.'
  13. expect(page).to have_text 'Username'
  14. fill_in 'login', with: 'admin@example.com'
  15. click_on 'Submit'
  16. expect(page).to have_text 'Admin password login instructions were sent'
  17. token = Token.last
  18. visit "/login?token=#{token.token}"
  19. expect(page).to have_text 'The token is valid. You are now able to login via password once.'
  20. expect(page).to have_field 'login', disabled: :all
  21. expect(page).to have_field 'password'
  22. end
  23. end