Skip to content

Commit

Permalink
CONFIG: validator rules & test
Browse files Browse the repository at this point in the history
Add support of 'certmap' config section to validator rules

Resolves:
https://pagure.io/SSSD/sssd/issue/3845
  • Loading branch information
alexey-tikhonov committed Jan 9, 2019
1 parent e4469fb commit bc7a282
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/config/cfg_rules.ini
Expand Up @@ -17,6 +17,7 @@ section_re = ^secrets/kcm$
section_re = ^domain/[^/\@]\+$
section_re = ^domain/[^/\@]\+/[^/\@]\+$
section_re = ^application/[^/\@]\+$
section_re = ^certmap/[^/\@]\+/[^/\@]\+$


[rule/allowed_sssd_options]
Expand Down Expand Up @@ -749,3 +750,12 @@ option = use_fully_qualified_names

[rule/sssd_checks]
validator = sssd_checks

[rule/allowed_certmap_options]
validator = ini_allowed_options
section_re = ^certmap/[^/\@]\+/[^/\@]\+$

option = matchrule
option = maprule
option = priority
option = domains
16 changes: 15 additions & 1 deletion src/tests/cmocka/test_config_check.c
Expand Up @@ -224,6 +224,18 @@ void config_check_test_bad_subdom_option_name(void **state)
config_check_test_common(cfg_str, 1, expected_errors);
}

void config_check_test_bad_certmap_option_name(void **state)
{
char cfg_str[] = "[certmap/files/testuser]\n"
"debug_level = 10\n";
const char *expected_errors[] = {
"[rule/allowed_certmap_options]: Attribute 'debug_level' is not "
"allowed in section 'certmap/files/testuser'. Check for typos.",
};

config_check_test_common(cfg_str, 1, expected_errors);
}

void config_check_test_good_sections(void **state)
{
char cfg_str[] = "[sssd]\n"
Expand All @@ -236,7 +248,8 @@ void config_check_test_good_sections(void **state)
"[secrets/users/1000]\n"
"[ssh]\n"
"[ifp]\n"
"[pac]\n";
"[pac]\n"
"[certmap/files/testuser]\n";
const char *expected_errors[] = { NULL };

config_check_test_common(cfg_str, 0, expected_errors);
Expand Down Expand Up @@ -284,6 +297,7 @@ int main(int argc, const char *argv[])
cmocka_unit_test(config_check_test_bad_ifp_option_name),
cmocka_unit_test(config_check_test_bad_appdomain_option_name),
cmocka_unit_test(config_check_test_bad_subdom_option_name),
cmocka_unit_test(config_check_test_bad_certmap_option_name),
cmocka_unit_test(config_check_test_good_sections),
cmocka_unit_test(config_check_test_inherit_from_in_normal_dom),
cmocka_unit_test(config_check_test_inherit_from_in_app_dom),
Expand Down

0 comments on commit bc7a282

Please sign in to comment.