Skip to main content

Framework for testing client/server network tunnelling libraries

Project description

The test-tunnel library: write tests for network tunnelling utilities

[Home | GitLab | Download | PyPI | ReadTheDocs]

Overview

The test-tunnel library's purpose is to make it easy to write either command-line tools or test modules that start some network tunnelling server (e.g. stunnel, microsocks, Dante) and verify that it does indeed forward connections and data as expected.

A tunnel test scenario

Test classes derived from the test-tunnel library's [TestTunnel][test_tunnel.run_test.TestTunnel] class have a [run()][test_tunnel.run_test.TestTunnel.run] method that performs the following actions:

  • examines the IPv4 and IPv6 network interfaces currently configured on the running system and picks two available ports to listen on for each one
  • makes a "possible connections" mapping, determining which of these addresses may be used as source and destination addresses for TCP connections. It is possible that some pairs are invalid either due to network protocol limitations or due to local system policy.
  • picks a set of (server, proxy as client, proxy as server, client) address/port combinations from the above mapping so that the client may connect to the proxy and the proxy, in turn, may connect to the server

Writing a test class for a new tool

To write a new test class it is enough to create a new Python class derived from [test_tunnel.run_test.TestTunnel][] and implement at least the three methods defined as abstract in that base class:

  • [slug()][test_tunnel.run_test.TestTunnel.slug]: return a short text string used in log messages to identify the tested program (e.g. "microsocks", "socat")
  • [do_spawn_server()][test_tunnel.run_test.TestTunnel.do_spawn_server]: start the tested tool with the specified address and port to listen on and address and port to forward connections to. This method may possibly prepare a configuration file if the tool needs it, or it may start the tool and pass the addresses and ports directly on the command line if supported.
  • [do_handshake()][test_tunnel.run_test.TestTunnel.do_handshake]: once a client socket has been connected to the already started tool (see the [do_spawn_server()][test_tunnel.run_test.TestTunnel.do_spawn_server] method), send and receive any "handshake" data required to make the tool establish a connection to the test listener started by the test-tunnel library itself. For a SOCKS5 server this should be the protocol negotiation and authentication, for an HTTP proxy server this would be the CONNECT request, etc.

Example tools

The test-tunnel library contains two example command-line tools that implement the test classes for two data forwarding programs: the [socat][test_tunnel.cmd_test.socat] multipurpose relay tool and the [microsocks][test_tunnel.cmd_test.microsocks] SOCKS5 server. They may serve as a starting point for writing new test classes.

Contact

The test-tunnel library was written by Peter Pentchev. It is developed in a GitLab repository. This documentation is hosted at Ringlet with a copy at ReadTheDocs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

test_tunnel-0.1.2.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

test_tunnel-0.1.2-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file test_tunnel-0.1.2.tar.gz.

File metadata

  • Download URL: test_tunnel-0.1.2.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.9

File hashes

Hashes for test_tunnel-0.1.2.tar.gz
Algorithm Hash digest
SHA256 81b6e072661b3665f485073ff37f6b57a121c9491bdd865080deb414ea33b425
MD5 ae684177b0a0ec3da3c4e08e509b5a04
BLAKE2b-256 94be2293e10e36075f4496734890b7bf8307ea030ae8f04696107a415704f611

See more details on using hashes here.

File details

Details for the file test_tunnel-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: test_tunnel-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.9

File hashes

Hashes for test_tunnel-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d738a1b8435c410cf84b8ca7dcaea7c4825efb4881ff16b52fc5937ffb16f176
MD5 88c224a65ac073e9021837dc57e94f8c
BLAKE2b-256 96a712776d9fb2e058c9681a10965fda0cdcd5b1b729ac78c91c39a83b6e709e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page