From 748a056b0964e2abf93ad66951957c834a32b81b Mon Sep 17 00:00:00 2001 From: Martin André Date: Tue, 6 Jun 2017 10:58:32 +0200 Subject: Allow setting copied files group more precisely Previously with the config_files structure of config.json, the group name was automatically set to the one of the user name. It is now possible to set the group name in the same fashion than the 'permissions' structure with: owner: 'desired_owner:desired_group' Closes-Bug: #1696095 Change-Id: Ibae9f74e2351c81a717294467aedc51ea773c41e --- tests/test_set_config.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/test_set_config.py b/tests/test_set_config.py index e67db9bc2..fa8e45301 100644 --- a/tests/test_set_config.py +++ b/tests/test_set_config.py @@ -10,7 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import collections import copy import imp import json @@ -117,23 +116,16 @@ class ConfigFileTest(base.BaseTestCase): mock_remove.assert_called_with(config_file.dest) @mock.patch('os.chmod') - @mock.patch('os.chown') - @mock.patch('pwd.getpwnam') + @mock.patch.object(set_configs, 'handle_permissions') def test_set_permission(self, - mock_getpwnam, - mock_chown, + mock_handle_permissions, mock_chmod): - User = collections.namedtuple('User', ['pw_uid', 'pw_gid']) - user = User(3333, 4444) - mock_getpwnam.return_value = user - config_file = copy.deepcopy(FAKE_CONFIG_FILE) config_file._set_permission(config_file.dest) - - mock_getpwnam.assert_called_with(config_file.owner) - mock_chown.assert_called_with(config_file.dest, 3333, 4444) - mock_chmod.assert_called_with(config_file.dest, 420) + mock_handle_permissions.assert_called_with({'owner': 'user1', + 'path': config_file.dest, + 'perm': '0644'}) @mock.patch('glob.glob', return_value=[]) def test_copy_no_source_not_optional(self, -- cgit v1.2.3