auth_customer_test.rb 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class AuthCustomerTest < TestCase
  4. def test_authentication
  5. tests = [
  6. {
  7. :name => 'start',
  8. :instance => browser_instance,
  9. :url => browser_url,
  10. :action => [
  11. {
  12. :execute => 'check',
  13. :css => '#login',
  14. :result => true,
  15. },
  16. {
  17. :execute => 'check',
  18. :css => '#login button',
  19. :result => true,
  20. },
  21. {
  22. :execute => 'click',
  23. :css => '#login button',
  24. },
  25. {
  26. :execute => 'wait',
  27. :value => 5,
  28. },
  29. {
  30. :execute => 'check',
  31. :css => '#login',
  32. :result => true,
  33. },
  34. ],
  35. },
  36. {
  37. :name => 'login',
  38. :action => [
  39. {
  40. :execute => 'check',
  41. :css => '#login',
  42. :result => true,
  43. },
  44. {
  45. :execute => 'set',
  46. :css => 'input[name="username"]',
  47. :value => 'nicole.braun@zammad.org',
  48. },
  49. {
  50. :execute => 'set',
  51. :css => 'input[name="password"]',
  52. :value => 'test'
  53. },
  54. {
  55. :execute => 'click',
  56. :css => '#login button',
  57. },
  58. {
  59. :execute => 'wait',
  60. :value => 5,
  61. },
  62. # check action
  63. {
  64. :execute => 'check',
  65. :css => '#login',
  66. :result => false,
  67. },
  68. {
  69. :execute => 'watch_for',
  70. :area => 'body',
  71. :value => 'nicole.braun@zammad.org',
  72. },
  73. {
  74. :execute => 'reload',
  75. },
  76. {
  77. :execute => 'watch_for',
  78. :area => 'body',
  79. :value => 'nicole.braun@zammad.org',
  80. },
  81. {
  82. :execute => 'match',
  83. :element => :cookie,
  84. :value => 'expires=>nil',
  85. },
  86. ],
  87. },
  88. ]
  89. browser_single_test(tests)
  90. end
  91. def test_authentication_new_browser_without_permanent_cookie_no_session_should_be
  92. tests = [
  93. {
  94. :name => 'start',
  95. :instance => browser_instance,
  96. :url => browser_url,
  97. :action => [
  98. {
  99. :execute => 'check',
  100. :css => '#login',
  101. :result => true,
  102. },
  103. {
  104. :execute => 'check',
  105. :css => '#login button',
  106. :result => true,
  107. },
  108. ],
  109. },
  110. ]
  111. browser_single_test(tests)
  112. end
  113. def test_new_browser_with_permanent_cookie_login
  114. tests = [
  115. {
  116. :name => 'start',
  117. :instance => browser_instance,
  118. :url => browser_url,
  119. :action => [
  120. {
  121. :execute => 'check',
  122. :css => '#login',
  123. :result => true,
  124. },
  125. {
  126. :execute => 'set',
  127. :css => 'input[name="username"]',
  128. :value => 'nicole.braun@zammad.org',
  129. },
  130. {
  131. :execute => 'set',
  132. :css => 'input[name="password"]',
  133. :value => 'test'
  134. },
  135. {
  136. :execute => 'click',
  137. :css => '#login [name="remember_me"]',
  138. },
  139. {
  140. :execute => 'click',
  141. :css => '#login button',
  142. },
  143. {
  144. :execute => 'wait',
  145. :value => 6,
  146. },
  147. # check action
  148. {
  149. :execute => 'check',
  150. :css => '#login',
  151. :result => false,
  152. },
  153. {
  154. :execute => 'watch_for',
  155. :area => 'body',
  156. :value => 'nicole.braun@zammad.org',
  157. },
  158. {
  159. :execute => 'match',
  160. :element => :cookie,
  161. :value => 'expires=>.+?\d{4}.+?,',
  162. },
  163. {
  164. :execute => 'logout',
  165. },
  166. ],
  167. },
  168. ]
  169. browser_single_test(tests)
  170. end
  171. end