2015-02-22 12:28:34 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
require 'browser_test_helper'
|
|
|
|
|
|
|
|
class AuthTest < TestCase
|
|
|
|
def test_authentication
|
|
|
|
@browser = browser_instance
|
2015-04-27 13:42:53 +00:00
|
|
|
location( url: browser_url )
|
2015-02-22 12:28:34 +00:00
|
|
|
match(
|
2015-04-27 13:42:53 +00:00
|
|
|
css: '#login',
|
|
|
|
value: 'username',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
2015-04-27 13:42:53 +00:00
|
|
|
click( css: '#login button' )
|
2015-02-22 12:28:34 +00:00
|
|
|
|
|
|
|
sleep 4
|
|
|
|
match(
|
2015-04-27 13:42:53 +00:00
|
|
|
css: '#login',
|
|
|
|
value: 'username',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# login with username/password
|
|
|
|
login(
|
2015-04-27 13:42:53 +00:00
|
|
|
username: 'nicole.braun@zammad.org',
|
|
|
|
password: 'test',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# reload page
|
|
|
|
reload()
|
|
|
|
|
|
|
|
# check if cookie is temporarily
|
|
|
|
watch_for(
|
2015-04-27 13:42:53 +00:00
|
|
|
css: 'body',
|
|
|
|
value: 'Overviews',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# verify session cookie
|
|
|
|
cookie(
|
2015-04-27 13:42:53 +00:00
|
|
|
name: '^_zammad.+?',
|
|
|
|
value: '.+?',
|
|
|
|
expires: '',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_authentication_new_browser_without_permanent_cookie_no_session_should_be
|
|
|
|
@browser = browser_instance
|
2015-04-27 13:42:53 +00:00
|
|
|
location( url: browser_url )
|
2015-02-22 12:28:34 +00:00
|
|
|
match(
|
2015-04-27 13:42:53 +00:00
|
|
|
css: '#login',
|
|
|
|
value: 'username',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_new_browser_with_permanent_cookie_login
|
|
|
|
@browser = browser_instance
|
2015-04-27 13:42:53 +00:00
|
|
|
location( url: browser_url )
|
2015-02-22 12:28:34 +00:00
|
|
|
|
|
|
|
# login with username/password
|
|
|
|
login(
|
2015-04-27 13:42:53 +00:00
|
|
|
username: 'nicole.braun@zammad.org',
|
|
|
|
password: 'test',
|
|
|
|
remember_me: true,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# check if cookie is temporarily
|
|
|
|
watch_for(
|
2015-04-27 13:42:53 +00:00
|
|
|
css: 'body',
|
|
|
|
value: 'Overviews',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# verify session cookie
|
|
|
|
cookie(
|
2015-04-27 13:42:53 +00:00
|
|
|
name: '^_zammad.+?',
|
|
|
|
value: '.+?',
|
|
|
|
expires: '\d{4}-\d{1,2}-\d{1,2}.+?',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
logout()
|
|
|
|
|
|
|
|
# verify session cookie
|
|
|
|
cookie(
|
2015-04-27 13:42:53 +00:00
|
|
|
name: '^_zammad.+?',
|
|
|
|
should_not_exist: true,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|