Add service API for Ladill Mail large attachment uploads.
Deploy Ladill Transfer / deploy (push) Successful in 39s
Deploy Ladill Transfer / deploy (push) Successful in 39s
Webmail can POST /api/v1/transfers with a mailbox address to create share links for files above 25 MB. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
|
||||
class TransferApiTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Storage::fake('qr');
|
||||
config([
|
||||
'transfer.service_api_keys' => ['webmail' => 'test-webmail-key'],
|
||||
'identity.api_url' => 'https://ladill.com/api',
|
||||
'identity.api_key' => 'test-identity-key',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_webmail_service_can_create_transfer_for_mailbox(): void
|
||||
{
|
||||
Http::fake([
|
||||
rtrim((string) config('identity.api_url'), '/').'/identity/profile*' => Http::response([
|
||||
'data' => [
|
||||
'public_id' => (string) Str::uuid(),
|
||||
'name' => 'Mail User',
|
||||
'email' => 'sender@acme.com',
|
||||
'picture' => null,
|
||||
],
|
||||
]),
|
||||
]);
|
||||
|
||||
$file = UploadedFile::fake()->create('large.zip', 30000, 'application/zip');
|
||||
|
||||
$this->withToken('test-webmail-key')
|
||||
->post('/api/v1/transfers', [
|
||||
'mailbox' => 'sender@acme.com',
|
||||
'title' => 'Email: Quarterly report',
|
||||
'files' => [$file],
|
||||
])
|
||||
->assertCreated()
|
||||
->assertJsonPath('data.title', 'Email: Quarterly report')
|
||||
->assertJsonStructure(['data' => ['public_url', 'files']]);
|
||||
|
||||
$this->assertDatabaseHas('users', ['email' => 'sender@acme.com']);
|
||||
$this->assertDatabaseCount('transfers', 1);
|
||||
}
|
||||
|
||||
public function test_transfer_api_rejects_unauthorized_callers(): void
|
||||
{
|
||||
$this->post('/api/v1/transfers', ['mailbox' => 'x@y.com'])
|
||||
->assertUnauthorized();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user