diff options
| author | Dennis <13968467+Decstasy@users.noreply.github.com> | 2025-11-25 15:02:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-25 15:02:52 +0100 |
| commit | cedfc166d42f4e89dddc1caa44e0655157d35a0a (patch) | |
| tree | ee980d8df72bc9611099f6a997274831098d4175 /plugins/t | |
| parent | 978343ed03d3327597fa3317901f1c1741a7e3c4 (diff) | |
| parent | 3657197cf77ca78f6e2d003a71d48dc5d4dc45ae (diff) | |
| download | monitoring-plugins-cedfc166d42f4e89dddc1caa44e0655157d35a0a.tar.gz | |
Merge branch 'master' into check_dig_flags_feature
Diffstat (limited to 'plugins/t')
| -rw-r--r-- | plugins/t/check_by_ssh.t | 50 | ||||
| -rw-r--r-- | plugins/t/check_dbi.t | 10 | ||||
| -rw-r--r-- | plugins/t/check_ldap.t | 14 | ||||
| -rw-r--r-- | plugins/t/check_mysql.t | 7 | ||||
| -rw-r--r-- | plugins/t/check_mysql_query.t | 2 | ||||
| -rw-r--r-- | plugins/t/check_smtp.t | 7 |
6 files changed, 45 insertions, 45 deletions
diff --git a/plugins/t/check_by_ssh.t b/plugins/t/check_by_ssh.t index b6479f1f..0ee310cd 100644 --- a/plugins/t/check_by_ssh.t +++ b/plugins/t/check_by_ssh.t | |||
| @@ -16,7 +16,7 @@ my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE", "A config file with ssh | |||
| 16 | 16 | ||
| 17 | plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key); | 17 | plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key); |
| 18 | 18 | ||
| 19 | plan tests => 42; | 19 | plan tests => 33; |
| 20 | 20 | ||
| 21 | # Some random check strings/response | 21 | # Some random check strings/response |
| 22 | my @response = ('OK: Everything is fine', | 22 | my @response = ('OK: Everything is fine', |
| @@ -47,70 +47,70 @@ for (my $i=0; $i<4; $i++) { | |||
| 47 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'" | 47 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'" |
| 48 | ); | 48 | ); |
| 49 | cmp_ok($result->return_code, '==', $i, "Exit with return code $i"); | 49 | cmp_ok($result->return_code, '==', $i, "Exit with return code $i"); |
| 50 | is($result->output, $response[$i], "Status text is correct for check $i"); | 50 | like($result->output, "/$response[$i]/", "Status text is correct for check $i"); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | $result = NPTest->testCmd( | 53 | $result = NPTest->testCmd( |
| 54 | "./check_by_ssh -i $ssh_key -H $ssh_service -C 'exit 0'" | 54 | "./check_by_ssh -i $ssh_key -H $ssh_service -C 'exit 0'" |
| 55 | ); | 55 | ); |
| 56 | cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); | 56 | cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); |
| 57 | is($result->output, 'OK - check_by_ssh: Remote command \'exit 0\' returned status 0', "Status text if command returned none (OK)"); | 57 | like($result->output, '/command \'exit 0\' returned status 0/', "Status text if command returned none (OK)"); |
| 58 | 58 | ||
| 59 | $result = NPTest->testCmd( | 59 | $result = NPTest->testCmd( |
| 60 | "./check_by_ssh -i $ssh_key -H $ssh_service -C 'exit 1'" | 60 | "./check_by_ssh -i $ssh_key -H $ssh_service -C 'exit 1'" |
| 61 | ); | 61 | ); |
| 62 | cmp_ok($result->return_code, '==', 1, "Exit with return code 1 (WARNING)"); | 62 | cmp_ok($result->return_code, '==', 1, "Exit with return code 1 (WARNING)"); |
| 63 | is($result->output, 'WARNING - check_by_ssh: Remote command \'exit 1\' returned status 1', "Status text if command returned none (WARNING)"); | 63 | like($result->output, '/command \'exit 1\' returned status 1/', "Status text if command returned none (WARNING)"); |
| 64 | 64 | ||
| 65 | $result = NPTest->testCmd( | 65 | $result = NPTest->testCmd( |
| 66 | "./check_by_ssh -i $ssh_key -H $ssh_service -C 'exit 2'" | 66 | "./check_by_ssh -i $ssh_key -H $ssh_service -C 'exit 2'" |
| 67 | ); | 67 | ); |
| 68 | cmp_ok($result->return_code, '==', 2, "Exit with return code 2 (CRITICAL)"); | 68 | cmp_ok($result->return_code, '==', 2, "Exit with return code 2 (CRITICAL)"); |
| 69 | is($result->output, 'CRITICAL - check_by_ssh: Remote command \'exit 2\' returned status 2', "Status text if command returned none (CRITICAL)"); | 69 | like($result->output, '/command \'exit 2\' returned status 2/', "Status text if command returned none (CRITICAL)"); |
| 70 | 70 | ||
| 71 | $result = NPTest->testCmd( | 71 | $result = NPTest->testCmd( |
| 72 | "./check_by_ssh -i $ssh_key -H $ssh_service -C 'exit 3'" | 72 | "./check_by_ssh -i $ssh_key -H $ssh_service -C 'exit 3'" |
| 73 | ); | 73 | ); |
| 74 | cmp_ok($result->return_code, '==', 3, "Exit with return code 3 (UNKNOWN)"); | 74 | cmp_ok($result->return_code, '==', 3, "Exit with return code 3 (UNKNOWN)"); |
| 75 | is($result->output, 'UNKNOWN - check_by_ssh: Remote command \'exit 3\' returned status 3', "Status text if command returned none (UNKNOWN)"); | 75 | like($result->output, '/command \'exit 3\' returned status 3/', "Status text if command returned none (UNKNOWN)"); |
| 76 | 76 | ||
| 77 | $result = NPTest->testCmd( | 77 | $result = NPTest->testCmd( |
| 78 | "./check_by_ssh -i $ssh_key -H $ssh_service -C 'exit 7'" | 78 | "./check_by_ssh -i $ssh_key -H $ssh_service -C 'exit 7'" |
| 79 | ); | 79 | ); |
| 80 | cmp_ok($result->return_code, '==', 7, "Exit with return code 7 (out of bounds)"); | 80 | cmp_ok($result->return_code, '==', 3, "Exit with return code 3"); |
| 81 | is($result->output, 'UNKNOWN - check_by_ssh: Remote command \'exit 7\' returned status 7', "Status text if command returned none (out of bounds)"); | 81 | like($result->output, '/command \'exit 7\' returned status 7/', "Status text if command returned none (out of bounds)"); |
| 82 | 82 | ||
| 83 | $result = NPTest->testCmd( | 83 | $result = NPTest->testCmd( |
| 84 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'" | 84 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'" |
| 85 | ); | 85 | ); |
| 86 | cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)"); | 86 | cmp_ok($result->return_code, '==', 3, "Exit with return code 3"); |
| 87 | is($result->output, $response[4], "Return proper status text even with unknown status codes"); | 87 | like($result->output, "/$response[4]/", "Return proper status text even with unknown status codes"); |
| 88 | 88 | ||
| 89 | $result = NPTest->testCmd( | 89 | $result = NPTest->testCmd( |
| 90 | "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'" | 90 | "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'" |
| 91 | ); | 91 | ); |
| 92 | cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); | 92 | cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); |
| 93 | is($result->output, 'OK - check_by_ssh: Remote command \'exit 0\' returned status 0', "Status text if command returned none (OK)"); | 93 | like($result->output, '/command \'exit 0\' returned status 0/', "Status text if command returned none (OK)"); |
| 94 | 94 | ||
| 95 | # Multiple active checks | 95 | # Multiple active checks |
| 96 | $result = NPTest->testCmd( | 96 | $result = NPTest->testCmd( |
| 97 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[1]; sh -c exit\\ 1' -C '$check[0]; sh -c exit\\ 0' -C '$check[3]; sh -c exit\\ 3' -C '$check[2]; sh -c exit\\ 2'" | 97 | "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[1]; sh -c exit\\ 1' -C '$check[0]; sh -c exit\\ 0' -C '$check[3]; sh -c exit\\ 3' -C '$check[2]; sh -c exit\\ 2'" |
| 98 | ); | 98 | ); |
| 99 | cmp_ok($result->return_code, '==', 0, "Multiple checks always return OK"); | 99 | cmp_ok($result->return_code, '==', 0, "Multiple checks always return OK"); |
| 100 | my @lines = split(/\n/, $result->output); | 100 | # my @lines = split(/\n/, $result->output); |
| 101 | cmp_ok(scalar(@lines), '==', 8, "Correct number of output lines for multiple checks"); | 101 | # cmp_ok(scalar(@lines), '==', 8, "Correct number of output lines for multiple checks"); |
| 102 | my %linemap = ( | 102 | # my %linemap = ( |
| 103 | '0' => '1', | 103 | # '0' => '1', |
| 104 | '2' => '0', | 104 | # '2' => '0', |
| 105 | '4' => '3', | 105 | # '4' => '3', |
| 106 | '6' => '2', | 106 | # '6' => '2', |
| 107 | ); | 107 | # ); |
| 108 | foreach my $line (0, 2, 4, 6) { | 108 | # foreach my $line (0, 2, 4, 6) { |
| 109 | my $code = $linemap{$line}; | 109 | # my $code = $linemap{$line}; |
| 110 | my $statline = $line+1; | 110 | # my $statline = $line+1; |
| 111 | is($lines[$line], "$response[$code]", "multiple checks status text is correct for line $line"); | 111 | # is($lines[$line], "$response[$code]", "multiple checks status text is correct for line $line"); |
| 112 | is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line"); | 112 | # is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line"); |
| 113 | } | 113 | # } |
| 114 | 114 | ||
| 115 | # Passive checks | 115 | # Passive checks |
| 116 | unlink("/tmp/check_by_ssh.$$"); | 116 | unlink("/tmp/check_by_ssh.$$"); |
diff --git a/plugins/t/check_dbi.t b/plugins/t/check_dbi.t index c24b5a8c..75444de4 100644 --- a/plugins/t/check_dbi.t +++ b/plugins/t/check_dbi.t | |||
| @@ -21,12 +21,12 @@ plan tests => $tests; | |||
| 21 | my $missing_driver_output = "failed to open DBI driver 'sqlite3'"; | 21 | my $missing_driver_output = "failed to open DBI driver 'sqlite3'"; |
| 22 | 22 | ||
| 23 | my $bad_driver_output = "/failed to open DBI driver 'nodriver'/"; | 23 | my $bad_driver_output = "/failed to open DBI driver 'nodriver'/"; |
| 24 | my $conn_time_output = "/OK - connection time: [0-9\.]+s \|/"; | 24 | my $conn_time_output = "/connection time: [0-9\.]+s \|/"; |
| 25 | my $missing_query_output = "/Must specify a query to execute/"; | 25 | my $missing_query_output = "/Must specify a query to execute/"; |
| 26 | my $no_rows_output = "/WARNING - no rows returned/"; | 26 | my $no_rows_output = "/no rows returned/"; |
| 27 | my $not_numeric_output = "/CRITICAL - result value is not a numeric:/"; | 27 | my $not_numeric_output = "/result value is not a numeric:/"; |
| 28 | my $query_time_output = "/OK - connection time: [0-9\.]+s, 'SELECT 1' returned 1.000000 in [0-9\.]+s \|/"; | 28 | my $query_time_output = "/connection time: [0-9\.]+s, 'SELECT 1' returned 1.000000 in [0-9\.]+s \|/"; |
| 29 | my $syntax_error_output = "/CRITICAL - failed to execute query 'GET ALL FROM test': 1: near \"GET\": syntax error/"; | 29 | my $syntax_error_output = "/1: near \"GET\": syntax error/"; |
| 30 | 30 | ||
| 31 | my $result; | 31 | my $result; |
| 32 | 32 | ||
diff --git a/plugins/t/check_ldap.t b/plugins/t/check_ldap.t index fcba0393..f3162ebb 100644 --- a/plugins/t/check_ldap.t +++ b/plugins/t/check_ldap.t | |||
| @@ -32,7 +32,7 @@ SKIP: { | |||
| 32 | 32 | ||
| 33 | $result = NPTest->testCmd("$command -H $hostname_invalid -b ou=blah -t 5"); | 33 | $result = NPTest->testCmd("$command -H $hostname_invalid -b ou=blah -t 5"); |
| 34 | is( $result->return_code, 2, "$command -H $hostname_invalid -b ou=blah -t 5" ); | 34 | is( $result->return_code, 2, "$command -H $hostname_invalid -b ou=blah -t 5" ); |
| 35 | is( $result->output, 'Could not bind to the LDAP server', "output ok" ); | 35 | like( $result->output, '/could not bind to the LDAP server/', "output ok" ); |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | SKIP: { | 38 | SKIP: { |
| @@ -42,30 +42,30 @@ SKIP: { | |||
| 42 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3"; | 42 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3"; |
| 43 | $result = NPTest->testCmd($cmd); | 43 | $result = NPTest->testCmd($cmd); |
| 44 | is( $result->return_code, 0, $cmd ); | 44 | is( $result->return_code, 0, $cmd ); |
| 45 | like( $result->output, '/^LDAP OK - \d+.\d+ seconds response time\|time=\d+\.\d+s;2\.0+;3\.0+;0\.0+$/', "output ok" ); | 45 | like( $result->output, '/connection time \d+.\d+s/', "output ok" ); |
| 46 | 46 | ||
| 47 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000 -C 10000001"; | 47 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000 -C 10000001"; |
| 48 | $result = NPTest->testCmd($cmd); | 48 | $result = NPTest->testCmd($cmd); |
| 49 | is( $result->return_code, 0, $cmd ); | 49 | is( $result->return_code, 0, $cmd ); |
| 50 | like( $result->output, '/^LDAP OK - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000;10000001;0\.0+$/', "output ok" ); | 50 | like( $result->output, '/found \d+ entries/', "output ok" ); |
| 51 | 51 | ||
| 52 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000: -C 10000001:"; | 52 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000: -C 10000001:"; |
| 53 | $result = NPTest->testCmd($cmd); | 53 | $result = NPTest->testCmd($cmd); |
| 54 | is( $result->return_code, 2, $cmd ); | 54 | is( $result->return_code, 2, $cmd ); |
| 55 | like( $result->output, '/^LDAP CRITICAL - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000:;10000001:;0\.0+$/', "output ok" ); | 55 | like( $result->output, '/found \d+ entries/', "output ok" ); |
| 56 | 56 | ||
| 57 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 0 -C 0"; | 57 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 0 -C 0"; |
| 58 | $result = NPTest->testCmd($cmd); | 58 | $result = NPTest->testCmd($cmd); |
| 59 | is( $result->return_code, 2, $cmd ); | 59 | is( $result->return_code, 2, $cmd ); |
| 60 | like( $result->output, '/^LDAP CRITICAL - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;0;0;0\.0+$/', "output ok" ); | 60 | like( $result->output, '/found \d+ entries/', "output ok" ); |
| 61 | 61 | ||
| 62 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000: -C 10000001"; | 62 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000: -C 10000001"; |
| 63 | $result = NPTest->testCmd($cmd); | 63 | $result = NPTest->testCmd($cmd); |
| 64 | is( $result->return_code, 1, $cmd ); | 64 | is( $result->return_code, 1, $cmd ); |
| 65 | like( $result->output, '/^LDAP WARNING - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000:;10000001;0\.0+$/', "output ok" ); | 65 | like( $result->output, '/found \d+ entries/', "output ok" ); |
| 66 | 66 | ||
| 67 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -C 10000001"; | 67 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -C 10000001"; |
| 68 | $result = NPTest->testCmd($cmd); | 68 | $result = NPTest->testCmd($cmd); |
| 69 | is( $result->return_code, 0, $cmd ); | 69 | is( $result->return_code, 0, $cmd ); |
| 70 | like( $result->output, '/^LDAP OK - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;;10000001;0\.0+$/', "output ok" ); | 70 | like( $result->output, '/found \d+ entries/', "output ok" ); |
| 71 | }; | 71 | }; |
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index a383bc99..9114cccc 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | # mysql -u$user -p$password -h$host $db | 11 | # mysql -u$user -p$password -h$host $db |
| 12 | 12 | ||
| 13 | use strict; | 13 | use strict; |
| 14 | use warnings; | ||
| 14 | use Test::More; | 15 | use Test::More; |
| 15 | use NPTest; | 16 | use NPTest; |
| 16 | 17 | ||
| @@ -40,7 +41,7 @@ SKIP: { | |||
| 40 | 41 | ||
| 41 | $result = NPTest->testCmd("./check_mysql -S -H $mysqlserver $mysql_login_details"); | 42 | $result = NPTest->testCmd("./check_mysql -S -H $mysqlserver $mysql_login_details"); |
| 42 | cmp_ok( $result->return_code, "==", 1, "No replicas defined" ); | 43 | cmp_ok( $result->return_code, "==", 1, "No replicas defined" ); |
| 43 | like( $result->output, "/No replicas defined/", "Correct error message"); | 44 | like( $result->output, "/no replicas defined/", "Correct error message"); |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | SKIP: { | 47 | SKIP: { |
| @@ -54,7 +55,7 @@ SKIP: { | |||
| 54 | 55 | ||
| 55 | $result = NPTest->testCmd("./check_mysql -S -s $mysqlsocket $mysql_login_details"); | 56 | $result = NPTest->testCmd("./check_mysql -S -s $mysqlsocket $mysql_login_details"); |
| 56 | cmp_ok( $result->return_code, "==", 1, "No replicas defined" ); | 57 | cmp_ok( $result->return_code, "==", 1, "No replicas defined" ); |
| 57 | like( $result->output, "/No replicas defined/", "Correct error message"); | 58 | like( $result->output, "/no replicas defined/", "Correct error message"); |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | SKIP: { | 61 | SKIP: { |
| @@ -70,5 +71,5 @@ SKIP: { | |||
| 70 | 71 | ||
| 71 | $result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login -w 60:"); | 72 | $result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login -w 60:"); |
| 72 | cmp_ok( $result->return_code, '==', 1, 'Alert warning if < 60 seconds behind'); | 73 | cmp_ok( $result->return_code, '==', 1, 'Alert warning if < 60 seconds behind'); |
| 73 | like( $result->output, "/^SLOW_REPLICA WARNING:/", "Output okay"); | 74 | like( $result->output, "/^slow_replica/", "Output okay"); |
| 74 | } | 75 | } |
diff --git a/plugins/t/check_mysql_query.t b/plugins/t/check_mysql_query.t index c30245b2..6de48bf6 100644 --- a/plugins/t/check_mysql_query.t +++ b/plugins/t/check_mysql_query.t | |||
| @@ -54,5 +54,5 @@ like( $result->output, "/No rows returned/", "No rows error message"); | |||
| 54 | 54 | ||
| 55 | $result = NPTest->testCmd("./check_mysql_query -q 'SHOW VARIABLES' -H $mysqlserver $mysql_login_details"); | 55 | $result = NPTest->testCmd("./check_mysql_query -q 'SHOW VARIABLES' -H $mysqlserver $mysql_login_details"); |
| 56 | cmp_ok( $result->return_code, '==', 2, "Data not numeric"); | 56 | cmp_ok( $result->return_code, '==', 2, "Data not numeric"); |
| 57 | like( $result->output, "/Is not a numeric/", "Data not numeric error message"); | 57 | like( $result->output, "/is not numeric/", "Data not numeric error message"); |
| 58 | 58 | ||
diff --git a/plugins/t/check_smtp.t b/plugins/t/check_smtp.t index 73b4a1fd..c2f53c3d 100644 --- a/plugins/t/check_smtp.t +++ b/plugins/t/check_smtp.t | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | # | 5 | # |
| 6 | 6 | ||
| 7 | use strict; | 7 | use strict; |
| 8 | use warnings; | ||
| 8 | use Test::More; | 9 | use Test::More; |
| 9 | use NPTest; | 10 | use NPTest; |
| 10 | 11 | ||
| @@ -24,7 +25,7 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", | |||
| 24 | "An invalid (not known to DNS) hostname", "nosuchhost" ); | 25 | "An invalid (not known to DNS) hostname", "nosuchhost" ); |
| 25 | my $res; | 26 | my $res; |
| 26 | 27 | ||
| 27 | plan tests => 15; | 28 | plan tests => 13; |
| 28 | 29 | ||
| 29 | SKIP: { | 30 | SKIP: { |
| 30 | skip "No SMTP server defined", 4 unless $host_tcp_smtp; | 31 | skip "No SMTP server defined", 4 unless $host_tcp_smtp; |
| @@ -42,12 +43,11 @@ SKIP: { | |||
| 42 | 43 | ||
| 43 | TODO: { | 44 | TODO: { |
| 44 | local $TODO = "Output is over two lines"; | 45 | local $TODO = "Output is over two lines"; |
| 45 | like ( $res->output, qr/^SMTP WARNING/, "Correct error message" ); | ||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp --ssl -p 25" ); | 48 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp --ssl -p 25" ); |
| 49 | is ($res->return_code, 2, "Check rc of connecting to $host_tcp_smtp with TLS on standard SMTP port" ); | 49 | is ($res->return_code, 2, "Check rc of connecting to $host_tcp_smtp with TLS on standard SMTP port" ); |
| 50 | like ($res->output, qr/^CRITICAL - Cannot make SSL connection\./, "Check output of connecting to $host_tcp_smtp with TLS on standard SMTP port"); | 50 | like ($res->output, qr/cannot create TLS context/, "Check output of connecting to $host_tcp_smtp with TLS on standard SMTP port"); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | SKIP: { | 53 | SKIP: { |
| @@ -68,7 +68,6 @@ SKIP: { | |||
| 68 | skip "No SMTP server with TLS defined", 1 unless $host_tcp_smtp_tls; | 68 | skip "No SMTP server with TLS defined", 1 unless $host_tcp_smtp_tls; |
| 69 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls --ssl" ); | 69 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls --ssl" ); |
| 70 | is ($res->return_code, 0, "Check rc of connecting to $host_tcp_smtp_tls with TLS" ); | 70 | is ($res->return_code, 0, "Check rc of connecting to $host_tcp_smtp_tls with TLS" ); |
| 71 | like ($res->output, qr/^SMTP OK - /, "Check output of connecting to $host_tcp_smtp_tls with TLS" ); | ||
| 72 | 71 | ||
| 73 | my $unused_port = 4465; | 72 | my $unused_port = 4465; |
| 74 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls -p $unused_port --ssl" ); | 73 | $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls -p $unused_port --ssl" ); |
