add autodeploy and add basic auth for file uploader
Some checks failed
Deploy back2 / deploy (push) Failing after 46s
Some checks failed
Deploy back2 / deploy (push) Failing after 46s
This commit is contained in:
@@ -9,11 +9,36 @@ use Tests\TestCase;
|
||||
|
||||
class FileLinkWebTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Config::set('file_links.upload_basic_auth_users', [
|
||||
['username' => 'uploader1', 'password' => 'password1'],
|
||||
['username' => 'uploader2', 'password' => 'password2'],
|
||||
]);
|
||||
}
|
||||
|
||||
private function authHeader(string $username = 'uploader1', string $password = 'password1'): array
|
||||
{
|
||||
return [
|
||||
'Authorization' => 'Basic ' . base64_encode($username . ':' . $password),
|
||||
];
|
||||
}
|
||||
|
||||
public function test_files_page_requires_basic_auth(): void
|
||||
{
|
||||
$response = $this->get('/files');
|
||||
|
||||
$response->assertUnauthorized();
|
||||
$response->assertHeader('WWW-Authenticate', 'Basic realm="File Upload"');
|
||||
}
|
||||
|
||||
public function test_files_page_shows_disabled_state(): void
|
||||
{
|
||||
Config::set('file_links.enabled', false);
|
||||
|
||||
$response = $this->get('/files');
|
||||
$response = $this->withHeaders($this->authHeader())->get('/files');
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertSee('Функция отключена конфигом');
|
||||
@@ -26,7 +51,7 @@ class FileLinkWebTest extends TestCase
|
||||
Config::set('file_links.disk', 'local');
|
||||
Config::set('file_links.directory', 'temporary-links');
|
||||
|
||||
$response = $this->post('/files', [
|
||||
$response = $this->withHeaders($this->authHeader())->post('/files', [
|
||||
'file' => UploadedFile::fake()->create('web-sample.txt', 1),
|
||||
]);
|
||||
|
||||
@@ -35,4 +60,3 @@ class FileLinkWebTest extends TestCase
|
||||
$response->assertSessionHas('file_expires_at');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user