trabajo-afectivo/test/browser/auth_test.rb

86 lines
1.5 KiB
Ruby
Raw Normal View History

2015-02-22 12:28:34 +00:00
# encoding: utf-8
require 'browser_test_helper'
class AuthTest < TestCase
def test_authentication
@browser = browser_instance
location( url: browser_url )
2015-02-22 12:28:34 +00:00
match(
css: '#login',
value: 'username',
2015-02-22 12:28:34 +00:00
)
click( css: '#login button' )
2015-02-22 12:28:34 +00:00
sleep 4
match(
css: '#login',
value: 'username',
2015-02-22 12:28:34 +00:00
)
# login with username/password
login(
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(
css: 'body',
value: 'Overviews',
2015-02-22 12:28:34 +00:00
)
# verify session cookie
cookie(
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
location( url: browser_url )
2015-02-22 12:28:34 +00:00
match(
css: '#login',
value: 'username',
2015-02-22 12:28:34 +00:00
)
end
def test_new_browser_with_permanent_cookie_login
@browser = browser_instance
location( url: browser_url )
2015-02-22 12:28:34 +00:00
# login with username/password
login(
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(
css: 'body',
value: 'Overviews',
2015-02-22 12:28:34 +00:00
)
# verify session cookie
cookie(
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(
name: '^_zammad.+?',
should_not_exist: true,
2015-02-22 12:28:34 +00:00
)
end
end