# Path: dftimewolf/lib/state.py
# T = TypeVar("T", bound="interface.AttributeContainer")  # pylint: disable=invalid-name,line-too-long
# NEW_ISSUE_URL = 'https://github.com/log2timeline/dftimewolf/issues/new'
# class DFTimewolfState(object):
#   def __init__(self, config: Type[Config]) -> None:
#   def _InvokeModulesInThreads(self, callback: Callable[[Any], Any]) -> None:
#   def ImportRecipeModules(self, module_locations: Dict[str, str]) -> None:
#   def LoadRecipe(self,
#                  recipe: Dict[str, Any],
#                  module_locations: Dict[str, str]) -> None:
#   def FormatExecutionPlan(self) -> str:
#   def LogExecutionPlan(self) -> None:
#   def AddToCache(self, name: str, value: Any) -> None:
#   def GetFromCache(self, name: str, default_value: Any=None) -> Any:
#   def StoreContainer(self, container: "interface.AttributeContainer") -> None:
#   def GetContainers(self,
#                     container_class: Type[T],
#                     pop: bool=False) -> Sequence[T]:
#   def DedupeContainers(self, container_class: Type[T]) -> None:
#   def _SetupModuleThread(self, module_definition: Dict[str, str]) -> None:
#   def SetupModules(self) -> None:
#   def _RunModuleThread(self, module_definition: Dict[str, str]) -> None:
#   def RunPreflights(self) -> None:
#   def CleanUpPreflights(self) -> None:
#   def InstantiateModule(self, module_name: str) -> "dftw_module.BaseModule":
#   def RunModules(self) -> None:
#   def RegisterStreamingCallback(
#       self,
#       target: Callable[["interface.AttributeContainer"], Any],
#       container_type: Type["interface.AttributeContainer"]) -> None:
#   def StreamContainer(self, container: "interface.AttributeContainer") -> None:
#   def AddError(self, error: DFTimewolfError) -> None:
#   def CleanUp(self) -> None:
#   def CheckErrors(self, is_global: bool=False) -> None:
# 
# Path: dftimewolf/lib/errors.py
# class DFTimewolfError(Exception):
# class BadConfigurationError(DFTimewolfError):
# class RecipeParseError(DFTimewolfError):
# class CommandLineParseError(DFTimewolfError):
# class CriticalError(DFTimewolfError):
#   def __init__(self,
#                message: Optional[str]=None,
#                name: Optional[str]=None,
#                stacktrace: Optional[str]=None,
#                critical: bool=False,
#                unexpected: bool=False) -> None:
# 
# Path: dftimewolf/lib/exporters/scp_ex.py
# class SCPExporter(module.BaseModule):
#   def __init__(self,
#                state: DFTimewolfState,
#                name: Optional[str]=None,
#                critical: bool=False) -> None:
#   def SetUp(self, # pylint: disable=arguments-differ
#             paths: str,
#             destination: str,
#             user: str,
#             hostname: str,
#             id_file: str,
#             extra_ssh_options: List[str],
#             direction: str,
#             multiplexing: bool,
#             check_ssh: bool) -> None:
#   def Process(self) -> None:
#   def _PrefixRemotePaths(self, paths: List[str]) -> List[str]:
#   def _GenerateRemotePrefix(self) -> str:
#   def _CreateDestinationDirectory(self, remote: bool) -> None:
#   def _SSHAvailable(self) -> bool:
# 
# Path: dftimewolf/config.py
# class Config(object):
#   def GetExtra(cls, name: str='') -> Dict[str, Any]:
#   def LoadExtra(cls, filename: str) -> bool:
#   def LoadExtraData(cls, json_string: bytes) -> None:
#   def ClearExtra(cls) -> None:


import unittest
import mock
from dftimewolf.lib import state
from dftimewolf.lib import errors
from dftimewolf.lib.exporters import scp_ex
from dftimewolf import config
    scp_exporter.SetUp('/path1,/path2', '/destination', 'fakeuser',
                       'fakehost', 'fakeid', ['-o', 'foo=bar'],
                       'download', False, True)
    scp_exporter.Process()

    mock_subprocess_call.assert_called_with(
        ['scp', '-o', 'foo=bar', '-i', 'fakeid',
        'fakeuser@fakehost:/path1', 'fakeuser@fakehost:/path2', '/destination'])

  @mock.patch('subprocess.call')
  def testProcessDownloadMultiplex(self, mock_subprocess_call):
    """Tests that the specified directory is used if created."""
    mock_subprocess_call.return_value = 0
    test_state = state.DFTimewolfState(config.Config)
    scp_exporter = scp_ex.SCPExporter(test_state)
    scp_exporter.SetUp('/path1,/path2', '/destination', 'fakeuser',
                       'fakehost', 'fakeid', [], 'download', True, True)
    scp_exporter.Process()

    mock_subprocess_call.assert_called_with(
        ['scp',
         '-o', 'ControlMaster=auto',
         '-o', 'ControlPath=~/.ssh/ctrl-%C',
         '-i', 'fakeid',
        'fakeuser@fakehost:/path1', 'fakeuser@fakehost:/path2', '/destination'])

  @mock.patch('subprocess.call')
  def testSetupError(self, mock_subprocess_call):
    """Tests that recipe errors out if connection check fails."""
    mock_subprocess_call.return_value = -1

# Path: dftimewolf/lib/state.py
# T = TypeVar("T", bound="interface.AttributeContainer")  # pylint: disable=invalid-name,line-too-long
# NEW_ISSUE_URL = 'https://github.com/log2timeline/dftimewolf/issues/new'
# class DFTimewolfState(object):
#   def __init__(self, config: Type[Config]) -> None:
#   def _InvokeModulesInThreads(self, callback: Callable[[Any], Any]) -> None:
#   def ImportRecipeModules(self, module_locations: Dict[str, str]) -> None:
#   def LoadRecipe(self,
#                  recipe: Dict[str, Any],
#                  module_locations: Dict[str, str]) -> None:
#   def FormatExecutionPlan(self) -> str:
#   def LogExecutionPlan(self) -> None:
#   def AddToCache(self, name: str, value: Any) -> None:
#   def GetFromCache(self, name: str, default_value: Any=None) -> Any:
#   def StoreContainer(self, container: "interface.AttributeContainer") -> None:
#   def GetContainers(self,
#                     container_class: Type[T],
#                     pop: bool=False) -> Sequence[T]:
#   def DedupeContainers(self, container_class: Type[T]) -> None:
#   def _SetupModuleThread(self, module_definition: Dict[str, str]) -> None:
#   def SetupModules(self) -> None:
#   def _RunModuleThread(self, module_definition: Dict[str, str]) -> None:
#   def RunPreflights(self) -> None:
#   def CleanUpPreflights(self) -> None:
#   def InstantiateModule(self, module_name: str) -> "dftw_module.BaseModule":
#   def RunModules(self) -> None:
#   def RegisterStreamingCallback(
#       self,
#       target: Callable[["interface.AttributeContainer"], Any],
#       container_type: Type["interface.AttributeContainer"]) -> None:
#   def StreamContainer(self, container: "interface.AttributeContainer") -> None:
#   def AddError(self, error: DFTimewolfError) -> None:
#   def CleanUp(self) -> None:
#   def CheckErrors(self, is_global: bool=False) -> None:
# 
# Path: dftimewolf/lib/errors.py
# class DFTimewolfError(Exception):
# class BadConfigurationError(DFTimewolfError):
# class RecipeParseError(DFTimewolfError):
# class CommandLineParseError(DFTimewolfError):
# class CriticalError(DFTimewolfError):
#   def __init__(self,
#                message: Optional[str]=None,
#                name: Optional[str]=None,
#                stacktrace: Optional[str]=None,
#                critical: bool=False,
#                unexpected: bool=False) -> None:
# 
# Path: dftimewolf/lib/exporters/scp_ex.py
# class SCPExporter(module.BaseModule):
#   def __init__(self,
#                state: DFTimewolfState,
#                name: Optional[str]=None,
#                critical: bool=False) -> None:
#   def SetUp(self, # pylint: disable=arguments-differ
#             paths: str,
#             destination: str,
#             user: str,
#             hostname: str,
#             id_file: str,
#             extra_ssh_options: List[str],
#             direction: str,
#             multiplexing: bool,
#             check_ssh: bool) -> None:
#   def Process(self) -> None:
#   def _PrefixRemotePaths(self, paths: List[str]) -> List[str]:
#   def _GenerateRemotePrefix(self) -> str:
#   def _CreateDestinationDirectory(self, remote: bool) -> None:
#   def _SSHAvailable(self) -> bool:
# 
# Path: dftimewolf/config.py
# class Config(object):
#   def GetExtra(cls, name: str='') -> Dict[str, Any]:
#   def LoadExtra(cls, filename: str) -> bool:
#   def LoadExtraData(cls, json_string: bytes) -> None:
#   def ClearExtra(cls) -> None:


# Path: tests/lib/exporters/scp_ex.py
import unittest
import mock
from dftimewolf.lib import state
from dftimewolf.lib import errors
from dftimewolf.lib.exporters import scp_ex
from dftimewolf import config

    scp_exporter.SetUp('/path1,/path2', '/destination', 'fakeuser',
                       'fakehost', 'fakeid', ['-o', 'foo=bar'],
                       'download', False, True)
    scp_exporter.Process()

    mock_subprocess_call.assert_called_with(
        ['scp', '-o', 'foo=bar', '-i', 'fakeid',
        'fakeuser@fakehost:/path1', 'fakeuser@fakehost:/path2', '/destination'])

  @mock.patch('subprocess.call')
  def testProcessDownloadMultiplex(self, mock_subprocess_call):
    """Tests that the specified directory is used if created."""
    mock_subprocess_call.return_value = 0
    test_state = state.DFTimewolfState(config.Config)
    scp_exporter = scp_ex.SCPExporter(test_state)
    scp_exporter.SetUp('/path1,/path2', '/destination', 'fakeuser',
                       'fakehost', 'fakeid', [], 'download', True, True)
    scp_exporter.Process()

    mock_subprocess_call.assert_called_with(
        ['scp',
         '-o', 'ControlMaster=auto',
         '-o', 'ControlPath=~/.ssh/ctrl-%C',
         '-i', 'fakeid',
        'fakeuser@fakehost:/path1', 'fakeuser@fakehost:/path2', '/destination'])

  @mock.patch('subprocess.call')
  def testSetupError(self, mock_subprocess_call):
    """Tests that recipe errors out if connection check fails."""
    mock_subprocess_call.return_value = -1

    test_state = state.DFTimewolfState(config.Config)