Skip to content

alex-anast/router-test-kit

Repository files navigation

Router Test Kit

Build Status Coverage PyPI version Python Support License Documentation

πŸš€ A professional-grade Python framework for automated network device testing

Router Test Kit provides a simple, secure, and comprehensive solution for testing virtual and physical routers, network devices, and Linux systems. Built with security-first principles and modern Python practices.

✨ Key Features

  • πŸ”’ Security First: SSH-based connections with modern authentication
  • 🌐 Multi-Device Support: OneOS6 routers, Cisco devices, Linux systems, RADIUS servers
  • πŸ§ͺ Test-Driven: Comprehensive test suite with >90% coverage
  • πŸ“š Professional Documentation: Auto-generated API docs with examples
  • πŸ”„ CI/CD Ready: GitHub Actions integration for automated testing
  • 🎯 Type-Safe: Full type hints for better development experience
  • 🐍 Modern Python: Support for Python 3.8 through 3.12

πŸ“‹ Table of Contents

πŸš€ Quick Start

from router_test_kit.device import LinuxDevice
from router_test_kit.connection import SSHConnection

# Create device and establish secure connection
device = LinuxDevice(username="admin", password="secure_pass")
conn = SSHConnection().connect(device, "192.168.1.100")

# Execute commands and verify results
result = conn.exec("ip route show")
print(f"Routes: {result}")

# Clean up
conn.disconnect()

πŸ“¦ Installation

From PyPI (Recommended)

pip install router-test-kit

πŸ”§ Basic Usage

Simple Device Connection

from router_test_kit.device import LinuxDevice
from router_test_kit.connection import SSHConnection

# Create a device with credentials
device = LinuxDevice(username="admin", password="secure_password")

# Establish SSH connection
with SSHConnection() as conn:
    conn.connect(device, "192.168.1.100")
    
    # Execute commands
    result = conn.exec("ls -la")
    print(result)
    
    # Connection automatically closed

Advanced Network Testing

from router_test_kit.device import OneOS6Device, RADIUSServer
from router_test_kit.static_utils import ping, print_banner

# Setup test environment
router = OneOS6Device(username="admin", password="router_pass")
radius = RADIUSServer(username="radius_admin", password="radius_pass")

# Execute network tests
print_banner("Network Connectivity Test")
loss_rate = ping(source_device=router, target_ip="192.168.1.1", count=10)
print(f"Packet loss: {loss_rate}%")

🌐 Supported Devices

Device Type Protocol Authentication Status
Linux Systems SSH/Telnet Password/Key βœ… Full Support
OneOS6 Routers SSH/Telnet Password βœ… Full Support
Cisco Devices SSH/Telnet Password βœ… Compatible
RADIUS Servers SSH Password βœ… Specialized Support
Generic Hosts Local N/A βœ… Host Commands

πŸ”’ Security

Router Test Kit prioritizes security in network testing:

  • SSH First: Default to secure SSH connections over insecure Telnet
  • Credential Management: Secure handling of authentication credentials
  • Input Validation: Comprehensive validation of all user inputs
  • Error Handling: Secure error messages that don't leak sensitive information
  • Dependency Security: Regular security audits of all dependencies

Security Best Practices

# βœ… Recommended: Use SSH connections
conn = SSHConnection()

# ⚠️  Use only when SSH is not available
conn = TelnetConnection()  # Consider security implications

# πŸ”’ Use environment variables for credentials
import os
device = LinuxDevice(
    username=os.getenv("DEVICE_USERNAME"),
    password=os.getenv("DEVICE_PASSWORD")
)

πŸ“– Examples

Quick Examples

Real-World Use Cases

# Network topology validation
def validate_network_topology():
    devices = [
        LinuxDevice("admin", "pass") for _ in range(3)
    ]
    
    # Test connectivity matrix
    for i, source in enumerate(devices):
        for j, target in enumerate(devices):
            if i != j:
                loss = ping(source, f"192.168.1.{j+1}")
                assert loss < 5, f"High packet loss: {loss}%"

# Router configuration testing
def test_router_config():
    router = OneOS6Device("admin", "config_pass")
    
    with SSHConnection() as conn:
        conn.connect(router, "192.168.1.1")
        
        # Load test configuration
        conn.load_config("test_config.txt")
        
        # Verify configuration
        result = conn.exec("show running-config")
        assert "test_interface" in result
        
        # Cleanup
        conn.unload_config()

πŸ“š Documentation

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Development Setup

git clone https://github.com/alex-anast/router-test-kit.git
cd router-test-kit

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e .

# Install development dependencies
pip install pytest pytest-cov ruff mypy mkdocs mkdocs-material

# Run tests
python -m pytest tests/unit/ -v

# Run linting
ruff check src/ tests/
ruff format src/ tests/

# Build documentation
mkdocs serve

Contributing Areas

  • πŸ› Bug Reports: Help us identify and fix issues
  • πŸš€ New Features: Add support for new device types or protocols
  • πŸ“– Documentation: Improve guides and API documentation
  • πŸ§ͺ Testing: Expand test coverage and add integration tests
  • πŸ”’ Security: Security audits and improvements

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built for the network testing and automation community
  • Inspired by the need for simple, secure router testing
  • Special thanks to all contributors and users

πŸ“Š Project Stats

  • 🐍 Python: 3.8+ support
  • πŸ“¦ Dependencies: Minimal, security-focused
  • πŸ§ͺ Tests: >90% coverage
  • πŸ“š Documentation: Auto-generated from code
  • πŸ”„ CI/CD: Automated testing and deployment

Ready to automate your network testing? Install Router Test Kit and start building reliable network tests today!

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages