def test_check_key_path_and_mode(self): with tempfile.NamedTemporaryFile() as f: key_file = f.name os.chmod(key_file, 0o644) self.assertFalse(cloud.check_key_path_and_mode('foo', key_file)) os.chmod(key_file, 0o600) self.assertTrue(cloud.check_key_path_and_mode('foo', key_file)) os.chmod(key_file, 0o400) self.assertTrue(cloud.check_key_path_and_mode('foo', key_file)) # tmp file removed self.assertFalse(cloud.check_key_path_and_mode('foo', key_file))
def test_check_key_path_and_mode(create_class): with tempfile.NamedTemporaryFile() as f: key_file = f.name os.chmod(key_file, 0o644) assert cloud.check_key_path_and_mode("foo", key_file) is False os.chmod(key_file, 0o600) assert cloud.check_key_path_and_mode("foo", key_file) is True os.chmod(key_file, 0o400) assert cloud.check_key_path_and_mode("foo", key_file) is True # tmp file removed assert cloud.check_key_path_and_mode("foo", key_file) is False