mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-07 08:54:22 +01:00
Upgrade to Laravel 8
This commit is contained in:
parent
65da59db64
commit
20856d62c6
@ -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
|
@ -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
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
/node_modules
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/tests/Coverage
|
||||
|
@ -1,7 +1,8 @@
|
||||
php:
|
||||
preset: laravel
|
||||
version: 8
|
||||
disabled:
|
||||
- unused_use
|
||||
- no_unused_imports
|
||||
finder:
|
||||
not-name:
|
||||
- index.php
|
||||
|
@ -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 @@ public function register(UserStoreRequest $request)
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
* @return \App\Models\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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 @@ public function store(GroupStoreRequest $request)
|
||||
/**
|
||||
* 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 @@ public function show(Group $group)
|
||||
* 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 @@ public function update(GroupStoreRequest $request, Group $group)
|
||||
* 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 @@ public function assignAccounts(GroupAssignRequest $request, Group $group)
|
||||
/**
|
||||
* 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 @@ public function accounts(Group $group)
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Group $group
|
||||
* @param \App\Models\Group $group
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function destroy(Group $group)
|
||||
|
@ -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 @@ public function __construct(QrCodeService $qrcodeService, TwoFAccountService $tw
|
||||
/**
|
||||
* Show a QR code image
|
||||
*
|
||||
* @param App\TwoFAccount $twofaccount
|
||||
* @param App\Models\TwoFAccount $twofaccount
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show(TwoFAccount $twofaccount)
|
||||
|
@ -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 @@ public function index(Request $request)
|
||||
/**
|
||||
* Display a 2FA account
|
||||
*
|
||||
* @param \App\TwoFAccount $twofaccount
|
||||
* @param \App\Models\TwoFAccount $twofaccount
|
||||
*
|
||||
* @return \App\Api\v1\Resources\TwoFAccountReadResource
|
||||
*/
|
||||
@ -104,7 +104,7 @@ public function store(TwoFAccountDynamicRequest $request)
|
||||
* 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 @@ public function withdraw(TwoFAccountBatchRequest $request)
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\TwoFAccount $twofaccount
|
||||
* @param \App\Models\TwoFAccount $twofaccount
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function destroy(TwoFAccount $twofaccount)
|
||||
|
@ -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;
|
||||
|
@ -7,15 +7,6 @@
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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 = [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -12,6 +12,7 @@ class TrimStrings extends Middleware
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
@ -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;
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\TwoFAccount;
|
||||
use App\Models\TwoFAccount;
|
||||
use App\Events\GroupDeleting;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
@ -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 @@ protected static function boot()
|
||||
*/
|
||||
public function twofaccounts()
|
||||
{
|
||||
return $this->hasMany('App\TwoFAccount');
|
||||
return $this->hasMany('App\Models\TwoFAccount');
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models;
|
||||
|
||||
use Exception;
|
||||
use App\Events\TwoFAccountDeleted;
|
||||
@ -10,11 +10,12 @@
|
||||
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;
|
||||
|
||||
|
||||
/**
|
@ -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\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
|
||||
*/
|
@ -14,7 +14,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Model' => 'App\Policies\ModelPolicy',
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -33,8 +33,6 @@ class EventServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ private function getApiNamespace($version)
|
||||
{
|
||||
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());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public function getAll() : Collection
|
||||
* 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 @@ public function create(array $data) : Group
|
||||
/**
|
||||
* 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 @@ public function delete($ids) : int
|
||||
* 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 @@ public function assign($ids, Group $group = null) : void
|
||||
/**
|
||||
* 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 @@ public function getAccounts(Group $group) : Collection
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
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;
|
||||
|
@ -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 @@ public function __construct()
|
||||
* @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 @@ public function createFromUri(string $uri, bool $saveToDB = true ) : TwoFAccount
|
||||
* @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 @@ public function createFromParameters(array $data, bool $saveToDB = true) : TwoFA
|
||||
/**
|
||||
* 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 @@ public function update(TwoFAccount $twofaccount, array $data) : TwoFAccount
|
||||
/**
|
||||
* 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 @@ public function getOTP($data) : OtpDto
|
||||
/**
|
||||
* 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 @@ private function commaSeparatedToArray($ids)
|
||||
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 @@ private function mapArrayToDto($array) : TwoFAccountDto
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -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
1749
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -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,
|
||||
'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 @@
|
||||
'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,
|
||||
|
@ -68,7 +68,7 @@
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\User::class,
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
@ -97,7 +97,21 @@
|
||||
'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,
|
||||
|
||||
];
|
||||
|
@ -41,6 +41,11 @@
|
||||
],
|
||||
],
|
||||
|
||||
'ably' => [
|
||||
'driver' => 'ably',
|
||||
'key' => env('ABLY_KEY'),
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
|
@ -13,9 +13,6 @@
|
||||
| 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 @@
|
||||
| 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 @@
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'cache',
|
||||
'connection' => null,
|
||||
'lock_connection' => null,
|
||||
],
|
||||
|
||||
'file' => [
|
||||
@ -74,6 +76,7 @@
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'cache',
|
||||
'lock_connection' => 'default',
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
@ -82,6 +85,11 @@
|
||||
'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',
|
||||
],
|
||||
|
||||
],
|
||||
|
@ -134,17 +134,18 @@
|
||||
],
|
||||
|
||||
'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'),
|
||||
],
|
||||
|
||||
],
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
|
||||
*/
|
||||
|
||||
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
|
||||
// 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -62,8 +62,25 @@
|
||||
'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'),
|
||||
],
|
||||
|
||||
];
|
||||
|
@ -18,6 +18,19 @@
|
||||
|
||||
'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 @@
|
||||
'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 @@
|
||||
'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 @@
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'with' => [
|
||||
@ -82,12 +96,21 @@
|
||||
|
||||
'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'),
|
||||
],
|
||||
],
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
| 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 @@
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|
@ -39,6 +39,7 @@
|
||||
'table' => 'jobs',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
@ -47,6 +48,7 @@
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
@ -55,7 +57,9 @@
|
||||
'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 @@
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => 90,
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
],
|
||||
@ -80,6 +85,7 @@
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'mysql'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
@ -30,18 +30,18 @@
|
||||
'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),
|
||||
// ],
|
||||
// ],
|
||||
|
||||
];
|
||||
|
@ -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
|
||||
| do not enable this as other CSRF protection services are in place.
|
||||
|
|
||||
| Supported: "lax", "strict"
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
|
3
database/.gitignore
vendored
3
database/.gitignore
vendored
@ -1,2 +1 @@
|
||||
*.sqlite
|
||||
*.sqlite-journal
|
||||
*.sqlite*
|
||||
|
@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -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' => '',
|
||||
];
|
||||
}
|
||||
}
|
@ -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,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
@ -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 @@ public function run()
|
||||
'name' => 'eCommerce',
|
||||
]);
|
||||
|
||||
$groupSocialNetwork->twofaccounts()->create([
|
||||
$groupECommerce->twofaccounts()->create([
|
||||
'otp_type' => 'totp',
|
||||
'account' => 'johndoe',
|
||||
'service' => 'Amazon',
|
@ -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
|
||||
{
|
||||
/**
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\User;
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UsersTableSeeder extends Seeder
|
@ -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 @@
|
||||
|
|
||||
*/
|
||||
|
||||
$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);
|
@ -15,6 +15,7 @@
|
||||
|
||||
// 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
|
||||
|
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
'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 @@
|
||||
],
|
||||
'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 @@
|
||||
'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.',
|
||||
|
@ -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;
|
||||
});
|
||||
|
@ -15,4 +15,4 @@
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->describe('Display an inspiring quote');
|
||||
})->purpose('Display an inspiring quote');
|
||||
|
13
storage/framework/.gitignore
vendored
13
storage/framework/.gitignore
vendored
@ -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
|
@ -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 @@
|
||||
class ForgotPasswordControllerTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @var \App\User
|
||||
* @var \App\Models\User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
@ -62,7 +62,7 @@ public function test_submit_email_password_request_returns_success()
|
||||
{
|
||||
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
|
||||
|
@ -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 @@ public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 @@
|
||||
class ResetPasswordControllerTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @var \App\User
|
||||
* @var \App\Models\User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
@ -71,7 +71,7 @@ public function test_submit_reset_password_returns_success()
|
||||
{
|
||||
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', [
|
||||
|
@ -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 @@ public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 @@
|
||||
class GroupControllerTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @var \App\User
|
||||
* @var \App\Models\User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
@ -27,7 +27,7 @@ public function setUp(): void
|
||||
{
|
||||
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()
|
||||
{
|
||||
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 @@ public function test_store_invalid_data_returns_validation_error()
|
||||
*/
|
||||
public function test_show_returns_group_resource()
|
||||
{
|
||||
$group = factory(Group::class)->create([
|
||||
$group = Group::factory()->create([
|
||||
'name' => 'My group',
|
||||
]);
|
||||
|
||||
@ -127,7 +127,7 @@ public function test_show_missing_group_returns_not_found()
|
||||
*/
|
||||
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 @@ public function test_update_missing_group_returns_not_found()
|
||||
*/
|
||||
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 @@ public function test_update_with_invalid_data_returns_validation_error()
|
||||
*/
|
||||
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 @@ public function test_assign_accounts_returns_updated_group_resource()
|
||||
*/
|
||||
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 @@ public function test_assign_accounts_to_missing_group_returns_not_found()
|
||||
*/
|
||||
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 @@ public function test_assign_invalid_accounts_returns_validation_error()
|
||||
*/
|
||||
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 @@ public function test_get_assigned_accounts_returns_twofaccounts_collection()
|
||||
*/
|
||||
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 @@ public function test_get_assigned_accounts_of_missing_group_returns_not_found()
|
||||
*/
|
||||
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)
|
||||
|
@ -6,7 +6,7 @@
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Tests\FeatureTestCase;
|
||||
|
||||
use App\TwoFAccount;
|
||||
use App\Models\TwoFAccount;
|
||||
|
||||
/**
|
||||
* @covers \App\Api\v1\Controllers\IconController
|
||||
|
@ -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 @@ public function setUp(): void
|
||||
{
|
||||
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()
|
||||
{
|
||||
$twofaccount = factory(TwoFAccount::class)->create([
|
||||
$twofaccount = TwoFAccount::factory()->create([
|
||||
'otp_type' => 'totp',
|
||||
'account' => 'account',
|
||||
'service' => 'service',
|
||||
|
@ -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 @@
|
||||
class SettingControllerTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @var \App\User
|
||||
* @var \App\Models\User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
@ -36,7 +36,7 @@ public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 @@
|
||||
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 @@ public function setUp(): void
|
||||
{
|
||||
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 @@ public function setUp(): void
|
||||
*/
|
||||
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 @@ public function test_index_returns_twofaccount_collection()
|
||||
*/
|
||||
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 @@ public function test_index_returns_twofaccount_collection_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')
|
||||
->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()
|
||||
{
|
||||
$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 @@ public function test_show_twofaccount_returns_twofaccount_resource_without_secre
|
||||
// $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 @@ public function test_store_assigns_created_account_when_default_group_does_not_e
|
||||
*/
|
||||
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 @@ public function test_update_totp_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')
|
||||
->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()
|
||||
{
|
||||
$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 @@ public function test_update_twofaccount_with_invalid_data_returns_validation_err
|
||||
*/
|
||||
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 @@ public function test_reorder_returns_success()
|
||||
*/
|
||||
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 @@ public function test_preview_with_unreachable_image_returns_success()
|
||||
*/
|
||||
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 @@ public function test_get_otp_by_posting_totp_parameters_returns_consistent_resou
|
||||
*/
|
||||
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 @@ public function test_get_otp_using_indecipherable_twofaccount_id_returns_bad_req
|
||||
$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 @@ public function test_get_otp_by_posting_invalid_parameters_returns_validation_er
|
||||
*/
|
||||
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 @@ public function test_count_returns_right_number_of_twofaccount()
|
||||
*/
|
||||
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 @@ public function test_withdraw_returns_success()
|
||||
*/
|
||||
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 @@ public function test_withdraw_too_many_ids_returns_bad_request()
|
||||
*/
|
||||
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 @@ public function test_destroy_twofaccount_returns_success()
|
||||
*/
|
||||
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 @@ public function test_destroy_missing_twofaccount_returns_not_found()
|
||||
*/
|
||||
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 @@ public function test_batch_destroy_twofaccount_returns_success()
|
||||
*/
|
||||
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')
|
||||
|
@ -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;
|
||||
|
@ -53,7 +53,7 @@ public function provideValidData() : array
|
||||
*/
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
$user = new \App\User(
|
||||
$user = new \App\Models\User(
|
||||
[
|
||||
'name' => 'John',
|
||||
'email' => 'john@example.com',
|
||||
|
@ -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 @@
|
||||
class LoginTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @var \App\User
|
||||
* @var \App\Models\User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
@ -27,7 +27,7 @@ public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 @@ public function test_user_is_authorized()
|
||||
*/
|
||||
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 @@ public function provideValidData() : array
|
||||
*/
|
||||
public function test_invalid_data(array $data) : void
|
||||
{
|
||||
factory(\App\User::class)->create([
|
||||
User::factory()->create([
|
||||
'email' => 'JOHN.DOE@example.com'
|
||||
]);
|
||||
|
||||
|
@ -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 @@ public function test_create_persists_and_returns_created_group()
|
||||
$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 @@ public function test_update_persists_and_returns_updated_group()
|
||||
$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);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 @@ public function setUp() : void
|
||||
*/
|
||||
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 @@ public function test_index_returns_api_resources_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')
|
||||
->once()
|
||||
@ -84,7 +84,7 @@ public function test_store_returns_api_resource_stored_using_groupService()
|
||||
|
||||
$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()
|
||||
{
|
||||
$group = factory(Group::class)->make();
|
||||
$group = Group::factory()->make();
|
||||
|
||||
$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()
|
||||
{
|
||||
$group = factory(Group::class)->make();
|
||||
$group = Group::factory()->make();
|
||||
|
||||
$this->groupStoreRequest->shouldReceive('validated')
|
||||
->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()
|
||||
{
|
||||
$group = factory(Group::class)->make();
|
||||
$group = Group::factory()->make();
|
||||
$groupAssignRequest = Mockery::mock('App\Api\v1\Requests\GroupAssignRequest');
|
||||
|
||||
$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()
|
||||
{
|
||||
$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 @@ public function test_accounts_returns_api_resources_fetched_using_groupService()
|
||||
*/
|
||||
public function test_destroy_uses_group_service()
|
||||
{
|
||||
$group = factory(Group::class)->make();
|
||||
$group = Group::factory()->make();
|
||||
|
||||
$this->groupServiceMock->shouldReceive('delete')
|
||||
->once()
|
||||
|
@ -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);
|
||||
|
@ -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 @@ public function test_event_constructor()
|
||||
->with('useEncryption')
|
||||
->andReturn(false);
|
||||
|
||||
$twofaccount = factory(TwoFAccount::class)->make();
|
||||
$twofaccount = TwoFAccount::factory()->make();
|
||||
$event = new TwoFAccountDeleted($twofaccount);
|
||||
|
||||
$this->assertSame($twofaccount, $event->twofaccount);
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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 @@ public function test_it_stores_time_to_session()
|
||||
->with('useEncryption')
|
||||
->andReturn(false);
|
||||
|
||||
$twofaccount = factory(TwoFAccount::class)->make();
|
||||
$twofaccount = TwoFAccount::factory()->make();
|
||||
$event = new TwoFAccountDeleted($twofaccount);
|
||||
$listener = new CleanIconStorage();
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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\Support\Facades\Crypt;
|
||||
|
||||
/**
|
||||
* @covers \App\TwoFAccount
|
||||
* @covers \App\Models\TwoFAccount
|
||||
*/
|
||||
class TwoFAccountModelTest extends ModelTestCase
|
||||
{
|
||||
@ -48,7 +48,7 @@ public function test_sensitive_attributes_are_stored_encrypted(string $attribute
|
||||
->with('useEncryption')
|
||||
->andReturn(true);
|
||||
|
||||
$twofaccount = factory(TwoFAccount::class)->make([
|
||||
$twofaccount = TwoFAccount::factory()->make([
|
||||
$attribute => 'string',
|
||||
]);
|
||||
|
||||
@ -84,7 +84,7 @@ public function test_sensitive_attributes_are_returned_clear(string $attribute)
|
||||
->with('useEncryption')
|
||||
->andReturn(false);
|
||||
|
||||
$twofaccount = factory(TwoFAccount::class)->make();
|
||||
$twofaccount = TwoFAccount::factory()->make();
|
||||
|
||||
$this->assertEquals($twofaccount->getAttributes()[$attribute], $twofaccount->$attribute);
|
||||
}
|
||||
@ -104,7 +104,7 @@ public function test_indecipherable_attributes_returns_masked_value(string $attr
|
||||
Crypt::shouldReceive('encryptString')
|
||||
->andReturn('indecipherableString');
|
||||
|
||||
$twofaccount = factory(TwoFAccount::class)->make();
|
||||
$twofaccount = TwoFAccount::factory()->make();
|
||||
|
||||
$this->assertEquals(__('errors.indecipherable'), $twofaccount->$attribute);
|
||||
}
|
||||
|
@ -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 @@ public function test_model_configuration()
|
||||
*/
|
||||
public function test_email_is_set_lowercased()
|
||||
{
|
||||
$user = factory(User::class)->make([
|
||||
$user = User::factory()->make([
|
||||
'email' => 'UPPERCASE@example.COM',
|
||||
]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user