Blame SOURCES/0177-testsuite-add-test-for-uid_in_group.patch

562801
From eed8e1ded537327132a7cec7dec7af75ddea5656 Mon Sep 17 00:00:00 2001
562801
From: Matej Habrnal <mhabrnal@redhat.com>
562801
Date: Wed, 16 Dec 2015 10:54:25 +0100
562801
Subject: [PATCH] testsuite: add test for uid_in_group()
562801
562801
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
562801
---
562801
 tests/dump_dir.at | 33 +++++++++++++++++++++++++++++++++
562801
 1 file changed, 33 insertions(+)
562801
562801
diff --git a/tests/dump_dir.at b/tests/dump_dir.at
562801
index fb8c7ce..70a97e6 100644
562801
--- a/tests/dump_dir.at
562801
+++ b/tests/dump_dir.at
562801
@@ -322,3 +322,36 @@ int main(void)
562801
     return 0;
562801
 }
562801
 ]])
562801
+
562801
+## ------------ ##
562801
+## uid_in_group ##
562801
+## ------------ ##
562801
+
562801
+AT_TESTFUN([uid_in_group],
562801
+[[
562801
+#include "internal_libreport.h"
562801
+#include <libtar.h>
562801
+#include <assert.h>
562801
+
562801
+int main(void)
562801
+{
562801
+    // not existing user id
562801
+    assert(uid_in_group((uid_t)-1, 0) == false);
562801
+
562801
+    // root user is member of root group
562801
+    assert(uid_in_group(0, 0) == true);
562801
+
562801
+    // user root isn't member of not existing group
562801
+    assert(uid_in_group(0, (gid_t)-1) == false);
562801
+
562801
+    // user root isn't member of nobody group
562801
+    gid_t nobody_gid = (gid_t)-1;
562801
+    struct group *gr = getgrnam("nobody");
562801
+    if (gr)
562801
+        nobody_gid = gr->gr_gid;
562801
+
562801
+    assert(uid_in_group(0, nobody_gid) == false);
562801
+
562801
+    return 0;
562801
+}
562801
+]])
562801
-- 
562801
1.8.3.1
562801