Apply Laravel Pint fixes

This commit is contained in:
Bubka 2022-12-13 12:07:29 +01:00
parent 6deb279c8d
commit 2d706e61b7
48 changed files with 246 additions and 260 deletions

View File

@ -2,8 +2,6 @@
namespace App\Helpers; namespace App\Helpers;
use Illuminate\Support\Str;
class Helpers class Helpers
{ {
/** /**

View File

@ -7,11 +7,11 @@
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Contracts\Support\Responsable; use Illuminate\Contracts\Support\Responsable;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Laragear\WebAuthn\Http\Requests\AssertedRequest; use Laragear\WebAuthn\Http\Requests\AssertedRequest;
use Laragear\WebAuthn\Http\Requests\AssertionRequest; use Laragear\WebAuthn\Http\Requests\AssertionRequest;
use Laragear\WebAuthn\WebAuthn; use Laragear\WebAuthn\WebAuthn;
use Illuminate\Support\Arr;
class WebAuthnLoginController extends Controller class WebAuthnLoginController extends Controller
{ {

View File

@ -22,6 +22,7 @@
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use OTPHP\Factory; use OTPHP\Factory;
use OTPHP\HOTP; use OTPHP\HOTP;
@ -30,7 +31,6 @@
use Spatie\EloquentSortable\Sortable; use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait; use Spatie\EloquentSortable\SortableTrait;
use SteamTotp\SteamTotp; use SteamTotp\SteamTotp;
use Illuminate\Support\Str;
class TwoFAccount extends Model implements Sortable class TwoFAccount extends Model implements Sortable
{ {
@ -582,7 +582,6 @@ private function storeFileDataAsIcon($content, $extension): string|null
return null; return null;
} }
/** /**
* Generate a unique filename * Generate a unique filename
* *
@ -609,7 +608,7 @@ private function isValidIcon($filename, $disk): bool
'image/webp', 'image/webp',
'image/bmp', 'image/bmp',
'image/x-ms-bmp', 'image/x-ms-bmp',
'image/svg+xml' 'image/svg+xml',
]) && (Storage::disk($disk)->mimeType($filename) !== 'image/svg+xml' ? getimagesize(Storage::disk($disk)->path($filename)) : true); ]) && (Storage::disk($disk)->mimeType($filename) !== 'image/svg+xml' ? getimagesize(Storage::disk($disk)->path($filename)) : true);
} }

View File

@ -50,6 +50,7 @@ public function boot()
* Get the services provided by the provider. * Get the services provided by the provider.
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*
* @return array * @return array
*/ */
public function provides() public function provides()

View File

@ -4,12 +4,10 @@
use App\Exceptions\InvalidMigrationDataException; use App\Exceptions\InvalidMigrationDataException;
use App\Facades\TwoFAccounts; use App\Facades\TwoFAccounts;
use App\Helpers\Helpers;
use App\Models\TwoFAccount; use App\Models\TwoFAccount;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
class AegisMigrator extends Migrator class AegisMigrator extends Migrator
{ {

View File

@ -39,7 +39,6 @@ public function manualScan(): false|string
protected function newRelease() : false|string protected function newRelease() : false|string
{ {
if ($latestReleaseData = json_decode($this->getLatestReleaseData())) { if ($latestReleaseData = json_decode($this->getLatestReleaseData())) {
$githubVersion = Helpers::cleanVersionNumber($latestReleaseData->tag_name); $githubVersion = Helpers::cleanVersionNumber($latestReleaseData->tag_name);
$installedVersion = Helpers::cleanVersionNumber(config('2fauth.version')); $installedVersion = Helpers::cleanVersionNumber(config('2fauth.version'));

View File

@ -9,9 +9,9 @@
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Tests\Classes\LocalFile; use Tests\Classes\LocalFile;
use Tests\Data\MigrationTestData;
use Tests\Data\OtpTestData; use Tests\Data\OtpTestData;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use Tests\Data\MigrationTestData;
/** /**
* @covers \App\Api\v1\Controllers\TwoFAccountController * @covers \App\Api\v1\Controllers\TwoFAccountController

View File

@ -4,8 +4,8 @@
use App\Facades\Settings; use App\Facades\Settings;
use App\Models\User; use App\Models\User;
use Tests\FeatureTestCase;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Tests\FeatureTestCase;
/** /**
* @covers \App\Http\Controllers\Auth\LoginController * @covers \App\Http\Controllers\Auth\LoginController

View File

@ -3,10 +3,10 @@
namespace Tests\Feature\Http\Auth; namespace Tests\Feature\Http\Auth;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\Notification;
use Tests\FeatureTestCase;
use App\Notifications\WebauthnRecoveryNotification; use App\Notifications\WebauthnRecoveryNotification;
use Illuminate\Support\Facades\Lang; use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Facades\Notification;
use Tests\FeatureTestCase;
/** /**
* @covers \App\Http\Controllers\Auth\WebAuthnDeviceLostController * @covers \App\Http\Controllers\Auth\WebAuthnDeviceLostController
@ -52,7 +52,7 @@ public function test_sendRecoveryEmail_sends_notification_on_success()
]); ]);
$this->assertDatabaseHas('webauthn_recoveries', [ $this->assertDatabaseHas('webauthn_recoveries', [
'email' => $this->user->email 'email' => $this->user->email,
]); ]);
} }
@ -113,7 +113,7 @@ public function test_sendRecoveryEmail_does_not_send_anything_to_unknown_email()
]); ]);
$this->assertDatabaseMissing('webauthn_recoveries', [ $this->assertDatabaseMissing('webauthn_recoveries', [
'email' => 'bad@email.com' 'email' => 'bad@email.com',
]); ]);
} }
@ -136,7 +136,7 @@ public function test_sendRecoveryEmail_does_not_send_anything_to_invalid_email()
]); ]);
$this->assertDatabaseMissing('webauthn_recoveries', [ $this->assertDatabaseMissing('webauthn_recoveries', [
'email' => 'bad@email.com' 'email' => 'bad@email.com',
]); ]);
} }
@ -182,7 +182,7 @@ public function test_sendRecoveryEmail_is_throttled()
]); ]);
$this->assertDatabaseHas('webauthn_recoveries', [ $this->assertDatabaseHas('webauthn_recoveries', [
'email' => $this->user->email 'email' => $this->user->email,
]); ]);
$this->json('POST', '/webauthn/lost', [ $this->json('POST', '/webauthn/lost', [
@ -191,7 +191,7 @@ public function test_sendRecoveryEmail_is_throttled()
->assertStatus(422) ->assertStatus(422)
->assertJsonValidationErrorfor('email') ->assertJsonValidationErrorfor('email')
->assertJsonFragment([ ->assertJsonFragment([
'message' => __('passwords.throttled') 'message' => __('passwords.throttled'),
]); ]);
} }
@ -203,7 +203,7 @@ public function test_error_if_no_broker_is_set()
$this->app['config']->set('auth.passwords.webauthn', null); $this->app['config']->set('auth.passwords.webauthn', null);
$this->json('POST', '/webauthn/lost', [ $this->json('POST', '/webauthn/lost', [
'email' => $this->user->email 'email' => $this->user->email,
]) ])
->assertStatus(500); ->assertStatus(500);
} }

View File

@ -3,12 +3,12 @@
namespace Tests\Feature\Http\Auth; namespace Tests\Feature\Http\Auth;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\DB;
use Laragear\WebAuthn\Http\Requests\AssertedRequest;
use Tests\FeatureTestCase;
use Laragear\WebAuthn\WebAuthn;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Laragear\WebAuthn\Assertion\Validator\AssertionValidator; use Laragear\WebAuthn\Assertion\Validator\AssertionValidator;
use Laragear\WebAuthn\Http\Requests\AssertedRequest;
use Laragear\WebAuthn\WebAuthn;
use Tests\FeatureTestCase;
/** /**
* @covers \App\Http\Controllers\Auth\WebAuthnLoginController * @covers \App\Http\Controllers\Auth\WebAuthnLoginController
@ -22,12 +22,15 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
protected $user; protected $user;
const CREDENTIAL_ID = 's06aG41wsIYh5X1YUhB-SlH8y3F2RzdJZVse8iXRXOCd3oqQdEyCOsBawzxrYBtJRQA2azAMEN_q19TUp6iMgg'; const CREDENTIAL_ID = 's06aG41wsIYh5X1YUhB-SlH8y3F2RzdJZVse8iXRXOCd3oqQdEyCOsBawzxrYBtJRQA2azAMEN_q19TUp6iMgg';
const CREDENTIAL_ID_ALT = '-VOLFKPY-_FuMI_sJ7gMllK76L3VoRUINj6lL_Z3qDg'; const CREDENTIAL_ID_ALT = '-VOLFKPY-_FuMI_sJ7gMllK76L3VoRUINj6lL_Z3qDg';
const CREDENTIAL_ID_ALT_RAW = '+VOLFKPY+/FuMI/sJ7gMllK76L3VoRUINj6lL/Z3qDg='; const CREDENTIAL_ID_ALT_RAW = '+VOLFKPY+/FuMI/sJ7gMllK76L3VoRUINj6lL/Z3qDg=';
const PUBLIC_KEY = 'eyJpdiI6ImYyUHlJOEJML0pwTXJ2UDkveTQwZFE9PSIsInZhbHVlIjoiQWFSYi9LVEszazlBRUZsWHp0cGNRNktGeEQ3aTBsbU9zZ1g5MEgrWFJJNmgraElsNU9hV0VsRVlWc3NoUVVHUjRRdlcxTS9pVklnOWtVYWY5TFJQTTFhR1Rxb1ZzTFkxTWE4VUVvK1lyU3pYQ1M3VlBMWWxZcDVaYWFnK25iaXVyWGR6ZFRmMFVoSmdPZ3UvSnptbVZER0FYdEEyYmNYcW43RkV5aTVqSjNwZEFsUjhUYSs0YjU2Z2V2bUJXa0E0aVB1VC8xSjdJZ2llRGlHY2RwOGk3MmNPTyt6eDFDWUs1dVBOSWp1ZUFSeUlkclgwRW16RE9sUUpDSWV6Sk50TSIsIm1hYyI6IjI3ODQ5NzcxZGY1MzMwYTNiZjAwZmEwMDJkZjYzMGU4N2UzZjZlOGM0ZWE3NDkyYWMxMThhNmE5NWZiMTVjNGEiLCJ0YWciOiIifQ=='; const PUBLIC_KEY = 'eyJpdiI6ImYyUHlJOEJML0pwTXJ2UDkveTQwZFE9PSIsInZhbHVlIjoiQWFSYi9LVEszazlBRUZsWHp0cGNRNktGeEQ3aTBsbU9zZ1g5MEgrWFJJNmgraElsNU9hV0VsRVlWc3NoUVVHUjRRdlcxTS9pVklnOWtVYWY5TFJQTTFhR1Rxb1ZzTFkxTWE4VUVvK1lyU3pYQ1M3VlBMWWxZcDVaYWFnK25iaXVyWGR6ZFRmMFVoSmdPZ3UvSnptbVZER0FYdEEyYmNYcW43RkV5aTVqSjNwZEFsUjhUYSs0YjU2Z2V2bUJXa0E0aVB1VC8xSjdJZ2llRGlHY2RwOGk3MmNPTyt6eDFDWUs1dVBOSWp1ZUFSeUlkclgwRW16RE9sUUpDSWV6Sk50TSIsIm1hYyI6IjI3ODQ5NzcxZGY1MzMwYTNiZjAwZmEwMDJkZjYzMGU4N2UzZjZlOGM0ZWE3NDkyYWMxMThhNmE5NWZiMTVjNGEiLCJ0YWciOiIifQ==';
const USER_ID = '3b758ac868b74307a7e96e69ae187339'; const USER_ID = '3b758ac868b74307a7e96e69ae187339';
const USER_ID_ALT = 'e8af6f703f8042aa91c30cf72289aa07'; const USER_ID_ALT = 'e8af6f703f8042aa91c30cf72289aa07';
const ASSERTION_RESPONSE = [ const ASSERTION_RESPONSE = [
@ -39,7 +42,7 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
'authenticatorData' => 'SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MFAAAAAQ==', 'authenticatorData' => 'SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MFAAAAAQ==',
'signature' => 'ca4IJ9h8bZnjMbEFuHX1zfX5LcbiPyDVz6sD1/ppR4t8++1DxKa5EdBIrfNlo8FSOv/JSzMrGGUCQvc/Ngj1KnZpO3s9OdTb54/gMDewH/K8EG4wSvxzHdL6sMbP7UUc5Wq1pcdu9MgXY8V+1gftXpzcoaae0X+mLEETgU7eB8jG0mZhVWvE4yQKuDnZA1i9r8oQhqsvG4nUw1BxvR8wAGiRR+R287LaL41k+xum5mS8zEojUmuLSH50miyVxZ4Y+/oyfxG7i+wSYGNSXlW5iNPB+2WupGS7ce4TuOgaFeMmP2a9rzP4m2IBSQoJ2FyrdzR7HwBEewqqrUVbGQw3Aw==', 'signature' => 'ca4IJ9h8bZnjMbEFuHX1zfX5LcbiPyDVz6sD1/ppR4t8++1DxKa5EdBIrfNlo8FSOv/JSzMrGGUCQvc/Ngj1KnZpO3s9OdTb54/gMDewH/K8EG4wSvxzHdL6sMbP7UUc5Wq1pcdu9MgXY8V+1gftXpzcoaae0X+mLEETgU7eB8jG0mZhVWvE4yQKuDnZA1i9r8oQhqsvG4nUw1BxvR8wAGiRR+R287LaL41k+xum5mS8zEojUmuLSH50miyVxZ4Y+/oyfxG7i+wSYGNSXlW5iNPB+2WupGS7ce4TuOgaFeMmP2a9rzP4m2IBSQoJ2FyrdzR7HwBEewqqrUVbGQw3Aw==',
'userHandle' => self::USER_ID_ALT, 'userHandle' => self::USER_ID_ALT,
] ],
]; ];
const ASSERTION_RESPONSE_NO_HANDLE = [ const ASSERTION_RESPONSE_NO_HANDLE = [
@ -51,7 +54,7 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
'authenticatorData' => 'SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MFAAAAAQ==', 'authenticatorData' => 'SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MFAAAAAQ==',
'signature' => 'ca4IJ9h8bZnjMbEFuHX1zfX5LcbiPyDVz6sD1/ppR4t8++1DxKa5EdBIrfNlo8FSOv/JSzMrGGUCQvc/Ngj1KnZpO3s9OdTb54/gMDewH/K8EG4wSvxzHdL6sMbP7UUc5Wq1pcdu9MgXY8V+1gftXpzcoaae0X+mLEETgU7eB8jG0mZhVWvE4yQKuDnZA1i9r8oQhqsvG4nUw1BxvR8wAGiRR+R287LaL41k+xum5mS8zEojUmuLSH50miyVxZ4Y+/oyfxG7i+wSYGNSXlW5iNPB+2WupGS7ce4TuOgaFeMmP2a9rzP4m2IBSQoJ2FyrdzR7HwBEewqqrUVbGQw3Aw==', 'signature' => 'ca4IJ9h8bZnjMbEFuHX1zfX5LcbiPyDVz6sD1/ppR4t8++1DxKa5EdBIrfNlo8FSOv/JSzMrGGUCQvc/Ngj1KnZpO3s9OdTb54/gMDewH/K8EG4wSvxzHdL6sMbP7UUc5Wq1pcdu9MgXY8V+1gftXpzcoaae0X+mLEETgU7eB8jG0mZhVWvE4yQKuDnZA1i9r8oQhqsvG4nUw1BxvR8wAGiRR+R287LaL41k+xum5mS8zEojUmuLSH50miyVxZ4Y+/oyfxG7i+wSYGNSXlW5iNPB+2WupGS7ce4TuOgaFeMmP2a9rzP4m2IBSQoJ2FyrdzR7HwBEewqqrUVbGQw3Aw==',
'userHandle' => null, 'userHandle' => null,
] ],
]; ];
const ASSERTION_CHALLENGE = 'iXozmynKi+YD2iRvKNbSPA=='; const ASSERTION_CHALLENGE = 'iXozmynKi+YD2iRvKNbSPA==';

View File

@ -3,19 +3,18 @@
namespace Tests\Feature\Http\Auth; namespace Tests\Feature\Http\Auth;
use App\Models\User; use App\Models\User;
use Tests\FeatureTestCase;
use Laragear\WebAuthn\Http\Requests\AttestedRequest;
use Laragear\WebAuthn\Http\Requests\AttestationRequest;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Laragear\WebAuthn\WebAuthn; use Laragear\WebAuthn\Http\Requests\AttestationRequest;
use Laragear\WebAuthn\Http\Requests\AttestedRequest;
use Laragear\WebAuthn\JsonTransport; use Laragear\WebAuthn\JsonTransport;
use Laragear\WebAuthn\WebAuthn;
use Tests\FeatureTestCase;
/** /**
* @covers \App\Http\Controllers\Auth\WebAuthnRegisterController * @covers \App\Http\Controllers\Auth\WebAuthnRegisterController
*/ */
class WebAuthnRegisterControllerTest extends FeatureTestCase class WebAuthnRegisterControllerTest extends FeatureTestCase
{ {
/** /**
* @var \App\Models\User * @var \App\Models\User
*/ */

View File

@ -3,8 +3,8 @@
namespace Tests\Feature\Http; namespace Tests\Feature\Http;
use App\Models\User; use App\Models\User;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use App\Services\ReleaseRadarService; use App\Services\ReleaseRadarService;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**

View File

@ -3,13 +3,12 @@
namespace Tests\Feature\Models; namespace Tests\Feature\Models;
use App\Models\TwoFAccount; use App\Models\TwoFAccount;
use Illuminate\Http\Testing\FileFactory;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
use Tests\Data\HttpRequestTestData;
use Tests\Data\OtpTestData; use Tests\Data\OtpTestData;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Testing\FileFactory;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Http;
use Tests\Data\HttpRequestTestData;
/** /**
* @covers \App\Models\TwoFAccount * @covers \App\Models\TwoFAccount
@ -28,7 +27,6 @@ class TwoFAccountModelTest extends FeatureTestCase
/** /**
* Helpers $helpers; * Helpers $helpers;
*/ */
protected $helpers; protected $helpers;
@ -461,7 +459,6 @@ public function test_getOTP_for_totp_returns_the_same_password()
*/ */
public function test_getOTP_for_hotp_returns_the_same_password() public function test_getOTP_for_hotp_returns_the_same_password()
{ {
Http::preventStrayRequests(); Http::preventStrayRequests();
Http::fake([ Http::fake([
'https://en.opensuse.org/images/4/44/Button-filled-colour.png' => Http::response(HttpRequestTestData::ICON_PNG, 200), 'https://en.opensuse.org/images/4/44/Button-filled-colour.png' => Http::response(HttpRequestTestData::ICON_PNG, 200),
@ -567,7 +564,6 @@ public function test_getURI_for_custom_hotp_model_returns_uri()
*/ */
public function test_fill_succeed_when_image_fetching_fails() public function test_fill_succeed_when_image_fetching_fails()
{ {
Http::preventStrayRequests(); Http::preventStrayRequests();
Storage::fake('imagesLink'); Storage::fake('imagesLink');

View File

@ -4,11 +4,10 @@
use App\Services\LogoService; use App\Services\LogoService;
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use Mockery\MockInterface;
use Tests\TestCase;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
use Tests\Data\HttpRequestTestData; use Tests\Data\HttpRequestTestData;
use Tests\TestCase;
/** /**
* @covers \App\Services\LogoService * @covers \App\Services\LogoService

View File

@ -5,9 +5,9 @@
use App\Facades\Settings; use App\Facades\Settings;
use App\Services\ReleaseRadarService; use App\Services\ReleaseRadarService;
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use Tests\FeatureTestCase;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Tests\Data\HttpRequestTestData; use Tests\Data\HttpRequestTestData;
use Tests\FeatureTestCase;
/** /**
* @covers \App\Services\ReleaseRadarService * @covers \App\Services\ReleaseRadarService
@ -37,7 +37,7 @@ public function test_manualScan_returns_no_new_release()
]); ]);
$this->assertDatabaseMissing('options', [ $this->assertDatabaseMissing('options', [
'key' => 'latestRelease', 'key' => 'latestRelease',
'value' => HttpRequestTestData::TAG_NAME 'value' => HttpRequestTestData::TAG_NAME,
]); ]);
} }
@ -59,7 +59,7 @@ public function test_manualScan_returns_new_release()
$this->assertEquals(HttpRequestTestData::NEW_TAG_NAME, $release); $this->assertEquals(HttpRequestTestData::NEW_TAG_NAME, $release);
$this->assertDatabaseHas('options', [ $this->assertDatabaseHas('options', [
'key' => 'latestRelease', 'key' => 'latestRelease',
'value' => HttpRequestTestData::NEW_TAG_NAME 'value' => HttpRequestTestData::NEW_TAG_NAME,
]); ]);
$this->assertDatabaseHas('options', [ $this->assertDatabaseHas('options', [
'key' => 'lastRadarScan', 'key' => 'lastRadarScan',

View File

@ -5,9 +5,9 @@
use App\Facades\TwoFAccounts; use App\Facades\TwoFAccounts;
use App\Models\Group; use App\Models\Group;
use App\Models\TwoFAccount; use App\Models\TwoFAccount;
use Tests\Data\MigrationTestData;
use Tests\Data\OtpTestData; use Tests\Data\OtpTestData;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
use Tests\Data\MigrationTestData;
/** /**
* @covers \App\Services\TwoFAccountService * @covers \App\Services\TwoFAccountService

View File

@ -2,20 +2,20 @@
namespace Tests\Unit\Exceptions; namespace Tests\Unit\Exceptions;
use App\Exceptions\DbEncryptionException;
use App\Exceptions\EncryptedMigrationException;
use App\Exceptions\Handler; use App\Exceptions\Handler;
use App\Exceptions\InvalidMigrationDataException;
use App\Exceptions\InvalidOtpParameterException;
use App\Exceptions\InvalidQrCodeException;
use App\Exceptions\InvalidSecretException;
use App\Exceptions\UndecipherableException;
use App\Exceptions\UnsupportedMigrationException;
use App\Exceptions\UnsupportedOtpTypeException;
use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Container\Container;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Tests\TestCase; use Tests\TestCase;
use App\Exceptions\InvalidOtpParameterException;
use \App\Exceptions\InvalidQrCodeException;
use App\Exceptions\InvalidSecretException;
use App\Exceptions\DbEncryptionException;
use App\Exceptions\InvalidMigrationDataException;
use App\Exceptions\UndecipherableException;
use App\Exceptions\UnsupportedMigrationException;
use App\Exceptions\UnsupportedOtpTypeException;
use App\Exceptions\EncryptedMigrationException;
/** /**
* @covers \App\Exceptions\Handler * @covers \App\Exceptions\Handler

View File

@ -7,8 +7,8 @@
use App\Models\Group; use App\Models\Group;
use App\Models\TwoFAccount; use App\Models\TwoFAccount;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use Tests\TestCase;
use Mockery\MockInterface; use Mockery\MockInterface;
use Tests\TestCase;
/** /**
* @covers \App\Listeners\DissociateTwofaccountFromGroup * @covers \App\Listeners\DissociateTwofaccountFromGroup
@ -23,7 +23,6 @@ class DissociateTwofaccountFromGroupTest extends TestCase
*/ */
public function test_twofaccount_is_released_on_group_deletion() public function test_twofaccount_is_released_on_group_deletion()
{ {
$this->mock('alias:' . TwoFAccount::class, function (MockInterface $twoFAccount) { $this->mock('alias:' . TwoFAccount::class, function (MockInterface $twoFAccount) {
$twoFAccount->shouldReceive('where->update') $twoFAccount->shouldReceive('where->update')
->once() ->once()

View File

@ -3,26 +3,23 @@
namespace Tests\Unit; namespace Tests\Unit;
use App\Exceptions\EncryptedMigrationException; use App\Exceptions\EncryptedMigrationException;
use App\Factories\MigratorFactory;
use App\Exceptions\InvalidMigrationDataException; use App\Exceptions\InvalidMigrationDataException;
use App\Exceptions\UnsupportedMigrationException;
use App\Factories\MigratorFactory;
use App\Models\TwoFAccount; use App\Models\TwoFAccount;
use App\Services\Migrators\AegisMigrator; use App\Services\Migrators\AegisMigrator;
use App\Services\Migrators\TwoFASMigrator; use App\Services\Migrators\GoogleAuthMigrator;
use App\Services\Migrators\Migrator; use App\Services\Migrators\Migrator;
use App\Services\Migrators\PlainTextMigrator; use App\Services\Migrators\PlainTextMigrator;
use App\Services\Migrators\GoogleAuthMigrator; use App\Services\Migrators\TwoFASMigrator;
use App\Services\SettingService; use App\Services\SettingService;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Mockery; use Mockery;
use Mockery\Mock;
use Mockery\MockInterface; use Mockery\MockInterface;
use ParagonIE\ConstantTime\Base32;
use Tests\Data\MigrationTestData; use Tests\Data\MigrationTestData;
use Tests\Data\OtpTestData; use Tests\Data\OtpTestData;
use Tests\TestCase; use Tests\TestCase;
use ParagonIE\ConstantTime\Base32;
use App\Protobuf\GoogleAuth\Payload\Algorithm;
use App\Exceptions\UnsupportedMigrationException;
/** /**
* @covers \App\Providers\MigrationServiceProvider * @covers \App\Providers\MigrationServiceProvider
@ -32,6 +29,7 @@
* @covers \App\Services\Migrators\TwoFASMigrator * @covers \App\Services\Migrators\TwoFASMigrator
* @covers \App\Services\Migrators\PlainTextMigrator * @covers \App\Services\Migrators\PlainTextMigrator
* @covers \App\Services\Migrators\GoogleAuthMigrator * @covers \App\Services\Migrators\GoogleAuthMigrator
*
* @uses \App\Models\TwoFAccount * @uses \App\Models\TwoFAccount
*/ */
class MigratorTest extends TestCase class MigratorTest extends TestCase
@ -179,25 +177,25 @@ public function validMigrationsProvider()
new PlainTextMigrator(), new PlainTextMigrator(),
MigrationTestData::VALID_PLAIN_TEXT_PAYLOAD, MigrationTestData::VALID_PLAIN_TEXT_PAYLOAD,
'custom', 'custom',
$hasSteam = true $hasSteam = true,
], ],
'PLAIN_TEXT_PAYLOAD_WITH_INTRUDER' => [ 'PLAIN_TEXT_PAYLOAD_WITH_INTRUDER' => [
new PlainTextMigrator(), new PlainTextMigrator(),
MigrationTestData::VALID_PLAIN_TEXT_PAYLOAD_WITH_INTRUDER, MigrationTestData::VALID_PLAIN_TEXT_PAYLOAD_WITH_INTRUDER,
'custom', 'custom',
$hasSteam = true $hasSteam = true,
], ],
'AEGIS_JSON_MIGRATION_PAYLOAD' => [ 'AEGIS_JSON_MIGRATION_PAYLOAD' => [
new AegisMigrator(), new AegisMigrator(),
MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD, MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD,
'custom', 'custom',
$hasSteam = true $hasSteam = true,
], ],
'2FAS_MIGRATION_PAYLOAD' => [ '2FAS_MIGRATION_PAYLOAD' => [
new TwoFASMigrator(), new TwoFASMigrator(),
MigrationTestData::VALID_2FAS_MIGRATION_PAYLOAD, MigrationTestData::VALID_2FAS_MIGRATION_PAYLOAD,
'custom', 'custom',
$hasSteam = false $hasSteam = false,
], ],
'GOOGLE_AUTH_MIGRATION_PAYLOAD' => [ 'GOOGLE_AUTH_MIGRATION_PAYLOAD' => [
new GoogleAuthMigrator(), new GoogleAuthMigrator(),
@ -466,17 +464,14 @@ public function encryptedMigrationDataProvider()
{ {
return [ return [
'ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD' => [ 'ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD' => [
MigrationTestData::ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD MigrationTestData::ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD,
], ],
'ENCRYPTED_2FAS_MIGRATION_PAYLOAD' => [ 'ENCRYPTED_2FAS_MIGRATION_PAYLOAD' => [
MigrationTestData::ENCRYPTED_2FAS_MIGRATION_PAYLOAD MigrationTestData::ENCRYPTED_2FAS_MIGRATION_PAYLOAD,
], ],
]; ];
} }
/**
*
*/
protected function tearDown() : void protected function tearDown() : void
{ {
Mockery::close(); Mockery::close();