• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python runner.get_chroot函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中test.runner.get_chroot函数的典型用法代码示例。如果您正苦于以下问题:Python get_chroot函数的具体用法?Python get_chroot怎么用?Python get_chroot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_chroot函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_authenticate_general_password

 def test_authenticate_general_password(self):
   """
   Tests the authenticate function's password argument.
   """
   
   if test.runner.require_control(self): return
   
   # this is a much better test if we're just using password auth, since
   # authenticate will work reguardless if there's something else to
   # authenticate with
   
   runner = test.runner.get_runner()
   tor_options = runner.get_options()
   is_password_only = test.runner.Torrc.PASSWORD in tor_options and not test.runner.Torrc.COOKIE in tor_options
   
   # tests without a password
   with runner.get_tor_socket(False) as control_socket:
     if is_password_only:
       self.assertRaises(stem.connection.MissingPassword, stem.connection.authenticate, control_socket)
     else:
       stem.connection.authenticate(control_socket, chroot_path = runner.get_chroot())
       test.runner.exercise_controller(self, control_socket)
   
   # tests with the incorrect password
   with runner.get_tor_socket(False) as control_socket:
     if is_password_only:
       self.assertRaises(stem.connection.IncorrectPassword, stem.connection.authenticate, control_socket, "blarg")
     else:
       stem.connection.authenticate(control_socket, "blarg", runner.get_chroot())
       test.runner.exercise_controller(self, control_socket)
   
   # tests with the right password
   with runner.get_tor_socket(False) as control_socket:
     stem.connection.authenticate(control_socket, test.runner.CONTROL_PASSWORD, runner.get_chroot())
     test.runner.exercise_controller(self, control_socket)
开发者ID:abcdef123,项目名称:stem,代码行数:35,代码来源:authentication.py


示例2: assert_matches_test_config

 def assert_matches_test_config(self, protocolinfo_response):
   """
   Makes assertions that the protocolinfo response's attributes match those of
   the test configuration.
   """
   
   runner = test.runner.get_runner()
   tor_options = runner.get_options()
   auth_methods, auth_cookie_path = [], None
   
   if test.runner.Torrc.COOKIE in tor_options:
     auth_methods.append(stem.response.protocolinfo.AuthMethod.COOKIE)
     chroot_path = runner.get_chroot()
     auth_cookie_path = runner.get_auth_cookie_path()
     
     if chroot_path and auth_cookie_path.startswith(chroot_path):
       auth_cookie_path = auth_cookie_path[len(chroot_path):]
   
   if test.runner.Torrc.PASSWORD in tor_options:
     auth_methods.append(stem.response.protocolinfo.AuthMethod.PASSWORD)
   
   if not auth_methods:
     auth_methods.append(stem.response.protocolinfo.AuthMethod.NONE)
   
   self.assertEqual((), protocolinfo_response.unknown_auth_methods)
   self.assertEqual(tuple(auth_methods), protocolinfo_response.auth_methods)
   self.assertEqual(auth_cookie_path, protocolinfo_response.cookie_path)
开发者ID:jacthinman,项目名称:Tor-Stem,代码行数:27,代码来源:protocolinfo.py


示例3: test_authenticate_general_cookie

 def test_authenticate_general_cookie(self):
   """
   Tests the authenticate function with only cookie authentication methods.
   This manipulates our PROTOCOLINFO response to test each method
   individually.
   """
   
   if test.runner.require_control(self): return
   
   runner = test.runner.get_runner()
   tor_options = runner.get_options()
   is_cookie_only = test.runner.Torrc.COOKIE in tor_options and not test.runner.Torrc.PASSWORD in tor_options
   
   # test both cookie authentication mechanisms
   with runner.get_tor_socket(False) as control_socket:
     if is_cookie_only:
       for method in (stem.connection.AuthMethod.COOKIE, stem.connection.AuthMethod.SAFECOOKIE):
         protocolinfo_response = stem.connection.get_protocolinfo(control_socket)
         
         if method in protocolinfo_response.auth_methods:
           # narrow to *only* use cookie auth or safecooke, so we exercise
           # both independently
           
           protocolinfo_response.auth_methods = (method, )
           stem.connection.authenticate(control_socket, chroot_path = runner.get_chroot(), protocolinfo_response = protocolinfo_response)
开发者ID:abcdef123,项目名称:stem,代码行数:25,代码来源:authentication.py


示例4: test_launch_tor_with_config

    def test_launch_tor_with_config(self):
        """
    Exercises launch_tor_with_config.
    """

        if test.runner.only_run_once(self, "test_launch_tor_with_config"):
            return

        # Launch tor without a torrc, but with a control port. Confirms that this
        # works by checking that we're still able to access the new instance.

        runner = test.runner.get_runner()
        tor_process = stem.process.launch_tor_with_config(
            tor_cmd=runner.get_tor_command(),
            config={"SocksPort": "2777", "ControlPort": "2778", "DataDirectory": self.data_directory},
            completion_percent=5,
        )

        control_socket = None
        try:
            control_socket = stem.socket.ControlPort(port=2778)
            stem.connection.authenticate(control_socket, chroot_path=runner.get_chroot())

            # exercises the socket
            control_socket.send("GETCONF ControlPort")
            getconf_response = control_socket.recv()
            self.assertEquals("ControlPort=2778", str(getconf_response))
        finally:
            if control_socket:
                control_socket.close()

            tor_process.kill()
            tor_process.communicate()
开发者ID:soult,项目名称:stem,代码行数:33,代码来源:process.py


示例5: test_authenticate_general_example

  def test_authenticate_general_example(self):
    """
    Tests the authenticate function with something like its pydoc example.
    """

    runner = test.runner.get_runner()
    tor_options = runner.get_options()

    try:
      control_socket = stem.socket.ControlPort(port = test.runner.CONTROL_PORT)
    except stem.SocketError:
      # assert that we didn't have a socket to connect to
      self.assertFalse(test.runner.Torrc.PORT in tor_options)
      return

    try:
      # this authenticate call should work for everything but password-only auth
      stem.connection.authenticate(control_socket, chroot_path = runner.get_chroot())
      test.runner.exercise_controller(self, control_socket)
    except stem.connection.IncorrectSocketType:
      self.fail()
    except stem.connection.MissingPassword:
      self.assertTrue(test.runner.Torrc.PASSWORD in tor_options)
      controller_password = test.runner.CONTROL_PASSWORD

      try:
        stem.connection.authenticate_password(control_socket, controller_password)
        test.runner.exercise_controller(self, control_socket)
      except stem.connection.PasswordAuthFailed:
        self.fail()
    except stem.connection.AuthenticationFailure:
      self.fail()
    finally:
      control_socket.close()
开发者ID:FedericoCeratto,项目名称:stem,代码行数:34,代码来源:authentication.py


示例6: test_launch_tor_with_config

 def test_launch_tor_with_config(self):
   """
   Exercises launch_tor_with_config.
   """
   
   test.runner.only_run_once(self, "test_launch_tor_with_config")
   
   # Launch tor without a torrc, but with a control port. Confirms that this
   # works by checking that we're still able to access the new instance.
   
   tor_process = stem.process.launch_tor_with_config(
     config = {'SocksPort': '2777', 'ControlPort': '2778'},
     completion_percent = 5
   )
   
   control_socket = None
   try:
     control_socket = stem.socket.ControlPort(control_port = 2778)
     runner = test.runner.get_runner()
     stem.connection.authenticate(control_socket, chroot_path = runner.get_chroot())
     
     # exercises the socket
     control_socket.send("GETCONF ControlPort")
     getconf_response = control_socket.recv()
     self.assertEquals("ControlPort=2778", str(getconf_response))
   finally:
     if control_socket: control_socket.close()
     tor_process.kill()
开发者ID:jacthinman,项目名称:Tor-Stem,代码行数:28,代码来源:process.py


示例7: test_launch_tor_with_config_via_stdin

  def test_launch_tor_with_config_via_stdin(self):
    """
    Exercises launch_tor_with_config when we provide our torrc via stdin.
    """

    runner = test.runner.get_runner()
    tor_process = stem.process.launch_tor_with_config(
      tor_cmd = runner.get_tor_command(),
      config = {
        'SocksPort': '2777',
        'ControlPort': '2778',
        'DataDirectory': self.data_directory,
      },
      completion_percent = 5
    )

    control_socket = None
    try:
      control_socket = stem.socket.ControlPort(port = 2778)
      stem.connection.authenticate(control_socket, chroot_path = runner.get_chroot())

      # exercises the socket
      control_socket.send('GETCONF ControlPort')
      getconf_response = control_socket.recv()
      self.assertEqual('ControlPort=2778', str(getconf_response))
    finally:
      if control_socket:
        control_socket.close()

      tor_process.kill()
      tor_process.wait()
开发者ID:sammyshj,项目名称:stem,代码行数:31,代码来源:process.py


示例8: test_launch_tor_with_config_via_file

  def test_launch_tor_with_config_via_file(self):
    """
    Exercises launch_tor_with_config when we write a torrc to disk.
    """

    # Launch tor without a torrc, but with a control port. Confirms that this
    # works by checking that we're still able to access the new instance.

    runner = test.runner.get_runner()
    tor_process = stem.process.launch_tor_with_config(
      tor_cmd = runner.get_tor_command(),
      config = {
        'SocksPort': '2777',
        'ControlPort': '2778',
        'DataDirectory': self.data_directory,
      },
      completion_percent = 5
    )

    control_socket = None
    try:
      control_socket = stem.socket.ControlPort(port = 2778)
      stem.connection.authenticate(control_socket, chroot_path = runner.get_chroot())

      # exercises the socket
      control_socket.send('GETCONF ControlPort')
      getconf_response = control_socket.recv()
      self.assertEqual('ControlPort=2778', str(getconf_response))
    finally:
      if control_socket:
        control_socket.close()

      tor_process.kill()
      tor_process.wait()
开发者ID:sammyshj,项目名称:stem,代码行数:34,代码来源:process.py


示例9: test_authenticate_general_controller

 def test_authenticate_general_controller(self):
   """
   Tests that the authenticate function can authenticate via a Controller.
   """
   
   runner = test.runner.get_runner()
   with runner.get_tor_controller(False) as controller:
     stem.connection.authenticate(controller, test.runner.CONTROL_PASSWORD, runner.get_chroot())
     test.runner.exercise_controller(self, controller)
开发者ID:jacthinman,项目名称:Tor-Stem,代码行数:9,代码来源:authentication.py


示例10: test_authenticate_general_socket

 def test_authenticate_general_socket(self):
   """
   Tests that the authenticate function can authenticate to our socket.
   """
   
   if test.runner.require_control(self): return
   
   runner = test.runner.get_runner()
   with runner.get_tor_socket(False) as control_socket:
     stem.connection.authenticate(control_socket, test.runner.CONTROL_PASSWORD, runner.get_chroot())
     test.runner.exercise_controller(self, control_socket)
开发者ID:abcdef123,项目名称:stem,代码行数:11,代码来源:authentication.py


示例11: test_connect

  def test_connect(self):
    """
    Basic sanity checks for the connect function.
    """

    runner = test.runner.get_runner()

    control_socket = stem.connection.connect(
      control_port = ('127.0.0.1', test.runner.CONTROL_PORT),
      control_socket = test.runner.CONTROL_SOCKET_PATH,
      password = test.runner.CONTROL_PASSWORD,
      chroot_path = runner.get_chroot(),
      controller = None)

    test.runner.exercise_controller(self, control_socket)
开发者ID:FedericoCeratto,项目名称:stem,代码行数:15,代码来源:connect.py


示例12: test_connect_socket_file

 def test_connect_socket_file(self):
   """
   Basic sanity checks for the connect_socket_file function.
   """
   
   runner = test.runner.get_runner()
   
   control_socket = stem.connection.connect_socket_file(
     socket_path = test.runner.CONTROL_SOCKET_PATH,
     password = test.runner.CONTROL_PASSWORD,
     chroot_path = runner.get_chroot(),
     controller = None)
   
   if test.runner.Torrc.SOCKET in runner.get_options():
     test.runner.exercise_controller(self, control_socket)
     control_socket.close()
   else:
     self.assertEquals(control_socket, None)
开发者ID:jacthinman,项目名称:Tor-Stem,代码行数:18,代码来源:connect.py


示例13: test_launch_tor_with_config

 def test_launch_tor_with_config(self):
   """
   Exercises launch_tor_with_config.
   """
   
   if not stem.prereq.is_python_26() and stem.util.system.is_windows():
     test.runner.skip(self, "(unable to kill subprocesses)")
     return
   
   if test.runner.only_run_once(self, "test_launch_tor_with_config"): return
   
   # Launch tor without a torrc, but with a control port. Confirms that this
   # works by checking that we're still able to access the new instance.
   
   runner = test.runner.get_runner()
   tor_process = stem.process.launch_tor_with_config(
     tor_cmd = runner.get_tor_command(),
     config = {'SocksPort': '2777', 'ControlPort': '2778'},
     completion_percent = 5
   )
   
   control_socket = None
   try:
     control_socket = stem.socket.ControlPort(control_port = 2778)
     stem.connection.authenticate(control_socket, chroot_path = runner.get_chroot())
     
     # exercises the socket
     control_socket.send("GETCONF ControlPort")
     getconf_response = control_socket.recv()
     self.assertEquals("ControlPort=2778", str(getconf_response))
   finally:
     if control_socket: control_socket.close()
     
     if stem.prereq.is_python_26():
       tor_process.kill()
     elif not stem.util.system.is_windows():
       os.kill(tor_process.pid, signal.SIGTERM)
       
       # On OSX, python 2.5 this kill call doesn't seem to block, causing our
       # tor instance to linger and cause a port conflict with the following
       # test. Giving it a moment to kill for realz.
       
       time.sleep(0.5)
开发者ID:eoinof,项目名称:stem,代码行数:43,代码来源:process.py


示例14: test_connect_port

 def test_connect_port(self):
   """
   Basic sanity checks for the connect_port function.
   """
   
   if test.runner.require_control(self): return
   
   runner = test.runner.get_runner()
   
   control_socket = stem.connection.connect_port(
     control_port = test.runner.CONTROL_PORT,
     password = test.runner.CONTROL_PASSWORD,
     chroot_path = runner.get_chroot(),
     controller = None)
   
   if test.runner.Torrc.PORT in runner.get_options():
     test.runner.exercise_controller(self, control_socket)
     control_socket.close()
   else:
     self.assertEquals(control_socket, None)
开发者ID:abcdef123,项目名称:stem,代码行数:20,代码来源:connect.py


示例15: test_launch_tor_with_config

  def test_launch_tor_with_config(self):
    """
    Exercises launch_tor_with_config.
    """

    if not stem.prereq.is_python_26() and stem.util.system.is_windows():
      test.runner.skip(self, "(unable to kill subprocesses)")
      return

    if test.runner.only_run_once(self, "test_launch_tor_with_config"):
      return

    # Launch tor without a torrc, but with a control port. Confirms that this
    # works by checking that we're still able to access the new instance.

    runner = test.runner.get_runner()
    tor_process = stem.process.launch_tor_with_config(
      tor_cmd = runner.get_tor_command(),
      config = {
        'SocksPort': '2777',
        'ControlPort': '2778',
        'DataDirectory': self.data_directory,
      },
      completion_percent = 5
    )

    control_socket = None
    try:
      control_socket = stem.socket.ControlPort(port = 2778)
      stem.connection.authenticate(control_socket, chroot_path = runner.get_chroot())

      # exercises the socket
      control_socket.send("GETCONF ControlPort")
      getconf_response = control_socket.recv()
      self.assertEquals("ControlPort=2778", str(getconf_response))
    finally:
      if control_socket:
        control_socket.close()

      _kill_process(tor_process)
开发者ID:ankitmodi,项目名称:Projects,代码行数:40,代码来源:process.py



注:本文中的test.runner.get_chroot函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python runner.get_options函数代码示例发布时间:2022-05-27
下一篇:
Python regrtest._parse_args函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap