# 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/preflights/ssh_multiplexer.py
# class SSHMultiplexer(module.PreflightModule):
#   def __init__(self,
#                state: DFTimewolfState,
#                name: Optional[str]=None,
#                critical: bool=False) -> None:
#   def SetUp(self,  # pylint: disable=arguments-differ
#             hostname: str,
#             user: Optional[str],
#             id_file: Optional[str],
#             extra_ssh_options: Optional[List[str]]) -> None:
#   def Process(self) -> None:
#   def CleanUp(self) -> None:
# 
# 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.preflights import ssh_multiplexer
from dftimewolf import config
  """Tests for the SSH multiplexer preflight."""

  def testInitialization(self):
    """Tests that the exporter can be initialized."""
    test_state = state.DFTimewolfState(config.Config)
    local_ssh_multiplexer = ssh_multiplexer.SSHMultiplexer(test_state)
    self.assertIsNotNone(local_ssh_multiplexer)

  @mock.patch('subprocess.call')
  def testProcess(self, mock_call):
    """Tests the SSH CLI has the expected parameters."""
    mock_call.return_value = 0
    test_state = state.DFTimewolfState(config.Config)
    ssh_multi = ssh_multiplexer.SSHMultiplexer(test_state)
    ssh_multi.SetUp('fakehost', 'fakeuser', None, ['-o', "ProxyCommand='test'"])
    ssh_multi.Process()

    mock_call.assert_called_with([
      'ssh', '-q', '-l', 'fakeuser',
      '-o', 'ControlMaster=auto',
      '-o', 'ControlPersist=yes',
      '-o', 'ControlPath=~/.ssh/ctrl-%C',
      '-o', "ProxyCommand='test'",
      'fakehost', 'true',
    ])

  @mock.patch('subprocess.call')
  def testCleanup(self, mock_call):
    """Tests that the SSH CLI is called with the expected arguments."""
    mock_call.return_value = 0

# 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/preflights/ssh_multiplexer.py
# class SSHMultiplexer(module.PreflightModule):
#   def __init__(self,
#                state: DFTimewolfState,
#                name: Optional[str]=None,
#                critical: bool=False) -> None:
#   def SetUp(self,  # pylint: disable=arguments-differ
#             hostname: str,
#             user: Optional[str],
#             id_file: Optional[str],
#             extra_ssh_options: Optional[List[str]]) -> None:
#   def Process(self) -> None:
#   def CleanUp(self) -> None:
# 
# 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/preflights/ssh_multiplexer.py
import unittest
import mock
from dftimewolf.lib import state
from dftimewolf.lib.preflights import ssh_multiplexer
from dftimewolf import config

  """Tests for the SSH multiplexer preflight."""

  def testInitialization(self):
    """Tests that the exporter can be initialized."""
    test_state = state.DFTimewolfState(config.Config)
    local_ssh_multiplexer = ssh_multiplexer.SSHMultiplexer(test_state)
    self.assertIsNotNone(local_ssh_multiplexer)

  @mock.patch('subprocess.call')
  def testProcess(self, mock_call):
    """Tests the SSH CLI has the expected parameters."""
    mock_call.return_value = 0
    test_state = state.DFTimewolfState(config.Config)
    ssh_multi = ssh_multiplexer.SSHMultiplexer(test_state)
    ssh_multi.SetUp('fakehost', 'fakeuser', None, ['-o', "ProxyCommand='test'"])
    ssh_multi.Process()

    mock_call.assert_called_with([
      'ssh', '-q', '-l', 'fakeuser',
      '-o', 'ControlMaster=auto',
      '-o', 'ControlPersist=yes',
      '-o', 'ControlPath=~/.ssh/ctrl-%C',
      '-o', "ProxyCommand='test'",
      'fakehost', 'true',
    ])

  @mock.patch('subprocess.call')
  def testCleanup(self, mock_call):
    """Tests that the SSH CLI is called with the expected arguments."""
    mock_call.return_value = 0

    test_state = state.DFTimewolfState(config.Config)