NAME

Test::RemoteServer - Test routines for remote servers.

SYNOPSIS

This module allows you to carry out basic tests against remote servers, and the following example should make usage clear:

use Test::More         tests => 5;
use Test::RemoteServer;

## testing ping responses
ping_ok("localhost", "Localhost is dead?" );
ping6_ok("localhost", "Localhost is dead?" );

## There should be a HTTP server
socket_open( "localhost", 80, "The webserver is dead!" );

## Our domain should resolve
resolve( "example.com", "Our domain is unreachable!" );

## We don't want plaintext-password authentication.
ssh_auth_disabled( "host.example.com:2222", "password",
                  "Password auth should be disabled");

DESCRIPTION

Test::RemoteServer allows you to use the Test::More interface to carry out basic health-checks against remote systems.

Currently the tests are only those that can be carried out without any authentication, or faking of source-address.

It would be interesting to be able to test ACLs such that a particular source address were able to connect to a host, but another was not.

(i.e. To test that a firewall is adequately protecting access by source-IP). However this kind of source-IP manipulation is not generally portable, and has to be ruled out on that basis.

TIMEOUTS

All the test-methods are carried out against remote hosts which might be slow, or even unreachable. On that basis the tests are wrapped with timeouts.

If you wish to change the default timeout, which is five seconds, please set the timeout value prior to invoking any tests:

use Test::More         tests => 5;
use Test::RemoteServer;

#
# Change each timeout to 20 seconds, from the default of 5.
#
$Test::RemoteServer::TIMEOUT = 20;

USEFUL COMPANION MODULES

If your tests are only to be carried out on the localhost you might enjoy the Test::Server module.

If you wish to perform more complex DNS tests you should investigate the Test::DNS module.

Finally there is the Test::Varnish which will examine the response of a remote HTTP-server and determine whether Varnish is being used.

AUTHOR

Steve Kemp <steve@steve.org.uk>

COPYRIGHT AND LICENSE

Copyright (C) 2014 Steve Kemp <steve@steve.org.uk>.

This library is free software. You can modify and or distribute it under the same terms as Perl itself.

METHODS

Now follows method-documentation

ping_ok

Test that a ping succeeds against the named host, by executing the system's ping binary.

ping6_ok

Test that a ping succeeds against the named host, by executing the system's ping6 binary.

resolves

Test that a DNS request returns something.

Because this method doesn't test the actual nature of the resolved result it might be less useful than the Test::DNS module, however it is a good starting point.

Test the authors domain exists:

## Our domain should resolve
resolves( "steve.org.uk", "Our domain is unreachable!" );

socket_open

This method ensures that a socket connection may be established to the remote host/port pair.

For example if you have a webserver you should expect it to be running:

socket_open( "www.example.com", 80, "HTTP should be enabled!" );

socket_closed

This method ensures that a socket connection cannot be established to the remote host/port pair.

For example if you believe that FTP is insecure you can ensure it isn't present via:

socket_closed( "localhost", 21, "FTP should be disabled!" );

ssh_auth_enabled

Ensure that the given SSH authentication-type is available. For example you might want to test that public-key authentication is supported:

ssh_auth_enabled( "test.example.com:2222", "publickey",
                 "Key auth is missing");

ssh_auth_disabled

Ensure that the given SSH authentication-type is disabled. For example you might want to test that password authentication is disabled:

ssh_auth_disabled( "test.example.com:2222", "password",
                   "Dictionary attacks are possible");