root/lib/common/tests/acl/pcmk__is_user_in_group_test.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. is_pcmk__is_user_in_group

   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 
  12 #include <crm/common/unittest_internal.h>
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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))

/* [previous][next][first][last][top][bottom][index][help] */