Exemplo n.º 1
0
def check_role_with_parametrization(clients, user, cluster_bundle: Bundle, provider_bundle: Bundle):
    """Check that update of role with parametrization leads to correct permissions update"""
    cluster, provider = cluster_bundle.cluster_create('clusteraster'), provider_bundle.provider_create('provideraider')
    role_name = "Role with parametrization"

    role = clients.admin.role_create(
        name=role_name,
        display_name=role_name,
        child=_form_children(clients.admin, BusinessRoles.EditClusterConfigurations),
    )
    policy = clients.admin.policy_create(name="User policy", role=role, objects=[cluster], user=[user])
    with new_client_instance(*TEST_USER_CREDENTIALS, clients.user.url) as user_client:
        user_cluster, user_provider = as_user_objects(user_client, cluster, provider)
        is_allowed(user_cluster, BusinessRoles.EditClusterConfigurations)
        is_denied(user_provider, BusinessRoles.EditProviderConfigurations)
    role.update(child=_form_children(clients.admin, BusinessRoles.EditProviderConfigurations))
    with new_client_instance(*TEST_USER_CREDENTIALS, clients.user.url) as user_client:
        user_cluster, user_provider = as_user_objects(user_client, cluster, provider)
        is_denied(user_cluster, BusinessRoles.EditClusterConfigurations)
        is_denied(user_provider, BusinessRoles.EditProviderConfigurations)
    policy.update(object=[{'type': 'provider', 'id': provider.id}])
    with new_client_instance(*TEST_USER_CREDENTIALS, clients.user.url) as user_client:
        user_cluster, user_provider = as_user_objects(user_client, cluster, provider)
        is_denied(user_cluster, BusinessRoles.EditClusterConfigurations)
        is_allowed(user_provider, BusinessRoles.EditProviderConfigurations)
    policy.delete()
    role.delete()
Exemplo n.º 2
0
    def create_complex_provider(
        self, provider_bundle: Bundle, template: str = 'complex-host', amount_of_hosts: int = 18
    ) -> Tuple[Provider, Task]:
        """
        Create provider, bunch of hosts via action (provide template if you want to use it more than 1 time).

        :returns: Create provider and hosts create tasks
        """
        provider = provider_bundle.provider_create(name=f'Complex Provider {random_string(6)}')
        provider.config_set_diff({'very_important_flag': 54.4})
        task = provider.action(name='create_hosts').run(config={'count': amount_of_hosts, 'template': template})
        return provider, task
Exemplo n.º 3
0
def provider(provider_bundle: Bundle) -> Provider:
    """Create provider"""
    return provider_bundle.provider_create(name=utils.random_string())
Exemplo n.º 4
0
def provider(provider_bundle: Bundle) -> Provider:
    """Create provider"""
    return provider_bundle.provider_create('Awesome Provider')