2021-01-18 22:03:31 +00:00
#!/usr/bin/env python3
2021-05-07 13:14:40 +00:00
import os
2021-01-18 22:03:31 +00:00
import sys
from testflows . core import *
append_path ( sys . path , " .. " , " .. " )
from helpers . cluster import Cluster
from helpers . argparser import argparser
from ldap . role_mapping . requirements import *
2022-02-11 01:08:41 +00:00
from helpers . common import check_clickhouse_version
2021-01-18 22:03:31 +00:00
# Cross-outs of known fails
xfails = {
2022-03-22 16:39:58 +00:00
" mapping/roles removed and added in parallel " : [ ( Fail , " known bug " ) ] ,
" user dn detection/mapping/roles removed and added in parallel " : [
( Fail , " known bug " )
] ,
" cluster secret/external user directory/:/:/cluster with secret/ldap user/:mapped True/select using mapped role/with privilege on source and distributed " : [
( Fail , " https://github.com/ClickHouse/ClickHouse/issues/34130 " )
] ,
2022-02-11 01:08:41 +00:00
}
# Force results without running the test
2022-03-22 16:39:58 +00:00
ffails = {
" cluster secret " : (
Skip ,
" feature available on 20.10+ " ,
check_clickhouse_version ( " <20.10 " ) ,
)
2021-01-18 22:03:31 +00:00
}
2022-03-22 16:39:58 +00:00
2021-01-18 22:03:31 +00:00
@TestFeature
@Name ( " role mapping " )
@ArgumentParser ( argparser )
2022-03-22 16:39:58 +00:00
@Specifications ( SRS_014_ClickHouse_LDAP_Role_Mapping )
@Requirements ( RQ_SRS_014_LDAP_RoleMapping ( " 1.0 " ) )
2021-01-18 22:03:31 +00:00
@XFails ( xfails )
2022-02-11 01:08:41 +00:00
@FFails ( ffails )
2022-03-22 16:39:58 +00:00
def regression (
self , local , clickhouse_binary_path , clickhouse_version = None , stress = None
) :
""" ClickHouse LDAP role mapping regression module. """
2021-01-18 22:03:31 +00:00
nodes = {
" clickhouse " : ( " clickhouse1 " , " clickhouse2 " , " clickhouse3 " ) ,
}
2022-02-11 01:08:41 +00:00
self . context . clickhouse_version = clickhouse_version
2021-05-10 20:59:47 +00:00
if stress is not None :
self . context . stress = stress
2022-02-11 01:08:41 +00:00
from platform import processor as current_cpu
folder_name = os . path . basename ( current_dir ( ) )
2022-03-22 16:39:58 +00:00
if current_cpu ( ) == " aarch64 " :
2022-02-11 01:08:41 +00:00
env = f " { folder_name } _env_arm64 "
else :
env = f " { folder_name } _env "
2021-05-10 20:59:47 +00:00
2022-03-22 16:39:58 +00:00
with Cluster (
local ,
clickhouse_binary_path ,
nodes = nodes ,
docker_compose_project_dir = os . path . join ( current_dir ( ) , env ) ,
) as cluster :
2021-01-18 22:03:31 +00:00
self . context . cluster = cluster
2022-03-22 16:39:58 +00:00
Scenario (
run = load ( " ldap.authentication.tests.sanity " , " scenario " ) , name = " ldap sanity "
)
2021-01-18 22:03:31 +00:00
Feature ( run = load ( " ldap.role_mapping.tests.server_config " , " feature " ) )
Feature ( run = load ( " ldap.role_mapping.tests.mapping " , " feature " ) )
2022-02-11 01:08:41 +00:00
Feature ( run = load ( " ldap.role_mapping.tests.user_dn_detection " , " feature " ) )
Feature ( run = load ( " ldap.role_mapping.tests.cluster_secret " , " feature " ) )
2021-01-18 22:03:31 +00:00
2022-03-22 16:39:58 +00:00
2021-01-18 22:03:31 +00:00
if main ( ) :
regression ( )