mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
refactoring
This commit is contained in:
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Stripe Keys
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The Stripe publishable key and secret key give you access to Stripe's
|
||||
| API. The "publishable" key is typically used when interacting with
|
||||
| Stripe.js while the "secret" key accesses private API endpoints.
|
||||
|
|
||||
*/
|
||||
|
||||
'key' => env('STRIPE_KEY'),
|
||||
|
||||
'secret' => env('STRIPE_SECRET'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cashier Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the base URI path where Cashier's views, such as the payment
|
||||
| verification screen, will be available from. You're free to tweak
|
||||
| this path according to your preferences and application design.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('CASHIER_PATH', 'stripe'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Stripe Webhooks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Your Stripe webhook secret is used to prevent unauthorized requests to
|
||||
| your Stripe webhook handling controllers. The tolerance setting will
|
||||
| check the drift between the current time and the signed request's.
|
||||
|
|
||||
*/
|
||||
|
||||
'webhook' => [
|
||||
'secret' => env('STRIPE_WEBHOOK_SECRET'),
|
||||
'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cashier Model
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the model in your application that implements the Billable trait
|
||||
| provided by Cashier. It will serve as the primary model you use while
|
||||
| interacting with Cashier related methods, subscriptions, and so on.
|
||||
|
|
||||
*/
|
||||
|
||||
'model' => env('CASHIER_MODEL', App\Users\Models\User::class),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Currency
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the default currency that will be used when generating charges
|
||||
| from your application. Of course, you are welcome to use any of the
|
||||
| various world currencies that are currently supported via Stripe.
|
||||
|
|
||||
*/
|
||||
|
||||
'currency' => env('CASHIER_CURRENCY', 'usd'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Currency Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the default locale in which your money values are formatted in
|
||||
| for display. To utilize other locales besides the default en locale
|
||||
| verify you have the "intl" PHP extension installed on the system.
|
||||
|
|
||||
*/
|
||||
|
||||
'currency_locale' => env('CASHIER_CURRENCY_LOCALE', 'en'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Payment Confirmation Notification
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If this setting is enabled, Cashier will automatically notify customers
|
||||
| whose payments require additional verification. You should listen to
|
||||
| Stripe's webhooks in order for this feature to function correctly.
|
||||
|
|
||||
*/
|
||||
|
||||
'payment_notification' => env('CASHIER_PAYMENT_NOTIFICATION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Invoice Paper Size
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option is the default paper size for all invoices generated using
|
||||
| Cashier. You are free to customize this settings based on the usual
|
||||
| paper size used by the customers using your Laravel applications.
|
||||
|
|
||||
| Supported sizes: 'letter', 'legal', 'A4'
|
||||
|
|
||||
*/
|
||||
|
||||
'paper' => env('CASHIER_PAPER', 'letter'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Stripe Logger
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This setting defines which logging channel will be used by the Stripe
|
||||
| library to write log messages. You are free to specify any of your
|
||||
| logging channels listed inside the "logging" configuration file.
|
||||
|
|
||||
*/
|
||||
|
||||
'logger' => env('CASHIER_LOGGER'),
|
||||
];
|
||||
@@ -5,7 +5,7 @@ use Illuminate\Http\Response;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Files\Requests\RemoteUploadRequest;
|
||||
use Domain\RemoteUpload\Requests\RemoteUploadRequest;
|
||||
use Domain\RemoteUpload\Actions\GetContentFromExternalSource;
|
||||
|
||||
class RemoteUploadFileController extends Controller
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace Domain\RemoteUpload\Controllers;
|
||||
|
||||
use DB;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Domain\Files\Requests\RemoteUploadRequest;
|
||||
use Domain\RemoteUpload\Requests\RemoteUploadRequest;
|
||||
use Domain\UploadRequest\Models\UploadRequest;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Domain\RemoteUpload\Actions\GetContentFromExternalSource;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Domain\RemoteUpload\Controllers;
|
||||
use Illuminate\Http\Response;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Files\Requests\RemoteUploadRequest;
|
||||
use Domain\RemoteUpload\Requests\RemoteUploadRequest;
|
||||
use Domain\Sharing\Actions\ProtectShareRecordAction;
|
||||
use Domain\Sharing\Actions\VerifyAccessToItemAction;
|
||||
use Domain\RemoteUpload\Actions\GetContentFromExternalSource;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Domain\Files\Requests;
|
||||
namespace Domain\RemoteUpload\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
namespace Domain\SetupWizard\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreStripeBillingRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'billing_phone_number' => 'sometimes|nullable|string',
|
||||
'billing_postal_code' => 'required|string',
|
||||
'billing_vat_number' => 'required|string',
|
||||
'billing_address' => 'required|string',
|
||||
'billing_country' => 'required|string',
|
||||
'billing_state' => 'required|string',
|
||||
'billing_city' => 'required|string',
|
||||
'billing_name' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
namespace Domain\SetupWizard\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreStripeCredentialsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'currency' => 'required|string',
|
||||
'webhookSecret' => 'required|string',
|
||||
'secret' => 'required|string',
|
||||
'key' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
namespace Domain\SetupWizard\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreStripePlansRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'plans' => 'required|array',
|
||||
'plans.*.type' => 'required|string',
|
||||
'plans.*.attributes.name' => 'required|string',
|
||||
'plans.*.attributes.price' => 'required|string',
|
||||
'plans.*.attributes.description' => 'sometimes|nullable|string',
|
||||
'plans.*.attributes.capacity' => 'required|digits_between:1,9',
|
||||
];
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -105,60 +105,6 @@ class FileTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_remotely_upload_new_file()
|
||||
{
|
||||
Event::fake([
|
||||
RemoteFileCreatedEvent::class,
|
||||
]);
|
||||
|
||||
$user = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$folder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$fakeFile = UploadedFile::fake()
|
||||
->create('top-secret-document.pdf', 12000000, 'application/pdf');
|
||||
|
||||
Http::fake([
|
||||
'https://fake.com/top-secret-document.pdf' => Http::response($fakeFile->getContent()),
|
||||
'https://fake.com/another-secret-document.pdf' => Http::response($fakeFile->getContent()),
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/upload/remote', [
|
||||
'urls' => [
|
||||
'https://fake.com/top-secret-document.pdf',
|
||||
'https://fake.com/another-secret-document.pdf',
|
||||
],
|
||||
'parent_id' => $folder->id,
|
||||
])->assertStatus(201);
|
||||
|
||||
$this
|
||||
->assertDatabaseHas('files', [
|
||||
'user_id' => $user->id,
|
||||
'name' => 'top-secret-document',
|
||||
'parent_id' => $folder->id,
|
||||
])
|
||||
->assertDatabaseHas('files', [
|
||||
'name' => 'another-secret-document',
|
||||
]);
|
||||
|
||||
File::all()
|
||||
->each(function ($file) {
|
||||
Event::assertDispatched(fn (RemoteFileCreatedEvent $event) => $event->payload['file']->id === $file->id);
|
||||
|
||||
Storage::assertExists("files/$file->user_id/$file->basename");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
||||
70
tests/Domain/RemoteUpload/RemoteUploadTest.php
Normal file
70
tests/Domain/RemoteUpload/RemoteUploadTest.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\RemoteUpload;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use Domain\Files\Models\File;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Domain\RemoteUpload\Events\RemoteFileCreatedEvent;
|
||||
use Event;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class RemoteUploadTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_remotely_upload_new_file()
|
||||
{
|
||||
Event::fake([
|
||||
RemoteFileCreatedEvent::class,
|
||||
]);
|
||||
|
||||
$user = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$folder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$fakeFile = UploadedFile::fake()
|
||||
->create('top-secret-document.pdf', 12000000, 'application/pdf');
|
||||
|
||||
Http::fake([
|
||||
'https://fake.com/top-secret-document.pdf' => Http::response($fakeFile->getContent()),
|
||||
'https://fake.com/another-secret-document.pdf' => Http::response($fakeFile->getContent()),
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/upload/remote', [
|
||||
'urls' => [
|
||||
'https://fake.com/top-secret-document.pdf',
|
||||
'https://fake.com/another-secret-document.pdf',
|
||||
],
|
||||
'parent_id' => $folder->id,
|
||||
])->assertStatus(201);
|
||||
|
||||
$this
|
||||
->assertDatabaseHas('files', [
|
||||
'user_id' => $user->id,
|
||||
'name' => 'top-secret-document',
|
||||
'parent_id' => $folder->id,
|
||||
])
|
||||
->assertDatabaseHas('files', [
|
||||
'name' => 'another-secret-document',
|
||||
]);
|
||||
|
||||
File::all()
|
||||
->each(function ($file) {
|
||||
Event::assertDispatched(fn (RemoteFileCreatedEvent $event) => $event->payload['file']->id === $file->id);
|
||||
|
||||
Storage::assertExists("files/$file->user_id/$file->basename");
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user