Upgrade to Laravel 8

This commit is contained in:
Bubka 2021-12-02 13:15:53 +01:00
parent 65da59db64
commit 20856d62c6
86 changed files with 1854 additions and 911 deletions

View File

@ -11,5 +11,8 @@ trim_trailing_whitespace = true
[*.md] [*.md]
trim_trailing_whitespace = false trim_trailing_whitespace = false
[*.yml] [*.{yml,yaml}]
indent_size = 2 indent_size = 2
[docker-compose.yml]
indent_size = 4

View File

@ -72,6 +72,7 @@ DB_DATABASE="path/to/your/database.sqlite"
# If you're looking for performance improvements, you could install memcached. # If you're looking for performance improvements, you could install memcached.
CACHE_DRIVER=file CACHE_DRIVER=file
SESSION_DRIVER=file SESSION_DRIVER=file
FILESYSTEM_DRIVER=local
# Mail settings # Mail settings

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/node_modules /node_modules
/public/hot
/public/storage /public/storage
/storage/*.key /storage/*.key
/tests/Coverage /tests/Coverage

View File

@ -1,7 +1,8 @@
php: php:
preset: laravel preset: laravel
version: 8
disabled: disabled:
- unused_use - no_unused_imports
finder: finder:
not-name: not-name:
- index.php - index.php

View File

@ -2,7 +2,7 @@
namespace App\Api\v1\Controllers\Auth; namespace App\Api\v1\Controllers\Auth;
use App\User; use App\Models\User;
use App\Api\v1\Requests\UserStoreRequest; use App\Api\v1\Requests\UserStoreRequest;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
@ -49,7 +49,7 @@ public function register(UserStoreRequest $request)
* Create a new user instance after a valid registration. * Create a new user instance after a valid registration.
* *
* @param array $data * @param array $data
* @return \App\User * @return \App\Models\User
*/ */
protected function create(array $data) protected function create(array $data)
{ {

View File

@ -2,7 +2,7 @@
namespace App\Api\v1\Controllers\Auth; namespace App\Api\v1\Controllers\Auth;
use App\User; use App\Models\User;
use App\Api\v1\Requests\UserUpdateRequest; use App\Api\v1\Requests\UserUpdateRequest;
use App\Api\v1\Resources\UserResource; use App\Api\v1\Resources\UserResource;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;

View File

@ -2,7 +2,7 @@
namespace App\Api\v1\Controllers; namespace App\Api\v1\Controllers;
use App\Group; use App\Models\Group;
use App\Services\GroupService; use App\Services\GroupService;
use App\Api\v1\Requests\GroupStoreRequest; use App\Api\v1\Requests\GroupStoreRequest;
use App\Api\v1\Requests\GroupAssignRequest; use App\Api\v1\Requests\GroupAssignRequest;
@ -64,7 +64,7 @@ public function store(GroupStoreRequest $request)
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param \App\Group $group * @param \App\Models\Group $group
* @return \App\Api\v1\Resources\GroupResource * @return \App\Api\v1\Resources\GroupResource
*/ */
public function show(Group $group) public function show(Group $group)
@ -77,7 +77,7 @@ public function show(Group $group)
* Update the specified resource in storage. * Update the specified resource in storage.
* *
* @param \App\Api\v1\Requests\GroupStoreRequest $request * @param \App\Api\v1\Requests\GroupStoreRequest $request
* @param \App\Group $group * @param \App\Models\Group $group
* @return \App\Api\v1\Resources\GroupResource * @return \App\Api\v1\Resources\GroupResource
*/ */
public function update(GroupStoreRequest $request, Group $group) public function update(GroupStoreRequest $request, Group $group)
@ -95,7 +95,7 @@ public function update(GroupStoreRequest $request, Group $group)
* Associate the specified accounts with the group * Associate the specified accounts with the group
* *
* @param \App\Api\v1\Requests\GroupAssignRequest $request * @param \App\Api\v1\Requests\GroupAssignRequest $request
* @param \App\Group $group * @param \App\Models\Group $group
* @return \App\Api\v1\Resources\GroupResource * @return \App\Api\v1\Resources\GroupResource
*/ */
public function assignAccounts(GroupAssignRequest $request, Group $group) public function assignAccounts(GroupAssignRequest $request, Group $group)
@ -112,7 +112,7 @@ public function assignAccounts(GroupAssignRequest $request, Group $group)
/** /**
* Get accounts assign to the group * Get accounts assign to the group
* *
* @param \App\Group $group * @param \App\Models\Group $group
* @return \App\Api\v1\Resources\TwoFAccountCollection * @return \App\Api\v1\Resources\TwoFAccountCollection
*/ */
public function accounts(Group $group) public function accounts(Group $group)
@ -127,7 +127,7 @@ public function accounts(Group $group)
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param \App\Group $group * @param \App\Models\Group $group
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function destroy(Group $group) public function destroy(Group $group)

View File

@ -2,7 +2,7 @@
namespace App\Api\v1\Controllers; namespace App\Api\v1\Controllers;
use App\TwoFAccount; use App\Models\TwoFAccount;
use App\Services\QrCodeService; use App\Services\QrCodeService;
use App\Services\TwoFAccountService; use App\Services\TwoFAccountService;
use App\Api\v1\Requests\QrCodeDecodeRequest; use App\Api\v1\Requests\QrCodeDecodeRequest;
@ -39,7 +39,7 @@ public function __construct(QrCodeService $qrcodeService, TwoFAccountService $tw
/** /**
* Show a QR code image * Show a QR code image
* *
* @param App\TwoFAccount $twofaccount * @param App\Models\TwoFAccount $twofaccount
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function show(TwoFAccount $twofaccount) public function show(TwoFAccount $twofaccount)

View File

@ -2,7 +2,7 @@
namespace App\Api\v1\Controllers; namespace App\Api\v1\Controllers;
use App\TwoFAccount; use App\Models\TwoFAccount;
use App\Exceptions\UndecipherableException; use App\Exceptions\UndecipherableException;
use App\Api\v1\Requests\TwoFAccountReorderRequest; use App\Api\v1\Requests\TwoFAccountReorderRequest;
use App\Api\v1\Requests\TwoFAccountStoreRequest; use App\Api\v1\Requests\TwoFAccountStoreRequest;
@ -60,7 +60,7 @@ public function index(Request $request)
/** /**
* Display a 2FA account * Display a 2FA account
* *
* @param \App\TwoFAccount $twofaccount * @param \App\Models\TwoFAccount $twofaccount
* *
* @return \App\Api\v1\Resources\TwoFAccountReadResource * @return \App\Api\v1\Resources\TwoFAccountReadResource
*/ */
@ -104,7 +104,7 @@ public function store(TwoFAccountDynamicRequest $request)
* Update a 2FA account * Update a 2FA account
* *
* @param \App\Api\v1\Requests\TwoFAccountUpdateRequest $request * @param \App\Api\v1\Requests\TwoFAccountUpdateRequest $request
* @param \App\TwoFAccount $twofaccount * @param \App\Models\TwoFAccount $twofaccount
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function update(TwoFAccountUpdateRequest $request, TwoFAccount $twofaccount) public function update(TwoFAccountUpdateRequest $request, TwoFAccount $twofaccount)
@ -236,7 +236,7 @@ public function withdraw(TwoFAccountBatchRequest $request)
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param \App\TwoFAccount $twofaccount * @param \App\Models\TwoFAccount $twofaccount
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function destroy(TwoFAccount $twofaccount) public function destroy(TwoFAccount $twofaccount)

View File

@ -2,7 +2,7 @@
namespace App\Console\Commands\Maintenance; namespace App\Console\Commands\Maintenance;
use App\TwoFAccount; use App\Models\TwoFAccount;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;

View File

@ -7,15 +7,6 @@
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
{ {
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/** /**
* Define the application's command schedule. * Define the application's command schedule.
* *

View File

@ -2,7 +2,7 @@
namespace App\Events; namespace App\Events;
use App\Group; use App\Models\Group;
use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
@ -16,7 +16,7 @@ class GroupDeleting
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \App\Group $group * @param \App\Models\Group $group
* @return void * @return void
*/ */
public function __construct(Group $group) public function __construct(Group $group)

View File

@ -2,7 +2,7 @@
namespace App\Events; namespace App\Events;
use App\TwoFAccount; use App\Models\TwoFAccount;
use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
@ -16,7 +16,7 @@ class TwoFAccountDeleted
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \App\TwoFAccount $twofaccount * @param \App\Models\TwoFAccount $twofaccount
* @return void * @return void
*/ */
public function __construct(TwoFAccount $twofaccount) public function __construct(TwoFAccount $twofaccount)

View File

@ -11,7 +11,7 @@ class Handler extends ExceptionHandler
/** /**
* A list of the exception types that are not reported. * A list of the exception types that are not reported.
* *
* @var array * @var string[]
*/ */
protected $dontReport = [ protected $dontReport = [
// //
@ -20,62 +20,50 @@ class Handler extends ExceptionHandler
/** /**
* A list of the inputs that are never flashed for validation exceptions. * A list of the inputs that are never flashed for validation exceptions.
* *
* @var array * @var string[]
*/ */
protected $dontFlash = [ protected $dontFlash = [
'current_password',
'password', 'password',
'password_confirmation', 'password_confirmation',
]; ];
/** /**
* Report or log an exception. * Register the exception handling callbacks for the application.
* *
* @param \Throwable $exception
* @return void * @return void
*/ */
public function report(Throwable $exception) public function register()
{ {
parent::report($exception); // $this->reportable(function (Throwable $e) {
} //
// });
/** $this->renderable(function (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $exception, $request) {
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, Throwable $exception)
{
if ($exception instanceof ModelNotFoundException) {
return response()->json([
'message' => str_replace('App\\', '', $exception->getModel()).' not found'], 404);
}
if ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
return response()->json([ return response()->json([
'message' => 'not found'], 404); 'message' => 'not found'], 404);
} });
if ($exception instanceof InvalidOtpParameterException) {
$this->renderable(function (InvalidOtpParameterException $exception, $request) {
return response()->json([ return response()->json([
'message' => 'invalid OTP parameters', 'message' => 'invalid OTP parameters',
'reason' => [$exception->getMessage()] 'reason' => [$exception->getMessage()]
], 400); ], 400);
} });
if ($exception instanceof InvalidQrCodeException) {
$this->renderable(function (InvalidQrCodeException $exception, $request) {
return response()->json([ return response()->json([
'message' => 'not a valid QR code'], 400); 'message' => 'not a valid QR code'], 400);
} });
if ($exception instanceof InvalidSecretException) {
$this->renderable(function (InvalidSecretException $exception, $request) {
return response()->json([ return response()->json([
'message' => 'not a valid base32 encoded secret'], 400); 'message' => 'not a valid base32 encoded secret'], 400);
} });
if ($exception instanceof DbEncryptionException) {
$this->renderable(function (DbEncryptionException $exception, $request) {
return response()->json([ return response()->json([
'message' => $exception->getMessage()], 400); 'message' => $exception->getMessage()], 400);
} });
return parent::render($request, $exception);
} }
} }

View File

@ -14,12 +14,13 @@ class Kernel extends HttpKernel
* @var array * @var array
*/ */
protected $middleware = [ protected $middleware = [
\App\Http\Middleware\CheckForMaintenanceMode::class, \App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
// \App\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class, \App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\SetLanguage::class, \App\Http\Middleware\SetLanguage::class,
\App\Http\Middleware\ForceJsonResponse::class, \App\Http\Middleware\ForceJsonResponse::class,
]; ];
@ -42,8 +43,8 @@ class Kernel extends HttpKernel
], ],
'api.v1' => [ 'api.v1' => [
'throttle:60,1', 'throttle:api',
'bindings', \Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\KickOutInactiveUser::class, \App\Http\Middleware\KickOutInactiveUser::class,
\App\Http\Middleware\LogUserLastSeen::class, \App\Http\Middleware\LogUserLastSeen::class,
], ],
@ -59,10 +60,10 @@ class Kernel extends HttpKernel
protected $routeMiddleware = [ protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class, 'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,

View File

@ -3,7 +3,7 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Closure; use Closure;
use App\User; use App\Models\User;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;

View File

@ -2,9 +2,9 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware; use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class CheckForMaintenanceMode extends Middleware class PreventRequestsDuringMaintenance extends Middleware
{ {
/** /**
* The URIs that should be reachable while maintenance mode is enabled. * The URIs that should be reachable while maintenance mode is enabled.

View File

@ -2,7 +2,9 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure; use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated class RedirectIfAuthenticated
@ -12,14 +14,18 @@ class RedirectIfAuthenticated
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @param string|null $guard * @param string|null ...$guards
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next, $guard = null) public function handle(Request $request, Closure $next, ...$guards)
{ {
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) { if (Auth::guard($guard)->check()) {
return response()->json(['message' => __('auth.already_authenticated')], 400); return response()->json(['message' => __('auth.already_authenticated')], 400);
} }
}
return $next($request); return $next($request);
} }

View File

@ -12,6 +12,7 @@ class TrimStrings extends Middleware
* @var array * @var array
*/ */
protected $except = [ protected $except = [
'current_password',
'password', 'password',
'password_confirmation', 'password_confirmation',
]; ];

View File

@ -2,15 +2,15 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware class TrustProxies extends Middleware
{ {
/** /**
* The trusted proxies for this application. * The trusted proxies for this application.
* *
* @var array|string * @var array|string|null
*/ */
protected $proxies; protected $proxies;
@ -19,5 +19,10 @@ class TrustProxies extends Middleware
* *
* @var int * @var int
*/ */
protected $headers = Request::HEADER_X_FORWARDED_ALL; protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
} }

View File

@ -2,7 +2,7 @@
namespace App\Listeners; namespace App\Listeners;
use App\TwoFAccount; use App\Models\TwoFAccount;
use App\Events\GroupDeleting; use App\Events\GroupDeleting;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;

View File

@ -1,14 +1,17 @@
<?php <?php
namespace App; namespace App\Models;
use App\Events\GroupDeleting; use App\Events\GroupDeleting;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Group extends Model class Group extends Model
{ {
use HasFactory;
/** /**
* model's array form. * model's array form.
* *
@ -75,6 +78,6 @@ protected static function boot()
*/ */
public function twofaccounts() public function twofaccounts()
{ {
return $this->hasMany('App\TwoFAccount'); return $this->hasMany('App\Models\TwoFAccount');
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App; namespace App\Models;
use Exception; use Exception;
use App\Events\TwoFAccountDeleted; use App\Events\TwoFAccountDeleted;
@ -10,11 +10,12 @@
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class TwoFAccount extends Model implements Sortable class TwoFAccount extends Model implements Sortable
{ {
use SortableTrait; use SortableTrait, HasFactory;
/** /**

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App; namespace App\Models;
use Illuminate\Auth\Notifications\ResetPassword; use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
@ -8,22 +8,23 @@
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens; use Laravel\Passport\HasApiTokens;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class User extends Authenticatable class User extends Authenticatable
{ {
use HasApiTokens, Notifiable; use HasApiTokens, HasFactory, Notifiable;
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
* *
* @var array * @var string[]
*/ */
protected $fillable = [ protected $fillable = [
'name', 'email', 'password', 'name', 'email', 'password',
]; ];
/** /**
* The attributes that should be hidden for arrays. * The attributes that should be hidden for serialization.
* *
* @var array * @var array
*/ */
@ -32,7 +33,7 @@ class User extends Authenticatable
]; ];
/** /**
* The attributes that should be cast to native types. * The attributes that should be cast.
* *
* @var array * @var array
*/ */

View File

@ -14,7 +14,7 @@ class AuthServiceProvider extends ServiceProvider
* @var array * @var array
*/ */
protected $policies = [ protected $policies = [
// 'App\Model' => 'App\Policies\ModelPolicy', // 'App\Models\Model' => 'App\Policies\ModelPolicy',
]; ];
/** /**

View File

@ -33,8 +33,6 @@ class EventServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
parent::boot();
// //
} }
} }

View File

@ -2,18 +2,30 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Route; use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider class RouteServiceProvider extends ServiceProvider
{ {
/** /**
* This namespace is applied to your controller routes. * The path to the "home" route for your application.
* *
* In addition, it is set as the URL generator's root namespace. * This is used by Laravel authentication to redirect users after login.
* *
* @var string * @var string
*/ */
public const HOME = '/accounts';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
protected $namespace = 'App\Http\Controllers'; protected $namespace = 'App\Http\Controllers';
/** /**
@ -24,67 +36,24 @@ class RouteServiceProvider extends ServiceProvider
public function boot() public function boot()
{ {
Route::pattern('settingName', '[a-zA-Z]+'); Route::pattern('settingName', '[a-zA-Z]+');
$this->configureRateLimiting();
parent::boot(); $this->routes(function () {
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiVersionOneRoutes();
// $this->mapApiVersionTwoRoutes();
$this->mapWebRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "v1 api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiVersionOneRoutes()
{
Route::prefix('api/v1') Route::prefix('api/v1')
->middleware('api.v1') ->middleware('api.v1')
->namespace($this->getApiNamespace(1)) ->namespace($this->getApiNamespace(1))
->group(base_path('routes/api/v1.php')); ->group(base_path('routes/api/v1.php'));
}
/**
* Define the "v2 api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
// protected function mapApiVersionTwoRoutes()
// {
// Route::prefix('api/v2') // Route::prefix('api/v2')
// ->middleware('api.v2') // ->middleware('api.v2')
// ->namespace($this->getApiNamespace(2)) // ->namespace($this->getApiNamespace(2))
// ->group(base_path('routes/api/v2.php')); // ->group(base_path('routes/api/v2.php'));
// }
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
/** /**
* Build Api namespace based on provided version * Build Api namespace based on provided version
@ -95,4 +64,16 @@ private function getApiNamespace($version)
{ {
return 'App\Api\v' . $version . '\Controllers'; return 'App\Api\v' . $version . '\Controllers';
} }
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
} }

View File

@ -2,8 +2,8 @@
namespace App\Services; namespace App\Services;
use App\Group; use App\Models\Group;
use App\TwoFAccount; use App\Models\TwoFAccount;
use App\Services\SettingService; use App\Services\SettingService;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
@ -59,7 +59,7 @@ public function getAll() : Collection
* Creates a group * Creates a group
* *
* @param array $data * @param array $data
* @return \App\Group The created group * @return \App\Models\Group The created group
*/ */
public function create(array $data) : Group public function create(array $data) : Group
{ {
@ -78,9 +78,9 @@ public function create(array $data) : Group
/** /**
* Updates a group using a list of parameters * Updates a group using a list of parameters
* *
* @param \App\Group $group The group * @param \App\Models\Group $group The group
* @param array $data The parameters * @param array $data The parameters
* @return \App\Group The updated group * @return \App\Models\Group The updated group
*/ */
public function update(Group $group, array $data) : Group public function update(Group $group, array $data) : Group
{ {
@ -133,7 +133,7 @@ public function delete($ids) : int
* Assign one or more accounts to a group * Assign one or more accounts to a group
* *
* @param array|int $ids accounts ids to assign * @param array|int $ids accounts ids to assign
* @param \App\Group $group The target group * @param \App\Models\Group $group The target group
* @return void * @return void
*/ */
public function assign($ids, Group $group = null) : void public function assign($ids, Group $group = null) : void
@ -162,7 +162,7 @@ public function assign($ids, Group $group = null) : void
/** /**
* Finds twofaccounts assigned to the group * Finds twofaccounts assigned to the group
* *
* @param \App\Group $group The group * @param \App\Models\Group $group The group
* @return Collection The assigned accounts * @return Collection The assigned accounts
*/ */
public function getAccounts(Group $group) : Collection public function getAccounts(Group $group) : Collection
@ -176,7 +176,7 @@ public function getAccounts(Group $group) : Collection
/** /**
* Determines the destination group * Determines the destination group
* *
* @return \App\Group|null The group or null if it does not exist * @return \App\Models\Group|null The group or null if it does not exist
*/ */
private function defaultGroup() private function defaultGroup()
{ {

View File

@ -2,7 +2,7 @@
namespace App\Services; namespace App\Services;
use App\TwoFAccount; use App\Models\TwoFAccount;
use Zxing\QrReader; use Zxing\QrReader;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;

View File

@ -4,7 +4,7 @@
use Throwable; use Throwable;
use Exception; use Exception;
use App\Option; use App\Models\Option;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;

View File

@ -2,7 +2,7 @@
namespace App\Services; namespace App\Services;
use App\TwoFAccount; use App\Models\TwoFAccount;
use App\Exceptions\InvalidSecretException; use App\Exceptions\InvalidSecretException;
use App\Exceptions\InvalidOtpParameterException; use App\Exceptions\InvalidOtpParameterException;
use App\Exceptions\UndecipherableException; use App\Exceptions\UndecipherableException;
@ -48,7 +48,7 @@ public function __construct()
* @param string $uri * @param string $uri
* @param bool $saveToDB Whether or not the created account should be saved to DB * @param bool $saveToDB Whether or not the created account should be saved to DB
* *
* @return \App\TwoFAccount The created account * @return \App\Models\TwoFAccount The created account
*/ */
public function createFromUri(string $uri, bool $saveToDB = true ) : TwoFAccount public function createFromUri(string $uri, bool $saveToDB = true ) : TwoFAccount
{ {
@ -76,7 +76,7 @@ public function createFromUri(string $uri, bool $saveToDB = true ) : TwoFAccount
* @param array $data * @param array $data
* @param bool $saveToDB Whether or not the created account should be saved to DB * @param bool $saveToDB Whether or not the created account should be saved to DB
* *
* @return \App\TwoFAccount The created account * @return \App\Models\TwoFAccount The created account
*/ */
public function createFromParameters(array $data, bool $saveToDB = true) : TwoFAccount public function createFromParameters(array $data, bool $saveToDB = true) : TwoFAccount
{ {
@ -102,10 +102,10 @@ public function createFromParameters(array $data, bool $saveToDB = true) : TwoFA
/** /**
* Updates an account using a list of parameters * Updates an account using a list of parameters
* *
* @param \App\TwoFAccount $twofaccount The account * @param \App\Models\TwoFAccount $twofaccount The account
* @param array $data The parameters * @param array $data The parameters
* *
* @return \App\TwoFAccount The updated account * @return \App\Models\TwoFAccount The updated account
*/ */
public function update(TwoFAccount $twofaccount, array $data) : TwoFAccount public function update(TwoFAccount $twofaccount, array $data) : TwoFAccount
{ {
@ -125,7 +125,7 @@ public function update(TwoFAccount $twofaccount, array $data) : TwoFAccount
/** /**
* Returns a One-Time Password (with its parameters) for the specified account * Returns a One-Time Password (with its parameters) for the specified account
* *
* @param \App\TwoFAccount|TwoFAccountDto|int|string $data Data defining an account * @param \App\Models\TwoFAccount|TwoFAccountDto|int|string $data Data defining an account
* *
* @return OtpDto an OTP DTO * @return OtpDto an OTP DTO
* *
@ -176,7 +176,7 @@ public function getOTP($data) : OtpDto
/** /**
* Returns a generated otpauth URI for the specified account * Returns a generated otpauth URI for the specified account
* *
* @param \App\TwoFAccount|TwoFAccountDto|int $data Data defining an account * @param \App\Models\TwoFAccount|TwoFAccountDto|int $data Data defining an account
*/ */
public function getURI($data) : string public function getURI($data) : string
{ {
@ -254,7 +254,7 @@ private function commaSeparatedToArray($ids)
private function initTokenWith($data) : void private function initTokenWith($data) : void
{ {
// init with a TwoFAccount instance // init with a TwoFAccount instance
if ( is_object($data) && get_class($data) === 'App\TwoFAccount' ) { if ( is_object($data) && get_class($data) === 'App\Models\TwoFAccount' ) {
$this->initTokenWithTwoFAccount($data); $this->initTokenWithTwoFAccount($data);
} }
// init with a TwoFAccountDto instance // init with a TwoFAccountDto instance
@ -307,7 +307,7 @@ private function mapArrayToDto($array) : TwoFAccountDto
/** /**
* Instanciates the token with a TwoFAccount * Instanciates the token with a TwoFAccount
* *
* @param \App\TwoFAccount $twofaccount * @param \App\Models\TwoFAccount $twofaccount
* *
* @param bool $usingUri Whether or not the token should be fed with the account uri * @param bool $usingUri Whether or not the token should be fed with the account uri
*/ */

View File

@ -8,25 +8,25 @@
], ],
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": "^7.4", "php": "^7.4|^8.0",
"chillerlan/php-qrcode": "^4.3",
"doctrine/dbal": "^2.10",
"fakerphp/faker": "^1.16",
"fideloper/proxy": "^4.4.1",
"fruitcake/laravel-cors": "^2.0", "fruitcake/laravel-cors": "^2.0",
"khanamiryan/qrcode-detector-decoder": "^1.0.4", "guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^7.0", "laravel/framework": "^8.0",
"laravel/passport": "^9.3.2", "laravel/passport": "^10.0",
"laravel/tinker": "^2.0", "laravel/tinker": "^2.5",
"laravel/ui": "^2.0", "laravel/ui": "^3.0",
"chillerlan/php-qrcode": "^4.3",
"doctrine/dbal": "^3.2",
"khanamiryan/qrcode-detector-decoder": "^1.0.5",
"paragonie/constant_time_encoding": "^2.4", "paragonie/constant_time_encoding": "^2.4",
"spatie/eloquent-sortable": "^3.11", "spatie/eloquent-sortable": "^3.11",
"spomky-labs/otphp": "^10.0" "spomky-labs/otphp": "^10.0"
}, },
"require-dev": { "require-dev": {
"facade/ignition": "^2.3", "facade/ignition": "^2.3.6",
"fakerphp/faker": "^1.16",
"mockery/mockery": "^1.3", "mockery/mockery": "^1.3",
"nunomaduro/collision": "^4.1", "nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.5" "phpunit/phpunit": "^9.5"
}, },
"config": { "config": {
@ -41,12 +41,10 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"App\\": "app/" "App\\": "app/",
}, "Database\\Factories\\": "database/factories/",
"classmap": [ "Database\\Seeders\\": "database/seeders/"
"database/seeds", }
"database/factories"
]
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {

1749
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,7 @@
| |
*/ */
'debug' => env('APP_DEBUG', false), 'debug' => (bool) env('APP_DEBUG', false),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -210,12 +210,15 @@
'Config' => Illuminate\Support\Facades\Config::class, 'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class, 'Crypt' => Illuminate\Support\Facades\Crypt::class,
'Date' => Illuminate\Support\Facades\Date::class,
'DB' => Illuminate\Support\Facades\DB::class, 'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class, 'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class, 'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class, 'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class, 'Hash' => Illuminate\Support\Facades\Hash::class,
'Http' => Illuminate\Support\Facades\Http::class,
'Js' => Illuminate\Support\Js::class,
'Lang' => Illuminate\Support\Facades\Lang::class, 'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class, 'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class, 'Mail' => Illuminate\Support\Facades\Mail::class,
@ -223,7 +226,7 @@
'Password' => Illuminate\Support\Facades\Password::class, 'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class, 'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class, // 'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class, 'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class, 'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class, 'Route' => Illuminate\Support\Facades\Route::class,

View File

@ -68,7 +68,7 @@
'providers' => [ 'providers' => [
'users' => [ 'users' => [
'driver' => 'eloquent', 'driver' => 'eloquent',
'model' => App\User::class, 'model' => App\Models\User::class,
], ],
// 'users' => [ // 'users' => [
@ -97,7 +97,21 @@
'provider' => 'users', 'provider' => 'users',
'table' => 'password_resets', 'table' => 'password_resets',
'expire' => 60, 'expire' => 60,
'throttle' => 60,
], ],
], ],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,
]; ];

View File

@ -41,6 +41,11 @@
], ],
], ],
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],
'redis' => [ 'redis' => [
'driver' => 'redis', 'driver' => 'redis',
'connection' => 'default', 'connection' => 'default',

View File

@ -13,9 +13,6 @@
| using this caching library. This connection is used when another is | using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function. | not explicitly specified when executing a given caching function.
| |
| Supported: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb"
|
*/ */
'default' => env('CACHE_DRIVER', 'file'), 'default' => env('CACHE_DRIVER', 'file'),
@ -29,6 +26,9 @@
| well as their drivers. You may even define multiple stores for the | well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches. | same cache driver to group types of items stored in your caches.
| |
| Supported drivers: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb", "octane", "null"
|
*/ */
'stores' => [ 'stores' => [
@ -39,12 +39,14 @@
'array' => [ 'array' => [
'driver' => 'array', 'driver' => 'array',
'serialize' => false,
], ],
'database' => [ 'database' => [
'driver' => 'database', 'driver' => 'database',
'table' => 'cache', 'table' => 'cache',
'connection' => null, 'connection' => null,
'lock_connection' => null,
], ],
'file' => [ 'file' => [
@ -74,6 +76,7 @@
'redis' => [ 'redis' => [
'driver' => 'redis', 'driver' => 'redis',
'connection' => 'cache', 'connection' => 'cache',
'lock_connection' => 'default',
], ],
'dynamodb' => [ 'dynamodb' => [
@ -82,6 +85,11 @@
'secret' => env('AWS_SECRET_ACCESS_KEY'), 'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
], ],
], ],

View File

@ -134,17 +134,18 @@
], ],
'default' => [ 'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'), 'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null), 'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379), 'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', 0), 'database' => env('REDIS_DB', '0'),
], ],
'cache' => [ 'cache' => [
'host' => env('REDIS_HOST', '127.0.0.1'), 'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null), 'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379), 'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', 1), 'database' => env('REDIS_CACHE_DB', '1'),
], ],
], ],

View File

@ -26,7 +26,7 @@
| |
*/ */
'cloud' => env('FILESYSTEM_CLOUD', 's3'), // 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -62,8 +62,25 @@
'region' => env('AWS_DEFAULT_REGION'), 'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'), 'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'), 'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
], ],
], ],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
]; ];

View File

@ -18,6 +18,19 @@
'default' => env('LOG_CHANNEL', 'stack'), 'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Log Channels | Log Channels
@ -43,13 +56,13 @@
'single' => [ 'single' => [
'driver' => 'single', 'driver' => 'single',
'path' => storage_path('logs/laravel.log'), 'path' => storage_path('logs/laravel.log'),
'level' => 'debug', 'level' => env('LOG_LEVEL', 'debug'),
], ],
'daily' => [ 'daily' => [
'driver' => 'daily', 'driver' => 'daily',
'path' => storage_path('logs/laravel.log'), 'path' => storage_path('logs/laravel.log'),
'level' => 'debug', 'level' => env('LOG_LEVEL', 'debug'),
'days' => 7, 'days' => 7,
], ],
@ -58,12 +71,12 @@
'url' => env('LOG_SLACK_WEBHOOK_URL'), 'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log', 'username' => 'Laravel Log',
'emoji' => ':boom:', 'emoji' => ':boom:',
'level' => 'critical', 'level' => env('LOG_LEVEL', 'critical'),
], ],
'papertrail' => [ 'papertrail' => [
'driver' => 'monolog', 'driver' => 'monolog',
'level' => 'debug', 'level' => env('LOG_LEVEL', 'debug'),
'handler' => SyslogUdpHandler::class, 'handler' => SyslogUdpHandler::class,
'handler_with' => [ 'handler_with' => [
'host' => env('PAPERTRAIL_URL'), 'host' => env('PAPERTRAIL_URL'),
@ -73,6 +86,7 @@
'stderr' => [ 'stderr' => [
'driver' => 'monolog', 'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class, 'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'), 'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [ 'with' => [
@ -82,12 +96,21 @@
'syslog' => [ 'syslog' => [
'driver' => 'syslog', 'driver' => 'syslog',
'level' => 'debug', 'level' => env('LOG_LEVEL', 'debug'),
], ],
'errorlog' => [ 'errorlog' => [
'driver' => 'errorlog', 'driver' => 'errorlog',
'level' => 'debug', 'level' => env('LOG_LEVEL', 'debug'),
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
], ],
], ],

View File

@ -29,7 +29,7 @@
| mailers below. You are free to add additional mailers as required. | mailers below. You are free to add additional mailers as required.
| |
| Supported: "smtp", "sendmail", "mailgun", "ses", | Supported: "smtp", "sendmail", "mailgun", "ses",
| "postmark", "log", "array" | "postmark", "log", "array", "failover"
| |
*/ */
@ -70,6 +70,14 @@
'array' => [ 'array' => [
'transport' => 'array', 'transport' => 'array',
], ],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
],
], ],
/* /*

View File

@ -39,6 +39,7 @@
'table' => 'jobs', 'table' => 'jobs',
'queue' => 'default', 'queue' => 'default',
'retry_after' => 90, 'retry_after' => 90,
'after_commit' => false,
], ],
'beanstalkd' => [ 'beanstalkd' => [
@ -47,6 +48,7 @@
'queue' => 'default', 'queue' => 'default',
'retry_after' => 90, 'retry_after' => 90,
'block_for' => 0, 'block_for' => 0,
'after_commit' => false,
], ],
'sqs' => [ 'sqs' => [
@ -55,7 +57,9 @@
'secret' => env('AWS_SECRET_ACCESS_KEY'), 'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'your-queue-name'), 'queue' => env('SQS_QUEUE', 'your-queue-name'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
], ],
'redis' => [ 'redis' => [
@ -64,6 +68,7 @@
'queue' => env('REDIS_QUEUE', 'default'), 'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90, 'retry_after' => 90,
'block_for' => null, 'block_for' => null,
'after_commit' => false,
], ],
], ],
@ -80,6 +85,7 @@
*/ */
'failed' => [ 'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'mysql'), 'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs', 'table' => 'failed_jobs',
], ],

View File

@ -30,18 +30,18 @@
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
], ],
'sparkpost' => [ // 'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'), // 'secret' => env('SPARKPOST_SECRET'),
], // ],
'stripe' => [ // 'stripe' => [
'model' => App\User::class, // 'model' => App\Models\User::class,
'key' => env('STRIPE_KEY'), // 'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'), // 'secret' => env('STRIPE_SECRET'),
'webhook' => [ // 'webhook' => [
'secret' => env('STRIPE_WEBHOOK_SECRET'), // 'secret' => env('STRIPE_WEBHOOK_SECRET'),
'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300), // 'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300),
], // ],
], // ],
]; ];

View File

@ -166,7 +166,7 @@
| |
*/ */
'secure' => env('SESSION_SECURE_COOKIE', null), 'secure' => env('SESSION_SECURE_COOKIE'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -190,7 +190,7 @@
| take place, and can be used to mitigate CSRF attacks. By default, we | take place, and can be used to mitigate CSRF attacks. By default, we
| do not enable this as other CSRF protection services are in place. | do not enable this as other CSRF protection services are in place.
| |
| Supported: "lax", "strict" | Supported: "lax", "strict", "none", null
| |
*/ */

3
database/.gitignore vendored
View File

@ -1,2 +1 @@
*.sqlite *.sqlite*
*.sqlite-journal

View File

@ -1,24 +1,21 @@
<?php <?php
/* @var $group \Illuminate\Database\Eloquent\Factory */ namespace Database\Factories;
use App\Group; use Illuminate\Database\Eloquent\Factories\Factory;
use Faker\Generator as Faker; use Illuminate\Support\Str;
/* class GroupFactory extends Factory
|-------------------------------------------------------------------------- {
| Model Factories /**
|-------------------------------------------------------------------------- * Define the model's default state.
| *
| This directory should contain each of the model factory definitions for * @return array
| your application. Factories provide a convenient way to generate new */
| model instances for testing / seeding your application's database. public function definition()
| {
*/
$factory->define(Group::class, function (Faker $faker) {
return [ return [
'name' => $faker->word, 'name' => $this->faker->word(),
]; ];
}); }
}

View File

@ -1,28 +1,23 @@
<?php <?php
/* @var $factory \Illuminate\Database\Eloquent\Factory */ namespace Database\Factories;
use App\TwoFAccount;
use Faker\Generator as Faker;
use ParagonIE\ConstantTime\Base32; use ParagonIE\ConstantTime\Base32;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/* class TwoFAccountFactory extends Factory
|-------------------------------------------------------------------------- {
| Model Factories /**
|-------------------------------------------------------------------------- * Define the model's default state.
| *
| This directory should contain each of the model factory definitions for * @return array
| your application. Factories provide a convenient way to generate new */
| model instances for testing / seeding your application's database. public function definition()
| {
*/ $account = $this->faker->safeEmail();
$service = $this->faker->unique()->domainName();
$secret = Base32::encodeUpper($this->faker->regexify('[A-Z0-9]{8}'));
$factory->define(TwoFAccount::class, function (Faker $faker) {
$account = $faker->safeEmail;
$service = $faker->unique()->domainName;
$secret = Base32::encodeUpper($faker->regexify('[A-Z0-9]{8}'));
return [ return [
'otp_type' => 'totp', 'otp_type' => 'totp',
@ -35,4 +30,5 @@
'legacy_uri' => 'otpauth://hotp/' . $service . ':' . $account . '?secret=' . $secret . '&issuer=' . $service, 'legacy_uri' => 'otpauth://hotp/' . $service . ':' . $account . '?secret=' . $secret . '&issuer=' . $service,
'icon' => '', 'icon' => '',
]; ];
}); }
}

View File

@ -1,27 +1,39 @@
<?php <?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */ namespace Database\Factories;
use App\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Faker\Generator as Faker;
/* class UserFactory extends Factory
|-------------------------------------------------------------------------- {
| Model Factories /**
|-------------------------------------------------------------------------- * Define the model's default state.
| *
| This directory should contain each of the model factory definitions for * @return array
| your application. Factories provide a convenient way to generate new */
| model instances for testing / seeding your application's database. public function definition()
| {
*/
$factory->define(User::class, function (Faker $faker) {
return [ return [
'name' => $faker->name, 'name' => $this->faker->name(),
'email' => $faker->unique()->safeEmail, 'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(), 'email_verified_at' => now(),
'password' => bcrypt('password'), 'password' => bcrypt('password'),
'remember_token' => Str::random(10), 'remember_token' => Str::random(10),
]; ];
}); }
/**
* Indicate that the model's email address should be unverified.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function unverified()
{
return $this->state(function (array $attributes) {
return [
'email_verified_at' => null,
];
});
}
}

View File

@ -1,6 +1,6 @@
<?php <?php
use App\TwoFAccount; use App\Models\TwoFAccount;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;

View File

@ -1,5 +1,7 @@
<?php <?php
namespace Database\Seeders;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder

View File

@ -1,8 +1,10 @@
<?php <?php
use App\User; namespace Database\Seeders;
use App\Group;
use App\TwoFAccount; use App\Models\User;
use App\Models\Group;
use App\Models\TwoFAccount;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class DemoSeeder extends Seeder class DemoSeeder extends Seeder
@ -75,7 +77,7 @@ public function run()
'name' => 'eCommerce', 'name' => 'eCommerce',
]); ]);
$groupSocialNetwork->twofaccounts()->create([ $groupECommerce->twofaccounts()->create([
'otp_type' => 'totp', 'otp_type' => 'totp',
'account' => 'johndoe', 'account' => 'johndoe',
'service' => 'Amazon', 'service' => 'Amazon',

View File

@ -1,7 +1,10 @@
<?php <?php
use App\TwoFAccount;
namespace Database\Seeders;
use App\Models\TwoFAccount;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Foundation\Testing\WithFaker;
class TwoFAccountsTableSeeder extends Seeder class TwoFAccountsTableSeeder extends Seeder
{ {
/** /**

View File

@ -1,6 +1,8 @@
<?php <?php
use App\User; namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class UsersTableSeeder extends Seeder class UsersTableSeeder extends Seeder

View File

@ -1,5 +1,8 @@
<?php <?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
/** /**
* Laravel - A PHP Framework For Web Artisans * Laravel - A PHP Framework For Web Artisans
* *
@ -9,6 +12,21 @@
define('LARAVEL_START', microtime(true)); define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
require __DIR__.'/../storage/framework/maintenance.php';
}
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Register The Auto Loader | Register The Auto Loader
@ -49,12 +67,10 @@
| |
*/ */
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); $kernel = $app->make(Kernel::class);
$response = $kernel->handle( $response = $kernel->handle(
$request = Illuminate\Http\Request::capture() $request = Request::capture()
); )->send();
$response->send();
$kernel->terminate($request, $response); $kernel->terminate($request, $response);

View File

@ -15,6 +15,7 @@
// Laravel // Laravel
'failed' => 'These credentials do not match our records.', 'failed' => 'These credentials do not match our records.',
'password' => 'The provided password is incorrect.',
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
// 2FAuth // 2FAuth

View File

@ -14,6 +14,7 @@
*/ */
'accepted' => 'The :attribute must be accepted.', 'accepted' => 'The :attribute must be accepted.',
'accepted_if' => 'The :attribute must be accepted when :other is :value.',
'active_url' => 'The :attribute is not a valid URL.', 'active_url' => 'The :attribute is not a valid URL.',
'after' => 'The :attribute must be a date after :date.', 'after' => 'The :attribute must be a date after :date.',
'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
@ -31,9 +32,12 @@
], ],
'boolean' => 'The :attribute field must be true or false.', 'boolean' => 'The :attribute field must be true or false.',
'confirmed' => 'The :attribute confirmation does not match.', 'confirmed' => 'The :attribute confirmation does not match.',
'current_password' => 'The password is incorrect.',
'date' => 'The :attribute is not a valid date.', 'date' => 'The :attribute is not a valid date.',
'date_equals' => 'The :attribute must be a date equal to :date.', 'date_equals' => 'The :attribute must be a date equal to :date.',
'date_format' => 'The :attribute does not match the format :format.', 'date_format' => 'The :attribute does not match the format :format.',
'declined' => 'The :attribute must be declined.',
'declined_if' => 'The :attribute must be declined when :other is :value.',
'different' => 'The :attribute and :other must be different.', 'different' => 'The :attribute and :other must be different.',
'digits' => 'The :attribute must be :digits digits.', 'digits' => 'The :attribute must be :digits digits.',
'digits_between' => 'The :attribute must be between :min and :max digits.', 'digits_between' => 'The :attribute must be between :min and :max digits.',
@ -90,11 +94,16 @@
'string' => 'The :attribute must be at least :min characters.', 'string' => 'The :attribute must be at least :min characters.',
'array' => 'The :attribute must have at least :min items.', 'array' => 'The :attribute must have at least :min items.',
], ],
'multiple_of' => 'The :attribute must be a multiple of :value.',
'not_in' => 'The selected :attribute is invalid.', 'not_in' => 'The selected :attribute is invalid.',
'not_regex' => 'The :attribute format is invalid.', 'not_regex' => 'The :attribute format is invalid.',
'numeric' => 'The :attribute must be a number.', 'numeric' => 'The :attribute must be a number.',
'password' => 'The password is incorrect.', 'password' => 'The password is incorrect.',
'present' => 'The :attribute field must be present.', 'present' => 'The :attribute field must be present.',
'prohibited' => 'The :attribute field is prohibited.',
'prohibited_if' => 'The :attribute field is prohibited when :other is :value.',
'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.',
'prohibits' => 'The :attribute field prohibits :other from being present.',
'regex' => 'The :attribute format is invalid.', 'regex' => 'The :attribute format is invalid.',
'required' => 'The :attribute field is required.', 'required' => 'The :attribute field is required.',
'required_if' => 'The :attribute field is required when :other is :value.', 'required_if' => 'The :attribute field is required when :other is :value.',

View File

@ -11,6 +11,6 @@
| |
*/ */
Broadcast::channel('App.User.{id}', function ($user, $id) { Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id; return (int) $user->id === (int) $id;
}); });

View File

@ -15,4 +15,4 @@
Artisan::command('inspire', function () { Artisan::command('inspire', function () {
$this->comment(Inspiring::quote()); $this->comment(Inspiring::quote());
})->describe('Display an inspiring quote'); })->purpose('Display an inspiring quote');

View File

@ -1,8 +1,9 @@
config.php
routes.php
schedule-*
compiled.php compiled.php
services.json config.php
events.scanned.php
routes.scanned.php
down down
events.scanned.php
maintenance.php
routes.php
routes.scanned.php
schedule-*
services.json

View File

@ -1,8 +1,8 @@
<?php <?php
namespace Tests\Feature\Auth; namespace Tests\Api\v1\Controllers\Auth;
use App\User; use App\Models\User;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Auth\Notifications\ResetPassword; use Illuminate\Auth\Notifications\ResetPassword;
@ -12,7 +12,7 @@
class ForgotPasswordControllerTest extends FeatureTestCase class ForgotPasswordControllerTest extends FeatureTestCase
{ {
/** /**
* @var \App\User * @var \App\Models\User
*/ */
protected $user; protected $user;
@ -62,7 +62,7 @@ public function test_submit_email_password_request_returns_success()
{ {
Notification::fake(); Notification::fake();
$this->user = factory(User::class)->create(); $this->user = User::factory()->create();
$response = $this->json('POST', '/api/v1/user/password/lost', [ $response = $this->json('POST', '/api/v1/user/password/lost', [
'email' => $this->user->email 'email' => $this->user->email

View File

@ -2,15 +2,15 @@
namespace Tests\Api\v1\Controllers\Auth; namespace Tests\Api\v1\Controllers\Auth;
use App\User; use App\Models\User;
use App\Group; use App\Models\Group;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use App\TwoFAccount; use App\Models\TwoFAccount;
class PasswordControllerTest extends FeatureTestCase class PasswordControllerTest extends FeatureTestCase
{ {
/** /**
* @var \App\User * @var \App\Models\User
*/ */
protected $user; protected $user;
@ -24,7 +24,7 @@ public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->user = factory(User::class)->create(); $this->user = User::factory()->create();
} }

View File

@ -1,8 +1,8 @@
<?php <?php
namespace Tests\Feature\Auth; namespace Tests\Api\v1\Controllers\Auth;
use App\User; use App\Models\User;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Password;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
@ -11,7 +11,7 @@
class ResetPasswordControllerTest extends FeatureTestCase class ResetPasswordControllerTest extends FeatureTestCase
{ {
/** /**
* @var \App\User * @var \App\Models\User
*/ */
protected $user; protected $user;
@ -71,7 +71,7 @@ public function test_submit_reset_password_returns_success()
{ {
Notification::fake(); Notification::fake();
$this->user = factory(User::class)->create(); $this->user = User::factory()->create();
$token = Password::broker()->createToken($this->user); $token = Password::broker()->createToken($this->user);
$response = $this->json('POST', '/api/v1/user/password/reset', [ $response = $this->json('POST', '/api/v1/user/password/reset', [

View File

@ -2,13 +2,13 @@
namespace Tests\Api\v1\Controllers\Auth; namespace Tests\Api\v1\Controllers\Auth;
use App\User; use App\Models\User;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
class UserControllerTest extends FeatureTestCase class UserControllerTest extends FeatureTestCase
{ {
/** /**
* @var \App\User * @var \App\Models\User
*/ */
protected $user; protected $user;
@ -23,7 +23,7 @@ public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->user = factory(User::class)->create(); $this->user = User::factory()->create();
} }

View File

@ -2,10 +2,10 @@
namespace Tests\Api\v1\Controllers; namespace Tests\Api\v1\Controllers;
use App\User; use App\Models\User;
use App\Group; use App\Models\Group;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use App\TwoFAccount; use App\Models\TwoFAccount;
/** /**
@ -15,7 +15,7 @@
class GroupControllerTest extends FeatureTestCase class GroupControllerTest extends FeatureTestCase
{ {
/** /**
* @var \App\User * @var \App\Models\User
*/ */
protected $user; protected $user;
@ -27,7 +27,7 @@ public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->user = factory(User::class)->create(); $this->user = User::factory()->create();
} }
@ -36,7 +36,7 @@ public function setUp(): void
*/ */
public function test_index_returns_group_collection_with_pseudo_group() public function test_index_returns_group_collection_with_pseudo_group()
{ {
factory(Group::class, 3)->create(); Group::factory()->count(3)->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('GET', '/api/v1/groups') ->json('GET', '/api/v1/groups')
@ -93,7 +93,7 @@ public function test_store_invalid_data_returns_validation_error()
*/ */
public function test_show_returns_group_resource() public function test_show_returns_group_resource()
{ {
$group = factory(Group::class)->create([ $group = Group::factory()->create([
'name' => 'My group', 'name' => 'My group',
]); ]);
@ -127,7 +127,7 @@ public function test_show_missing_group_returns_not_found()
*/ */
public function test_update_returns_updated_group_resource() public function test_update_returns_updated_group_resource()
{ {
$group = factory(Group::class)->create(); $group = Group::factory()->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('PUT', '/api/v1/groups/' . $group->id, [ ->json('PUT', '/api/v1/groups/' . $group->id, [
@ -163,7 +163,7 @@ public function test_update_missing_group_returns_not_found()
*/ */
public function test_update_with_invalid_data_returns_validation_error() public function test_update_with_invalid_data_returns_validation_error()
{ {
$group = factory(Group::class)->create(); $group = Group::factory()->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('PUT', '/api/v1/groups/' . $group->id, [ ->json('PUT', '/api/v1/groups/' . $group->id, [
@ -178,8 +178,8 @@ public function test_update_with_invalid_data_returns_validation_error()
*/ */
public function test_assign_accounts_returns_updated_group_resource() public function test_assign_accounts_returns_updated_group_resource()
{ {
$group = factory(Group::class)->create(); $group = Group::factory()->create();
$accounts = factory(TwoFAccount::class, 2)->create(); $accounts = TwoFAccount::factory()->count(2)->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('POST', '/api/v1/groups/' . $group->id . '/assign', [ ->json('POST', '/api/v1/groups/' . $group->id . '/assign', [
@ -199,7 +199,7 @@ public function test_assign_accounts_returns_updated_group_resource()
*/ */
public function test_assign_accounts_to_missing_group_returns_not_found() public function test_assign_accounts_to_missing_group_returns_not_found()
{ {
$accounts = factory(TwoFAccount::class, 2)->create(); $accounts = TwoFAccount::factory()->count(2)->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('POST', '/api/v1/groups/1000/assign', [ ->json('POST', '/api/v1/groups/1000/assign', [
@ -217,8 +217,8 @@ public function test_assign_accounts_to_missing_group_returns_not_found()
*/ */
public function test_assign_invalid_accounts_returns_validation_error() public function test_assign_invalid_accounts_returns_validation_error()
{ {
$group = factory(Group::class)->create(); $group = Group::factory()->create();
$accounts = factory(TwoFAccount::class, 2)->create(); $accounts = TwoFAccount::factory()->count(2)->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('POST', '/api/v1/groups/' . $group->id . '/assign', [ ->json('POST', '/api/v1/groups/' . $group->id . '/assign', [
@ -233,8 +233,8 @@ public function test_assign_invalid_accounts_returns_validation_error()
*/ */
public function test_get_assigned_accounts_returns_twofaccounts_collection() public function test_get_assigned_accounts_returns_twofaccounts_collection()
{ {
$group = factory(Group::class)->create(); $group = Group::factory()->create();
$accounts = factory(TwoFAccount::class, 2)->create(); $accounts = TwoFAccount::factory()->count(2)->create();
$assign = $this->actingAs($this->user, 'api') $assign = $this->actingAs($this->user, 'api')
->json('POST', '/api/v1/groups/' . $group->id . '/assign', [ ->json('POST', '/api/v1/groups/' . $group->id . '/assign', [
@ -266,8 +266,8 @@ public function test_get_assigned_accounts_returns_twofaccounts_collection()
*/ */
public function test_get_assigned_accounts_returns_twofaccounts_collection_with_secret() public function test_get_assigned_accounts_returns_twofaccounts_collection_with_secret()
{ {
$group = factory(Group::class)->create(); $group = Group::factory()->create();
$accounts = factory(TwoFAccount::class, 2)->create(); $accounts = TwoFAccount::factory()->count(2)->create();
$assign = $this->actingAs($this->user, 'api') $assign = $this->actingAs($this->user, 'api')
->json('POST', '/api/v1/groups/' . $group->id . '/assign', [ ->json('POST', '/api/v1/groups/' . $group->id . '/assign', [
@ -316,7 +316,7 @@ public function test_get_assigned_accounts_of_missing_group_returns_not_found()
*/ */
public function test_destroy_group_returns_success() public function test_destroy_group_returns_success()
{ {
$group = factory(Group::class)->create(); $group = Group::factory()->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('DELETE', '/api/v1/groups/' . $group->id) ->json('DELETE', '/api/v1/groups/' . $group->id)

View File

@ -6,7 +6,7 @@
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use App\TwoFAccount; use App\Models\TwoFAccount;
/** /**
* @covers \App\Api\v1\Controllers\IconController * @covers \App\Api\v1\Controllers\IconController

View File

@ -2,9 +2,9 @@
namespace Tests\Api\v1\Controllers; namespace Tests\Api\v1\Controllers;
use App\User; use App\Models\User;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use App\TwoFAccount; use App\Models\TwoFAccount;
use Tests\Classes\LocalFile; use Tests\Classes\LocalFile;
@ -15,7 +15,7 @@ class QrCodeControllerTest extends FeatureTestCase
{ {
/** /**
* @var \App\User * @var \App\Models\User
*/ */
protected $user; protected $user;
@ -27,7 +27,7 @@ public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->user = factory(User::class)->create(); $this->user = User::factory()->create();
} }
@ -36,7 +36,7 @@ public function setUp(): void
*/ */
public function test_show_qrcode_returns_base64_image() public function test_show_qrcode_returns_base64_image()
{ {
$twofaccount = factory(TwoFAccount::class)->create([ $twofaccount = TwoFAccount::factory()->create([
'otp_type' => 'totp', 'otp_type' => 'totp',
'account' => 'account', 'account' => 'account',
'service' => 'service', 'service' => 'service',

View File

@ -2,10 +2,10 @@
namespace Tests\Api\v1\Controllers; namespace Tests\Api\v1\Controllers;
use App\User; use App\Models\User;
use App\Group; use App\Models\Group;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use App\TwoFAccount; use App\Models\TwoFAccount;
/** /**
@ -14,7 +14,7 @@
class SettingControllerTest extends FeatureTestCase class SettingControllerTest extends FeatureTestCase
{ {
/** /**
* @var \App\User * @var \App\Models\User
*/ */
protected $user; protected $user;
@ -36,7 +36,7 @@ public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->user = factory(User::class)->create(); $this->user = User::factory()->create();
} }

View File

@ -2,10 +2,10 @@
namespace Tests\Api\v1\Controllers; namespace Tests\Api\v1\Controllers;
use App\User; use App\Models\User;
use App\Group; use App\Models\Group;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use App\TwoFAccount; use App\Models\TwoFAccount;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
@ -18,12 +18,12 @@
class TwoFAccountControllerTest extends FeatureTestCase class TwoFAccountControllerTest extends FeatureTestCase
{ {
/** /**
* @var \App\User * @var \App\Models\User
*/ */
protected $user; protected $user;
/** /**
* @var \App\Group * @var \App\Models\Group
*/ */
protected $group; protected $group;
@ -167,8 +167,8 @@ public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->user = factory(User::class)->create(); $this->user = User::factory()->create();
$this->group = factory(Group::class)->create(); $this->group = Group::factory()->create();
} }
@ -177,7 +177,7 @@ public function setUp(): void
*/ */
public function test_index_returns_twofaccount_collection() public function test_index_returns_twofaccount_collection()
{ {
factory(TwoFAccount::class, 3)->create(); TwoFAccount::factory()->count(3)->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('GET', '/api/v1/twofaccounts') ->json('GET', '/api/v1/twofaccounts')
@ -194,7 +194,7 @@ public function test_index_returns_twofaccount_collection()
*/ */
public function test_index_returns_twofaccount_collection_with_secret() public function test_index_returns_twofaccount_collection_with_secret()
{ {
factory(TwoFAccount::class, 3)->create(); TwoFAccount::factory()->count(3)->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('GET', '/api/v1/twofaccounts?withSecret=1') ->json('GET', '/api/v1/twofaccounts?withSecret=1')
@ -211,7 +211,7 @@ public function test_index_returns_twofaccount_collection_with_secret()
*/ */
public function test_show_twofaccount_returns_twofaccount_resource_with_secret() public function test_show_twofaccount_returns_twofaccount_resource_with_secret()
{ {
$twofaccount = factory(TwoFAccount::class)->create(); $twofaccount = TwoFAccount::factory()->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('GET', '/api/v1/twofaccounts/' . $twofaccount->id) ->json('GET', '/api/v1/twofaccounts/' . $twofaccount->id)
@ -225,7 +225,7 @@ public function test_show_twofaccount_returns_twofaccount_resource_with_secret()
*/ */
public function test_show_twofaccount_returns_twofaccount_resource_without_secret() public function test_show_twofaccount_returns_twofaccount_resource_without_secret()
{ {
$twofaccount = factory(TwoFAccount::class)->create(); $twofaccount = TwoFAccount::factory()->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('GET', '/api/v1/twofaccounts/' . $twofaccount->id . '?withSecret=0') ->json('GET', '/api/v1/twofaccounts/' . $twofaccount->id . '?withSecret=0')
@ -242,7 +242,7 @@ public function test_show_twofaccount_returns_twofaccount_resource_without_secre
// $dbEncryptionService = resolve('App\Services\DbEncryptionService'); // $dbEncryptionService = resolve('App\Services\DbEncryptionService');
// $dbEncryptionService->setTo(true); // $dbEncryptionService->setTo(true);
// $twofaccount = factory(TwoFAccount::class)->create(); // $twofaccount = TwoFAccount::factory()->create();
// DB::table('twofaccounts') // DB::table('twofaccounts')
// ->where('id', $twofaccount->id) // ->where('id', $twofaccount->id)
@ -518,7 +518,7 @@ public function test_store_assigns_created_account_when_default_group_does_not_e
*/ */
public function test_update_totp_returns_success_with_updated_resource() public function test_update_totp_returns_success_with_updated_resource()
{ {
$twofaccount = factory(TwoFAccount::class)->create(); $twofaccount = TwoFAccount::factory()->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('PUT', '/api/v1/twofaccounts/' . $twofaccount->id, self::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_CUSTOM_TOTP) ->json('PUT', '/api/v1/twofaccounts/' . $twofaccount->id, self::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_CUSTOM_TOTP)
@ -532,7 +532,7 @@ public function test_update_totp_returns_success_with_updated_resource()
*/ */
public function test_update_hotp_returns_success_with_updated_resource() public function test_update_hotp_returns_success_with_updated_resource()
{ {
$twofaccount = factory(TwoFAccount::class)->create(); $twofaccount = TwoFAccount::factory()->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('PUT', '/api/v1/twofaccounts/' . $twofaccount->id, self::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_CUSTOM_HOTP) ->json('PUT', '/api/v1/twofaccounts/' . $twofaccount->id, self::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_CUSTOM_HOTP)
@ -557,7 +557,7 @@ public function test_update_missing_twofaccount_returns_not_found()
*/ */
public function test_update_twofaccount_with_invalid_data_returns_validation_error() public function test_update_twofaccount_with_invalid_data_returns_validation_error()
{ {
$twofaccount = factory(TwoFAccount::class)->create(); $twofaccount = TwoFAccount::factory()->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('PUT', '/api/v1/twofaccounts/' . $twofaccount->id, self::ARRAY_OF_INVALID_PARAMETERS) ->json('PUT', '/api/v1/twofaccounts/' . $twofaccount->id, self::ARRAY_OF_INVALID_PARAMETERS)
@ -570,7 +570,7 @@ public function test_update_twofaccount_with_invalid_data_returns_validation_err
*/ */
public function test_reorder_returns_success() public function test_reorder_returns_success()
{ {
factory(TwoFAccount::class, 3)->create(); TwoFAccount::factory()->count(3)->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('POST', '/api/v1/twofaccounts/reorder', [ ->json('POST', '/api/v1/twofaccounts/reorder', [
@ -587,7 +587,7 @@ public function test_reorder_returns_success()
*/ */
public function test_reorder_with_invalid_data_returns_validation_error() public function test_reorder_with_invalid_data_returns_validation_error()
{ {
factory(TwoFAccount::class, 3)->create(); TwoFAccount::factory()->count(3)->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('POST', '/api/v1/twofaccounts/reorder', [ ->json('POST', '/api/v1/twofaccounts/reorder', [
@ -644,7 +644,7 @@ public function test_preview_with_unreachable_image_returns_success()
*/ */
public function test_get_otp_using_totp_twofaccount_id_returns_consistent_resource() public function test_get_otp_using_totp_twofaccount_id_returns_consistent_resource()
{ {
$twofaccount = factory(TwoFAccount::class)->create([ $twofaccount = TwoFAccount::factory()->create([
'otp_type' => 'totp', 'otp_type' => 'totp',
'account' => self::ACCOUNT, 'account' => self::ACCOUNT,
'service' => self::SERVICE, 'service' => self::SERVICE,
@ -706,7 +706,7 @@ public function test_get_otp_by_posting_totp_parameters_returns_consistent_resou
*/ */
public function test_get_otp_using_hotp_twofaccount_id_returns_consistent_resource() public function test_get_otp_using_hotp_twofaccount_id_returns_consistent_resource()
{ {
$twofaccount = factory(TwoFAccount::class)->create([ $twofaccount = TwoFAccount::factory()->create([
'otp_type' => 'hotp', 'otp_type' => 'hotp',
'account' => self::ACCOUNT, 'account' => self::ACCOUNT,
'service' => self::SERVICE, 'service' => self::SERVICE,
@ -789,7 +789,7 @@ public function test_get_otp_using_indecipherable_twofaccount_id_returns_bad_req
$settingService = resolve('App\Services\SettingService'); $settingService = resolve('App\Services\SettingService');
$settingService->set('useEncryption', true); $settingService->set('useEncryption', true);
$twofaccount = factory(TwoFAccount::class)->create(); $twofaccount = TwoFAccount::factory()->create();
DB::table('twofaccounts') DB::table('twofaccounts')
->where('id', $twofaccount->id) ->where('id', $twofaccount->id)
@ -846,7 +846,7 @@ public function test_get_otp_by_posting_invalid_parameters_returns_validation_er
*/ */
public function test_count_returns_right_number_of_twofaccount() public function test_count_returns_right_number_of_twofaccount()
{ {
factory(TwoFAccount::class, 3)->create(); TwoFAccount::factory()->count(3)->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('GET', '/api/v1/twofaccounts/count') ->json('GET', '/api/v1/twofaccounts/count')
@ -862,7 +862,7 @@ public function test_count_returns_right_number_of_twofaccount()
*/ */
public function test_withdraw_returns_success() public function test_withdraw_returns_success()
{ {
factory(TwoFAccount::class, 3)->create(); TwoFAccount::factory()->count(3)->create();
$ids = DB::table('twofaccounts')->pluck('id')->implode(','); $ids = DB::table('twofaccounts')->pluck('id')->implode(',');
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
@ -879,7 +879,7 @@ public function test_withdraw_returns_success()
*/ */
public function test_withdraw_too_many_ids_returns_bad_request() public function test_withdraw_too_many_ids_returns_bad_request()
{ {
factory(TwoFAccount::class, 102)->create(); TwoFAccount::factory()->count(102)->create();
$ids = DB::table('twofaccounts')->pluck('id')->implode(','); $ids = DB::table('twofaccounts')->pluck('id')->implode(',');
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
@ -897,7 +897,7 @@ public function test_withdraw_too_many_ids_returns_bad_request()
*/ */
public function test_destroy_twofaccount_returns_success() public function test_destroy_twofaccount_returns_success()
{ {
$twofaccount = factory(TwoFAccount::class)->create(); $twofaccount = TwoFAccount::factory()->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('DELETE', '/api/v1/twofaccounts/' . $twofaccount->id) ->json('DELETE', '/api/v1/twofaccounts/' . $twofaccount->id)
@ -910,7 +910,7 @@ public function test_destroy_twofaccount_returns_success()
*/ */
public function test_destroy_missing_twofaccount_returns_not_found() public function test_destroy_missing_twofaccount_returns_not_found()
{ {
$twofaccount = factory(TwoFAccount::class)->create(); $twofaccount = TwoFAccount::factory()->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('DELETE', '/api/v1/twofaccounts/1000') ->json('DELETE', '/api/v1/twofaccounts/1000')
@ -923,7 +923,7 @@ public function test_destroy_missing_twofaccount_returns_not_found()
*/ */
public function test_batch_destroy_twofaccount_returns_success() public function test_batch_destroy_twofaccount_returns_success()
{ {
factory(TwoFAccount::class, 3)->create(); TwoFAccount::factory()->count(3)->create();
$ids = DB::table('twofaccounts')->pluck('id')->implode(','); $ids = DB::table('twofaccounts')->pluck('id')->implode(',');
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
@ -937,7 +937,7 @@ public function test_batch_destroy_twofaccount_returns_success()
*/ */
public function test_batch_destroy_too_many_twofaccounts_returns_bad_request() public function test_batch_destroy_too_many_twofaccounts_returns_bad_request()
{ {
factory(TwoFAccount::class, 102)->create(); TwoFAccount::factory()->count(102)->create();
$ids = DB::table('twofaccounts')->pluck('id')->implode(','); $ids = DB::table('twofaccounts')->pluck('id')->implode(',');
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')

View File

@ -2,7 +2,7 @@
namespace Tests\Api\v1\Requests; namespace Tests\Api\v1\Requests;
use App\Group; use App\Models\Group;
use App\Api\v1\Requests\GroupStoreRequest; use App\Api\v1\Requests\GroupStoreRequest;
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;

View File

@ -53,7 +53,7 @@ public function provideValidData() : array
*/ */
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$user = new \App\User( $user = new \App\Models\User(
[ [
'name' => 'John', 'name' => 'John',
'email' => 'john@example.com', 'email' => 'john@example.com',

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Auth; namespace Tests\Feature\Auth;
use App\User; use App\Models\User;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use Illuminate\Auth\Authenticatable; use Illuminate\Auth\Authenticatable;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@ -13,7 +13,7 @@
class LoginTest extends FeatureTestCase class LoginTest extends FeatureTestCase
{ {
/** /**
* @var \App\User * @var \App\Models\User
*/ */
protected $user; protected $user;
@ -27,7 +27,7 @@ public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->user = factory(User::class)->create(); $this->user = User::factory()->create();
} }

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Console; namespace Tests\Feature\Console;
use App\User; use App\Models\User;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Console; namespace Tests\Feature\Console;
use App\User; use App\Models\User;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;

View File

@ -1,7 +1,8 @@
<?php <?php
namespace Tests\Api\v1\Requests; namespace Tests\Feature\Http\Requests;
use App\Models\User;
use App\Http\Requests\LoginRequest; use App\Http\Requests\LoginRequest;
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@ -33,7 +34,7 @@ public function test_user_is_authorized()
*/ */
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
factory(\App\User::class)->create([ User::factory()->create([
'email' => 'JOHN.DOE@example.com' 'email' => 'JOHN.DOE@example.com'
]); ]);
@ -67,7 +68,7 @@ public function provideValidData() : array
*/ */
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
factory(\App\User::class)->create([ User::factory()->create([
'email' => 'JOHN.DOE@example.com' 'email' => 'JOHN.DOE@example.com'
]); ]);

View File

@ -2,8 +2,8 @@
namespace Tests\Feature\Services; namespace Tests\Feature\Services;
use App\Group; use App\Models\Group;
use App\TwoFAccount; use App\Models\TwoFAccount;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use Tests\Classes\LocalFile; use Tests\Classes\LocalFile;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -27,13 +27,13 @@ class GroupServiceTest extends FeatureTestCase
/** /**
* App\Group $groupOne, $groupTwo * App\Models\Group $groupOne, $groupTwo
*/ */
protected $groupOne, $groupTwo; protected $groupOne, $groupTwo;
/** /**
* App\Group $twofaccountOne, $twofaccountTwo * App\Models\Group $twofaccountOne, $twofaccountTwo
*/ */
protected $twofaccountOne, $twofaccountTwo; protected $twofaccountOne, $twofaccountTwo;
@ -137,7 +137,7 @@ public function test_create_persists_and_returns_created_group()
$newGroup = $this->groupService->create(['name' => self::NEW_GROUP_NAME]); $newGroup = $this->groupService->create(['name' => self::NEW_GROUP_NAME]);
$this->assertDatabaseHas('groups', ['name' => self::NEW_GROUP_NAME]); $this->assertDatabaseHas('groups', ['name' => self::NEW_GROUP_NAME]);
$this->assertInstanceOf(\App\Group::class, $newGroup); $this->assertInstanceOf(\App\Models\Group::class, $newGroup);
$this->assertEquals(self::NEW_GROUP_NAME, $newGroup->name); $this->assertEquals(self::NEW_GROUP_NAME, $newGroup->name);
} }
@ -150,7 +150,7 @@ public function test_update_persists_and_returns_updated_group()
$this->groupOne = $this->groupService->update($this->groupOne, ['name' => self::NEW_GROUP_NAME]); $this->groupOne = $this->groupService->update($this->groupOne, ['name' => self::NEW_GROUP_NAME]);
$this->assertDatabaseHas('groups', ['name' => self::NEW_GROUP_NAME]); $this->assertDatabaseHas('groups', ['name' => self::NEW_GROUP_NAME]);
$this->assertInstanceOf(\App\Group::class, $this->groupOne); $this->assertInstanceOf(\App\Models\Group::class, $this->groupOne);
$this->assertEquals(self::NEW_GROUP_NAME, $this->groupOne->name); $this->assertEquals(self::NEW_GROUP_NAME, $this->groupOne->name);
} }

View File

@ -5,7 +5,7 @@
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use App\TwoFAccount; use App\Models\TwoFAccount;
/** /**
@ -20,7 +20,7 @@ class SettingServiceTest extends FeatureTestCase
/** /**
* App\Group $groupOne, $groupTwo * App\Models\Group $groupOne, $groupTwo
*/ */
protected $twofaccountOne, $twofaccountTwo; protected $twofaccountOne, $twofaccountTwo;

View File

@ -2,8 +2,8 @@
namespace Tests\Feature\Services; namespace Tests\Feature\Services;
use App\Group; use App\Models\Group;
use App\TwoFAccount; use App\Models\TwoFAccount;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -20,19 +20,19 @@ class TwoFAccountServiceTest extends FeatureTestCase
/** /**
* App\TwoFAccount $customTotpTwofaccount * App\Models\TwoFAccount $customTotpTwofaccount
*/ */
protected $customTotpTwofaccount; protected $customTotpTwofaccount;
/** /**
* App\Group $group * App\Models\Group $group
*/ */
protected $group; protected $group;
/** /**
* App\TwoFAccount $customTotpTwofaccount * App\Models\TwoFAccount $customTotpTwofaccount
*/ */
protected $customHotpTwofaccount; protected $customHotpTwofaccount;

View File

@ -2,10 +2,10 @@
namespace Tests\Unit\Api\v1\Controllers; namespace Tests\Unit\Api\v1\Controllers;
use App\User; use App\Models\User;
use App\Group; use App\Models\Group;
use Tests\TestCase; use Tests\TestCase;
use App\TwoFAccount; use App\Models\TwoFAccount;
use App\Services\GroupService; use App\Services\GroupService;
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use App\Api\v1\Controllers\GroupController; use App\Api\v1\Controllers\GroupController;
@ -55,7 +55,7 @@ public function setUp() : void
*/ */
public function test_index_returns_api_resources_using_groupService() public function test_index_returns_api_resources_using_groupService()
{ {
$groups = factory(Group::class, 3)->make(); $groups = Group::factory()->count(3)->make();
$this->groupServiceMock->shouldReceive('getAll') $this->groupServiceMock->shouldReceive('getAll')
->once() ->once()
@ -72,7 +72,7 @@ public function test_index_returns_api_resources_using_groupService()
*/ */
public function test_store_returns_api_resource_stored_using_groupService() public function test_store_returns_api_resource_stored_using_groupService()
{ {
$group = factory(Group::class)->make(); $group = Group::factory()->make();
$this->groupStoreRequest->shouldReceive('validated') $this->groupStoreRequest->shouldReceive('validated')
->once() ->once()
@ -84,7 +84,7 @@ public function test_store_returns_api_resource_stored_using_groupService()
$response = $this->controller->store($this->groupStoreRequest); $response = $this->controller->store($this->groupStoreRequest);
$this->assertInstanceOf('App\Group', $response->original); $this->assertInstanceOf('App\Models\Group', $response->original);
} }
@ -93,7 +93,7 @@ public function test_store_returns_api_resource_stored_using_groupService()
*/ */
public function test_show_returns_api_resource() public function test_show_returns_api_resource()
{ {
$group = factory(Group::class)->make(); $group = Group::factory()->make();
$response = $this->controller->show($group); $response = $this->controller->show($group);
@ -106,7 +106,7 @@ public function test_show_returns_api_resource()
*/ */
public function test_update_returns_api_resource_updated_using_groupService() public function test_update_returns_api_resource_updated_using_groupService()
{ {
$group = factory(Group::class)->make(); $group = Group::factory()->make();
$this->groupStoreRequest->shouldReceive('validated') $this->groupStoreRequest->shouldReceive('validated')
->once() ->once()
@ -127,7 +127,7 @@ public function test_update_returns_api_resource_updated_using_groupService()
*/ */
public function test_assignAccounts_returns_api_resource_assigned_using_groupService() public function test_assignAccounts_returns_api_resource_assigned_using_groupService()
{ {
$group = factory(Group::class)->make(); $group = Group::factory()->make();
$groupAssignRequest = Mockery::mock('App\Api\v1\Requests\GroupAssignRequest'); $groupAssignRequest = Mockery::mock('App\Api\v1\Requests\GroupAssignRequest');
$groupAssignRequest->shouldReceive('validated') $groupAssignRequest->shouldReceive('validated')
@ -149,13 +149,13 @@ public function test_assignAccounts_returns_api_resource_assigned_using_groupSer
*/ */
public function test_accounts_returns_api_resources_fetched_using_groupService() public function test_accounts_returns_api_resources_fetched_using_groupService()
{ {
$group = factory(Group::class)->make(); $group = Group::factory()->make();
\Facades\App\Services\SettingService::shouldReceive('get') \Facades\App\Services\SettingService::shouldReceive('get')
->with('useEncryption') ->with('useEncryption')
->andReturn(false); ->andReturn(false);
$twofaccounts = factory(TwoFAccount::class, 3)->make(); $twofaccounts = TwoFAccount::factory()->count(3)->make();
$this->groupServiceMock->shouldReceive('getAccounts') $this->groupServiceMock->shouldReceive('getAccounts')
->with($group) ->with($group)
@ -173,7 +173,7 @@ public function test_accounts_returns_api_resources_fetched_using_groupService()
*/ */
public function test_destroy_uses_group_service() public function test_destroy_uses_group_service()
{ {
$group = factory(Group::class)->make(); $group = Group::factory()->make();
$this->groupServiceMock->shouldReceive('delete') $this->groupServiceMock->shouldReceive('delete')
->once() ->once()

View File

@ -2,7 +2,7 @@
namespace Tests\Unit\Events; namespace Tests\Unit\Events;
use App\Group; use App\Models\Group;
use App\Events\GroupDeleting; use App\Events\GroupDeleting;
use Tests\TestCase; use Tests\TestCase;
@ -17,7 +17,7 @@ class GroupDeletingTest extends TestCase
*/ */
public function test_event_constructor() public function test_event_constructor()
{ {
$group = factory(Group::class)->make(); $group = Group::factory()->make();
$event = new GroupDeleting($group); $event = new GroupDeleting($group);
$this->assertSame($group, $event->group); $this->assertSame($group, $event->group);

View File

@ -2,7 +2,7 @@
namespace Tests\Unit\Events; namespace Tests\Unit\Events;
use App\TwoFAccount; use App\Models\TwoFAccount;
use App\Events\TwoFAccountDeleted; use App\Events\TwoFAccountDeleted;
use Tests\TestCase; use Tests\TestCase;
@ -21,7 +21,7 @@ public function test_event_constructor()
->with('useEncryption') ->with('useEncryption')
->andReturn(false); ->andReturn(false);
$twofaccount = factory(TwoFAccount::class)->make(); $twofaccount = TwoFAccount::factory()->make();
$event = new TwoFAccountDeleted($twofaccount); $event = new TwoFAccountDeleted($twofaccount);
$this->assertSame($twofaccount, $event->twofaccount); $this->assertSame($twofaccount, $event->twofaccount);

View File

@ -2,14 +2,14 @@
namespace Tests\Unit; namespace Tests\Unit;
use App\Group; use App\Models\Group;
use App\TwoFAccount; use App\Models\TwoFAccount;
use App\Events\GroupDeleting; use App\Events\GroupDeleting;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Tests\ModelTestCase; use Tests\ModelTestCase;
/** /**
* @covers \App\Group * @covers \App\Models\Group
*/ */
class GroupModelTest extends ModelTestCase class GroupModelTest extends ModelTestCase
{ {

View File

@ -2,7 +2,7 @@
namespace Tests\Unit\Listeners; namespace Tests\Unit\Listeners;
use App\TwoFAccount; use App\Models\TwoFAccount;
use App\Events\TwoFAccountDeleted; use App\Events\TwoFAccountDeleted;
use Tests\TestCase; use Tests\TestCase;
use App\Listeners\CleanIconStorage; use App\Listeners\CleanIconStorage;
@ -20,7 +20,7 @@ public function test_it_stores_time_to_session()
->with('useEncryption') ->with('useEncryption')
->andReturn(false); ->andReturn(false);
$twofaccount = factory(TwoFAccount::class)->make(); $twofaccount = TwoFAccount::factory()->make();
$event = new TwoFAccountDeleted($twofaccount); $event = new TwoFAccountDeleted($twofaccount);
$listener = new CleanIconStorage(); $listener = new CleanIconStorage();

View File

@ -2,8 +2,8 @@
namespace Tests\Unit\Listeners; namespace Tests\Unit\Listeners;
use App\Group; use App\Models\Group;
use App\TwoFAccount; use App\Models\TwoFAccount;
use App\Events\GroupDeleting; use App\Events\GroupDeleting;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use App\Listeners\DissociateTwofaccountFromGroup; use App\Listeners\DissociateTwofaccountFromGroup;
@ -17,7 +17,7 @@ class DissociateTwofaccountFromGroupTest extends FeatureTestCase
{ {
public function test_it_stores_time_to_session() public function test_it_stores_time_to_session()
{ {
$group = factory(Group::class)->make(); $group = Group::factory()->make();
$event = new GroupDeleting($group); $event = new GroupDeleting($group);
$listener = new DissociateTwofaccountFromGroup(); $listener = new DissociateTwofaccountFromGroup();

View File

@ -2,7 +2,7 @@
namespace Tests\Unit; namespace Tests\Unit;
use App\TwoFAccount; use App\Models\TwoFAccount;
use App\Events\TwoFAccountDeleted; use App\Events\TwoFAccountDeleted;
use Tests\ModelTestCase; use Tests\ModelTestCase;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
@ -10,7 +10,7 @@
use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Crypt;
/** /**
* @covers \App\TwoFAccount * @covers \App\Models\TwoFAccount
*/ */
class TwoFAccountModelTest extends ModelTestCase class TwoFAccountModelTest extends ModelTestCase
{ {
@ -48,7 +48,7 @@ public function test_sensitive_attributes_are_stored_encrypted(string $attribute
->with('useEncryption') ->with('useEncryption')
->andReturn(true); ->andReturn(true);
$twofaccount = factory(TwoFAccount::class)->make([ $twofaccount = TwoFAccount::factory()->make([
$attribute => 'string', $attribute => 'string',
]); ]);
@ -84,7 +84,7 @@ public function test_sensitive_attributes_are_returned_clear(string $attribute)
->with('useEncryption') ->with('useEncryption')
->andReturn(false); ->andReturn(false);
$twofaccount = factory(TwoFAccount::class)->make(); $twofaccount = TwoFAccount::factory()->make();
$this->assertEquals($twofaccount->getAttributes()[$attribute], $twofaccount->$attribute); $this->assertEquals($twofaccount->getAttributes()[$attribute], $twofaccount->$attribute);
} }
@ -104,7 +104,7 @@ public function test_indecipherable_attributes_returns_masked_value(string $attr
Crypt::shouldReceive('encryptString') Crypt::shouldReceive('encryptString')
->andReturn('indecipherableString'); ->andReturn('indecipherableString');
$twofaccount = factory(TwoFAccount::class)->make(); $twofaccount = TwoFAccount::factory()->make();
$this->assertEquals(__('errors.indecipherable'), $twofaccount->$attribute); $this->assertEquals(__('errors.indecipherable'), $twofaccount->$attribute);
} }

View File

@ -2,11 +2,11 @@
namespace Tests\Unit; namespace Tests\Unit;
use App\User; use App\Models\User;
use Tests\ModelTestCase; use Tests\ModelTestCase;
/** /**
* @covers \App\User * @covers \App\Models\User
*/ */
class UserModelTest extends ModelTestCase class UserModelTest extends ModelTestCase
{ {
@ -30,7 +30,7 @@ public function test_model_configuration()
*/ */
public function test_email_is_set_lowercased() public function test_email_is_set_lowercased()
{ {
$user = factory(User::class)->make([ $user = User::factory()->make([
'email' => 'UPPERCASE@example.COM', 'email' => 'UPPERCASE@example.COM',
]); ]);