tunnel-manager 0.0.5__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tunnel-manager might be problematic. Click here for more details.

tests/test_tunnel.py ADDED
@@ -0,0 +1,77 @@
1
+ import os
2
+ from tunnel_manager.tunnel_manager import Tunnel
3
+
4
+
5
+ username = os.environ.get("TUNNEL_USERNAME")
6
+ password = os.environ.get("TUNNEL_PASSWORD")
7
+
8
+
9
+ def test_password_authentication():
10
+ print("Testing password-based authentication...")
11
+ try:
12
+ # Initialize tunnel with username and password
13
+ tunnel = Tunnel(
14
+ remote_host="10.0.0.11",
15
+ username=username,
16
+ password=password,
17
+ )
18
+
19
+ # Connect to the remote host
20
+ tunnel.connect()
21
+
22
+ # Run a simple command
23
+ out, err = tunnel.run_command("whoami; cd ~/Development/; ls -la")
24
+ print(f"Command 'whoami' output: {out}")
25
+ if err:
26
+ print(f"Command error: {err}")
27
+
28
+ print(f"Command output: {out}")
29
+ # Example file transfer (uncomment to test, ensure files exist)
30
+ tunnel.send_file(
31
+ "/home/genius/Development/inventory/inventory.yml",
32
+ "/home/genius/Downloads/remote_test.txt",
33
+ )
34
+ tunnel.receive_file(
35
+ "/home/genius/Downloads/remote_test.txt", "./tests/downloaded_inventory.txt"
36
+ )
37
+
38
+ tunnel.close()
39
+ print("Password-based authentication test completed successfully.")
40
+ except Exception as e:
41
+ print(f"Password-based authentication test failed: {str(e)}")
42
+
43
+
44
+ def test_key_authentication():
45
+ print("\nTesting key-based authentication...")
46
+ try:
47
+ # Initialize tunnel with identity file
48
+ tunnel = Tunnel(
49
+ remote_host="10.0.0.11",
50
+ username=username,
51
+ identity_file=os.path.expanduser("~/.ssh/id_rsa"),
52
+ )
53
+
54
+ # Connect to the remote host
55
+ tunnel.connect()
56
+
57
+ # Run a simple command
58
+ out, err = tunnel.run_command("whoami")
59
+ print(f"Command 'whoami' output: {out}")
60
+ if err:
61
+ print(f"Command error: {err}")
62
+
63
+ # Example file transfer (uncomment to test, ensure files exist)
64
+ # tunnel.send_file("local_test.txt", "/home/genius/remote_test.txt")
65
+ # tunnel.receive_file("/home/genius/remote_test.txt", "downloaded_test.txt")
66
+
67
+ tunnel.close()
68
+ print("Key-based authentication test completed successfully.")
69
+ except Exception as e:
70
+ print(f"Key-based authentication test failed: {str(e)}")
71
+
72
+
73
+ if __name__ == "__main__":
74
+ print("Starting SSH Tunnel Tests\n")
75
+ test_password_authentication()
76
+ test_key_authentication()
77
+ print("\nAll tests completed.")
@@ -1,16 +1,31 @@
1
1
  #!/usr/bin/env python
2
2
  # coding: utf-8
3
3
 
4
- from tunnel_manager.tunnel_manager import (
5
- Tunnel,
6
- )
7
- from tunnel_manager.tunnel_manager_mcp import tunnel_manager_mcp
4
+ import importlib
5
+ import inspect
6
+
7
+ # List of modules to import from
8
+ MODULES = [
9
+ "tunnel_manager.tunnel_manager",
10
+ "tunnel_manager.tunnel_manager_mcp",
11
+ ]
12
+
13
+ # Initialize __all__ to expose all public classes and functions
14
+ __all__ = []
15
+
16
+ # Dynamically import all classes and functions from the specified modules
17
+ for module_name in MODULES:
18
+ module = importlib.import_module(module_name)
19
+ for name, obj in inspect.getmembers(module):
20
+ # Include only classes and functions, excluding private (starting with '_')
21
+ if (inspect.isclass(obj) or inspect.isfunction(obj)) and not name.startswith(
22
+ "_"
23
+ ):
24
+ globals()[name] = obj
25
+ __all__.append(name)
8
26
 
9
27
  """
10
28
  tunnel-manager
11
29
 
12
30
  Create SSH tunnels to your remote hosts!
13
31
  """
14
-
15
-
16
- __all__ = ["tunnel_manager_mcp", "Tunnel"]