2013-08-16 11:18:53 -05:00
|
|
|
# Authors:
|
|
|
|
# Petr Vobornik <pvoborni@redhat.com>
|
|
|
|
#
|
|
|
|
# Copyright (C) 2013 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
"""
|
|
|
|
Range tasks
|
|
|
|
"""
|
|
|
|
|
|
|
|
from ipatests.test_webui.ui_driver import UI_driver
|
|
|
|
|
|
|
|
|
|
|
|
class range_tasks(UI_driver):
|
|
|
|
|
|
|
|
def get_shifts(self, idranges=None):
|
|
|
|
|
|
|
|
if not idranges:
|
|
|
|
result = self.execute_api_from_ui('idrange_find', [], {})
|
|
|
|
idranges = result['result']['result']
|
|
|
|
|
2014-04-24 10:24:59 -05:00
|
|
|
max_id = 0
|
|
|
|
max_rid = 0
|
2013-08-16 11:18:53 -05:00
|
|
|
|
|
|
|
for idrange in idranges:
|
|
|
|
size = int(idrange['ipaidrangesize'][0])
|
|
|
|
base_id = int(idrange['ipabaseid'][0])
|
|
|
|
|
|
|
|
id_end = base_id + size
|
|
|
|
rid_end = 0
|
|
|
|
|
|
|
|
if 'ipabaserid' in idrange:
|
|
|
|
base_rid = int(idrange['ipabaserid'][0])
|
|
|
|
rid_end = base_rid + size
|
|
|
|
|
|
|
|
if 'ipasecondarybaserid' in idrange:
|
|
|
|
secondary_base_rid = int(idrange['ipasecondarybaserid'][0])
|
|
|
|
rid_end = max(base_rid, secondary_base_rid) + size
|
|
|
|
|
2014-04-24 10:24:59 -05:00
|
|
|
if max_id < id_end:
|
|
|
|
max_id = id_end + 1000000
|
2013-08-16 11:18:53 -05:00
|
|
|
|
2014-04-24 10:24:59 -05:00
|
|
|
if max_rid < rid_end:
|
|
|
|
max_rid = rid_end + 1000000
|
2013-08-16 11:18:53 -05:00
|
|
|
|
2014-04-24 10:24:59 -05:00
|
|
|
self.max_id = max_id
|
|
|
|
self.max_rid = max_rid
|
2013-08-16 11:18:53 -05:00
|
|
|
|
2014-11-04 06:38:12 -06:00
|
|
|
def get_domain(self):
|
2013-08-16 11:18:53 -05:00
|
|
|
result = self.execute_api_from_ui('trust_find', [], {})
|
|
|
|
trusts = result['result']['result']
|
2014-11-04 06:38:12 -06:00
|
|
|
domain = None
|
2013-08-16 11:18:53 -05:00
|
|
|
if trusts:
|
2014-11-04 06:38:12 -06:00
|
|
|
domain = trusts[0]['cn']
|
|
|
|
return domain
|
2013-08-16 11:18:53 -05:00
|
|
|
|
|
|
|
def get_data(self, pkey, size=50, add_data=None):
|
|
|
|
|
|
|
|
if not add_data:
|
|
|
|
add_data = self.get_add_data(pkey, size=size)
|
|
|
|
|
|
|
|
data = {
|
|
|
|
'pkey': pkey,
|
|
|
|
'add': add_data,
|
|
|
|
'mod': [
|
|
|
|
('textbox', 'ipaidrangesize', str(size + 1)),
|
|
|
|
],
|
|
|
|
}
|
|
|
|
return data
|
|
|
|
|
2014-11-04 06:38:12 -06:00
|
|
|
def get_add_data(self, pkey, range_type='ipa-local', size=50, shift=100, domain=None):
|
2013-08-16 11:18:53 -05:00
|
|
|
|
2014-04-24 10:24:59 -05:00
|
|
|
base_id = self.max_id + shift
|
|
|
|
self.max_id = base_id + size
|
|
|
|
|
|
|
|
base_rid = self.max_rid + shift
|
|
|
|
self.max_rid = base_rid + size
|
|
|
|
|
2013-08-16 11:18:53 -05:00
|
|
|
add = [
|
|
|
|
('textbox', 'cn', pkey),
|
2014-04-24 10:24:59 -05:00
|
|
|
('textbox', 'ipabaseid', str(base_id)),
|
2013-08-16 11:18:53 -05:00
|
|
|
('textbox', 'ipaidrangesize', str(size)),
|
2014-04-24 10:24:59 -05:00
|
|
|
('textbox', 'ipabaserid', str(base_rid)),
|
2013-08-16 11:18:53 -05:00
|
|
|
('radio', 'iparangetype', range_type),
|
2014-05-06 09:49:03 -05:00
|
|
|
('callback', self.check_range_type_mod, range_type)
|
2013-08-16 11:18:53 -05:00
|
|
|
]
|
|
|
|
|
2014-11-04 06:38:12 -06:00
|
|
|
if not domain:
|
2014-04-24 10:24:59 -05:00
|
|
|
base_rid = self.max_rid + shift
|
|
|
|
self.max_rid = base_rid + size
|
|
|
|
add.append(('textbox', 'ipasecondarybaserid', str(base_rid)))
|
2014-11-04 06:38:12 -06:00
|
|
|
if domain:
|
|
|
|
add.append(('textbox', 'ipanttrusteddomainname', domain))
|
2013-08-16 11:18:53 -05:00
|
|
|
|
|
|
|
return add
|
2014-05-06 09:49:03 -05:00
|
|
|
|
|
|
|
def check_range_type_mod(self, range_type):
|
|
|
|
if range_type == 'ipa-local':
|
2014-11-04 06:38:12 -06:00
|
|
|
self.assert_disabled("[name=ipanttrusteddomainname]")
|
2014-05-06 09:49:03 -05:00
|
|
|
self.assert_disabled("[name=ipasecondarybaserid]", negative=True)
|
|
|
|
elif range_type == 'ipa-ad-trust':
|
2014-11-04 06:38:12 -06:00
|
|
|
self.assert_disabled("[name=ipanttrusteddomainname]", negative=True)
|
2014-05-06 09:49:03 -05:00
|
|
|
self.assert_disabled("[name=ipasecondarybaserid]")
|