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;
use Illuminate\Support\Str;
class Helpers
{
/**

View File

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

View File

@ -22,6 +22,7 @@ use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
use OTPHP\Factory;
use OTPHP\HOTP;
@ -30,7 +31,6 @@ use ParagonIE\ConstantTime\Base32;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;
use SteamTotp\SteamTotp;
use Illuminate\Support\Str;
class TwoFAccount extends Model implements Sortable
{
@ -582,7 +582,6 @@ class TwoFAccount extends Model implements Sortable
return null;
}
/**
* Generate a unique filename
*
@ -609,7 +608,7 @@ class TwoFAccount extends Model implements Sortable
'image/webp',
'image/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);
}

View File

@ -50,6 +50,7 @@ class TwoFAuthServiceProvider extends ServiceProvider implements DeferrableProvi
* Get the services provided by the provider.
*
* @codeCoverageIgnore
*
* @return array
*/
public function provides()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,12 +3,12 @@
namespace Tests\Feature\Http\Auth;
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\DB;
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
@ -22,12 +22,15 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
protected $user;
const CREDENTIAL_ID = 's06aG41wsIYh5X1YUhB-SlH8y3F2RzdJZVse8iXRXOCd3oqQdEyCOsBawzxrYBtJRQA2azAMEN_q19TUp6iMgg';
const CREDENTIAL_ID_ALT = '-VOLFKPY-_FuMI_sJ7gMllK76L3VoRUINj6lL_Z3qDg';
const CREDENTIAL_ID_ALT_RAW = '+VOLFKPY+/FuMI/sJ7gMllK76L3VoRUINj6lL/Z3qDg=';
const PUBLIC_KEY = 'eyJpdiI6ImYyUHlJOEJML0pwTXJ2UDkveTQwZFE9PSIsInZhbHVlIjoiQWFSYi9LVEszazlBRUZsWHp0cGNRNktGeEQ3aTBsbU9zZ1g5MEgrWFJJNmgraElsNU9hV0VsRVlWc3NoUVVHUjRRdlcxTS9pVklnOWtVYWY5TFJQTTFhR1Rxb1ZzTFkxTWE4VUVvK1lyU3pYQ1M3VlBMWWxZcDVaYWFnK25iaXVyWGR6ZFRmMFVoSmdPZ3UvSnptbVZER0FYdEEyYmNYcW43RkV5aTVqSjNwZEFsUjhUYSs0YjU2Z2V2bUJXa0E0aVB1VC8xSjdJZ2llRGlHY2RwOGk3MmNPTyt6eDFDWUs1dVBOSWp1ZUFSeUlkclgwRW16RE9sUUpDSWV6Sk50TSIsIm1hYyI6IjI3ODQ5NzcxZGY1MzMwYTNiZjAwZmEwMDJkZjYzMGU4N2UzZjZlOGM0ZWE3NDkyYWMxMThhNmE5NWZiMTVjNGEiLCJ0YWciOiIifQ==';
const USER_ID = '3b758ac868b74307a7e96e69ae187339';
const USER_ID_ALT = 'e8af6f703f8042aa91c30cf72289aa07';
const ASSERTION_RESPONSE = [
@ -39,7 +42,7 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
'authenticatorData' => 'SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MFAAAAAQ==',
'signature' => 'ca4IJ9h8bZnjMbEFuHX1zfX5LcbiPyDVz6sD1/ppR4t8++1DxKa5EdBIrfNlo8FSOv/JSzMrGGUCQvc/Ngj1KnZpO3s9OdTb54/gMDewH/K8EG4wSvxzHdL6sMbP7UUc5Wq1pcdu9MgXY8V+1gftXpzcoaae0X+mLEETgU7eB8jG0mZhVWvE4yQKuDnZA1i9r8oQhqsvG4nUw1BxvR8wAGiRR+R287LaL41k+xum5mS8zEojUmuLSH50miyVxZ4Y+/oyfxG7i+wSYGNSXlW5iNPB+2WupGS7ce4TuOgaFeMmP2a9rzP4m2IBSQoJ2FyrdzR7HwBEewqqrUVbGQw3Aw==',
'userHandle' => self::USER_ID_ALT,
]
],
];
const ASSERTION_RESPONSE_NO_HANDLE = [
@ -51,7 +54,7 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
'authenticatorData' => 'SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MFAAAAAQ==',
'signature' => 'ca4IJ9h8bZnjMbEFuHX1zfX5LcbiPyDVz6sD1/ppR4t8++1DxKa5EdBIrfNlo8FSOv/JSzMrGGUCQvc/Ngj1KnZpO3s9OdTb54/gMDewH/K8EG4wSvxzHdL6sMbP7UUc5Wq1pcdu9MgXY8V+1gftXpzcoaae0X+mLEETgU7eB8jG0mZhVWvE4yQKuDnZA1i9r8oQhqsvG4nUw1BxvR8wAGiRR+R287LaL41k+xum5mS8zEojUmuLSH50miyVxZ4Y+/oyfxG7i+wSYGNSXlW5iNPB+2WupGS7ce4TuOgaFeMmP2a9rzP4m2IBSQoJ2FyrdzR7HwBEewqqrUVbGQw3Aw==',
'userHandle' => null,
]
],
];
const ASSERTION_CHALLENGE = 'iXozmynKi+YD2iRvKNbSPA==';

View File

@ -3,19 +3,18 @@
namespace Tests\Feature\Http\Auth;
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 Laragear\WebAuthn\WebAuthn;
use Laragear\WebAuthn\Http\Requests\AttestationRequest;
use Laragear\WebAuthn\Http\Requests\AttestedRequest;
use Laragear\WebAuthn\JsonTransport;
use Laragear\WebAuthn\WebAuthn;
use Tests\FeatureTestCase;
/**
* @covers \App\Http\Controllers\Auth\WebAuthnRegisterController
*/
class WebAuthnRegisterControllerTest extends FeatureTestCase
{
/**
* @var \App\Models\User
*/

View File

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

View File

@ -3,13 +3,12 @@
namespace Tests\Feature\Models;
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\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
@ -28,7 +27,6 @@ class TwoFAccountModelTest extends FeatureTestCase
/**
* Helpers $helpers;
*/
protected $helpers;
@ -461,7 +459,6 @@ class TwoFAccountModelTest extends FeatureTestCase
*/
public function test_getOTP_for_hotp_returns_the_same_password()
{
Http::preventStrayRequests();
Http::fake([
'https://en.opensuse.org/images/4/44/Button-filled-colour.png' => Http::response(HttpRequestTestData::ICON_PNG, 200),
@ -567,7 +564,6 @@ class TwoFAccountModelTest extends FeatureTestCase
*/
public function test_fill_succeed_when_image_fetching_fails()
{
Http::preventStrayRequests();
Storage::fake('imagesLink');

View File

@ -4,11 +4,10 @@ namespace Tests\Feature\Services;
use App\Services\LogoService;
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\Storage;
use Tests\Data\HttpRequestTestData;
use Tests\TestCase;
/**
* @covers \App\Services\LogoService

View File

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

View File

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

View File

@ -2,20 +2,20 @@
namespace Tests\Unit\Exceptions;
use App\Exceptions\DbEncryptionException;
use App\Exceptions\EncryptedMigrationException;
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\Http\JsonResponse;
use Illuminate\Http\Request;
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

View File

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

View File

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