Пример #1
0
def test_permission_edit(request, product_features, action):
    """
    Ensures that changes in permissions are enforced on next login
    """
    product_features = version.pick(product_features)
    request.addfinalizer(login.login_admin)
    role_name = fauxfactory.gen_alphanumeric()
    role = Role(name=role_name,
        vm_restriction=None,
        product_features=[(['Everything'], False)] +    # role_features
            [(k, True) for k in product_features])
    role.create()
    group = new_group(role=role.name)
    group.create()
    user = new_user(group=group)
    user.create()
    with user:
        try:
            action()
        except Exception:
            pytest.fail('Incorrect permissions set')
    login.login_admin()
    role.update({'product_features': [(['Everything'], True)] +
                                     [(k, False) for k in product_features]
                 })
    with user:
        try:
            with error.expected(Exception):
                action()
        except error.UnexpectedSuccessException:
            pytest.Fails('Permissions have not been updated')
Пример #2
0
def test_permission_edit(appliance, request, product_features, action):
    """
    Ensures that changes in permissions are enforced on next login
    """
    product_features = version.pick(product_features)
    request.addfinalizer(appliance.server.login_admin())
    role_name = fauxfactory.gen_alphanumeric()
    role = Role(
        name=role_name,
        vm_restriction=None,
        product_features=[(['Everything'], False)] +  # role_features
        [(k, True) for k in product_features])
    role.create()
    group = new_group(role=role.name)
    group.create()
    user = new_user(group=group)
    user.create()
    with user:
        try:
            action()
        except Exception:
            pytest.fail('Incorrect permissions set')
    appliance.server.login_admin()
    role.update({
        'product_features':
        [(['Everything'], True)] + [(k, False) for k in product_features]
    })
    with user:
        try:
            with error.expected(Exception):
                action()
        except error.UnexpectedSuccessException:
            pytest.Fails('Permissions have not been updated')
Пример #3
0
def role():
    """
        Returns role object used in test module
    """
    role = Role(name='role{}'.format(fauxfactory.gen_alphanumeric()),
                vm_restriction='None')
    role.create()
    yield role
    role.delete()
Пример #4
0
def role():
    """
        Returns role object used in test module
    """
    role = Role(
        name='role{}'.format(fauxfactory.gen_alphanumeric()),
        vm_restriction='None')
    role.create()
    yield role
    role.delete()
def test_permission_edit(appliance, request, product_features, action):
    """
    Ensures that changes in permissions are enforced on next login
    Args:
        appliance: cfme appliance fixture
        request: pytest request fixture
        product_features: product features to set for test role
        action: reference to a function to execute under the test user context
    """
    product_features = version.pick(product_features)
    request.addfinalizer(appliance.server.login_admin)
    role_name = fauxfactory.gen_alphanumeric()
    role = Role(
        name=role_name,
        vm_restriction=None,
        product_features=[(['Everything'], False)] +  # role_features
        [(k, True) for k in product_features])
    role.create()
    group_description = 'grp{}'.format(fauxfactory.gen_alphanumeric())
    group = group_collection(appliance).create(description=group_description,
                                               role=role.name)
    user = new_user(group=group)
    user.create()
    with user:
        try:
            action()
        except Exception:
            pytest.fail('Incorrect permissions set')
    appliance.server.login_admin()
    role.update({
        'product_features':
        [(['Everything'], True)] + [(k, False) for k in product_features]
    })
    with user:
        try:
            with error.expected(Exception):
                action()
        except error.UnexpectedSuccessException:
            pytest.Fails('Permissions have not been updated')
def test_permission_edit(appliance, request, product_features, action):
    """
    Ensures that changes in permissions are enforced on next login
    Args:
        appliance: cfme appliance fixture
        request: pytest request fixture
        product_features: product features to set for test role
        action: reference to a function to execute under the test user context
    """
    product_features = version.pick(product_features)
    request.addfinalizer(appliance.server.login_admin)
    role_name = fauxfactory.gen_alphanumeric()
    role = Role(name=role_name,
                vm_restriction=None,
                product_features=[(['Everything'], False)] +  # role_features
                                 [(k, True) for k in product_features])
    role.create()
    group_description = 'grp{}'.format(fauxfactory.gen_alphanumeric())
    group = group_collection(appliance).create(description=group_description, role=role.name)
    user = new_user(group=group)
    user.create()
    with user:
        try:
            action()
        except Exception:
            pytest.fail('Incorrect permissions set')
    appliance.server.login_admin()
    role.update({'product_features': [(['Everything'], True)] +
                                     [(k, False) for k in product_features]
                 })
    with user:
        try:
            with error.expected(Exception):
                action()
        except error.UnexpectedSuccessException:
            pytest.Fails('Permissions have not been updated')
def test_rolename_required_error_validation():
    role = Role(
        name=None,
        vm_restriction='Only User Owned')
    with error.expected("Name can't be blank"):
        role.create()