auth_test.rb 1.6 KB

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