Bug 43608 - Add unit tests to Policy Kit
Summary: Add unit tests to Policy Kit
Status: RESOLVED FIXED
Alias: None
Product: PolicyKit
Classification: Unclassified
Component: daemon (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: David Zeuthen (not reading bugmail)
QA Contact: David Zeuthen (not reading bugmail)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-07 17:15 UTC by Nikki VonHollen
Modified: 2011-12-20 08:29 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Added netgroup support, added MockLibc support for mocking NSS calls in unit tests, expanded previous unit tests to include new mock users/groups. (48.12 KB, patch)
2011-12-14 20:45 UTC, Nikki VonHollen
Details | Splinter Review
Basic unittest support and a few tests (34.87 KB, patch)
2011-12-14 20:49 UTC, Nikki VonHollen
Details | Splinter Review

Description Nikki VonHollen 2011-12-07 17:15:56 UTC
I'll be submitting a patch shortly to add basic unit tests to PolicyKit. 

In preparation for adding netgroup support, I'm adding tests for the normal cases of: PolkitUnixUser, PolkitUnixGroup, PolkitIdentity, PolkitBackendLocalAuthority, and PolkitBackendLocalAuthorizationStore.

Tests use glib's test framework: http://developer.gnome.org/glib/2.30/glib-Testing.html

Tests should run when 'make check' is called, and should cause 'make check' to fail if any tests fail.

Unit tests link against libraries built for each part of Policy Kit in ./src, and do import private headers. Future integration tests should only use public interfaces.
Comment 1 Nikki VonHollen 2011-12-14 20:45:41 UTC
Created attachment 54449 [details] [review]
Added netgroup support, added MockLibc support for mocking NSS calls in unit tests, expanded previous unit tests to include new mock users/groups.

This patch relies on 'policykit-unittest.patch' from bug #43608.

There are a few issues I ran into implementing netgroups:
1. Netgroups can't support glob syntax like other identities do in *.pkla files.
2. A netgroup with a wildcard entry like (,,), which means any user/host/domain, will be ignored in the admin identities list.
3. I use git submodules to include the MockLibc source code, but I'm not sure if that's what we should stick with. I can include code

Since I'm using submodules, the first commit with the submodule needs to run 'git submodule add' to put special metadata in the repo which can't happen via patch AFAIK. For eaxmple:
cd PolicyKit
patch -p1 < ~/policykit-unittest.patch
patch -p1 < ~/policykit-netgroup.patch
git submodule add -b v1 https://code.google.com/p/mocklibc/ noinst/mocklibc
Comment 2 Nikki VonHollen 2011-12-14 20:49:51 UTC
Created attachment 54451 [details] [review]
Basic unittest support and a few tests

Please ignore the previous comment/attachment. I got the two bug numbers mixed
up.

Adds basic unit tests for:
PolkitIdentity, PolkitUnixUser, PolkitUnixGroup,
PolkitBackendLocalAuthorizationStore, and PolkitBackendLocalAuthority.
Comment 3 David Zeuthen (not reading bugmail) 2011-12-20 08:29:05 UTC
Patch looks great, I've committed it here

http://cgit.freedesktop.org/PolicyKit/commit/?id=15d2e90a54009efb31300d8b59292d71ce98a5b2

Thanks!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.