mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-06-15 13:32:43 +01:00
Extended healthcheck debug in debug mode
This commit is contained in:
@@ -45,18 +45,34 @@ class HealthCheckController extends Controller
|
|||||||
|
|
||||||
$dbTimezone = DB::select('show timezone;');
|
$dbTimezone = DB::select('show timezone;');
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
'ip_address' => $ipAddress,
|
||||||
|
'url' => $request->url(),
|
||||||
|
'path' => $request->path(),
|
||||||
|
'hostname' => $hostname,
|
||||||
|
'timestamp' => Carbon::now()->timestamp,
|
||||||
|
'date_time_utc' => Carbon::now('UTC')->toDateTimeString(),
|
||||||
|
'date_time_app' => Carbon::now()->toDateTimeString(),
|
||||||
|
'timezone' => $dbTimezone[0]->TimeZone,
|
||||||
|
'secure' => $secure,
|
||||||
|
'is_trusted_proxy' => $isTrustedProxy,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (app()->hasDebugModeEnabled()) {
|
||||||
|
$response['app_debug'] = true;
|
||||||
|
$response['app_url'] = config('app.url');
|
||||||
|
$response['app_env'] = app()->environment();
|
||||||
|
$response['app_timezone'] = config('app.timezone');
|
||||||
|
$response['app_force_https'] = config('app.force_https');
|
||||||
|
$response['trusted_proxies'] = config('trustedproxy.proxies');
|
||||||
|
$headers = $request->headers->all();
|
||||||
|
if (isset($headers['cookie'])) {
|
||||||
|
$headers['cookie'] = '***';
|
||||||
|
}
|
||||||
|
$response['headers'] = $headers;
|
||||||
|
}
|
||||||
|
|
||||||
return response()
|
return response()
|
||||||
->json([
|
->json($response);
|
||||||
'ip_address' => $ipAddress,
|
|
||||||
'url' => $request->url(),
|
|
||||||
'path' => $request->path(),
|
|
||||||
'hostname' => $hostname,
|
|
||||||
'timestamp' => Carbon::now()->timestamp,
|
|
||||||
'date_time_utc' => Carbon::now('UTC')->toDateTimeString(),
|
|
||||||
'date_time_app' => Carbon::now()->toDateTimeString(),
|
|
||||||
'timezone' => $dbTimezone[0]->TimeZone,
|
|
||||||
'secure' => $secure,
|
|
||||||
'is_trusted_proxy' => $isTrustedProxy,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ return [
|
|||||||
|
|
||||||
'asset_url' => env('ASSET_URL'),
|
'asset_url' => env('ASSET_URL'),
|
||||||
|
|
||||||
'force_https' => env('APP_FORCE_HTTPS', false),
|
'force_https' => (bool) env('APP_FORCE_HTTPS', false),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -33,20 +33,57 @@ class HealthCheckEndpointTest extends EndpointTestAbstract
|
|||||||
|
|
||||||
public function test_debug_endpoint_returns_ok(): void
|
public function test_debug_endpoint_returns_ok(): void
|
||||||
{
|
{
|
||||||
|
// Arrange
|
||||||
|
config(['app.debug' => false]);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
$response = $this->get('health-check/debug');
|
$response = $this->get('health-check/debug');
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
$response->assertSuccessful();
|
$response->assertSuccessful();
|
||||||
$response->assertJsonStructure([
|
$response->assertExactJsonStructure([
|
||||||
'ip_address',
|
|
||||||
'hostname',
|
|
||||||
'timestamp',
|
|
||||||
'date_time_utc',
|
|
||||||
'date_time_app',
|
'date_time_app',
|
||||||
'timezone',
|
'date_time_utc',
|
||||||
'secure',
|
'hostname',
|
||||||
|
'ip_address',
|
||||||
'is_trusted_proxy',
|
'is_trusted_proxy',
|
||||||
|
'path',
|
||||||
|
'secure',
|
||||||
|
'timestamp',
|
||||||
|
'timezone',
|
||||||
|
'url',
|
||||||
|
]);
|
||||||
|
config(['app.debug' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_debug_endpoint_returns_more_information_if_debug_mode_is_enabled(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
config(['app.debug' => true]);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->get('health-check/debug');
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertSuccessful();
|
||||||
|
$response->assertExactJsonStructure([
|
||||||
|
'app_debug',
|
||||||
|
'app_env',
|
||||||
|
'app_force_https',
|
||||||
|
'app_timezone',
|
||||||
|
'app_url',
|
||||||
|
'date_time_app',
|
||||||
|
'date_time_utc',
|
||||||
|
'headers',
|
||||||
|
'hostname',
|
||||||
|
'ip_address',
|
||||||
|
'is_trusted_proxy',
|
||||||
|
'path',
|
||||||
|
'secure',
|
||||||
|
'timestamp',
|
||||||
|
'timezone',
|
||||||
|
'trusted_proxies',
|
||||||
|
'url',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user