Ejemplo n.º 1
0
 def test_verify_file_private_not_windows_raises_when_bad(
         self, mock_platform):
     mock_platform.system.return_value = 'Linux'
     tempfilename = make_temp_filename()
     set_file_perm(tempfilename, '0777')
     with self.assertRaises(ValueError):
         verify_file_private(tempfilename)
Ejemplo n.º 2
0
def create_config(allow_insecure_config_file=False):
    """
    Create config based on /etc/ddsclient.conf and ~/.ddsclient.conf($DDSCLIENT_CONF)
    :param allow_insecure_config_file: bool: when true we will not check ~/.ddsclient permissions.
    :return: Config with the configuration to use for DDSClient.
    """
    config = Config()
    config.add_properties(GLOBAL_CONFIG_FILENAME)
    user_config_filename = get_user_config_filename()
    if user_config_filename == LOCAL_CONFIG_FILENAME and not allow_insecure_config_file:
        verify_file_private(user_config_filename)
    config.add_properties(user_config_filename)
    return config
Ejemplo n.º 3
0
def create_config(allow_insecure_config_file=False):
    """
    Create config based on /etc/ddsclient.conf and ~/.ddsclient.conf($DDSCLIENT_CONF)
    :param allow_insecure_config_file: bool: when true we will not check ~/.ddsclient permissions.
    :return: Config with the configuration to use for DDSClient.
    """
    config = Config()
    config.add_properties(GLOBAL_CONFIG_FILENAME)
    user_config_filename = get_user_config_filename()
    if user_config_filename == LOCAL_CONFIG_FILENAME and not allow_insecure_config_file:
        verify_file_private(user_config_filename)
    config.add_properties(user_config_filename)
    return config
Ejemplo n.º 4
0
 def test_verify_file_private_not_windows_ok(self, mock_platform):
     mock_platform.system.return_value = 'Linux'
     tempfilename = make_temp_filename()
     set_file_perm(tempfilename, '0700')
     verify_file_private(tempfilename)
     set_file_perm(tempfilename, '0600')
     verify_file_private(tempfilename)
     set_file_perm(tempfilename, '0500')
     verify_file_private(tempfilename)
Ejemplo n.º 5
0
 def test_verify_file_private_not_windows_ok(self, mock_platform):
     mock_platform.system.return_value = 'Linux'
     tempfilename = make_temp_filename()
     set_file_perm(tempfilename, '0700')
     verify_file_private(tempfilename)
     set_file_perm(tempfilename, '0600')
     verify_file_private(tempfilename)
     set_file_perm(tempfilename, '0500')
     verify_file_private(tempfilename)
Ejemplo n.º 6
0
 def test_non_existant_file_no_raises(self, mock_platform):
     mock_platform.system.return_value = 'Linux'
     tempfilename = './file.never.gonna.exist'
     verify_file_private(tempfilename)
Ejemplo n.º 7
0
 def test_verify_file_private_not_windows_raises_when_bad(self, mock_platform):
     mock_platform.system.return_value = 'Linux'
     tempfilename = make_temp_filename()
     set_file_perm(tempfilename, '0777')
     with self.assertRaises(ValueError):
         verify_file_private(tempfilename)
Ejemplo n.º 8
0
 def test_verify_file_private_on_windows_no_raise(self, mock_platform):
     mock_platform.system.return_value = 'Windows'
     tempfilename = make_temp_filename()
     set_file_perm(tempfilename, '0777')
     verify_file_private(tempfilename)
Ejemplo n.º 9
0
 def test_non_existant_file_no_raises(self, mock_platform):
     mock_platform.system.return_value = 'Linux'
     tempfilename = './file.never.gonna.exist'
     verify_file_private(tempfilename)
Ejemplo n.º 10
0
 def test_verify_file_private_on_windows_no_raise(self, mock_platform):
     mock_platform.system.return_value = 'Windows'
     tempfilename = make_temp_filename()
     set_file_perm(tempfilename, '0777')
     verify_file_private(tempfilename)