From ea7cb8ccb7f19fa8f4c5e6c61147dd6a4a877e22 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 10 Nov 2011 17:11:56 +1100 Subject: lib/param: Add tests for security= behaviour now it operates with server role Pair-Programmed-With: Amitay Isaacs --- source4/param/tests/loadparm.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source4/param') diff --git a/source4/param/tests/loadparm.c b/source4/param/tests/loadparm.c index 19eaabe833..5f27439912 100644 --- a/source4/param/tests/loadparm.c +++ b/source4/param/tests/loadparm.c @@ -149,6 +149,7 @@ 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"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_USER, "security should be user"); return true; } @@ -157,6 +158,7 @@ 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"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_USER, "security should be USER"); return true; } @@ -165,6 +167,36 @@ 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"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_ADS, "security should be ADS"); + return true; +} + +static bool test_server_role_member_specified2(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(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"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_DOMAIN, "security should be domain"); + return true; +} + +static bool test_server_role_member_specified3(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(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"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_ADS, "security should be ads"); + return true; +} + +static bool test_server_role_standalone_specified(struct torture_context *tctx) +{ + struct loadparm_context *lp_ctx = loadparm_init(tctx); + torture_assert(tctx, lpcfg_set_option(lp_ctx, "server role=standalone"), "lpcfg_set_option failed"); + torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_STANDALONE, "ROLE should be standalone"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_USER, "security should be USER"); return true; } @@ -173,6 +205,7 @@ 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"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_USER, "security should be user"); return true; } @@ -182,6 +215,7 @@ static bool test_server_role_dc_domain_logons_and_not_master(struct torture_cont 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"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_USER, "security should be user"); return true; } @@ -190,6 +224,7 @@ 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"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_ADS, "security should be ads"); return true; } @@ -198,6 +233,7 @@ 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"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_DOMAIN, "security should be domain"); return true; } @@ -206,6 +242,7 @@ 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"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_SHARE, "security should be share"); return true; } @@ -214,6 +251,7 @@ 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"); + torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_SERVER, "security should be server"); return true; } @@ -237,6 +275,9 @@ struct torture_suite *torture_local_loadparm(TALLOC_CTX *mem_ctx) 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_member_specified2", test_server_role_member_specified2); + torture_suite_add_simple_test(suite, "test_server_role_member_specified3", test_server_role_member_specified3); + torture_suite_add_simple_test(suite, "test_server_role_standalone_specified", test_server_role_standalone_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); -- cgit