Opened 2 years ago

#15999 new enhancement

End-to-end integ test for hidden service

Reported by: atagar Owned by: atagar
Priority: Low Milestone:
Component: Core Tor/Stem Version:
Severity: Keywords: testing
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

While adding support for ephemeral hidden services I tried to add a end-to-end integ test without success. Ideally the test would create a new hidden service, then use tor to retrieve its content.

Really shouldn't be a big whoop. We have a tutorial for something similar after all. But for some reason even the tutorial wasn't working for me (hidden service was inaccessible)...

  @require_online
  @require_controller
  @require_version(Requirement.ADD_ONION)
  def test_using_ephemeral_hidden_services(self):
    """  
    Create and use a live ephemeral hidden service.
    """

    # TODO: Not having success getting... well, just about any damn hidden
    # serivce working. Even our prior tutorial is failing right now. >:(

    return

    with test.runner.get_runner().get_tor_controller() as controller:
      incoming_address = None, None 

      def run_server():
        serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        serversocket.bind(('localhost', 4567))
        serversocket.listen(5)
        incoming_socket, incoming_address = serversocket.accept()
        incoming_socket.write('hello world')
        serversocket.shutdown(socket.SHUT_RDWR)

      server_thread = threading.Thread(target = run_server)
      server_thread.setDaemon(True)
      server_thread.start()

      response = controller.create_ephemeral_hidden_service({80: 4567})

      with test.network.Socks(controller.get_socks_listeners()[0]) as s:
        s.settimeout(30)
        s.connect(('%s.onion' % response.service_id, 80)) 
        print s.read()

      self.assertTrue(incoming_address is not None)

      server_thread.join()

Child Tickets

Change History (0)

Note: See TracTickets for help on using tickets.