From a6f53c546ed3df0c993f45ab7915bc2a7d576f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Mon, 20 Jan 2020 18:00:30 +0100 Subject: [PATCH] better error messages in selftest --- www/data/css/styles.css | 2 +- www/data/css/styles.min.css | 2 +- www/data/css/styles_admin.scss | 2 +- www/internals/modules/selftest.php | 17 ++++++++++------- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/www/data/css/styles.css b/www/data/css/styles.css index fd3e460..4beadf0 100644 --- a/www/data/css/styles.css +++ b/www/data/css/styles.css @@ -854,7 +854,7 @@ html, body { } .consistency_result { - min-width: 400px; + width: 500px; color: #222222; border: 1px solid #888; padding: 0 5px; diff --git a/www/data/css/styles.min.css b/www/data/css/styles.min.css index 5ee24b8..5f4c5c8 100644 --- a/www/data/css/styles.min.css +++ b/www/data/css/styles.min.css @@ -167,7 +167,7 @@ html,body{margin:0;padding:0;height:100%} .kvl_100 div span:first-child{min-width:100px} .kvl_200 div span:first-child{min-width:200px} .kvl_300 div span:first-child{min-width:300px} -.consistency_result{min-width:400px;color:#222;border:1px solid #888;padding:0 5px;margin:1px 0} +.consistency_result{width:500px;color:#222;border:1px solid #888;padding:0 5px;margin:1px 0} .consistency_result:after{content:" "} .consistency_result_ok{background:#0f0} .consistency_result_warn{background:#ff0} diff --git a/www/data/css/styles_admin.scss b/www/data/css/styles_admin.scss index cdc741b..462c48e 100644 --- a/www/data/css/styles_admin.scss +++ b/www/data/css/styles_admin.scss @@ -42,7 +42,7 @@ .kvl_300 div span:first-child { min-width: 300px; } .consistency_result { - min-width: 400px; + width: 500px; color: $COL_ADMIN_STATUS_FG; border: $COL_ADMIN_STATUS_BORDER; padding: 0 5px; diff --git a/www/internals/modules/selftest.php b/www/internals/modules/selftest.php index f5ce7e5..b2c3aea 100644 --- a/www/internals/modules/selftest.php +++ b/www/internals/modules/selftest.php @@ -190,6 +190,7 @@ class SelfTest implements IWebsiteModule 'exception' => null, ]; + $url = $_SERVER['HTTP_HOST'] . $path; $r = curl_http_request($_SERVER['HTTP_HOST'] . $path); if ($r['statuscode'] === $status) return [ @@ -203,7 +204,7 @@ class SelfTest implements IWebsiteModule [ 'result' => self::STATUS_ERROR, 'message' => '{'.$xname.'} failed: Request returned wrong statuscode', - 'long' => 'Wrong HTTP Statuscode (Expected: ['.$status.']; Found: ['.$r['statuscode'].'])' . "\n" . "Response:\n" . $r['output'] . "\nError [" . $r['errnum'] . "]:\n" . $r['errstr'], + 'long' => 'Wrong HTTP Statuscode (Expected: ['.$status.']; Found: ['.$r['statuscode'].'])' . "\nURL: $url\n" . "Response:\n" . $r['output'] . "\nError [" . $r['errnum'] . "]:\n" . $r['errstr'], 'exception' => null, ]; } @@ -246,7 +247,8 @@ class SelfTest implements IWebsiteModule $count = 0; foreach ($supdata as $d) { - $r = curl_http_request($_SERVER['HTTP_HOST'] . str_replace('{0}', $d, $path)); + $url = $_SERVER['HTTP_HOST'] . str_replace('{0}', $d, $path); + $r = curl_http_request($url); $count++; if ($r['statuscode'] === $status) { $message .= "{".$xname."} succeeded" . "\n"; continue; } @@ -254,7 +256,7 @@ class SelfTest implements IWebsiteModule [ 'result' => self::STATUS_ERROR, 'message' => '{'.$xname.'} failed: Request returned wrong statuscode', - 'long' => 'Wrong HTTP Statuscode (Expected: ['.$status.']; Found: ['.$r['statuscode'].'])' . "\n" . "Response:\n" . $r['output'] . "\nError [" . $r['errnum'] . "]:\n" . $r['errstr'], + 'long' => 'Wrong HTTP Statuscode (Expected: ['.$status.']; Found: ['.$r['statuscode'].'])' . "\nURL: $url\n" . "Response:\n" . $r['output'] . "\nError [" . $r['errnum'] . "]:\n" . $r['errstr'], 'exception' => null, ]; } @@ -354,14 +356,15 @@ class SelfTest implements IWebsiteModule 'exception' => null, ]; - $r = curl_http_request($_SERVER['HTTP_HOST'] . $path); + $url = $_SERVER['HTTP_HOST'] . $path; + $r = curl_http_request($url); if ($r['statuscode'] !== $status) { return [ 'result' => self::STATUS_ERROR, 'message' => '{'.$xname.'} failed: Request returned wrong statuscode', - 'long' => 'Wrong HTTP Statuscode (Expected: ['.$status.']; Found: ['.$r['statuscode'].'])' . "\n" . "Response:\n" . $r['output'] . "\nError [" . $r['errnum'] . "]:\n" . $r['errstr'], + 'long' => 'Wrong HTTP Statuscode (Expected: ['.$status.']; Found: ['.$r['statuscode'].'])' . "\nURL: $url\n" . "Response:\n" . $r['output'] . "\nError [" . $r['errnum'] . "]:\n" . $r['errstr'], 'exception' => null, ]; } @@ -371,7 +374,7 @@ class SelfTest implements IWebsiteModule [ 'result' => self::STATUS_ERROR, 'message' => '{'.$xname.'} failed: Request returned wrong statuscode', - 'long' => "Wrong HTTP Response\nExpected:\n$json_expected\nFound:\n".$r['output'] . "\n" . "HTTP Statuscode:\n" . $r['statuscode'] . "\nError [" . $r['errnum'] . "]:\n" . $r['errstr'], + 'long' => "Wrong HTTP Response\nExpected:\n$json_expected\nFound:\n".$r['output'] . "\nURL: $url\n" . "HTTP Statuscode:\n" . $r['statuscode'] . "\nError [" . $r['errnum'] . "]:\n" . $r['errstr'], 'exception' => null, ]; } @@ -551,7 +554,7 @@ class SelfTest implements IWebsiteModule [ 'result' => self::STATUS_ERROR, 'message' => '{'.$xname.'} failed: Request returned wrong statuscode', - 'long' => 'Wrong HTTP Statuscode (Expected: [200]; Found: ['.$r['statuscode'].'])' . "\n" . "Response:\n" . $r['output'] . "\n" . "Redirect:\n" . $r['redirect'] . "\nError [" . $r['errnum'] . "]:\n" . $r['errstr'], + 'long' => 'Wrong HTTP Statuscode (Expected: [200]; Found: ['.$r['statuscode'].'])' . "\nURL: $url1 >> $url2\n" . "Response:\n" . $r['output'] . "\n" . "Redirect:\n" . $r['redirect'] . "\nError [" . $r['errnum'] . "]:\n" . $r['errstr'], 'exception' => null, ]; }