This source file includes following definitions.
- is_xml_acl_denied_without_node
- is_xml_acl_denied_with_node
- main
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11 #include <crm/common/acl.h>
12 #include "../../crmcommon_private.h"
13
14 #include <stdarg.h>
15 #include <stddef.h>
16 #include <stdint.h>
17 #include <setjmp.h>
18 #include <cmocka.h>
19
20 static void
21 is_xml_acl_denied_without_node(void **state)
22 {
23 xmlNode *test_xml = create_xml_node(NULL, "test_xml");
24 assert_false(xml_acl_denied(test_xml));
25
26 test_xml->doc->_private = NULL;
27 assert_false(xml_acl_denied(test_xml));
28
29 test_xml->doc = NULL;
30 assert_false(xml_acl_denied(test_xml));
31
32 test_xml = NULL;
33 assert_false(xml_acl_denied(test_xml));
34 }
35
36 static void
37 is_xml_acl_denied_with_node(void **state)
38 {
39 xml_private_t *p;
40
41 xmlNode *test_xml = create_xml_node(NULL, "test_xml");
42
43
44 test_xml->doc->_private = calloc(1, sizeof(xml_private_t));
45
46 assert_false(xml_acl_denied(test_xml));
47
48
49 p = test_xml->doc->_private;
50
51
52 p->flags |= pcmk__xf_acl_enabled;
53
54 assert_false(xml_acl_denied(test_xml));
55
56
57 p->flags |= pcmk__xf_acl_denied;
58
59 assert_true(xml_acl_denied(test_xml));
60 }
61
62 int
63 main(int argc, char **argv)
64 {
65 const struct CMUnitTest tests[] = {
66 cmocka_unit_test(is_xml_acl_denied_without_node),
67 cmocka_unit_test(is_xml_acl_denied_with_node),
68 };
69
70 cmocka_set_message_output(CM_OUTPUT_TAP);
71 return cmocka_run_group_tests(tests, NULL, NULL);
72 }