9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# Abstract passwd/group entry management
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# Copyright (c) 2015 Red Hat, Inc.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# Author: Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# This is free software; you can redistribute it and/or modify it
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# under the terms of the GNU General Public License as published by
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# the Free Software Foundation; version 2 only
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# This program is distributed in the hope that it will be useful, but
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# WITHOUT ANY WARRANTY; without even the implied warranty of
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# General Public License for more details.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# You should have received a copy of the GNU General Public License
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov# along with this program. If not, see <http://www.gnu.org/licenses/>.
efdcf49660505e13607b99ba82eb504cf37b8794Nikolai Kondrashov_GROUP_DESC = {"mem": ("member list", {None: ("member", {})})}
efdcf49660505e13607b99ba82eb504cf37b8794Nikolai Kondrashov_GROUP_LIST_DESC = {None: ("group", _GROUP_DESC)}
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Get an item description from a container description map.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov desc_map Container description map.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov key Item key, None for wildcard description.
efdcf49660505e13607b99ba82eb504cf37b8794Nikolai Kondrashov if key is not None:
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov desc = (desc[0] + " " + pformat(key), desc[1])
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return ("item", {})
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Describe difference between an entry and a pattern.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Return None, if none.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov pattern Pattern.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov desc_map Container pattern description map.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov An entry is a value, a list of entries, or a dictionary of entries.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Entries are used to store passwd and group database entries as
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov dictionaries, in lists and dictionaries.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov A pattern is a value, a tuple, a list, or a dictionary of patterns.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov E.g. 123, "abc", [ 123, "abc" ], { "abc": 123 }, { "abc": ( 123 ) }
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov A pattern can be matched against a value, a list, or a dictionary entry.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov A value is considered matching, if it's equal to the pattern.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov E.g. 123 == 123, 123 != 456, "abc" == "abc", "abc" != "def", 123 != "abc"
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov A list is considered matching a pattern, if the pattern is a list or a
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov tuple, where each of pattern list items matches an entry list item and
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov vice versa, or where each pattern tuple item matches an entry list item,
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov but not necessarily the other way around.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov E.g. [] != "abc", [] == [], [ "abc", 123 ] == [ 123, "abc" ],
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov [ "abc" ] != [ 123 ], [ 123 ] != [],
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov [] == (), [ "abc", 123 ] == ( 123, "abc" ),
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov [ "abc" ] != ( 123 ), [ 123 ] == (), [ 123, "abc" ] == ( 123 )
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov NOTE: For the sake of readability, it is recommended to use
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov "contains_only" function to create patterns matching all entry list
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov items (list patterns), and "contains" function to create patterns
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov matching a subset of entry list items (tuple patterns).
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov A dictionary is considered matching a pattern, if it is also a dictionary,
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov and all of pattern values match identically-keyed values of the
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov E.g. {} == {}, {} != "abc", { "abc": 123, "def": 456 } == { "abc": 123 },
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov { "abc": 123 } == {}
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Container pattern description map is a dictionary with keys being item
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov keys/indices and values being (name, description map) tuples. None key
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov points to a wildcard description, others to specific item descriptions.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov The description map argument is optional, and is used to generate more
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov readable difference explanations.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov item_name, item_map = _get_desc(desc_map, key)
1fef02f87429597e82965a9870e4597e0fadf212Lukas Slebodnik unmatched_pattern = [pattern[pi] for pi in range(0, len(pattern))
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov items = _get_desc(desc_map, None)[0] + "s"
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return "\nexpected " + items + " not found:\n" + \
1fef02f87429597e82965a9870e4597e0fadf212Lukas Slebodnik unmatched_pattern = [pattern[pi] for pi in range(0, len(pattern))
1fef02f87429597e82965a9870e4597e0fadf212Lukas Slebodnik unmatched_ent = [ent[pi] for pi in range(0, len(ent))
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov items = _get_desc(desc_map, None)[0] + "s"
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d += "\nexpected " + items + " not found:\n" + \
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d += "\nunexpected " + items + " found:\n" + \
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return pformat(pattern) + " != " + pformat(ent)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Produce a pattern matching all list items against arguments.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Use this function instead of constructing bare lists, for readability.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Produce a pattern matching a subset of list items against arguments.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Use this function instead of constructing bare tuples, for readability.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Convert a passwd entry returned by pwd module to an entry dictionary.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Get a passwd database entry by name."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return _convert_passwd(pwd.getpwnam(name))
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Get a passwd database entry by UID."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return _convert_passwd(pwd.getpwuid(uid))
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Assert a passwd entry, retrieved by name, matches a pattern."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Assert a passwd entry, retrieved by UID, matches a pattern."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Get passwd database entry list with root user removed."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov if v.pw_name == "root" and v.pw_uid == 0 and v.pw_gid == 0:
554734a2073eaf1e862bfc08b1e9761931455454Lukas Slebodnik return list(map(_convert_passwd, passwd_list))
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Assert retrieved passwd list matches a pattern."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff(get_passwd_list(), pattern, _PASSWD_LIST_DESC)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef _diff_each_passwd_by_name(pattern_dict):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Describe difference between each pattern_dict value and a passwd entry
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov retrieved by name being the corresponding key.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov ent = dict((k, get_passwd_by_name(k)) for k in pattern_dict.keys())
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return _diff(ent, pattern_dict, _PASSWD_LIST_DESC)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef _diff_each_passwd_by_uid(pattern_dict):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Describe difference between each pattern_dict value and a passwd entry
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov retrieved by UID being the corresponding key.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov ent = dict((k, get_passwd_by_uid(k)) for k in pattern_dict.keys())
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return _diff(ent, pattern_dict, _PASSWD_LIST_DESC)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef _diff_each_passwd_with_name(pattern_seq):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Describe difference between each pattern in pattern_seq sequence and a
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov passwd entry retrieved by name being the pattern's "name" value.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return _diff_each_passwd_by_name(dict((p["name"], p) for p in pattern_seq))
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef _diff_each_passwd_with_uid(pattern_seq):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Describe difference between each pattern in pattern_seq sequence and a
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov passwd entry retrieved by UID being the pattern's "uid" value.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return _diff_each_passwd_by_uid(dict((p["uid"], p) for p in pattern_seq))
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef assert_each_passwd_by_name(pattern_dict):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Assert each pattern_dict value matches a passwd entry retrieved by
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov name being the corresponding key.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff_each_passwd_by_name(pattern_dict)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef assert_each_passwd_by_uid(pattern_dict):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Assert each pattern_dict value matches a passwd entry retrieved by
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov UID being the corresponding key.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff_each_passwd_by_uid(pattern_dict)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef assert_each_passwd_with_name(pattern_seq):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Assert each pattern in pattern_seq sequence matches a passwd entry
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov retrieved by name being the pattern's "name" value.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff_each_passwd_with_name(pattern_seq)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef assert_each_passwd_with_uid(pattern_seq):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Assert each pattern in pattern_seq sequence matches a passwd entry
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov retrieved by UID being the pattern's "uid" value.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff_each_passwd_with_uid(pattern_seq)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Describe difference between passwd database and a pattern.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Each pattern entry must have "name" and "uid" attribute.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff(get_passwd_list(), pattern, _PASSWD_LIST_DESC)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return "list mismatch: " + d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return "name retrieval mismatch: " + d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return "UID retrieval mismatch: " + d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Assert passwd database matches a pattern.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Each pattern entry must have "name" and "uid" attribute.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Convert a group entry returned by grp module to an entry dictionary.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Get a group database entry by name."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return _convert_group(grp.getgrnam(name))
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Get a group database entry by GID."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Assert a group entry, retrieved by name, matches a pattern."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Assert a group entry, retrieved by GID, matches a pattern."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Get group database entry list with root group removed."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov if v.gr_name == "root" and v.gr_gid == 0:
554734a2073eaf1e862bfc08b1e9761931455454Lukas Slebodnik return list(map(_convert_group, group_list))
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov """Assert retrieved group list matches a pattern."""
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff(get_group_list(), pattern, _GROUP_LIST_DESC)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef _diff_each_group_by_name(pattern_dict):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Describe difference between each pattern_dict value and a group entry
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov retrieved by name being the corresponding key.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov ent = dict((k, get_group_by_name(k)) for k in pattern_dict.keys())
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return _diff(ent, pattern_dict, _GROUP_LIST_DESC)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef _diff_each_group_by_gid(pattern_dict):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Describe difference between each pattern_dict value and a group entry
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov retrieved by GID being the corresponding key.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov ent = dict((k, get_group_by_gid(k)) for k in pattern_dict.keys())
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return _diff(ent, pattern_dict, _GROUP_LIST_DESC)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef _diff_each_group_with_name(pattern_seq):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Describe difference between each pattern in pattern_seq sequence and a
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov group entry retrieved name being the pattern's "name" value.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return _diff_each_group_by_name(dict((p["name"], p) for p in pattern_seq))
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef _diff_each_group_with_gid(pattern_seq):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Describe difference between each pattern in pattern_seq sequence and a
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov group entry retrieved by GID being the pattern's "gid" value.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return _diff_each_group_by_gid(dict((p["gid"], p) for p in pattern_seq))
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef assert_each_group_by_name(pattern_dict):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Assert each pattern_dict value matches a group entry retrieved by
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov name being the corresponding key.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff_each_group_by_name(pattern_dict)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef assert_each_group_by_gid(pattern_dict):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Assert each pattern_dict value matches a group entry retrieved by
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov GID being the corresponding key.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff_each_group_by_gid(pattern_dict)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef assert_each_group_with_name(pattern_seq):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Assert each pattern in pattern_seq sequence matches a group entry
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov retrieved by name being the pattern's "name" value.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff_each_group_with_name(pattern_seq)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashovdef assert_each_group_with_gid(pattern_seq):
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Assert each pattern in pattern_seq sequence matches a group entry
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov retrieved by GID being the pattern's "gid" value.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff_each_group_with_gid(pattern_seq)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Describe difference between group database and a pattern.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Each pattern entry must have "name" and "gid" attribute.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov d = _diff(get_group_list(), pattern, _GROUP_LIST_DESC)
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return "list mismatch: " + d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return "name retrieval mismatch: " + d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov return "GID retrieval mismatch: " + d
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Assert group database matches a pattern.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov Each pattern entry must have "name" and "gid" attribute.
9d453f1e8b28983b363b44c49b7cd701a994fd97Nikolai Kondrashov assert not d, d