010-no-ssl.t 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. BEGIN {
  5. use File::Basename;
  6. use lib (dirname(__FILE__));
  7. }
  8. use Test::More;
  9. use nrpe;
  10. my @output;
  11. if (!supports_ssl()) {
  12. plan skip_all => 'SSL/TLS support unavailable.';
  13. }
  14. plan tests => 8;
  15. ensure_daemon_running();
  16. switch_config_file("configs/nossl.cfg");
  17. restart_daemon();
  18. @output = `$checknrpe -H 127.0.0.1 -p 40321`;
  19. is($?, STATE_UNKNOWN, 'connect ssl') || diag @output;
  20. like($output[0], qr/CHECK_NRPE:.* Error - Could not .*: /, 'connect ssl response') || diag @output;
  21. @output = `$checknrpe -H 127.0.0.1 -p 40321 -n`;
  22. is($?, STATE_OK, 'connect without ssl') || diag @output;
  23. like($output[0], qr/NRPE v.*/, 'connect without ssl response') || diag @output;
  24. @output = `$checknrpe -H 127.0.0.1 -p 40321 -n -2`;
  25. is($?, 0, 'version check - v2 packet') || diag @output;
  26. like($output[0], qr/NRPE v.*/, 'version check response - v2 packet') || diag @output;
  27. # Note: Server may fail v3 packet and we'll retry with a v2 packet. Could check log for difference if we care.
  28. @output = `$checknrpe -H 127.0.0.1 -p 40321 -n -3`;
  29. is($?, 0, 'version check - v3 packet') || diag @output;
  30. like($output[0], qr/NRPE v.*/, 'version check response - v3 packet') || diag @output;
  31. done_testing();