auth_test.rb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. require 'browser_test_helper'
  2. class AuthTest < TestCase
  3. def test_authentication
  4. @browser = browser_instance
  5. location(url: browser_url)
  6. match(
  7. css: '#login',
  8. value: 'username',
  9. )
  10. click(css: '#login button')
  11. sleep 4
  12. match(
  13. css: '#login',
  14. value: 'username',
  15. )
  16. # login with username/password
  17. login(
  18. username: 'nicole.braun@zammad.org',
  19. password: 'test',
  20. )
  21. tasks_close_all()
  22. # reload page
  23. reload()
  24. # check if cookie is temporarily
  25. watch_for(
  26. css: 'body',
  27. value: 'Overviews',
  28. )
  29. # verify session cookie
  30. cookie(
  31. name: '^_zammad.+?',
  32. value: '.+?',
  33. expires: '',
  34. )
  35. end
  36. def test_authentication_new_browser_without_permanent_cookie_no_session_should_be
  37. @browser = browser_instance
  38. location(url: browser_url)
  39. match(
  40. css: '#login',
  41. value: 'username',
  42. )
  43. end
  44. def test_new_browser_with_permanent_cookie_login
  45. @browser = browser_instance
  46. location(url: browser_url)
  47. # login with username/password
  48. login(
  49. username: 'nicole.braun@zammad.org',
  50. password: 'test',
  51. remember_me: true,
  52. )
  53. # check if cookie is temporarily
  54. watch_for(
  55. css: 'body',
  56. value: 'Overviews',
  57. )
  58. # verify session cookie
  59. cookie(
  60. name: '^_zammad.+?',
  61. value: '.+?',
  62. expires: '\d{4}-\d{1,2}-\d{1,2}.+?',
  63. )
  64. logout()
  65. # verify session cookie
  66. sleep 2
  67. cookie(
  68. name: '^_zammad.+?',
  69. value: '.+?',
  70. expires: '',
  71. )
  72. end
  73. end