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]
trim_trailing_whitespace = false
[*.yml]
[*.{yml,yaml}]
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.
CACHE_DRIVER=file
SESSION_DRIVER=file
FILESYSTEM_DRIVER=local
# Mail settings

1
.gitignore vendored
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
namespace App\Events;
use App\TwoFAccount;
use App\Models\TwoFAccount;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
@ -16,7 +16,7 @@ class TwoFAccountDeleted
/**
* Create a new event instance.
*
* @param \App\TwoFAccount $twofaccount
* @param \App\Models\TwoFAccount $twofaccount
* @return void
*/
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.
*
* @var array
* @var string[]
*/
protected $dontReport = [
//
@ -20,62 +20,50 @@ class Handler extends ExceptionHandler
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
* @var string[]
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Report or log an exception.
* Register the exception handling callbacks for the application.
*
* @param \Throwable $exception
* @return void
*/
public function report(Throwable $exception)
public function register()
{
parent::report($exception);
}
// $this->reportable(function (Throwable $e) {
//
// });
/**
* 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) {
$this->renderable(function (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $exception, $request) {
return response()->json([
'message' => 'not found'], 404);
}
if ($exception instanceof InvalidOtpParameterException) {
});
$this->renderable(function (InvalidOtpParameterException $exception, $request) {
return response()->json([
'message' => 'invalid OTP parameters',
'reason' => [$exception->getMessage()]
], 400);
}
if ($exception instanceof InvalidQrCodeException) {
});
$this->renderable(function (InvalidQrCodeException $exception, $request) {
return response()->json([
'message' => 'not a valid QR code'], 400);
}
if ($exception instanceof InvalidSecretException) {
});
$this->renderable(function (InvalidSecretException $exception, $request) {
return response()->json([
'message' => 'not a valid base32 encoded secret'], 400);
}
if ($exception instanceof DbEncryptionException) {
});
$this->renderable(function (DbEncryptionException $exception, $request) {
return response()->json([
'message' => $exception->getMessage()], 400);
}
return parent::render($request, $exception);
});
}
}

View File

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

View File

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

View File

@ -2,9 +2,9 @@
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.
@ -14,4 +14,4 @@ class CheckForMaintenanceMode extends Middleware
protected $except = [
//
];
}
}

View File

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

View File

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

View File

@ -2,15 +2,15 @@
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string
* @var array|string|null
*/
protected $proxies;
@ -19,5 +19,10 @@ class TrustProxies extends Middleware
*
* @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;
use App\TwoFAccount;
use App\Models\TwoFAccount;
use App\Events\GroupDeleting;
use Illuminate\Support\Facades\Log;

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@ class AuthServiceProvider extends ServiceProvider
* @var array
*/
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()
{
parent::boot();
//
}
}

View File

@ -2,18 +2,30 @@
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Cache\RateLimiting\Limit;
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
{
/**
* 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
*/
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';
/**
@ -24,68 +36,25 @@ class RouteServiceProvider extends ServiceProvider
public function boot()
{
Route::pattern('settingName', '[a-zA-Z]+');
$this->configureRateLimiting();
parent::boot();
$this->routes(function () {
Route::prefix('api/v1')
->middleware('api.v1')
->namespace($this->getApiNamespace(1))
->group(base_path('routes/api/v1.php'));
// Route::prefix('api/v2')
// ->middleware('api.v2')
// ->namespace($this->getApiNamespace(2))
// ->group(base_path('routes/api/v2.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
/**
* 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')
->middleware('api.v1')
->namespace($this->getApiNamespace(1))
->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')
// ->middleware('api.v2')
// ->namespace($this->getApiNamespace(2))
// ->group(base_path('routes/api/v2.php'));
// }
/**
* Build Api namespace based on provided version
*
@ -95,4 +64,16 @@ class RouteServiceProvider extends ServiceProvider
{
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;
use App\Group;
use App\TwoFAccount;
use App\Models\Group;
use App\Models\TwoFAccount;
use App\Services\SettingService;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Log;
@ -59,7 +59,7 @@ class GroupService
* Creates a group
*
* @param array $data
* @return \App\Group The created group
* @return \App\Models\Group The created group
*/
public function create(array $data) : Group
{
@ -78,9 +78,9 @@ class GroupService
/**
* 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
* @return \App\Group The updated group
* @return \App\Models\Group The updated group
*/
public function update(Group $group, array $data) : Group
{
@ -133,7 +133,7 @@ class GroupService
* Assign one or more accounts to a group
*
* @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
*/
public function assign($ids, Group $group = null) : void
@ -162,7 +162,7 @@ class GroupService
/**
* Finds twofaccounts assigned to the group
*
* @param \App\Group $group The group
* @param \App\Models\Group $group The group
* @return Collection The assigned accounts
*/
public function getAccounts(Group $group) : Collection
@ -176,7 +176,7 @@ class GroupService
/**
* 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()
{

View File

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

View File

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

View File

@ -2,7 +2,7 @@
namespace App\Services;
use App\TwoFAccount;
use App\Models\TwoFAccount;
use App\Exceptions\InvalidSecretException;
use App\Exceptions\InvalidOtpParameterException;
use App\Exceptions\UndecipherableException;
@ -48,7 +48,7 @@ class TwoFAccountService
* @param string $uri
* @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
{
@ -76,7 +76,7 @@ class TwoFAccountService
* @param array $data
* @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
{
@ -102,10 +102,10 @@ class TwoFAccountService
/**
* 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
*
* @return \App\TwoFAccount The updated account
* @return \App\Models\TwoFAccount The updated account
*/
public function update(TwoFAccount $twofaccount, array $data) : TwoFAccount
{
@ -125,7 +125,7 @@ class TwoFAccountService
/**
* 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
*
@ -176,7 +176,7 @@ class TwoFAccountService
/**
* 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
{
@ -254,7 +254,7 @@ class TwoFAccountService
private function initTokenWith($data) : void
{
// 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);
}
// init with a TwoFAccountDto instance
@ -307,7 +307,7 @@ class TwoFAccountService
/**
* 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
*/

View File

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

1749
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -68,7 +68,7 @@ return [
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
'model' => App\Models\User::class,
],
// 'users' => [
@ -97,7 +97,21 @@ return [
'provider' => 'users',
'table' => 'password_resets',
'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 @@ return [
],
],
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',

View File

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

View File

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

View File

@ -26,7 +26,7 @@ return [
|
*/
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
// 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
/*
|--------------------------------------------------------------------------
@ -62,8 +62,25 @@ return [
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'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 @@ return [
'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
@ -43,13 +56,13 @@ return [
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
'days' => 7,
],
@ -58,12 +71,12 @@ return [
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
'level' => env('LOG_LEVEL', 'critical'),
],
'papertrail' => [
'driver' => 'monolog',
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => SyslogUdpHandler::class,
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
@ -73,6 +86,7 @@ return [
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
@ -82,12 +96,21 @@ return [
'syslog' => [
'driver' => 'syslog',
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
],
'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 @@ return [
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
| "postmark", "log", "array"
| "postmark", "log", "array", "failover"
|
*/
@ -70,6 +70,14 @@ return [
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
],
],
/*

View File

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

View File

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

View File

@ -166,7 +166,7 @@ return [
|
*/
'secure' => env('SESSION_SECURE_COOKIE', null),
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
@ -190,7 +190,7 @@ return [
| 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.
|
| Supported: "lax", "strict"
| Supported: "lax", "strict", "none", null
|
*/

3
database/.gitignore vendored
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,8 @@
<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
/**
* Laravel - A PHP Framework For Web Artisans
*
@ -9,6 +12,21 @@
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
@ -49,12 +67,10 @@ $app = require_once __DIR__.'/../bootstrap/app.php';
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$kernel = $app->make(Kernel::class);
$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 @@ return [
// Laravel
'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.',
// 2FAuth

View File

@ -14,6 +14,7 @@ return [
*/
'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.',
'after' => 'The :attribute must be a date after :date.',
'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
@ -31,9 +32,12 @@ return [
],
'boolean' => 'The :attribute field must be true or false.',
'confirmed' => 'The :attribute confirmation does not match.',
'current_password' => 'The password is incorrect.',
'date' => 'The :attribute is not a valid date.',
'date_equals' => 'The :attribute must be a date equal to :date.',
'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.',
'digits' => 'The :attribute must be :digits digits.',
'digits_between' => 'The :attribute must be between :min and :max digits.',
@ -90,11 +94,16 @@ return [
'string' => 'The :attribute must be at least :min characters.',
'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_regex' => 'The :attribute format is invalid.',
'numeric' => 'The :attribute must be a number.',
'password' => 'The password is incorrect.',
'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.',
'required' => 'The :attribute field is required.',
'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;
});

View File

@ -15,4 +15,4 @@ use Illuminate\Foundation\Inspiring;
Artisan::command('inspire', function () {
$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
services.json
events.scanned.php
routes.scanned.php
config.php
down
events.scanned.php
maintenance.php
routes.php
routes.scanned.php
schedule-*
services.json

View File

@ -1,8 +1,8 @@
<?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\Config;
use Illuminate\Auth\Notifications\ResetPassword;
@ -12,7 +12,7 @@ use Tests\FeatureTestCase;
class ForgotPasswordControllerTest extends FeatureTestCase
{
/**
* @var \App\User
* @var \App\Models\User
*/
protected $user;
@ -62,7 +62,7 @@ class ForgotPasswordControllerTest extends FeatureTestCase
{
Notification::fake();
$this->user = factory(User::class)->create();
$this->user = User::factory()->create();
$response = $this->json('POST', '/api/v1/user/password/lost', [
'email' => $this->user->email

View File

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

View File

@ -1,8 +1,8 @@
<?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\Password;
use Illuminate\Support\Facades\Notification;
@ -11,7 +11,7 @@ use Tests\FeatureTestCase;
class ResetPasswordControllerTest extends FeatureTestCase
{
/**
* @var \App\User
* @var \App\Models\User
*/
protected $user;
@ -71,7 +71,7 @@ class ResetPasswordControllerTest extends FeatureTestCase
{
Notification::fake();
$this->user = factory(User::class)->create();
$this->user = User::factory()->create();
$token = Password::broker()->createToken($this->user);
$response = $this->json('POST', '/api/v1/user/password/reset', [

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,8 +2,8 @@
namespace Tests\Feature\Services;
use App\Group;
use App\TwoFAccount;
use App\Models\Group;
use App\Models\TwoFAccount;
use Tests\FeatureTestCase;
use Tests\Classes\LocalFile;
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;
/**
* App\Group $twofaccountOne, $twofaccountTwo
* App\Models\Group $twofaccountOne, $twofaccountTwo
*/
protected $twofaccountOne, $twofaccountTwo;
@ -137,7 +137,7 @@ class GroupServiceTest extends FeatureTestCase
$newGroup = $this->groupService->create(['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);
}
@ -150,7 +150,7 @@ class GroupServiceTest extends FeatureTestCase
$this->groupOne = $this->groupService->update($this->groupOne, ['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);
}

View File

@ -5,7 +5,7 @@ namespace Tests\Feature\Services;
use Tests\FeatureTestCase;
use Illuminate\Support\Facades\Crypt;
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;

View File

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

View File

@ -2,10 +2,10 @@
namespace Tests\Unit\Api\v1\Controllers;
use App\User;
use App\Group;
use App\Models\User;
use App\Models\Group;
use Tests\TestCase;
use App\TwoFAccount;
use App\Models\TwoFAccount;
use App\Services\GroupService;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use App\Api\v1\Controllers\GroupController;
@ -55,7 +55,7 @@ class GroupControllerTest extends TestCase
*/
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')
->once()
@ -72,7 +72,7 @@ class GroupControllerTest extends TestCase
*/
public function test_store_returns_api_resource_stored_using_groupService()
{
$group = factory(Group::class)->make();
$group = Group::factory()->make();
$this->groupStoreRequest->shouldReceive('validated')
->once()
@ -84,7 +84,7 @@ class GroupControllerTest extends TestCase
$response = $this->controller->store($this->groupStoreRequest);
$this->assertInstanceOf('App\Group', $response->original);
$this->assertInstanceOf('App\Models\Group', $response->original);
}
@ -93,7 +93,7 @@ class GroupControllerTest extends TestCase
*/
public function test_show_returns_api_resource()
{
$group = factory(Group::class)->make();
$group = Group::factory()->make();
$response = $this->controller->show($group);
@ -106,7 +106,7 @@ class GroupControllerTest extends TestCase
*/
public function test_update_returns_api_resource_updated_using_groupService()
{
$group = factory(Group::class)->make();
$group = Group::factory()->make();
$this->groupStoreRequest->shouldReceive('validated')
->once()
@ -127,7 +127,7 @@ class GroupControllerTest extends TestCase
*/
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->shouldReceive('validated')
@ -149,13 +149,13 @@ class GroupControllerTest extends TestCase
*/
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')
->with('useEncryption')
->andReturn(false);
$twofaccounts = factory(TwoFAccount::class, 3)->make();
$twofaccounts = TwoFAccount::factory()->count(3)->make();
$this->groupServiceMock->shouldReceive('getAccounts')
->with($group)
@ -173,7 +173,7 @@ class GroupControllerTest extends TestCase
*/
public function test_destroy_uses_group_service()
{
$group = factory(Group::class)->make();
$group = Group::factory()->make();
$this->groupServiceMock->shouldReceive('delete')
->once()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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