diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-11-10 16:07:52 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-11-17 00:34:09 +0100 |
commit | 31ba7af757bc7a872140b6fc91e67dab28c9ac8f (patch) | |
tree | 371616a04dc5357028777ec6fd811e1f195ec856 /source4/param/tests | |
parent | 42406d63a4475ed167ca46ae21c850ee77a071ef (diff) | |
download | samba-31ba7af757bc7a872140b6fc91e67dab28c9ac8f.tar.gz samba-31ba7af757bc7a872140b6fc91e67dab28c9ac8f.tar.bz2 samba-31ba7af757bc7a872140b6fc91e67dab28c9ac8f.zip |
param: Add tests for automatic server role guessing
Pair-Programmed-With: Amitay Isaacs <amitay@samba.org>
Diffstat (limited to 'source4/param/tests')
-rw-r--r-- | source4/param/tests/loadparm.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/source4/param/tests/loadparm.c b/source4/param/tests/loadparm.c index fb269a1a9f..19eaabe833 100644 --- a/source4/param/tests/loadparm.c +++ b/source4/param/tests/loadparm.c @@ -145,6 +145,78 @@ static bool test_lp_service(struct torture_context *tctx) return true; } +static bool test_server_role_default(struct torture_context *tctx) +{ + struct loadparm_context *lp_ctx = loadparm_init(tctx); + torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_STANDALONE, "ROLE should be standalone by default"); + return true; +} + +static bool test_server_role_dc_specified(struct torture_context *tctx) +{ + struct loadparm_context *lp_ctx = loadparm_init(tctx); + torture_assert(tctx, lpcfg_set_option(lp_ctx, "server role=domain controller"), "lpcfg_set_option failed"); + torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_DOMAIN_CONTROLLER, "ROLE should be DC"); + return true; +} + +static bool test_server_role_member_specified(struct torture_context *tctx) +{ + struct loadparm_context *lp_ctx = loadparm_init(tctx); + torture_assert(tctx, lpcfg_set_option(lp_ctx, "server role=member"), "lpcfg_set_option failed"); + torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_DOMAIN_MEMBER, "ROLE should be member"); + return true; +} + +static bool test_server_role_dc_domain_logons(struct torture_context *tctx) +{ + struct loadparm_context *lp_ctx = loadparm_init(tctx); + torture_assert(tctx, lpcfg_set_option(lp_ctx, "domain logons=true"), "lpcfg_set_option failed"); + torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_DOMAIN_PDC, "ROLE should be PDC"); + return true; +} + +static bool test_server_role_dc_domain_logons_and_not_master(struct torture_context *tctx) +{ + struct loadparm_context *lp_ctx = loadparm_init(tctx); + torture_assert(tctx, lpcfg_set_option(lp_ctx, "domain logons=true"), "lpcfg_set_option failed"); + torture_assert(tctx, lpcfg_set_option(lp_ctx, "domain master=false"), "lpcfg_set_option failed"); + torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_DOMAIN_BDC, "ROLE should be BDC"); + return true; +} + +static bool test_server_role_security_ads(struct torture_context *tctx) +{ + struct loadparm_context *lp_ctx = loadparm_init(tctx); + torture_assert(tctx, lpcfg_set_option(lp_ctx, "security=ads"), "lpcfg_set_option failed"); + torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_DOMAIN_MEMBER, "ROLE should be MEMBER"); + return true; +} + +static bool test_server_role_security_domain(struct torture_context *tctx) +{ + struct loadparm_context *lp_ctx = loadparm_init(tctx); + torture_assert(tctx, lpcfg_set_option(lp_ctx, "security=domain"), "lpcfg_set_option failed"); + torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_DOMAIN_MEMBER, "ROLE should be MEMBER"); + return true; +} + +static bool test_server_role_security_share(struct torture_context *tctx) +{ + struct loadparm_context *lp_ctx = loadparm_init(tctx); + torture_assert(tctx, lpcfg_set_option(lp_ctx, "security=share"), "lpcfg_set_option failed"); + torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_STANDALONE, "ROLE should be STANDALONE"); + return true; +} + +static bool test_server_role_security_server(struct torture_context *tctx) +{ + struct loadparm_context *lp_ctx = loadparm_init(tctx); + torture_assert(tctx, lpcfg_set_option(lp_ctx, "security=server"), "lpcfg_set_option failed"); + torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_STANDALONE, "ROLE should be STANDALONE"); + return true; +} + struct torture_suite *torture_local_loadparm(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, "loadparm"); @@ -162,6 +234,15 @@ struct torture_suite *torture_local_loadparm(TALLOC_CTX *mem_ctx) torture_suite_add_simple_test(suite, "lpcfg_service", test_lp_service); torture_suite_add_simple_test(suite, "do_global_parameter_var", test_do_global_parameter_var); torture_suite_add_simple_test(suite, "do_global_parameter", test_do_global_parameter); + torture_suite_add_simple_test(suite, "test_server_role_default", test_server_role_default); + torture_suite_add_simple_test(suite, "test_server_role_dc_specified", test_server_role_dc_specified); + torture_suite_add_simple_test(suite, "test_server_role_member_specified", test_server_role_member_specified); + torture_suite_add_simple_test(suite, "test_server_role_dc_domain_logons", test_server_role_dc_domain_logons); + torture_suite_add_simple_test(suite, "test_server_role_dc_domain_logons_and_not_master", test_server_role_dc_domain_logons_and_not_master); + torture_suite_add_simple_test(suite, "test_server_role_security_ads", test_server_role_security_ads); + torture_suite_add_simple_test(suite, "test_server_role_security_domain", test_server_role_security_domain); + torture_suite_add_simple_test(suite, "test_server_role_security_share", test_server_role_security_share); + torture_suite_add_simple_test(suite, "test_server_role_security_server", test_server_role_security_server); return suite; } |