1
0
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:
Dan Brown
2020-07-28 12:59:43 +01:00
parent 2f6ff07347
commit 2ed0317129
8 changed files with 98 additions and 30 deletions

View File

@ -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.