本文整理汇总了Python中robottelo.cli.settings.Settings类的典型用法代码示例。如果您正苦于以下问题:Python Settings类的具体用法?Python Settings怎么用?Python Settings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Settings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tearDownClass
def tearDownClass(cls):
super(BruteForceLogin, cls).tearDownClass()
# reset failed_login_attempts_limit value
sleep(301)
Settings.set({
u'name': u'failed_login_attempts_limit',
u'value': cls.host_value})
示例2: test_positive_update_hostname_prefix_without_value
def test_positive_update_hostname_prefix_without_value(self):
"""Update the Hostname_prefix settings without any string(empty values)
:id: a84c28ea-6821-4c31-b4ab-8662c22c9135
:expectedresults: Hostname_prefix should be set without any text
"""
Settings.set({'name': "discovery_prefix", 'value': ""})
discovery_prefix = Settings.list({
'search': 'name=discovery_prefix'
})[0]
self.assertEqual('', discovery_prefix['value'])
示例3: setUp
def setUp(self):
"""Create a directory for export, configure permissions and satellite
settings
"""
super(RepositoryExportTestCase, self).setUp()
if not RepositoryExportTestCase.is_set_up:
RepositoryExportTestCase.export_dir = gen_string('alphanumeric')
# Create a new 'export' directory on the Satellite system
result = ssh.command('mkdir /mnt/{0}'.format(self.export_dir))
self.assertEqual(result.return_code, 0)
result = ssh.command(
'chown foreman.foreman /mnt/{0}'.format(self.export_dir))
self.assertEqual(result.return_code, 0)
result = ssh.command(
'ls -Z /mnt/ | grep {0}'.format(self.export_dir))
self.assertEqual(result.return_code, 0)
self.assertGreaterEqual(len(result.stdout), 1)
self.assertIn('unconfined_u:object_r:mnt_t:s0', result.stdout[0])
# Fix SELinux policy for new directory
result = ssh.command(
'semanage fcontext -a -t foreman_var_run_t "/mnt/{0}(/.*)?"'
.format(self.export_dir)
)
self.assertEqual(result.return_code, 0)
result = ssh.command(
'restorecon -Rv /mnt/{0}'.format(self.export_dir))
self.assertEqual(result.return_code, 0)
# Assert that we have the correct policy
result = ssh.command(
'ls -Z /mnt/ | grep {0}'.format(self.export_dir))
self.assertEqual(result.return_code, 0)
self.assertGreaterEqual(len(result.stdout), 1)
self.assertIn(
'unconfined_u:object_r:foreman_var_run_t:s0', result.stdout[0])
# Update the 'pulp_export_destination' settings to new directory
Settings.set({
'name': 'pulp_export_destination',
'value': '/mnt/{0}'.format(self.export_dir),
})
# Create an organization to reuse in tests
RepositoryExportTestCase.org = make_org()
RepositoryExportTestCase.is_set_up = True
示例4: test_positive_session_preceeds_saved_credentials
def test_positive_session_preceeds_saved_credentials(self):
"""Check if enabled session is mutually exclusive with
saved credentials in hammer config
:id: e4277298-1c24-494b-84a6-22f45f96e144
:BZ: 1471099
:Steps:
1. Set use_sessions, set usernam and password,
set short expiration time
2. Authenticate, assert credentials are not demanded
on next command run
3. Wait until session expires
:expectedresults: Session expires after specified time
and saved credentials are not applied
"""
try:
idle_timeout = Settings.list({
'search': 'name=idle_timeout'})[0][u'value']
Settings.set({'name': 'idle_timeout', 'value': 1})
result = configure_sessions(add_default_creds=True)
self.assertEqual(result, 0, 'Failed to configure hammer sessions')
Auth.login({
'username': self.uname_admin,
'password': self.password
})
result = Auth.with_user().status()
self.assertIn(
LOGEDIN_MSG.format(self.uname_admin),
result[0][u'message']
)
# list organizations without supplying credentials
with self.assertNotRaises(CLIReturnCodeError):
Org.with_user().list()
# wait until session expires
sleep(70)
with self.assertRaises(CLIReturnCodeError):
Org.with_user().list()
result = Auth.with_user().status()
self.assertIn(
LOGEDOFF_MSG.format(self.uname_admin),
result[0][u'message']
)
finally:
# reset timeout to default
Settings.set({'name': 'idle_timeout', 'value': '{}'.format(
idle_timeout)})
示例5: test_positive_update_login_page_footer_text_without_value
def test_positive_update_login_page_footer_text_without_value(self):
"""Updates parameter "login_text" without any string (empty value)
:id: 01ce95de-2994-42b6-b9f8-f7882981fb69
:steps:
1. Execute "settings" command with "set" as sub-command
without any string(empty value) in value parameter
:expectedresults: Message on login screen should be removed
"""
Settings.set({'name': "login_text", 'value': ""})
login_text = Settings.list({'search': 'name=login_text'})[0]
self.assertEqual('', login_text['value'])
示例6: test_negative_update_send_welcome_email
def test_negative_update_send_welcome_email(value):
"""Check email send welcome email is updated
:id: 2f75775d-72a1-4b2f-86c2-98c36e446099
:steps: set invalid values: not booleans
:expectedresults: send_welcome_email is not updated
:caseautomation: automated
:caseimportance: low
"""
with pytest.raises(CLIReturnCodeError):
Settings.set({'name': 'send_welcome_email', 'value': value})
示例7: setUpClass
def setUpClass(cls):
"""Steps to Configure foreman discovery
1. Build PXE default template
2. Create Organization/Location
3. Update Global parameters to set default org and location for
discovered hosts.
4. Enable auto_provision flag to perform discovery via discovery
rules.
"""
super(DiscoveredTestCase, cls).setUpClass()
# Build PXE default template to get default PXE file
Template.build_pxe_default()
# let's just modify the timeouts to speed things up
ssh.command("sed -ie 's/TIMEOUT [[:digit:]]\\+/TIMEOUT 1/g' "
"/var/lib/tftpboot/pxelinux.cfg/default")
ssh.command("sed -ie '/APPEND initrd/s/$/ fdi.countdown=1/' "
"/var/lib/tftpboot/pxelinux.cfg/default")
# Create Org and location
cls.org = make_org()
cls.loc = make_location()
# Get default settings values
cls.default_discovery_loc = Settings.list(
{'search': 'name=%s' % 'discovery_location'})[0]
cls.default_discovery_org = Settings.list(
{'search': 'name=%s' % 'discovery_organization'})[0]
cls.default_discovery_auto = Settings.list(
{'search': 'name=%s' % 'discovery_auto'})[0]
# Update default org and location params to place discovered host
Settings.set({'name': 'discovery_location', 'value': cls.loc['name']})
Settings.set(
{'name': 'discovery_organization', 'value': cls.org['name']})
# Enable flag to auto provision discovered hosts via discovery rules
Settings.set({'name': 'discovery_auto', 'value': 'true'})
# Flag which shows whether environment is fully configured for
# discovered host provisioning.
cls.configured_env = False
if bz_bug_is_open(1578290):
ssh.command('mkdir /var/lib/tftpboot/boot/fdi-image')
ssh.command('ln -s /var/lib/tftpboot/boot/'
'foreman-discovery-image-3.4.4-1.iso-vmlinuz'
' /var/lib/tftpboot/boot/fdi-image/vmlinuz0')
ssh.command('ln -s /var/lib/tftpboot/boot/'
'foreman-discovery-image-3.4.4-1.iso-img'
' /var/lib/tftpboot/boot/fdi-image/initrd0.img')
ssh.command('chown -R foreman-proxy /var/lib/tftpboot/boot/')
示例8: test_positive_update_hostname_default_prefix
def test_positive_update_hostname_default_prefix(self):
"""Update the default set prefix of hostname_prefix setting
:id: a6e46e53-6273-406a-8009-f184d9551d66
:expectedresults: Default set prefix should be updated with new value
"""
hostname_prefix_value = gen_string('alpha')
Settings.set({
'name': "discovery_prefix",
'value': hostname_prefix_value
})
discovery_prefix = Settings.list({
'search': 'name=discovery_prefix'
})[0]
self.assertEqual(hostname_prefix_value, discovery_prefix['value'])
示例9: test_positive_create_session
def test_positive_create_session(self):
"""Check if user stays authenticated with session enabled
:id: fcee7f5f-1040-41a9-bf17-6d0c24a93e22
:Steps:
1. Set use_sessions, set short expiration time
2. Authenticate, assert credentials are not demanded
on next command run
3. Wait until session expires, assert credentials
are required
:expectedresults: The session is successfully created and
expires after specified time
"""
try:
idle_timeout = Settings.list({
'search': 'name=idle_timeout'})[0][u'value']
Settings.set({'name': 'idle_timeout', 'value': 1})
result = configure_sessions()
self.assertEqual(result, 0, 'Failed to configure hammer sessions')
Auth.login({
'username': self.uname_admin,
'password': self.password
})
result = Auth.with_user().status()
self.assertIn(
LOGEDIN_MSG.format(self.uname_admin),
result[0][u'message']
)
# list organizations without supplying credentials
with self.assertNotRaises(CLIReturnCodeError):
Org.with_user().list()
# wait until session expires
sleep(70)
with self.assertRaises(CLIReturnCodeError):
Org.with_user().list()
result = Auth.with_user().status()
self.assertIn(
LOGEDOFF_MSG.format(self.uname_admin),
result[0][u'message']
)
finally:
# reset timeout to default
Settings.set({'name': 'idle_timeout', 'value': '{}'.format(
idle_timeout)})
示例10: test_positive_update_login_page_footer_text
def test_positive_update_login_page_footer_text(self):
"""Updates parameter "login_text" in settings
:id: 4d4e1151-5bd6-4fa2-8dbb-e182b43ad7ec
:steps:
1. Execute "settings" command with "set" as sub-command
with any string
:expectedresults: Parameter is updated successfully
"""
for login_text_value in valid_data_list():
with self.subTest(login_text_value):
Settings.set({'name': "login_text", 'value': login_text_value})
login_text = Settings.list({'search': 'name=login_text'})[0]
self.assertEqual(login_text_value, login_text['value'])
示例11: test_positive_update_send_welcome_email
def test_positive_update_send_welcome_email(self):
"""Check email send welcome email is updated
:id: cdaf6cd0-5eea-4252-87c5-f9ec3ba79ac1
:steps: valid values: boolean true or false
:expectedresults: send_welcome_email is updated
:caseautomation: automated
:caseimportance: low
"""
for value in ['true', 'false']:
Settings.set({'name': 'send_welcome_email', 'value': value})
host_value = Settings.list(
{'search': 'name=send_welcome_email'})[0]['value']
assert value == host_value
示例12: test_positive_update_login_page_footer_text_with_long_string
def test_positive_update_login_page_footer_text_with_long_string(self):
"""Attempt to update parameter "Login_page_footer_text"
with long length string under General tab
:id: 87ef6b19-fdc5-4541-aba8-e730f1a3caa7
:steps:
1. Execute "settings" command with "set" as sub-command
with long length string
:expectedresults: Parameter is updated
:caseimportance: low
"""
for login_text_value in generate_strings_list(1000):
with self.subTest(login_text_value):
Settings.set({'name': "login_text", 'value': login_text_value})
login_text = Settings.list({'search': 'name=login_text'})[0]
self.assertEqual(login_text_value, login_text['value'])
示例13: test_negative_update_email_reply_address
def test_negative_update_email_reply_address(self):
"""Check email reply address is not updated
:id: 2a2220c2-badf-47d5-ba3f-e6329930ab39
:steps: provide invalid email addresses
:expectedresults: email_reply_address is not updated
:caseimportance: low
:caseautomation: automated
"""
for email in invalid_emails_list():
with self.subTest(email):
with self.assertRaises(CLIReturnCodeError):
Settings.set({
'name': 'email_reply_address',
'value': email
})
示例14: test_positive_create_with_default_download_policy
def test_positive_create_with_default_download_policy(self):
"""Verify if the default download policy is assigned
when creating a YUM repo without `--download-policy`
@id: 9a3c4d95-d6ca-4377-9873-2c552b7d6ce7
@Assert: YUM repository with a default download policy
"""
default_dl_policy = Settings.list({"search": "name=default_download_policy"})
self.assertTrue(default_dl_policy)
new_repo = self._make_repository({u"content-type": u"yum"})
self.assertEqual(new_repo["download-policy"], default_dl_policy[0]["value"])
示例15: test_positive_failed_login_attempts_limit
def test_positive_failed_login_attempts_limit(self):
"""automate brute force protection limit configurable function
:id: f95407ed-451b-4387-ac9b-2959ae2f51ae
:steps:
1. Make sure login works.
2. Save current value and set it to some lower value:
3. Try to login with wrong password till failed_login_attempts_limit
4. Make sure login now does not work:
5. Wait timeout - 5 minutes + 1 second
6. Verify you can now login fine
7. Return the setting to previous value
:expectedresults: failed_login_attempts_limit works as expected
:caseautomation: automated
"""
result = ssh.command(
'hammer -u {0} -p {1} user list'
.format(self.foreman_user, self.foreman_password))
self.assertEqual(result.return_code, 0)
Settings.set({
u'name': u'failed_login_attempts_limit',
u'value': '5'
})
for i in range(5):
output = ssh.command(
'hammer -u {0} -p BAD_PASS user list'.format(
self.foreman_user))
self.assertEqual(output.return_code, 129)
result = ssh.command(
'hammer -u {0} -p {1} user list'
.format(self.foreman_user, self.foreman_password))
self.assertEqual(result.return_code, 129)
sleep(301)
result = ssh.command(
'hammer -u {0} -p {1} user list'
.format(self.foreman_user, self.foreman_password))
self.assertEqual(result.return_code, 0)