mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Updated functionality for logging failed access
- Added testing to cover. - Linked logging into Laravel's monolog logging system and made log channel configurable. - Updated env var names to be specific to login access. - Added extra locations as to where failed logins would be captured. Related to #1881 and #728
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
<?php namespace Tests\Unit;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -36,6 +37,28 @@ class ConfigTest extends TestCase
|
||||
$this->checkEnvConfigResult('APP_URL', $oldDefault, 'app.url', '');
|
||||
}
|
||||
|
||||
public function test_errorlog_plain_webserver_channel()
|
||||
{
|
||||
// We can't full test this due to it being targeted for the SAPI logging handler
|
||||
// so we just overwrite that component so we can capture the error log output.
|
||||
config()->set([
|
||||
'logging.channels.errorlog_plain_webserver.handler_with' => [0],
|
||||
]);
|
||||
|
||||
$temp = tempnam(sys_get_temp_dir(), 'bs-test');
|
||||
$original = ini_set( 'error_log', $temp);
|
||||
|
||||
Log::channel('errorlog_plain_webserver')->info('Aww, look, a cute puppy');
|
||||
|
||||
ini_set( 'error_log', $original);
|
||||
|
||||
$output = file_get_contents($temp);
|
||||
$this->assertStringContainsString('Aww, look, a cute puppy', $output);
|
||||
$this->assertStringNotContainsString('INFO', $output);
|
||||
$this->assertStringNotContainsString('info', $output);
|
||||
$this->assertStringNotContainsString('testing', $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an environment variable of the given name and value
|
||||
* then check the given config key to see if it matches the given result.
|
||||
|
Reference in New Issue
Block a user