diff options
author | David Zeuthen <davidz@redhat.com> | 2012-05-21 13:42:43 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2012-05-21 13:42:43 -0400 |
commit | 31c0ce425a03c59726b7c1a83aaf8cd8dfab79f7 (patch) | |
tree | a61d6b510f2289a6170da77d784c03cb1e6a6546 /test | |
parent | 8e0c53ecf7129cd1be8bc9ac322aab4af992ce61 (diff) | |
download | polkit-31c0ce425a03c59726b7c1a83aaf8cd8dfab79f7.tar.gz |
Add netgroup support
Signed-off-by: David Zeuthen <davidz@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 3 | ||||
-rw-r--r-- | test/data/etc/polkit-1/rules.d/10-testing.rules | 18 | ||||
-rw-r--r-- | test/polkitbackend/test-polkitbackendjsauthority.c | 24 |
3 files changed, 43 insertions, 2 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 8426977..598e426 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,7 +2,7 @@ SUBDIRS = mocklibc . polkit polkitbackend AM_CFLAGS = $(GLIB_CFLAGS) -check_LTLIBRARIES = libpolkit-test-helper.la +noinst_LTLIBRARIES = libpolkit-test-helper.la libpolkit_test_helper_la_SOURCES = polkittesthelper.c polkittesthelper.h libpolkit_test_helper_la_LIBADD = $(GLIB_LIBS) @@ -17,7 +17,6 @@ export TESTS_ENVIRONMENT := $(abs_top_builddir)/test/mocklibc/bin/mocklibc # Include path to mock config files export POLKIT_TEST_DATA := $(abs_top_srcdir)/test/data - clean-local : rm -f *~ diff --git a/test/data/etc/polkit-1/rules.d/10-testing.rules b/test/data/etc/polkit-1/rules.d/10-testing.rules index 4cd184c..0cad62c 100644 --- a/test/data/etc/polkit-1/rules.d/10-testing.rules +++ b/test/data/etc/polkit-1/rules.d/10-testing.rules @@ -16,6 +16,12 @@ polkit.addAdminRule(function(action, subject, details) { } }); +polkit.addAdminRule(function(action, subject, details) { + if (action == "net.company.action3") { + return ["unix-netgroup:foo"]; + } +}); + // Fallback polkit.addAdminRule(function(action, subject, details) { return ["unix-group:admin", "unix-user:root"]; @@ -53,3 +59,15 @@ polkit.addRule(function(action, subject, details) { return "no"; } }); + +// --------------------------------------------------------------------- +// netgroup membership + +polkit.addRule(function(action, subject, details) { + if (action == "net.company.group.only_netgroup_users") { + if (subject.isInNetGroup("foo")) + return "yes"; + else + return "no"; + } +}); diff --git a/test/polkitbackend/test-polkitbackendjsauthority.c b/test/polkitbackend/test-polkitbackendjsauthority.c index a210f68..f81c7fb 100644 --- a/test/polkitbackend/test-polkitbackendjsauthority.c +++ b/test/polkitbackend/test-polkitbackendjsauthority.c @@ -130,6 +130,12 @@ test_get_admin_identities (void) "unix-group:users" } }, + { + "net.company.action3", + { + "unix-netgroup:foo" + } + }, }; guint n; @@ -222,6 +228,24 @@ static const RulesTestCase rules_test_cases[] = { POLKIT_IMPLICIT_AUTHORIZATION_NOT_AUTHORIZED, NULL }, + + /* check netgroup membership */ + { + /* john is a member of netgroup 'foo', see test/etc/netgroup */ + "netgroup_membership_with_member", + "net.company.group.only_netgroup_users", + "unix-user:john", + POLKIT_IMPLICIT_AUTHORIZATION_AUTHORIZED, + NULL + }, + { + /* sally is not a member of netgroup 'foo', see test/etc/netgroup */ + "netgroup_membership_with_non_member", + "net.company.group.only_netgroup_users", + "unix-user:sally", + POLKIT_IMPLICIT_AUTHORIZATION_NOT_AUTHORIZED, + NULL + }, }; /* ---------------------------------------------------------------------------------------------------- */ |