diff options
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Metadata.py | 6 | ||||
-rw-r--r-- | testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py index 447a7cd05..5dcaa8bdb 100644 --- a/src/lib/Bcfg2/Server/Plugins/Metadata.py +++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py @@ -858,10 +858,10 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, def merge_additional_groups(self, imd, groups): for group in groups: - if group in imd.groups or group not in self.groups: + if group in imd.groups: continue - category = self.groups[group].category - if category: + if group in self.groups and self.groups[group].category: + category = self.groups[group].category if self.groups[group].category in imd.categories: self.logger.warning("%s: Group %s suppressed by category " "%s; %s already a member of %s" % diff --git a/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py b/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py index a0a3aaee1..9aacbe5cc 100644 --- a/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py +++ b/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py @@ -875,6 +875,14 @@ class TestMetadata(unittest.TestCase): self.assertItemsEqual(imd.groups, oldgroups.union(["group6", "group8", "group9"])) + # test adding a group that is not defined in groups.xml + imd = metadata.get_initial_metadata("client2") + oldgroups = imd.groups + metadata.merge_additional_groups(imd, ["group6", "newgroup"]) + self.assertItemsEqual(imd.groups, + oldgroups.union(["group6", "newgroup"])) + + @patch("Bcfg2.Server.Plugins.Metadata.XMLMetadataConfig.load_xml", Mock()) def test_merge_additional_data(self): metadata = self.load_clients_data(metadata=self.load_groups_data()) |