本文整理汇总了Python中cfme.configure.access_control.User类的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_user_change_password
def test_user_change_password(request):
user = User(
name="user {}".format(fauxfactory.gen_alphanumeric()),
credential=Credential(
principal="user_principal_{}".format(fauxfactory.gen_alphanumeric()),
secret="very_secret",
verify_secret="very_secret"
),
email="[email protected]",
group=usergrp,
)
user.create()
request.addfinalizer(user.delete)
request.addfinalizer(login.login_admin)
with user:
assert not login.logged_in()
login.login(user)
assert login.current_full_name() == user.name
login.login_admin()
with update(user):
user.credential = Credential(
principal=user.credential.principal,
secret="another_very_secret",
verify_secret="another_very_secret",
)
with user:
assert not login.logged_in()
login.login(user)
assert login.current_full_name() == user.name
示例2: test_current_user_login_delete
def test_current_user_login_delete(request):
"""Test for deleting current user login.
Steps:
* Login as Admin user
* Create a new user
* Login with the new user
* Try deleting the user
"""
group_user = Group("EvmGroup-super_administrator")
user = User(
name='user' + fauxfactory.gen_alphanumeric(),
credential=new_credential(),
email='[email protected]',
group=group_user)
user.create()
request.addfinalizer(user.delete)
request.addfinalizer(login.login_admin)
with user:
if version.current_version() >= '5.7':
navigate_to(user, 'Details')
menu_item = ('Configuration', 'Delete this User')
assert tb.exists(*menu_item) and tb.is_greyed(*menu_item), "Delete User is not dimmed"
else:
with error.expected("Current EVM User \"{}\" cannot be deleted".format(user.name)):
user.delete()
示例3: test_userid_required_error_validation
def test_userid_required_error_validation():
user = User(
name='user' + fauxfactory.gen_alphanumeric(),
credential=Credential(principal='', secret='redhat'),
email='[email protected]',
group=group_user)
with error.expected("Userid can't be blank"):
user.create()
示例4: test_user_group_error_validation
def test_user_group_error_validation():
user = User(
name='user{}'.format(fauxfactory.gen_alphanumeric()),
credential=new_credential(),
email='[email protected]',
group='')
with error.expected("A User must be assigned to a Group"):
user.create()
示例5: test_username_required_error_validation
def test_username_required_error_validation():
user = User(
name="",
credential=new_credential(),
email='[email protected]',
group=group_user)
with error.expected("Name can't be blank"):
user.create()
示例6: user
def user():
user = User(
credential=Credential(principal=fauxfactory.gen_alphanumeric(), secret=fauxfactory.gen_alphanumeric()),
name=fauxfactory.gen_alphanumeric(),
group=Group(description="EvmGroup-super_administrator"),
)
user.create()
return user
示例7: test_user_email_error_validation
def test_user_email_error_validation():
user = User(
name='user' + fauxfactory.gen_alphanumeric(),
credential=new_credential(),
email='xyzdhat.com',
group=group_user)
with error.expected("Email must be a valid email address"):
user.create()
示例8: test_userid_required_error_validation
def test_userid_required_error_validation():
user = User(
name="user" + fauxfactory.gen_alphanumeric(),
credential=Credential(principal="", secret="redhat"),
email="[email protected]",
group=group_user,
)
with error.expected("Userid can't be blank"):
user.create()
示例9: test_delete_default_user
def test_delete_default_user():
"""Test for deleting default user Administrator.
Steps:
* Login as Administrator user
* Try deleting the user
"""
user = User(name='Administrator')
with pytest.raises(RBACOperationBlocked):
user.delete()
示例10: test_username_required_error_validation
def test_username_required_error_validation(group_collection):
group_name = 'EvmGroup-user'
group = group_collection.instantiate(description=group_name)
user = User(
name="",
credential=new_credential(),
email='[email protected]',
group=group)
with error.expected("Name can't be blank"):
user.create()
示例11: test_user_email_error_validation
def test_user_email_error_validation(group_collection):
group_name = 'EvmGroup-user'
group = group_collection.instantiate(description=group_name)
user = User(
name='user{}'.format(fauxfactory.gen_alphanumeric()),
credential=new_credential(),
email='xyzdhat.com',
group=group)
with error.expected("Email must be a valid email address"):
user.create()
示例12: test_user_password_required_error_validation
def test_user_password_required_error_validation():
user = User(
name='user' + fauxfactory.gen_alphanumeric(),
credential=Credential(principal='uid' + fauxfactory.gen_alphanumeric(), secret=None),
email='[email protected]',
group=group_user)
if version.current_version() < "5.5":
check = "Password_digest can't be blank"
else:
check = "Password can't be blank"
with error.expected(check):
user.create()
示例13: login
def login(user, submit_method=_js_auth_fn):
"""
Login to CFME with the given username and password.
Optionally, submit_method can be press_enter_after_password
to use the enter key to login, rather than clicking the button.
Args:
user: The username to fill in the username field.
password: The password to fill in the password field.
submit_method: A function to call after the username and password have been input.
Raises:
RuntimeError: If the login fails, ie. if a flash message appears
"""
if not user:
username = conf.credentials['default']['username']
password = conf.credentials['default']['password']
cred = Credential(principal=username, secret=password)
user = User(credential=cred)
if not logged_in() or user.credential.principal is not current_username():
if logged_in():
logout()
# workaround for strange bug where we are logged out
# as soon as we click something on the dashboard
sel.sleep(1.0)
logger.debug('Logging in as user %s', user.credential.principal)
try:
fill(form, {'username': user.credential.principal, 'password': user.credential.secret})
except sel.InvalidElementStateException as e:
logger.warning("Got an error. Details follow.")
msg = str(e).lower()
if "element is read-only" in msg:
logger.warning("Got a read-only login form, will reload the browser.")
# Reload browser
quit()
ensure_browser_open()
sel.sleep(1.0)
sel.wait_for_ajax()
# And try filling the form again
fill(form, {'username': user.credential.principal,
'password': user.credential.secret})
else:
logger.warning("Unknown error, reraising.")
logger.exception(e)
raise
with sel.ajax_timeout(90):
submit_method()
flash.assert_no_errors()
user.full_name = _full_name()
store.user = user
示例14: login_admin
def login_admin(self, **kwargs):
"""
Convenience function to log into CFME using the admin credentials from the yamls.
Args:
kwargs: A dict of keyword arguments to supply to the :py:meth:`login` method.
"""
username = conf.credentials['default']['username']
password = conf.credentials['default']['password']
cred = Credential(principal=username, secret=password)
from cfme.configure.access_control import User
user = User(credential=cred)
user.name = 'Administrator'
self.login(user, **kwargs)
示例15: user_restricted
def user_restricted(group_with_tag, new_credential):
"""
Returns restricted user object assigned
to group with tag filter used in test module
"""
user = User(
name='user{}'.format(fauxfactory.gen_alphanumeric()),
credential=new_credential,
email='[email protected]',
group=group_with_tag,
cost_center='Workload',
value_assign='Database')
user.create()
yield user
user.delete()