2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
require 'browser_test_helper'
|
|
|
|
|
|
|
|
class AuthTest < TestCase
|
|
|
|
def test_authentication
|
|
|
|
@browser = browser_instance
|
2016-03-10 07:39:41 +00:00
|
|
|
location(url: browser_url)
|
2015-02-22 12:28:34 +00:00
|
|
|
match(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '#login',
|
2015-04-27 13:42:53 +00:00
|
|
|
value: 'username',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
2016-03-10 07:39:41 +00:00
|
|
|
click(css: '#login button')
|
2015-02-22 12:28:34 +00:00
|
|
|
|
|
|
|
sleep 4
|
|
|
|
match(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '#login',
|
2015-04-27 13:42:53 +00:00
|
|
|
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
|
|
|
)
|
2016-03-10 07:39:41 +00:00
|
|
|
tasks_close_all()
|
2015-02-22 12:28:34 +00:00
|
|
|
|
|
|
|
# reload page
|
|
|
|
reload()
|
|
|
|
|
|
|
|
# check if cookie is temporarily
|
|
|
|
watch_for(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: 'body',
|
2015-04-27 13:42:53 +00:00
|
|
|
value: 'Overviews',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# verify session cookie
|
|
|
|
cookie(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '^_zammad.+?',
|
|
|
|
value: '.+?',
|
2015-04-27 13:42:53 +00:00
|
|
|
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
|
2016-03-10 07:39:41 +00:00
|
|
|
location(url: browser_url)
|
2015-02-22 12:28:34 +00:00
|
|
|
match(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '#login',
|
2015-04-27 13:42:53 +00:00
|
|
|
value: 'username',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_new_browser_with_permanent_cookie_login
|
|
|
|
@browser = browser_instance
|
2016-03-10 07:39:41 +00:00
|
|
|
location(url: browser_url)
|
2015-02-22 12:28:34 +00:00
|
|
|
|
|
|
|
# login with username/password
|
|
|
|
login(
|
2018-12-19 17:31:51 +00:00
|
|
|
username: 'nicole.braun@zammad.org',
|
|
|
|
password: 'test',
|
2015-04-27 13:42:53 +00:00
|
|
|
remember_me: true,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# check if cookie is temporarily
|
|
|
|
watch_for(
|
2018-12-19 17:31:51 +00:00
|
|
|
css: 'body',
|
2015-04-27 13:42:53 +00:00
|
|
|
value: 'Overviews',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# verify session cookie
|
|
|
|
cookie(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '^_zammad.+?',
|
|
|
|
value: '.+?',
|
2015-04-27 13:42:53 +00:00
|
|
|
expires: '\d{4}-\d{1,2}-\d{1,2}.+?',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
logout()
|
|
|
|
|
|
|
|
# verify session cookie
|
2017-02-15 12:29:25 +00:00
|
|
|
sleep 2
|
2015-02-22 12:28:34 +00:00
|
|
|
cookie(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '^_zammad.+?',
|
|
|
|
value: '.+?',
|
2017-02-15 12:29:25 +00:00
|
|
|
expires: '',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|