Coder Social home page Coder Social logo

openvpn-windows-test's Introduction

openvpn-windows-test

Powershell scripts for testing OpenVPN on Windows. The Test-Openvpn.ps1 script can test OpenVPN in cmd.exe, OpenVPN-GUI and openvpnserv2. Success and failure are based on simple ping tests to one or more hosts. A typical use-case for these scripts is smoke-testing an installer prior to a major release.

The Test-Installer.ps1 script currently tests how OpenVPN reinstalls and full uninstall/install cycles affect the service states. The script was motivated by the need to test the changes in openvpn-build pull request #80. Later the script can be extended to other things and integrated with Test-OpenVPN.ps1.

The Test-Installer.ps1 script will use the management interface to cleanly shut down OpenVPN instances launched from cmd.exe. Similarly, in OpenVPNService-based tests, OpenVPN instances are cleanly shut down using exit-events implemented in OpenVPNService itself. However, there's currently no way to signal OpenVPN GUI to shut down itself, or the OpenVPN instances it manages.

Using test-openvpn.ps1

Test-Openvpn.ps1 tests only one VPN connection:

Usage: Test-Openvpn.ps1 -Config <openvpn-config-file> -Ping <hosts> [-Openvpn <openvpn-exe>] [-Gui <openvpn-gui-exe>] [-TestCmdexe] [-TestService] [-TestRespawn] [-TestGui] [-Help]

Parameters:
   -Openvpn     Path to openvpn.exe (defaults to C:\Program Files\OpenVPN\bin\openvpn.exe)
   -Gui         Path to openvpn-gui.exe (defaults to C:\Program Files\OpenVPN\bin\openvpn-gui.exe)
   -Config      Path to the OpenVPN configuration file
   -Ping        Target host(s) inside VPN to ping (should succeed). Separate multiple entries
                with commas.
   -Suspend     Test suspend and resume [UNIMPLEMENTED]
   -TestCmdexe  Test connection from the command-line
   -TestGui     Test OpenVPN-GUI
   -TestService Test openvpnserv2.exe
   -TestRespawn Test if openvpnserv2 is able to respawn a dead connection properly
   -Help        Display this help

Example: .\Test-Openvpn.ps1 -Config "C:\Program Files\OpenVPN\config\company.ovpn" -Ping 192.168.40.7 -TestCmdexe -TestService -TestGui

To verify that the connections do not succeed because of a bug or by accident, -Ping a fake IP that can only fail.

Note that Windows may prompt for user feedback at certain points, e.g. to allow connections through the firewall. The answers can typically be cached, so that the script can run without user interaction.

To test several connections in a row copy run-sample.ps1 to run.ps1 and adapt it to your needs. This way you can verify that your particular version of OpenVPN works with all of your VPN connections.

Note that right now OpenVPN might mess up IPv6 routes if OpenVPN instances are killed forcibly, as this script does in most cases. This can cause IPv6 ping tests to fail after an initial connection.

Scope of the tests

OpenVPN inside cmd.exe:

Connect -> ping test -> disconnect

OpenVPN GUI:

Connect -> ping test -> disconnect

Openvpnserv2:

Connect -> ping test -> kill openvpn -> openvpnserv2 restart openvpn -> ping test -> disconnect

Warnings

The test-openvpn.ps1 script brutally kills every openvpn.exe and openvpn-gui.exe process it finds at startup, as well as stops OpenVPNService. As described above, in OpenVPN GUI tests OpenVPN GUI and the OpenVPN instances it manages are killled without signaling.

The openvpnserv2-based tests move irrelevant .ovpn files out of the way to the current working directory before launching the service. After the test the files are put back where they belong. If the script is stopped in the middle, some .ovpn files may have to be moved back manually.

While this script seems to work fine, it can potentially cause issues. At minimum make sure that your VPN configurations are backed up.

Using Test-Installer.ps1

Test-Installer.ps1 is straightforward to use:

Usage: Test-Installer.ps1 -Installer <installer-file> [-Verbose] [-TestUpgrade] [-TestCleanInstall] [-Help]

Parameters:
   -Installer        Path to the OpenVPN installer you wish to test
   -Verbose          Show what is happening, even if there is nothing
                     noteworthy to report
   -TestUpgrade      Test reinstalling on top of old installation
   -TestCleanInstall Test full uninstall -> install cycle
   -Help             Display this help

openvpn-windows-test's People

Contributors

mattock avatar chipitsine avatar

Watchers

Chaminda Bandara avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.