mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix test_user::test_login_without_username (Web UI test)
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com> Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
parent
1f04c481e3
commit
685cef554b
@ -95,7 +95,8 @@ class test_automember(UI_driver):
|
|||||||
self.init_app()
|
self.init_app()
|
||||||
|
|
||||||
host_util = host_tasks()
|
host_util = host_tasks()
|
||||||
host_util.setup(self.driver, self.config)
|
host_util.driver = self.driver
|
||||||
|
host_util.config = self.config
|
||||||
domain = self.config.get('ipa_domain')
|
domain = self.config.get('ipa_domain')
|
||||||
host1 = 'web1.%s' % domain
|
host1 = 'web1.%s' % domain
|
||||||
host2 = 'web2.%s' % domain
|
host2 = 'web2.%s' % domain
|
||||||
|
@ -59,7 +59,9 @@ class test_hostgroup(UI_driver):
|
|||||||
"""
|
"""
|
||||||
self.init_app()
|
self.init_app()
|
||||||
host = host_tasks()
|
host = host_tasks()
|
||||||
host.setup(self.driver, self.config)
|
host.driver = self.driver
|
||||||
|
host.config = self.config
|
||||||
|
host.prep_data2()
|
||||||
|
|
||||||
# prepare
|
# prepare
|
||||||
# -------
|
# -------
|
||||||
@ -101,7 +103,9 @@ class test_hostgroup(UI_driver):
|
|||||||
"""
|
"""
|
||||||
self.init_app()
|
self.init_app()
|
||||||
host = host_tasks()
|
host = host_tasks()
|
||||||
host.setup(self.driver, self.config)
|
host.driver = self.driver
|
||||||
|
host.config = self.config
|
||||||
|
host.prep_data2()
|
||||||
|
|
||||||
# add
|
# add
|
||||||
# ---
|
# ---
|
||||||
@ -163,7 +167,8 @@ class test_hostgroup(UI_driver):
|
|||||||
"""
|
"""
|
||||||
self.init_app()
|
self.init_app()
|
||||||
host = host_tasks()
|
host = host_tasks()
|
||||||
host.setup(self.driver, self.config)
|
host.driver = self.driver
|
||||||
|
host.config = self.config
|
||||||
|
|
||||||
self.add_record(hostgroup.ENTITY, hostgroup.DATA6)
|
self.add_record(hostgroup.ENTITY, hostgroup.DATA6)
|
||||||
self.add_record(hostgroup.ENTITY, hostgroup.DATA7, navigate=False)
|
self.add_record(hostgroup.ENTITY, hostgroup.DATA7, navigate=False)
|
||||||
|
@ -96,7 +96,9 @@ class test_idviews(UI_driver):
|
|||||||
"""
|
"""
|
||||||
self.init_app()
|
self.init_app()
|
||||||
host = host_tasks()
|
host = host_tasks()
|
||||||
host.setup(self.driver, self.config)
|
host.driver = self.driver
|
||||||
|
host.config = self.config
|
||||||
|
host.prep_data()
|
||||||
|
|
||||||
self.add_record(HOST_ENTITY, host.data)
|
self.add_record(HOST_ENTITY, host.data)
|
||||||
self.add_record(hostgroup.ENTITY, hostgroup.DATA)
|
self.add_record(hostgroup.ENTITY, hostgroup.DATA)
|
||||||
|
@ -293,7 +293,10 @@ class test_netgroup(UI_driver):
|
|||||||
"""
|
"""
|
||||||
self.init_app()
|
self.init_app()
|
||||||
host = host_tasks()
|
host = host_tasks()
|
||||||
host.setup(self.driver, self.config)
|
host.driver = self.driver
|
||||||
|
host.config = self.config
|
||||||
|
host.prep_data()
|
||||||
|
host.prep_data2()
|
||||||
|
|
||||||
self.add_record(netgroup.ENTITY, netgroup.DATA2)
|
self.add_record(netgroup.ENTITY, netgroup.DATA2)
|
||||||
self.add_record(user.ENTITY, user.DATA)
|
self.add_record(user.ENTITY, user.DATA)
|
||||||
|
@ -68,7 +68,10 @@ class test_selinuxusermap(UI_driver):
|
|||||||
"""
|
"""
|
||||||
self.init_app()
|
self.init_app()
|
||||||
host = host_tasks()
|
host = host_tasks()
|
||||||
host.setup(self.driver, self.config)
|
host.driver = self.driver
|
||||||
|
host.config = self.config
|
||||||
|
host.prep_data()
|
||||||
|
host.prep_data2()
|
||||||
|
|
||||||
self.add_record(user.ENTITY, user.DATA)
|
self.add_record(user.ENTITY, user.DATA)
|
||||||
self.add_record(user.ENTITY, user.DATA2, navigate=False)
|
self.add_record(user.ENTITY, user.DATA2, navigate=False)
|
||||||
|
@ -53,7 +53,10 @@ class test_sudo(UI_driver):
|
|||||||
"""
|
"""
|
||||||
self.init_app()
|
self.init_app()
|
||||||
host = host_tasks()
|
host = host_tasks()
|
||||||
host.setup(self.driver, self.config)
|
host.driver = self.driver
|
||||||
|
host.config = self.config
|
||||||
|
host.prep_data()
|
||||||
|
host.prep_data2()
|
||||||
|
|
||||||
self.add_record(netgroup.ENTITY, netgroup.DATA2)
|
self.add_record(netgroup.ENTITY, netgroup.DATA2)
|
||||||
|
|
||||||
|
@ -124,7 +124,8 @@ class test_trust(trust_tasks):
|
|||||||
self.init_app()
|
self.init_app()
|
||||||
|
|
||||||
r_tasks = range_tasks()
|
r_tasks = range_tasks()
|
||||||
r_tasks.setup(self.driver, self.config)
|
r_tasks.driver = self.driver
|
||||||
|
r_tasks.config = self.config
|
||||||
r_tasks.get_shifts()
|
r_tasks.get_shifts()
|
||||||
range_add = r_tasks.get_add_data('')
|
range_add = r_tasks.get_add_data('')
|
||||||
base_id = range_add[2][2]
|
base_id = range_add[2][2]
|
||||||
|
@ -419,7 +419,10 @@ class test_user(user_tasks):
|
|||||||
|
|
||||||
@screenshot
|
@screenshot
|
||||||
def test_login_without_username(self):
|
def test_login_without_username(self):
|
||||||
|
"""
|
||||||
|
Try to login with no username provided
|
||||||
|
"""
|
||||||
|
self.driver.delete_all_cookies()
|
||||||
self.init_app(login='', password='xxx123')
|
self.init_app(login='', password='xxx123')
|
||||||
|
|
||||||
alert_e = self.find('.alert[data-name="username"]',
|
alert_e = self.find('.alert[data-name="username"]',
|
||||||
|
@ -122,20 +122,22 @@ class UI_driver(object):
|
|||||||
if NO_SELENIUM:
|
if NO_SELENIUM:
|
||||||
raise unittest.SkipTest('Selenium not installed')
|
raise unittest.SkipTest('Selenium not installed')
|
||||||
|
|
||||||
def setup(self, driver=None, config=None):
|
cls.driver = None
|
||||||
|
cls.config = None
|
||||||
|
cls.load_config()
|
||||||
|
if not cls.driver:
|
||||||
|
cls.driver = cls.get_driver()
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
self.request_timeout = 60
|
self.request_timeout = 60
|
||||||
self.driver = driver
|
|
||||||
self.config = config
|
|
||||||
if not config:
|
|
||||||
self.load_config()
|
|
||||||
if not self.driver:
|
|
||||||
self.driver = self.get_driver()
|
|
||||||
self.driver.maximize_window()
|
self.driver.maximize_window()
|
||||||
|
|
||||||
def teardown(self):
|
@classmethod
|
||||||
self.driver.quit()
|
def teardown_class(cls):
|
||||||
|
cls.driver.quit()
|
||||||
|
|
||||||
def load_config(self):
|
@classmethod
|
||||||
|
def load_config(cls):
|
||||||
"""
|
"""
|
||||||
Load configuration
|
Load configuration
|
||||||
|
|
||||||
@ -148,7 +150,7 @@ class UI_driver(object):
|
|||||||
if not NO_YAML and os.path.isfile(path):
|
if not NO_YAML and os.path.isfile(path):
|
||||||
try:
|
try:
|
||||||
with open(path, 'r') as conf:
|
with open(path, 'r') as conf:
|
||||||
self.config = yaml.load(conf)
|
cls.config = yaml.load(conf)
|
||||||
except yaml.YAMLError as e:
|
except yaml.YAMLError as e:
|
||||||
raise unittest.SkipTest("Invalid Web UI config.\n%s" % e)
|
raise unittest.SkipTest("Invalid Web UI config.\n%s" % e)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
@ -156,9 +158,9 @@ class UI_driver(object):
|
|||||||
"Can't load Web UI test config: %s" % e
|
"Can't load Web UI test config: %s" % e
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.config = {}
|
cls.config = {}
|
||||||
|
|
||||||
c = self.config
|
c = cls.config
|
||||||
|
|
||||||
# override with environmental variables
|
# override with environmental variables
|
||||||
for k, v in ENV_MAP.items():
|
for k, v in ENV_MAP.items():
|
||||||
@ -174,13 +176,14 @@ class UI_driver(object):
|
|||||||
if 'type' not in c:
|
if 'type' not in c:
|
||||||
c['type'] = DEFAULT_TYPE
|
c['type'] = DEFAULT_TYPE
|
||||||
|
|
||||||
def get_driver(self):
|
@classmethod
|
||||||
|
def get_driver(cls):
|
||||||
"""
|
"""
|
||||||
Get WebDriver according to configuration
|
Get WebDriver according to configuration
|
||||||
"""
|
"""
|
||||||
browser = self.config["browser"]
|
browser = cls.config["browser"]
|
||||||
port = self.config["port"]
|
port = cls.config["port"]
|
||||||
driver_type = self.config["type"]
|
driver_type = cls.config["type"]
|
||||||
|
|
||||||
options = None
|
options = None
|
||||||
|
|
||||||
@ -189,9 +192,9 @@ class UI_driver(object):
|
|||||||
options.binary_location = paths.CHROMIUM_BROWSER
|
options.binary_location = paths.CHROMIUM_BROWSER
|
||||||
|
|
||||||
if driver_type == 'remote':
|
if driver_type == 'remote':
|
||||||
if 'host' not in self.config:
|
if 'host' not in cls.config:
|
||||||
raise unittest.SkipTest('Selenium server host not configured')
|
raise unittest.SkipTest('Selenium server host not configured')
|
||||||
host = self.config["host"]
|
host = cls.config["host"]
|
||||||
|
|
||||||
if browser == 'chrome':
|
if browser == 'chrome':
|
||||||
capabilities = DesiredCapabilities.CHROME
|
capabilities = DesiredCapabilities.CHROME
|
||||||
@ -221,9 +224,9 @@ class UI_driver(object):
|
|||||||
driver = webdriver.Ie()
|
driver = webdriver.Ie()
|
||||||
else:
|
else:
|
||||||
fp = None
|
fp = None
|
||||||
if "ff_profile" in self.config:
|
if "ff_profile" in cls.config:
|
||||||
fp = webdriver.FirefoxProfile(self.config["ff_profile"])
|
fp = webdriver.FirefoxProfile(cls.config["ff_profile"])
|
||||||
ff_log_path = self.config.get("geckodriver_log_path")
|
ff_log_path = cls.config.get("geckodriver_log_path")
|
||||||
driver = webdriver.Firefox(fp, log_path=ff_log_path)
|
driver = webdriver.Firefox(fp, log_path=ff_log_path)
|
||||||
except URLError as e:
|
except URLError as e:
|
||||||
raise unittest.SkipTest(
|
raise unittest.SkipTest(
|
||||||
@ -354,22 +357,6 @@ class UI_driver(object):
|
|||||||
"""
|
"""
|
||||||
Navigate to Web UI first page and wait for loading of all dependencies.
|
Navigate to Web UI first page and wait for loading of all dependencies.
|
||||||
"""
|
"""
|
||||||
# If the application is already loaded, there is no need to re-enter
|
|
||||||
# the URL on the address bar and reloading everything.
|
|
||||||
# This help us to create scenarios like login -> logout -> login
|
|
||||||
|
|
||||||
# if a page is already loaded we click in the IPA logo to go to the
|
|
||||||
# initial page
|
|
||||||
ipa_logo = self.find('.navbar-brand', By.CSS_SELECTOR)
|
|
||||||
if ipa_logo and ipa_logo.is_displayed():
|
|
||||||
self.move_to_element_in_page(ipa_logo)
|
|
||||||
ipa_logo.click()
|
|
||||||
return
|
|
||||||
|
|
||||||
# already on the first page
|
|
||||||
if self.login_screen_visible():
|
|
||||||
return
|
|
||||||
|
|
||||||
# if is not any of above cases, we need to load the application for
|
# if is not any of above cases, we need to load the application for
|
||||||
# its first time entering the URL in the address bar
|
# its first time entering the URL in the address bar
|
||||||
self.driver.get(self.get_base_url())
|
self.driver.get(self.get_base_url())
|
||||||
|
Loading…
Reference in New Issue
Block a user