Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix(Tinebase/Cli): skip test if netcat is not installed
Browse files Browse the repository at this point in the history
Change-Id: Ib34d05c30b9e85592d53ef6eb495162e7af7b734
  • Loading branch information
ccheng-dev committed May 6, 2021
1 parent 7acdefc commit 6809796
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
6 changes: 4 additions & 2 deletions tests/tine20/Tinebase/Frontend/CliTest.php
Expand Up @@ -388,12 +388,14 @@ public function testMonitoringCheckCache()
*/
public function testMonitoringMailServers()
{
self::markTestSkipped('FIXME not working in jenkins ci yet');

ob_start();
$result = $this->_cli->monitoringMailServers();
$out = ob_get_clean();

if ($result === 99) {
self::markTestSkipped('netcat is not installed');
}

self::assertStringContainsString('CONNECTION ', $out);
self::assertLessThanOrEqual(1, $result);
}
Expand Down
22 changes: 11 additions & 11 deletions tine20/Tinebase/Frontend/Cli.php
Expand Up @@ -1567,19 +1567,19 @@ public function monitoringMailServers() {

$output = shell_exec('nc -d -N -w3 ' . $host . ' ' . $port . PHP_EOL);

if ($output) {
if (strpos($output, 'OK') || strstr($output, '220')) {
$message .= ' -> CONNECTION OK' . PHP_EOL;
} else {
$message .= ' -> CONNECTION ERROR' . PHP_EOL;
$result = 1;
}

$message .= PHP_EOL . $output . PHP_EOL;
if (!$output) {
echo 'COMMAND CANNOT BE EXECUTE' . PHP_EOL;
return 99;
}

if (strpos($output, 'OK') || strstr($output, '220')) {
$message .= ' -> CONNECTION OK' . PHP_EOL;
} else {
$message .= ' -> CONNECTION FAILED' . PHP_EOL;
$result = 2;
$message .= ' -> CONNECTION ERROR' . PHP_EOL;
$result = 1;
}

$message .= PHP_EOL . $output . PHP_EOL;
}

echo $message . "\n";
Expand Down

0 comments on commit 6809796

Please sign in to comment.