pacemaker  2.1.9-49aab99839
Scalable High-Availability cluster resource manager
pcmk__is_user_in_group_test.c
Go to the documentation of this file.
1 /*
2  * Copyright 2020-2022 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU General Public License version 2
7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
8  */
9 
10 #include <crm_internal.h>
11 
13 #include <crm/common/acl.h>
14 
15 #include "../../crmcommon_private.h"
16 #include "mock_private.h"
17 
18 static void
19 is_pcmk__is_user_in_group(void **state)
20 {
21  pcmk__mock_grent = true;
22 
23  // null user
24  assert_false(pcmk__is_user_in_group(NULL, "grp0"));
25  // null group
26  assert_false(pcmk__is_user_in_group("user0", NULL));
27  // nonexistent group
28  assert_false(pcmk__is_user_in_group("user0", "nonexistent_group"));
29  // user is in group
30  assert_true(pcmk__is_user_in_group("user0", "grp0"));
31  // user is not in group
32  assert_false(pcmk__is_user_in_group("user2", "grp0"));
33 
34  pcmk__mock_grent = false;
35 }
36 
37 PCMK__UNIT_TEST(NULL, NULL,
38  cmocka_unit_test(is_pcmk__is_user_in_group))
bool pcmk__mock_grent
Definition: mock.c:236
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
G_GNUC_INTERNAL bool pcmk__is_user_in_group(const char *user, const char *group)
Definition: utils.c:51
Low-level API for XML Access Control Lists (ACLs)