lib/param: Add tests for security= behaviour now it operates with server role
authorAndrew Bartlett <abartlet@samba.org>
Thu, 10 Nov 2011 06:11:56 +0000 (17:11 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 16 Nov 2011 23:34:09 +0000 (00:34 +0100)
Pair-Programmed-With: Amitay Isaacs <amitay@samba.org>

source4/param/tests/loadparm.c

index 19eaabe833b5e71da6075e65520e11517d5da538..5f27439912456e6e913f6b42945cd3fce6ea9246 100644 (file)
@@ -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);