10 #include "include/config.h"
11 #include "librpc/gen_ndr/ndr_samr.h"
12 #include "librpc/gen_ndr/ndr_samr_scompat.h"
13 #include "source3/rpc_server/srv_pipe.h"
14 #include "librpc/rpc/rpc_common.h"
15 #include "librpc/rpc/dcesrv_core.h"
20 struct loadparm_context
*lp_ctx
;
21 struct dcesrv_context
*dce_ctx
;
24 static struct dcesrv_context_callbacks srv_callbacks
= {
25 .log
.successful_authz
= NULL
,
28 static int setup_samr(void **state
)
32 const struct dcesrv_endpoint_server
*ep_server
;
35 mem_ctx
= talloc_new(NULL
);
36 assert_non_null(mem_ctx
);
38 s
= talloc_zero(mem_ctx
, struct test_state
);
43 ep_server
= samr_get_ep_server();
44 assert_non_null(ep_server
);
46 status
= dcerpc_register_ep_server(ep_server
);
47 assert_true(NT_STATUS_IS_OK(status
));
49 status
= dcesrv_init_context(s
, NULL
, &srv_callbacks
, &s
->dce_ctx
);
50 assert_true(NT_STATUS_IS_OK(status
));
52 status
= dcesrv_init_ep_server(s
->dce_ctx
, "samr");
53 assert_true(NT_STATUS_IS_OK(status
));
60 static int teardown_samr(void **state
)
62 struct test_state
*s
= talloc_get_type_abort(*state
,
65 unsetenv("UNITTEST_DUMMY_MODULE_LOADED");
67 dcesrv_shutdown_ep_server(s
->dce_ctx
, "samr");
69 talloc_free(s
->mem_ctx
);
74 static void test_is_known_pipename(void **state
)
76 struct test_state
*s
= talloc_get_type_abort(*state
,
78 struct dcesrv_endpoint
*ep
;
79 char dummy_module_path
[4096] = {0};
80 const char *module_env
;
83 status
= is_known_pipename(s
->dce_ctx
, "samr", &ep
);
84 assert_true(NT_STATUS_IS_OK(status
));
86 status
= is_known_pipename(s
->dce_ctx
, "SAMR", &ep
);
87 assert_true(NT_STATUS_IS_OK(status
));
89 snprintf(dummy_module_path
,
90 sizeof(dummy_module_path
),
91 "%s/bin/modules/rpc/test_dummy_module.so",
94 status
= is_known_pipename(s
->dce_ctx
, dummy_module_path
, &ep
);
95 assert_false(NT_STATUS_IS_OK(status
));
97 module_env
= getenv("UNITTEST_DUMMY_MODULE_LOADED");
98 assert_null(module_env
);
102 const struct CMUnitTest tests
[] = {
103 cmocka_unit_test_setup_teardown(test_is_known_pipename
,
108 cmocka_set_message_output(CM_OUTPUT_SUBUNIT
);
109 return cmocka_run_group_tests(tests
, NULL
, NULL
);