diff --git a/app/Extensions/WebauthnCredentialBroker.php b/app/Extensions/WebauthnCredentialBroker.php index 029a4879..4b1cc83d 100644 --- a/app/Extensions/WebauthnCredentialBroker.php +++ b/app/Extensions/WebauthnCredentialBroker.php @@ -16,11 +16,11 @@ class WebauthnCredentialBroker extends PasswordBroker * @param \Closure|null $callback * @return string */ - public function sendResetLink(array $credentials, Closure $callback = null): string + public function sendResetLink(array $credentials, Closure $callback = null) : string { $user = $this->getUser($credentials); - if (!$user instanceof WebAuthnAuthenticatable) { + if (! $user instanceof WebAuthnAuthenticatable) { return static::INVALID_USER; } @@ -50,7 +50,7 @@ public function reset(array $credentials, Closure $callback) { $user = $this->validateReset($credentials); - if (!$user instanceof CanResetPasswordContract || !$user instanceof WebAuthnAuthenticatable) { + if (! $user instanceof CanResetPasswordContract || ! $user instanceof WebAuthnAuthenticatable) { return $user; } diff --git a/app/Helpers/Helpers.php b/app/Helpers/Helpers.php index 88221133..2953c925 100644 --- a/app/Helpers/Helpers.php +++ b/app/Helpers/Helpers.php @@ -2,8 +2,6 @@ namespace App\Helpers; -use Illuminate\Support\Str; - class Helpers { /** @@ -12,7 +10,7 @@ class Helpers * @param string|null $release * @return string|false */ - public static function cleanVersionNumber(?string $release): string|false + public static function cleanVersionNumber(?string $release) : string|false { // We use the regex for semver detection (see https://semver.org/) return preg_match('/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?/', $release, $version) ? $version[0] : false; @@ -24,7 +22,7 @@ public static function cleanVersionNumber(?string $release): string|false * @param string $str * @return string The filename */ - public static function PadToBase32Format(?string $str): string + public static function PadToBase32Format(?string $str) : string { return blank($str) ? '' : strtoupper(str_pad($str, (int) ceil(strlen($str) / 8) * 8, '=')); } diff --git a/app/Http/Controllers/Auth/WebAuthnLoginController.php b/app/Http/Controllers/Auth/WebAuthnLoginController.php index 72be2922..826a63ac 100644 --- a/app/Http/Controllers/Auth/WebAuthnLoginController.php +++ b/app/Http/Controllers/Auth/WebAuthnLoginController.php @@ -7,11 +7,11 @@ 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 { @@ -32,7 +32,7 @@ class WebAuthnLoginController extends Controller * @param \Laragear\WebAuthn\Http\Requests\AssertionRequest $request * @return \Illuminate\Contracts\Support\Responsable|\Illuminate\Http\JsonResponse */ - public function options(AssertionRequest $request): Responsable|JsonResponse + public function options(AssertionRequest $request) : Responsable|JsonResponse { switch (config('webauthn.user_verification')) { case WebAuthn::USER_VERIFICATION_DISCOURAGED: @@ -70,7 +70,7 @@ public function login(AssertedRequest $request) // Some authenticators do not send a userHandle so we hack the response to be compliant // with Larapass/webauthn-lib implementation that waits for a userHandle - if (!Arr::exists($response, 'userHandle') || blank($response['userHandle'])) { + if (! Arr::exists($response, 'userHandle') || blank($response['userHandle'])) { $response['userHandle'] = User::getFromCredentialId($request->id)?->userHandle(); $request->merge(['response' => $response]); } diff --git a/app/Http/Controllers/Auth/WebAuthnRegisterController.php b/app/Http/Controllers/Auth/WebAuthnRegisterController.php index 712d6e80..5c014ef8 100644 --- a/app/Http/Controllers/Auth/WebAuthnRegisterController.php +++ b/app/Http/Controllers/Auth/WebAuthnRegisterController.php @@ -17,7 +17,7 @@ class WebAuthnRegisterController extends Controller * @param \Laragear\WebAuthn\Http\Requests\AttestationRequest $request * @return \Illuminate\Contracts\Support\Responsable */ - public function options(AttestationRequest $request): Responsable + public function options(AttestationRequest $request) : Responsable { switch (config('webauthn.user_verification')) { case WebAuthn::USER_VERIFICATION_DISCOURAGED: @@ -40,7 +40,7 @@ public function options(AttestationRequest $request): Responsable * @param \Laragear\WebAuthn\Http\Requests\AttestedRequest $request * @return \Illuminate\Http\Response */ - public function register(AttestedRequest $request): Response + public function register(AttestedRequest $request) : Response { $request->save(); diff --git a/app/Models/TwoFAccount.php b/app/Models/TwoFAccount.php index 1f31ac26..b66afd34 100644 --- a/app/Models/TwoFAccount.php +++ b/app/Models/TwoFAccount.php @@ -22,6 +22,7 @@ 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 Spatie\EloquentSortable\Sortable; use Spatie\EloquentSortable\SortableTrait; use SteamTotp\SteamTotp; -use Illuminate\Support\Str; class TwoFAccount extends Model implements Sortable { @@ -144,13 +144,13 @@ protected static function boot() parent::boot(); static::saving(function (TwoFAccount $twofaccount) { - if (!$twofaccount->legacy_uri) { + if (! $twofaccount->legacy_uri) { $twofaccount->legacy_uri = $twofaccount->getURI(); } - if ($twofaccount->otp_type == TwoFAccount::TOTP && !$twofaccount->period) { + if ($twofaccount->otp_type == TwoFAccount::TOTP && ! $twofaccount->period) { $twofaccount->period = TwoFAccount::DEFAULT_PERIOD; } - if ($twofaccount->otp_type == TwoFAccount::HOTP && !$twofaccount->counter) { + if ($twofaccount->otp_type == TwoFAccount::HOTP && ! $twofaccount->counter) { $twofaccount->counter = TwoFAccount::DEFAULT_COUNTER; } }); @@ -255,7 +255,7 @@ public function setSecretAttribute($value) */ public function setDigitsAttribute($value) { - $this->attributes['digits'] = !$value ? 6 : $value; + $this->attributes['digits'] = ! $value ? 6 : $value; } /** @@ -266,7 +266,7 @@ public function setDigitsAttribute($value) */ public function setAlgorithmAttribute($value) { - $this->attributes['algorithm'] = !$value ? self::SHA1 : strtolower($value); + $this->attributes['algorithm'] = ! $value ? self::SHA1 : strtolower($value); } /** @@ -277,7 +277,7 @@ public function setAlgorithmAttribute($value) */ public function setPeriodAttribute($value) { - $this->attributes['period'] = !$value && $this->otp_type === self::TOTP ? self::DEFAULT_PERIOD : $value; + $this->attributes['period'] = ! $value && $this->otp_type === self::TOTP ? self::DEFAULT_PERIOD : $value; } /** @@ -376,7 +376,7 @@ public function fillWithOtpParameters(array $parameters, bool $skipIconFetching $this->enforceAsSteam(); } - if (!$this->icon && Settings::get('getOfficialIcons') && !$skipIconFetching) { + if (! $this->icon && Settings::get('getOfficialIcons') && ! $skipIconFetching) { $this->icon = $this->getDefaultIcon(); } @@ -403,7 +403,7 @@ public function fillWithURI(string $uri, bool $isSteamTotp = false, bool $skipIc // As loadFromProvisioningUri() accept URI without label (nor account nor service) we check // that the account is set - if (!$this->generator->getLabel()) { + if (! $this->generator->getLabel()) { Log::error('URI passed to fillWithURI() must contain a label'); throw ValidationException::withMessages([ @@ -428,7 +428,7 @@ public function fillWithURI(string $uri, bool $isSteamTotp = false, bool $skipIc self::setIcon($this->generator->getParameter('image')); } - if (!$this->icon && Settings::get('getOfficialIcons') && !$skipIconFetching) { + if (! $this->icon && Settings::get('getOfficialIcons') && ! $skipIconFetching) { $this->icon = $this->getDefaultIcon(); } @@ -440,7 +440,7 @@ public function fillWithURI(string $uri, bool $isSteamTotp = false, bool $skipIc /** * Compare 2 TwoFAccounts */ - public function equals(self $other): bool + public function equals(self $other) : bool { return $this->service === $other->service && $this->account === $other->account && @@ -456,7 +456,7 @@ public function equals(self $other): bool /** * Sets model attributes to STEAM values */ - private function enforceAsSteam(): void + private function enforceAsSteam() : void { $this->otp_type = self::STEAM_TOTP; $this->digits = 5; @@ -479,7 +479,7 @@ private function getGeneratorOtpType() /** * Returns an otpauth URI built with model attribute values */ - public function getURI(): string + public function getURI() : string { $this->initGenerator(); @@ -492,7 +492,7 @@ public function getURI(): string * @throws UnsupportedOtpTypeException The defined OTP type is not supported * @throws InvalidOtpParameterException One OTP parameter is invalid */ - private function initGenerator(): void + private function initGenerator() : void { try { switch ($this->otp_type) { @@ -538,11 +538,11 @@ private function initGenerator(): void /** * Store and set the provided icon - * + * * @param \Psr\Http\Message\StreamInterface|\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|resource $data * @param string|null $extension The resource extension, without the dot */ - public function setIcon($data, $extension = null): void + public function setIcon($data, $extension = null) : void { $isRemoteData = Str::startsWith($data, ['http://', 'https://']) && Validator::make( [$data], @@ -565,7 +565,7 @@ public function setIcon($data, $extension = null): void * @param string $extension The file extension, without the dot * @return string|null The filename of the stored icon or null if the operation fails */ - private function storeFileDataAsIcon($content, $extension): string|null + private function storeFileDataAsIcon($content, $extension) : string|null { $filename = self::getUniqueFilename($extension); @@ -582,14 +582,13 @@ private function storeFileDataAsIcon($content, $extension): string|null return null; } - /** * Generate a unique filename * * @param string $extension * @return string The filename */ - private function getUniqueFilename(string $extension): string + private function getUniqueFilename(string $extension) : string { return Str::random(40) . '.' . $extension; } @@ -601,7 +600,7 @@ private function getUniqueFilename(string $extension): string * @param string $disk * @return bool */ - private function isValidIcon($filename, $disk): bool + private function isValidIcon($filename, $disk) : bool { return in_array(Storage::disk($disk)->mimeType($filename), [ 'image/png', @@ -609,7 +608,7 @@ private function isValidIcon($filename, $disk): bool '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); } @@ -618,7 +617,7 @@ private function isValidIcon($filename, $disk): bool * * @return string|null The filename of the stored icon or null if the operation fails */ - private function storeRemoteImageAsIcon(string $url): string|null + private function storeRemoteImageAsIcon(string $url) : string|null { try { $path_parts = pathinfo($url); @@ -672,7 +671,7 @@ private function getDefaultIcon() /** * Returns an acceptable value */ - private function decryptOrReturn(mixed $value): mixed + private function decryptOrReturn(mixed $value) : mixed { // Decipher when needed if (Settings::get('useEncryption') && $value) { @@ -689,7 +688,7 @@ private function decryptOrReturn(mixed $value): mixed /** * Encrypt a value */ - private function encryptOrReturn(mixed $value): mixed + private function encryptOrReturn(mixed $value) : mixed { // should be replaced by laravel 8 attribute encryption casting return Settings::get('useEncryption') ? Crypt::encryptString($value) : $value; diff --git a/app/Providers/TwoFAuthServiceProvider.php b/app/Providers/TwoFAuthServiceProvider.php index 01a13d70..0eaaa391 100644 --- a/app/Providers/TwoFAuthServiceProvider.php +++ b/app/Providers/TwoFAuthServiceProvider.php @@ -50,6 +50,7 @@ public function boot() * Get the services provided by the provider. * * @codeCoverageIgnore + * * @return array */ public function provides() diff --git a/app/Services/LogoService.php b/app/Services/LogoService.php index 435f0239..5fe328a6 100644 --- a/app/Services/LogoService.php +++ b/app/Services/LogoService.php @@ -60,7 +60,7 @@ protected function getLogo($serviceName) $domain = $this->tfas->get($this->cleanDomain(strval($serviceName))); $logoFilename = $domain . '.svg'; - if ($domain && !Storage::disk('logos')->exists($logoFilename)) { + if ($domain && ! Storage::disk('logos')->exists($logoFilename)) { $this->fetchLogo($logoFilename); } @@ -72,7 +72,7 @@ protected function getLogo($serviceName) * * @return void */ - protected function setTfaCollection(): void + protected function setTfaCollection() : void { // We fetch a fresh tfaDirectory if necessary to prevent too many API calls if (Storage::disk('logos')->exists(self::TFA_JSON)) { @@ -93,7 +93,7 @@ protected function setTfaCollection(): void * * @return void */ - protected function cacheTfaDirectorySource(): void + protected function cacheTfaDirectorySource() : void { try { $response = Http::retry(3, 100)->get(self::TFA_URL); @@ -119,7 +119,7 @@ protected function cacheTfaDirectorySource(): void * @param string $logoFile Logo filename to fetch * @return void */ - protected function fetchLogo(string $logoFile): void + protected function fetchLogo(string $logoFile) : void { try { $response = Http::retry(3, 100) @@ -141,7 +141,7 @@ protected function fetchLogo(string $logoFile): void * @param string $domain * @return string Optimized domain name */ - protected function cleanDomain(string $domain): string + protected function cleanDomain(string $domain) : string { return strtolower(str_replace(['+'], ['plus'], $domain)); } @@ -153,7 +153,7 @@ protected function cleanDomain(string $domain): string * @param string $iconFilename * @return bool Weither the copy succed or not */ - protected function copyToIcons($logoFilename, $iconFilename): bool + protected function copyToIcons($logoFilename, $iconFilename) : bool { return Storage::disk('icons')->put($iconFilename, Storage::disk('logos')->get($logoFilename)); } diff --git a/app/Services/Migrators/AegisMigrator.php b/app/Services/Migrators/AegisMigrator.php index 5f9742fe..5ad7dc46 100644 --- a/app/Services/Migrators/AegisMigrator.php +++ b/app/Services/Migrators/AegisMigrator.php @@ -4,12 +4,10 @@ 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 { @@ -38,7 +36,7 @@ class AegisMigrator extends Migrator * @param mixed $migrationPayload * @return \Illuminate\Support\Collection The converted accounts */ - public function migrate(mixed $migrationPayload): Collection + public function migrate(mixed $migrationPayload) : Collection { $json = json_decode(htmlspecialchars_decode($migrationPayload), true); diff --git a/app/Services/Migrators/GoogleAuthMigrator.php b/app/Services/Migrators/GoogleAuthMigrator.php index 89332bb6..c998b573 100644 --- a/app/Services/Migrators/GoogleAuthMigrator.php +++ b/app/Services/Migrators/GoogleAuthMigrator.php @@ -23,7 +23,7 @@ class GoogleAuthMigrator extends Migrator * @param mixed $migrationPayload migration uri provided by Google Authenticator export feature * @return \Illuminate\Support\Collection The converted accounts */ - public function migrate(mixed $migrationPayload): Collection + public function migrate(mixed $migrationPayload) : Collection { try { $migrationData = base64_decode(urldecode(Str::replace('otpauth-migration://offline?data=', '', $migrationPayload))); diff --git a/app/Services/Migrators/PlainTextMigrator.php b/app/Services/Migrators/PlainTextMigrator.php index b703c2a3..8dcdb8da 100644 --- a/app/Services/Migrators/PlainTextMigrator.php +++ b/app/Services/Migrators/PlainTextMigrator.php @@ -17,7 +17,7 @@ class PlainTextMigrator extends Migrator * @param mixed $migrationPayload * @return \Illuminate\Support\Collection The converted accounts */ - public function migrate(mixed $migrationPayload): Collection + public function migrate(mixed $migrationPayload) : Collection { $otpauthURIs = preg_split('~\R~', $migrationPayload); $otpauthURIs = Arr::where($otpauthURIs, function ($value, $key) { diff --git a/app/Services/Migrators/TwoFASMigrator.php b/app/Services/Migrators/TwoFASMigrator.php index 07845257..337ec7f9 100644 --- a/app/Services/Migrators/TwoFASMigrator.php +++ b/app/Services/Migrators/TwoFASMigrator.php @@ -92,7 +92,7 @@ public function migrate(mixed $migrationPayload) : Collection $parameters['counter'] = strtolower($parameters['otp_type']) === 'hotp' && $otp_parameters['otp']['counter'] > 0 ? $otp_parameters['otp']['counter'] : null; - $parameters['period'] = strtolower($parameters['otp_type']) === 'totp' && $otp_parameters['otp']['period'] > 0 + $parameters['period'] = strtolower($parameters['otp_type']) === 'totp' && $otp_parameters['otp']['period'] > 0 ? $otp_parameters['otp']['period'] : null; diff --git a/app/Services/ReleaseRadarService.php b/app/Services/ReleaseRadarService.php index fc9eb9b5..10fa10e4 100644 --- a/app/Services/ReleaseRadarService.php +++ b/app/Services/ReleaseRadarService.php @@ -14,7 +14,7 @@ class ReleaseRadarService * * @return void */ - public function scheduledScan(): void + public function scheduledScan() : void { if ((Settings::get('lastRadarScan') + (60 * 60 * 24 * 7)) < time()) { $this->newRelease(); @@ -26,7 +26,7 @@ public function scheduledScan(): void * * @return false|string False if no new release, the new release number otherwise */ - public function manualScan(): false|string + public function manualScan() : false|string { return $this->newRelease(); } @@ -36,10 +36,9 @@ public function manualScan(): false|string * * @return false|string False if no new release, the new release number otherwise */ - protected function newRelease(): false|string + protected function newRelease() : false|string { if ($latestReleaseData = json_decode($this->getLatestReleaseData())) { - $githubVersion = Helpers::cleanVersionNumber($latestReleaseData->tag_name); $installedVersion = Helpers::cleanVersionNumber(config('2fauth.version')); @@ -62,7 +61,7 @@ protected function newRelease(): false|string * * @return string|null */ - protected function getLatestReleaseData(): string|null + protected function getLatestReleaseData() : string|null { try { $response = Http::retry(3, 100) diff --git a/tests/Api/v1/Controllers/Auth/UserControllerTest.php b/tests/Api/v1/Controllers/Auth/UserControllerTest.php index f2d13940..4a9c57a2 100644 --- a/tests/Api/v1/Controllers/Auth/UserControllerTest.php +++ b/tests/Api/v1/Controllers/Auth/UserControllerTest.php @@ -19,7 +19,7 @@ class UserControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); diff --git a/tests/Api/v1/Controllers/GroupControllerTest.php b/tests/Api/v1/Controllers/GroupControllerTest.php index 78f9d6fb..eb0926d4 100644 --- a/tests/Api/v1/Controllers/GroupControllerTest.php +++ b/tests/Api/v1/Controllers/GroupControllerTest.php @@ -21,7 +21,7 @@ class GroupControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); diff --git a/tests/Api/v1/Controllers/TwoFAccountControllerTest.php b/tests/Api/v1/Controllers/TwoFAccountControllerTest.php index a83d7445..5b21b454 100644 --- a/tests/Api/v1/Controllers/TwoFAccountControllerTest.php +++ b/tests/Api/v1/Controllers/TwoFAccountControllerTest.php @@ -9,9 +9,9 @@ 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 @@ -125,7 +125,7 @@ class TwoFAccountControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); diff --git a/tests/Api/v1/Requests/GroupAssignRequestTest.php b/tests/Api/v1/Requests/GroupAssignRequestTest.php index 5ac1e04b..6dd1bda2 100644 --- a/tests/Api/v1/Requests/GroupAssignRequestTest.php +++ b/tests/Api/v1/Requests/GroupAssignRequestTest.php @@ -32,7 +32,7 @@ public function test_user_is_authorized() /** * @dataProvider provideValidData */ - public function test_valid_data(array $data): void + public function test_valid_data(array $data) : void { $request = new GroupAssignRequest(); $validator = Validator::make($data, $request->rules()); @@ -43,7 +43,7 @@ public function test_valid_data(array $data): void /** * Provide Valid data for validation test */ - public function provideValidData(): array + public function provideValidData() : array { return [ [[ @@ -57,7 +57,7 @@ public function provideValidData(): array /** * @dataProvider provideInvalidData */ - public function test_invalid_data(array $data): void + public function test_invalid_data(array $data) : void { $request = new GroupAssignRequest(); $validator = Validator::make($data, $request->rules()); @@ -68,7 +68,7 @@ public function test_invalid_data(array $data): void /** * Provide invalid data for validation test */ - public function provideInvalidData(): array + public function provideInvalidData() : array { return [ [[ diff --git a/tests/Api/v1/Requests/GroupStoreRequestTest.php b/tests/Api/v1/Requests/GroupStoreRequestTest.php index ba81e6ae..31a9c6cf 100644 --- a/tests/Api/v1/Requests/GroupStoreRequestTest.php +++ b/tests/Api/v1/Requests/GroupStoreRequestTest.php @@ -35,7 +35,7 @@ public function test_user_is_authorized() /** * @dataProvider provideValidData */ - public function test_valid_data(array $data): void + public function test_valid_data(array $data) : void { $request = new GroupStoreRequest(); $validator = Validator::make($data, $request->rules()); @@ -46,7 +46,7 @@ public function test_valid_data(array $data): void /** * Provide Valid data for validation test */ - public function provideValidData(): array + public function provideValidData() : array { return [ [[ @@ -58,7 +58,7 @@ public function provideValidData(): array /** * @dataProvider provideInvalidData */ - public function test_invalid_data(array $data): void + public function test_invalid_data(array $data) : void { $group = new Group([ 'name' => $this->uniqueGroupName, @@ -75,7 +75,7 @@ public function test_invalid_data(array $data): void /** * Provide invalid data for validation test */ - public function provideInvalidData(): array + public function provideInvalidData() : array { return [ [[ diff --git a/tests/Api/v1/Requests/QrCodeDecodeRequestTest.php b/tests/Api/v1/Requests/QrCodeDecodeRequestTest.php index f6408aa3..93d33fb2 100644 --- a/tests/Api/v1/Requests/QrCodeDecodeRequestTest.php +++ b/tests/Api/v1/Requests/QrCodeDecodeRequestTest.php @@ -33,7 +33,7 @@ public function test_user_is_authorized() /** * @dataProvider provideValidData */ - public function test_valid_data(array $data): void + public function test_valid_data(array $data) : void { $request = new QrCodeDecodeRequest(); $validator = Validator::make($data, $request->rules()); @@ -44,7 +44,7 @@ public function test_valid_data(array $data): void /** * Provide Valid data for validation test */ - public function provideValidData(): array + public function provideValidData() : array { $file = LocalFile::fake()->validQrcode(); @@ -58,7 +58,7 @@ public function provideValidData(): array /** * @dataProvider provideInvalidData */ - public function test_invalid_data(array $data): void + public function test_invalid_data(array $data) : void { $request = new QrCodeDecodeRequest(); $validator = Validator::make($data, $request->rules()); @@ -69,7 +69,7 @@ public function test_invalid_data(array $data): void /** * Provide invalid data for validation test */ - public function provideInvalidData(): array + public function provideInvalidData() : array { return [ [[ diff --git a/tests/Api/v1/Requests/SettingStoreRequestTest.php b/tests/Api/v1/Requests/SettingStoreRequestTest.php index a25154a7..ac0950ea 100644 --- a/tests/Api/v1/Requests/SettingStoreRequestTest.php +++ b/tests/Api/v1/Requests/SettingStoreRequestTest.php @@ -35,7 +35,7 @@ public function test_user_is_authorized() /** * @dataProvider provideValidData */ - public function test_valid_data(array $data): void + public function test_valid_data(array $data) : void { $request = new SettingStoreRequest(); $validator = Validator::make($data, $request->rules()); @@ -46,7 +46,7 @@ public function test_valid_data(array $data): void /** * Provide Valid data for validation test */ - public function provideValidData(): array + public function provideValidData() : array { return [ [[ @@ -67,7 +67,7 @@ public function provideValidData(): array /** * @dataProvider provideInvalidData */ - public function test_invalid_data(array $data): void + public function test_invalid_data(array $data) : void { Settings::set($this->uniqueKey, 'uniqueValue'); @@ -80,7 +80,7 @@ public function test_invalid_data(array $data): void /** * Provide invalid data for validation test */ - public function provideInvalidData(): array + public function provideInvalidData() : array { return [ [[ diff --git a/tests/Api/v1/Requests/SettingUpdateRequestTest.php b/tests/Api/v1/Requests/SettingUpdateRequestTest.php index f1e7ba02..83276a3b 100644 --- a/tests/Api/v1/Requests/SettingUpdateRequestTest.php +++ b/tests/Api/v1/Requests/SettingUpdateRequestTest.php @@ -32,7 +32,7 @@ public function test_user_is_authorized() /** * @dataProvider provideValidData */ - public function test_valid_data(array $data): void + public function test_valid_data(array $data) : void { $request = new SettingUpdateRequest(); $validator = Validator::make($data, $request->rules()); @@ -43,7 +43,7 @@ public function test_valid_data(array $data): void /** * Provide Valid data for validation test */ - public function provideValidData(): array + public function provideValidData() : array { return [ [[ @@ -61,7 +61,7 @@ public function provideValidData(): array /** * @dataProvider provideInvalidData */ - public function test_invalid_data(array $data): void + public function test_invalid_data(array $data) : void { $request = new SettingUpdateRequest(); $validator = Validator::make($data, $request->rules()); @@ -72,7 +72,7 @@ public function test_invalid_data(array $data): void /** * Provide invalid data for validation test */ - public function provideInvalidData(): array + public function provideInvalidData() : array { return [ [[ diff --git a/tests/Api/v1/Requests/TwoFAccountBatchRequestTest.php b/tests/Api/v1/Requests/TwoFAccountBatchRequestTest.php index eff74e8e..6744447b 100644 --- a/tests/Api/v1/Requests/TwoFAccountBatchRequestTest.php +++ b/tests/Api/v1/Requests/TwoFAccountBatchRequestTest.php @@ -32,7 +32,7 @@ public function test_user_is_authorized() /** * @dataProvider provideValidData */ - public function test_valid_data(array $data): void + public function test_valid_data(array $data) : void { $request = new TwoFAccountBatchRequest(); $validator = Validator::make($data, $request->rules()); @@ -43,7 +43,7 @@ public function test_valid_data(array $data): void /** * Provide Valid data for validation test */ - public function provideValidData(): array + public function provideValidData() : array { return [ [[ @@ -58,7 +58,7 @@ public function provideValidData(): array /** * @dataProvider provideInvalidData */ - public function test_invalid_data(array $data): void + public function test_invalid_data(array $data) : void { $request = new TwoFAccountBatchRequest(); $validator = Validator::make($data, $request->rules()); @@ -69,7 +69,7 @@ public function test_invalid_data(array $data): void /** * Provide invalid data for validation test */ - public function provideInvalidData(): array + public function provideInvalidData() : array { return [ [[ diff --git a/tests/Api/v1/Requests/TwoFAccountImportRequestTest.php b/tests/Api/v1/Requests/TwoFAccountImportRequestTest.php index 77199e43..44cc478b 100644 --- a/tests/Api/v1/Requests/TwoFAccountImportRequestTest.php +++ b/tests/Api/v1/Requests/TwoFAccountImportRequestTest.php @@ -32,7 +32,7 @@ public function test_user_is_authorized() /** * @dataProvider provideValidData */ - public function test_valid_data(array $data): void + public function test_valid_data(array $data) : void { $request = new TwoFAccountImportRequest(); $validator = Validator::make($data, $request->rules()); @@ -43,7 +43,7 @@ public function test_valid_data(array $data): void /** * Provide Valid data for validation test */ - public function provideValidData(): array + public function provideValidData() : array { return [ [[ @@ -55,7 +55,7 @@ public function provideValidData(): array /** * @dataProvider provideInvalidData */ - public function test_invalid_data(array $data): void + public function test_invalid_data(array $data) : void { $request = new TwoFAccountImportRequest(); $validator = Validator::make($data, $request->rules()); @@ -66,7 +66,7 @@ public function test_invalid_data(array $data): void /** * Provide invalid data for validation test */ - public function provideInvalidData(): array + public function provideInvalidData() : array { return [ [[ diff --git a/tests/Api/v1/Requests/TwoFAccountReorderRequestTest.php b/tests/Api/v1/Requests/TwoFAccountReorderRequestTest.php index 2a546dc1..8abc324e 100644 --- a/tests/Api/v1/Requests/TwoFAccountReorderRequestTest.php +++ b/tests/Api/v1/Requests/TwoFAccountReorderRequestTest.php @@ -32,7 +32,7 @@ public function test_user_is_authorized() /** * @dataProvider provideValidData */ - public function test_valid_data(array $data): void + public function test_valid_data(array $data) : void { $request = new TwoFAccountReorderRequest(); $validator = Validator::make($data, $request->rules()); @@ -43,7 +43,7 @@ public function test_valid_data(array $data): void /** * Provide Valid data for validation test */ - public function provideValidData(): array + public function provideValidData() : array { return [ [[ @@ -58,7 +58,7 @@ public function provideValidData(): array /** * @dataProvider provideInvalidData */ - public function test_invalid_data(array $data): void + public function test_invalid_data(array $data) : void { $request = new TwoFAccountReorderRequest(); $validator = Validator::make($data, $request->rules()); @@ -69,7 +69,7 @@ public function test_invalid_data(array $data): void /** * Provide invalid data for validation test */ - public function provideInvalidData(): array + public function provideInvalidData() : array { return [ [[ diff --git a/tests/Api/v1/Requests/TwoFAccountStoreRequestTest.php b/tests/Api/v1/Requests/TwoFAccountStoreRequestTest.php index 4827ef58..1dad786e 100644 --- a/tests/Api/v1/Requests/TwoFAccountStoreRequestTest.php +++ b/tests/Api/v1/Requests/TwoFAccountStoreRequestTest.php @@ -33,7 +33,7 @@ public function test_user_is_authorized() /** * @dataProvider provideValidData */ - public function test_valid_data(array $data): void + public function test_valid_data(array $data) : void { $request = new TwoFAccountStoreRequest(); $validator = Validator::make($data, $request->rules()); @@ -44,7 +44,7 @@ public function test_valid_data(array $data): void /** * Provide Valid data for validation test */ - public function provideValidData(): array + public function provideValidData() : array { return [ [[ @@ -108,7 +108,7 @@ public function provideValidData(): array /** * @dataProvider provideInvalidData */ - public function test_invalid_data(array $data): void + public function test_invalid_data(array $data) : void { $request = new TwoFAccountStoreRequest(); $validator = Validator::make($data, $request->rules()); @@ -119,7 +119,7 @@ public function test_invalid_data(array $data): void /** * Provide invalid data for validation test */ - public function provideInvalidData(): array + public function provideInvalidData() : array { return [ [[ diff --git a/tests/Api/v1/Requests/TwoFAccountUpdateRequestTest.php b/tests/Api/v1/Requests/TwoFAccountUpdateRequestTest.php index 83483e90..9590f065 100644 --- a/tests/Api/v1/Requests/TwoFAccountUpdateRequestTest.php +++ b/tests/Api/v1/Requests/TwoFAccountUpdateRequestTest.php @@ -33,7 +33,7 @@ public function test_user_is_authorized() /** * @dataProvider provideValidData */ - public function test_valid_data(array $data): void + public function test_valid_data(array $data) : void { $request = new TwoFAccountUpdateRequest(); $validator = Validator::make($data, $request->rules()); @@ -44,7 +44,7 @@ public function test_valid_data(array $data): void /** * Provide Valid data for validation test */ - public function provideValidData(): array + public function provideValidData() : array { return [ [[ @@ -84,7 +84,7 @@ public function provideValidData(): array /** * @dataProvider provideInvalidData */ - public function test_invalid_data(array $data): void + public function test_invalid_data(array $data) : void { $request = new TwoFAccountUpdateRequest(); $validator = Validator::make($data, $request->rules()); @@ -95,7 +95,7 @@ public function test_invalid_data(array $data): void /** * Provide invalid data for validation test */ - public function provideInvalidData(): array + public function provideInvalidData() : array { return [ [[ diff --git a/tests/Api/v1/Requests/TwoFAccountUriRequestTest.php b/tests/Api/v1/Requests/TwoFAccountUriRequestTest.php index ee1b0b5c..336249a0 100644 --- a/tests/Api/v1/Requests/TwoFAccountUriRequestTest.php +++ b/tests/Api/v1/Requests/TwoFAccountUriRequestTest.php @@ -32,7 +32,7 @@ public function test_user_is_authorized() /** * @dataProvider provideValidData */ - public function test_valid_data(array $data): void + public function test_valid_data(array $data) : void { $request = new TwoFAccountUriRequest(); $validator = Validator::make($data, $request->rules()); @@ -43,7 +43,7 @@ public function test_valid_data(array $data): void /** * Provide Valid data for validation test */ - public function provideValidData(): array + public function provideValidData() : array { return [ [[ @@ -62,7 +62,7 @@ public function provideValidData(): array /** * @dataProvider provideInvalidData */ - public function test_invalid_data(array $data): void + public function test_invalid_data(array $data) : void { $request = new TwoFAccountUriRequest(); $validator = Validator::make($data, $request->rules()); @@ -73,7 +73,7 @@ public function test_invalid_data(array $data): void /** * Provide invalid data for validation test */ - public function provideInvalidData(): array + public function provideInvalidData() : array { return [ [[ diff --git a/tests/Feature/Http/Auth/LoginTest.php b/tests/Feature/Http/Auth/LoginTest.php index 1f627cb5..3171210c 100644 --- a/tests/Feature/Http/Auth/LoginTest.php +++ b/tests/Feature/Http/Auth/LoginTest.php @@ -4,8 +4,8 @@ use App\Facades\Settings; use App\Models\User; -use Tests\FeatureTestCase; use Illuminate\Support\Carbon; +use Tests\FeatureTestCase; /** * @covers \App\Http\Controllers\Auth\LoginController @@ -28,7 +28,7 @@ class LoginTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); @@ -53,7 +53,7 @@ public function test_user_login_returns_success() /** * @test - * + * * @covers \App\Rules\CaseInsensitiveEmailExists */ public function test_user_login_with_uppercased_email_returns_success() @@ -71,7 +71,7 @@ public function test_user_login_with_uppercased_email_returns_success() /** * @test - * + * * @covers \App\Http\Middleware\SkipIfAuthenticated */ public function test_user_login_already_authenticated_returns_bad_request() @@ -111,7 +111,7 @@ public function test_user_login_with_missing_data_returns_validation_error() /** * @test - * + * * @covers \App\Exceptions\Handler */ public function test_user_login_with_invalid_credentials_returns_authentication_error() @@ -184,7 +184,7 @@ public function test_user_logout_returns_validation_success() /** * @test - * + * * @covers \App\Http\Middleware\KickOutInactiveUser * @covers \App\Http\Middleware\LogUserLastSeen */ diff --git a/tests/Feature/Http/Auth/PasswordControllerTest.php b/tests/Feature/Http/Auth/PasswordControllerTest.php index ffcab462..7319e1f8 100644 --- a/tests/Feature/Http/Auth/PasswordControllerTest.php +++ b/tests/Feature/Http/Auth/PasswordControllerTest.php @@ -22,7 +22,7 @@ class PasswordControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); diff --git a/tests/Feature/Http/Auth/RegisterControllerTest.php b/tests/Feature/Http/Auth/RegisterControllerTest.php index b8cd4a34..93b35318 100644 --- a/tests/Feature/Http/Auth/RegisterControllerTest.php +++ b/tests/Feature/Http/Auth/RegisterControllerTest.php @@ -20,7 +20,7 @@ class RegisterControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); } @@ -50,7 +50,7 @@ public function test_register_returns_success() /** * @test - * + * * @covers \App\Rules\FirstUser */ public function test_register_returns_already_an_existing_user() diff --git a/tests/Feature/Http/Auth/UserControllerTest.php b/tests/Feature/Http/Auth/UserControllerTest.php index 2b24fa2e..c87fd833 100644 --- a/tests/Feature/Http/Auth/UserControllerTest.php +++ b/tests/Feature/Http/Auth/UserControllerTest.php @@ -27,7 +27,7 @@ class UserControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); diff --git a/tests/Feature/Http/Auth/WebAuthnDeviceLostControllerTest.php b/tests/Feature/Http/Auth/WebAuthnDeviceLostControllerTest.php index 0cef8d29..e158294b 100644 --- a/tests/Feature/Http/Auth/WebAuthnDeviceLostControllerTest.php +++ b/tests/Feature/Http/Auth/WebAuthnDeviceLostControllerTest.php @@ -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 @@ -25,7 +25,7 @@ class WebAuthnDeviceLostControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); @@ -52,7 +52,7 @@ public function test_sendRecoveryEmail_sends_notification_on_success() ]); $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', [ - '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', [ - 'email' => 'bad@email.com' + 'email' => 'bad@email.com', ]); } @@ -182,7 +182,7 @@ public function test_sendRecoveryEmail_is_throttled() ]); $this->assertDatabaseHas('webauthn_recoveries', [ - 'email' => $this->user->email + 'email' => $this->user->email, ]); $this->json('POST', '/webauthn/lost', [ @@ -191,7 +191,7 @@ public function test_sendRecoveryEmail_is_throttled() ->assertStatus(422) ->assertJsonValidationErrorfor('email') ->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->json('POST', '/webauthn/lost', [ - 'email' => $this->user->email + 'email' => $this->user->email, ]) ->assertStatus(500); } diff --git a/tests/Feature/Http/Auth/WebAuthnLoginControllerTest.php b/tests/Feature/Http/Auth/WebAuthnLoginControllerTest.php index 9348ea8d..87356c5c 100644 --- a/tests/Feature/Http/Auth/WebAuthnLoginControllerTest.php +++ b/tests/Feature/Http/Auth/WebAuthnLoginControllerTest.php @@ -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,36 +22,39 @@ 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 = [ - 'id' => self::CREDENTIAL_ID_ALT, - 'rawId' => self::CREDENTIAL_ID_ALT_RAW, - 'type' => 'public-key', + 'id' => self::CREDENTIAL_ID_ALT, + 'rawId' => self::CREDENTIAL_ID_ALT_RAW, + 'type' => 'public-key', 'response' => [ - 'clientDataJSON' => 'eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiaVhvem15bktpLVlEMmlSdktOYlNQQSIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3QiLCJjcm9zc09yaWdpbiI6ZmFsc2V9', + 'clientDataJSON' => 'eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiaVhvem15bktpLVlEMmlSdktOYlNQQSIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3QiLCJjcm9zc09yaWdpbiI6ZmFsc2V9', 'authenticatorData' => 'SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MFAAAAAQ==', - 'signature' => 'ca4IJ9h8bZnjMbEFuHX1zfX5LcbiPyDVz6sD1/ppR4t8++1DxKa5EdBIrfNlo8FSOv/JSzMrGGUCQvc/Ngj1KnZpO3s9OdTb54/gMDewH/K8EG4wSvxzHdL6sMbP7UUc5Wq1pcdu9MgXY8V+1gftXpzcoaae0X+mLEETgU7eB8jG0mZhVWvE4yQKuDnZA1i9r8oQhqsvG4nUw1BxvR8wAGiRR+R287LaL41k+xum5mS8zEojUmuLSH50miyVxZ4Y+/oyfxG7i+wSYGNSXlW5iNPB+2WupGS7ce4TuOgaFeMmP2a9rzP4m2IBSQoJ2FyrdzR7HwBEewqqrUVbGQw3Aw==', - 'userHandle' => self::USER_ID_ALT, - ] + '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 = [ - 'id' => self::CREDENTIAL_ID_ALT, - 'rawId' => self::CREDENTIAL_ID_ALT_RAW, - 'type' => 'public-key', + 'id' => self::CREDENTIAL_ID_ALT, + 'rawId' => self::CREDENTIAL_ID_ALT_RAW, + 'type' => 'public-key', 'response' => [ - 'clientDataJSON' => 'eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiaVhvem15bktpLVlEMmlSdktOYlNQQSIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3QiLCJjcm9zc09yaWdpbiI6ZmFsc2V9', + 'clientDataJSON' => 'eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiaVhvem15bktpLVlEMmlSdktOYlNQQSIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3QiLCJjcm9zc09yaWdpbiI6ZmFsc2V9', 'authenticatorData' => 'SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MFAAAAAQ==', - 'signature' => 'ca4IJ9h8bZnjMbEFuHX1zfX5LcbiPyDVz6sD1/ppR4t8++1DxKa5EdBIrfNlo8FSOv/JSzMrGGUCQvc/Ngj1KnZpO3s9OdTb54/gMDewH/K8EG4wSvxzHdL6sMbP7UUc5Wq1pcdu9MgXY8V+1gftXpzcoaae0X+mLEETgU7eB8jG0mZhVWvE4yQKuDnZA1i9r8oQhqsvG4nUw1BxvR8wAGiRR+R287LaL41k+xum5mS8zEojUmuLSH50miyVxZ4Y+/oyfxG7i+wSYGNSXlW5iNPB+2WupGS7ce4TuOgaFeMmP2a9rzP4m2IBSQoJ2FyrdzR7HwBEewqqrUVbGQw3Aw==', - 'userHandle' => null, - ] + 'signature' => 'ca4IJ9h8bZnjMbEFuHX1zfX5LcbiPyDVz6sD1/ppR4t8++1DxKa5EdBIrfNlo8FSOv/JSzMrGGUCQvc/Ngj1KnZpO3s9OdTb54/gMDewH/K8EG4wSvxzHdL6sMbP7UUc5Wq1pcdu9MgXY8V+1gftXpzcoaae0X+mLEETgU7eB8jG0mZhVWvE4yQKuDnZA1i9r8oQhqsvG4nUw1BxvR8wAGiRR+R287LaL41k+xum5mS8zEojUmuLSH50miyVxZ4Y+/oyfxG7i+wSYGNSXlW5iNPB+2WupGS7ce4TuOgaFeMmP2a9rzP4m2IBSQoJ2FyrdzR7HwBEewqqrUVbGQw3Aw==', + 'userHandle' => null, + ], ]; const ASSERTION_CHALLENGE = 'iXozmynKi+YD2iRvKNbSPA=='; @@ -59,7 +62,7 @@ class WebAuthnLoginControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); diff --git a/tests/Feature/Http/Auth/WebAuthnManageControllerTest.php b/tests/Feature/Http/Auth/WebAuthnManageControllerTest.php index d3678cb6..48c2fcd3 100644 --- a/tests/Feature/Http/Auth/WebAuthnManageControllerTest.php +++ b/tests/Feature/Http/Auth/WebAuthnManageControllerTest.php @@ -28,7 +28,7 @@ class WebAuthnManageControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); diff --git a/tests/Feature/Http/Auth/WebAuthnRecoveryControllerTest.php b/tests/Feature/Http/Auth/WebAuthnRecoveryControllerTest.php index 191f30d7..5c1508cd 100644 --- a/tests/Feature/Http/Auth/WebAuthnRecoveryControllerTest.php +++ b/tests/Feature/Http/Auth/WebAuthnRecoveryControllerTest.php @@ -35,7 +35,7 @@ class WebAuthnRecoveryControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); @@ -96,8 +96,8 @@ public function test_recover_with_expired_token_returns_validation_error() ]); $this->json('POST', '/webauthn/recover', [ - 'token' => self::ACTUAL_TOKEN_VALUE, - 'email' => $this->user->email, + 'token' => self::ACTUAL_TOKEN_VALUE, + 'email' => $this->user->email, 'password' => UserFactory::USER_PASSWORD, ]) ->assertStatus(422) diff --git a/tests/Feature/Http/Auth/WebAuthnRegisterControllerTest.php b/tests/Feature/Http/Auth/WebAuthnRegisterControllerTest.php index 01927c34..7b9a24fb 100644 --- a/tests/Feature/Http/Auth/WebAuthnRegisterControllerTest.php +++ b/tests/Feature/Http/Auth/WebAuthnRegisterControllerTest.php @@ -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 */ @@ -24,7 +23,7 @@ class WebAuthnRegisterControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); @@ -34,7 +33,7 @@ public function setUp(): void /** * @test */ - public function test_uses_attestation_with_fastRegistration_request(): void + public function test_uses_attestation_with_fastRegistration_request() : void { Config::set('webauthn.user_verification', WebAuthn::USER_VERIFICATION_DISCOURAGED); @@ -51,7 +50,7 @@ public function test_uses_attestation_with_fastRegistration_request(): void /** * @test */ - public function test_uses_attestation_with_secureRegistration_request(): void + public function test_uses_attestation_with_secureRegistration_request() : void { Config::set('webauthn.user_verification', WebAuthn::USER_VERIFICATION_REQUIRED); @@ -68,7 +67,7 @@ public function test_uses_attestation_with_secureRegistration_request(): void /** * @test */ - public function test_register_uses_attested_request(): void + public function test_register_uses_attested_request() : void { $this->mock(AttestedRequest::class)->expects('save')->andReturn(); diff --git a/tests/Feature/Http/SystemControllerTest.php b/tests/Feature/Http/SystemControllerTest.php index 7377256c..de701889 100644 --- a/tests/Feature/Http/SystemControllerTest.php +++ b/tests/Feature/Http/SystemControllerTest.php @@ -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; /** @@ -22,7 +22,7 @@ class SystemControllerTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); diff --git a/tests/Feature/Models/TwoFAccountModelTest.php b/tests/Feature/Models/TwoFAccountModelTest.php index ca1a144f..28ef21d1 100644 --- a/tests/Feature/Models/TwoFAccountModelTest.php +++ b/tests/Feature/Models/TwoFAccountModelTest.php @@ -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,14 +27,13 @@ class TwoFAccountModelTest extends FeatureTestCase /** * Helpers $helpers; - */ protected $helpers; /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); @@ -461,7 +459,6 @@ public function test_getOTP_for_totp_returns_the_same_password() */ 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 @@ public function test_getURI_for_custom_hotp_model_returns_uri() */ public function test_fill_succeed_when_image_fetching_fails() { - Http::preventStrayRequests(); Storage::fake('imagesLink'); @@ -585,11 +581,11 @@ public function test_fill_succeed_when_image_fetching_fails() */ public function test_saving_totp_without_period_set_default_one() { - $twofaccount = new TwoFAccount; - $twofaccount->service = OtpTestData::SERVICE; - $twofaccount->account = OtpTestData::ACCOUNT; + $twofaccount = new TwoFAccount; + $twofaccount->service = OtpTestData::SERVICE; + $twofaccount->account = OtpTestData::ACCOUNT; $twofaccount->otp_type = TwoFAccount::TOTP; - $twofaccount->secret = OtpTestData::SECRET; + $twofaccount->secret = OtpTestData::SECRET; $twofaccount->save(); @@ -603,11 +599,11 @@ public function test_saving_totp_without_period_set_default_one() */ public function test_saving_hotp_without_counter_set_default_one() { - $twofaccount = new TwoFAccount; - $twofaccount->service = OtpTestData::SERVICE; - $twofaccount->account = OtpTestData::ACCOUNT; + $twofaccount = new TwoFAccount; + $twofaccount->service = OtpTestData::SERVICE; + $twofaccount->account = OtpTestData::ACCOUNT; $twofaccount->otp_type = TwoFAccount::HOTP; - $twofaccount->secret = OtpTestData::SECRET; + $twofaccount->secret = OtpTestData::SECRET; $twofaccount->save(); @@ -660,7 +656,7 @@ public function test_equals_returns_false() /** * @test - * + * * @dataProvider iconResourceProvider */ public function test_set_icon_stores_and_set_the_icon($res, $ext) @@ -708,7 +704,7 @@ public function iconResourceProvider() /** * @test - * + * * @dataProvider invalidIconResourceProvider */ public function test_set_invalid_icon_ends_without_error($res, $ext) diff --git a/tests/Feature/Services/GroupServiceTest.php b/tests/Feature/Services/GroupServiceTest.php index ccf1a271..a8af2730 100644 --- a/tests/Feature/Services/GroupServiceTest.php +++ b/tests/Feature/Services/GroupServiceTest.php @@ -53,7 +53,7 @@ class GroupServiceTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); diff --git a/tests/Feature/Services/LogoServiceTest.php b/tests/Feature/Services/LogoServiceTest.php index fadc7fe5..9645320f 100644 --- a/tests/Feature/Services/LogoServiceTest.php +++ b/tests/Feature/Services/LogoServiceTest.php @@ -4,11 +4,10 @@ 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 @@ -20,7 +19,7 @@ class LogoServiceTest extends TestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); } @@ -30,20 +29,20 @@ public function setUp(): void */ public function test_getIcon_returns_stored_icon_file_when_logo_exists() { - $svgLogo = HttpRequestTestData::SVG_LOGO_BODY; + $svgLogo = HttpRequestTestData::SVG_LOGO_BODY; $tfaJsonBody = HttpRequestTestData::TFA_JSON_BODY; Http::preventStrayRequests(); Http::fake([ 'https://raw.githubusercontent.com/2factorauth/twofactorauth/master/img/*' => Http::response($svgLogo, 200), - 'https://2fa.directory/api/v3/tfa.json' => Http::response($tfaJsonBody, 200), + 'https://2fa.directory/api/v3/tfa.json' => Http::response($tfaJsonBody, 200), ]); Storage::fake('icons'); Storage::fake('logos'); $logoService = new LogoService(); - $icon = $logoService->getIcon('twitter'); + $icon = $logoService->getIcon('twitter'); $this->assertNotNull($icon); Storage::disk('icons')->assertExists($icon); @@ -117,7 +116,7 @@ public function test_logoService_loads_empty_collection_when_tfajson_fetching_fa Storage::fake('logos'); $logoService = new LogoService(); - $icon = $logoService->getIcon('twitter'); + $icon = $logoService->getIcon('twitter'); $this->assertNull($icon); Storage::disk('logos')->assertMissing(LogoService::TFA_JSON); diff --git a/tests/Feature/Services/QrCodeServiceTest.php b/tests/Feature/Services/QrCodeServiceTest.php index e0dbea58..47081959 100644 --- a/tests/Feature/Services/QrCodeServiceTest.php +++ b/tests/Feature/Services/QrCodeServiceTest.php @@ -21,7 +21,7 @@ class QrCodeServiceTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); } diff --git a/tests/Feature/Services/ReleaseRadarServiceTest.php b/tests/Feature/Services/ReleaseRadarServiceTest.php index ee9a7150..ad7bcbcb 100644 --- a/tests/Feature/Services/ReleaseRadarServiceTest.php +++ b/tests/Feature/Services/ReleaseRadarServiceTest.php @@ -5,9 +5,9 @@ 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 @@ -29,15 +29,15 @@ public function test_manualScan_returns_no_new_release() ]); $releaseRadarService = new ReleaseRadarService(); - $release = $releaseRadarService->manualScan(); + $release = $releaseRadarService->manualScan(); $this->assertFalse($release); $this->assertDatabaseHas('options', [ - 'key' => 'lastRadarScan', + 'key' => 'lastRadarScan', ]); $this->assertDatabaseMissing('options', [ - 'key' => 'latestRelease', - 'value' => HttpRequestTestData::TAG_NAME + 'key' => 'latestRelease', + 'value' => HttpRequestTestData::TAG_NAME, ]); } @@ -54,15 +54,15 @@ public function test_manualScan_returns_new_release() ]); $releaseRadarService = new ReleaseRadarService(); - $release = $releaseRadarService->manualScan(); + $release = $releaseRadarService->manualScan(); $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', + 'key' => 'lastRadarScan', ]); } @@ -77,7 +77,7 @@ public function test_manualScan_succeed_when_something_fails() Http::preventStrayRequests(); $releaseRadarService = new ReleaseRadarService(); - $release = $releaseRadarService->manualScan(); + $release = $releaseRadarService->manualScan(); $this->assertFalse($release); } @@ -95,7 +95,7 @@ public function test_manualScan_succeed_when_github_is_unreachable() ]); $releaseRadarService = new ReleaseRadarService(); - $release = $releaseRadarService->manualScan(); + $release = $releaseRadarService->manualScan(); $this->assertFalse($release); } diff --git a/tests/Feature/Services/SettingServiceTest.php b/tests/Feature/Services/SettingServiceTest.php index 8c679fe2..4445225c 100644 --- a/tests/Feature/Services/SettingServiceTest.php +++ b/tests/Feature/Services/SettingServiceTest.php @@ -58,7 +58,7 @@ class SettingServiceTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); @@ -239,7 +239,7 @@ public function test_set_useEncryption_off_returns_exception_when_data_are_undec /** * Provide invalid data for validation test */ - public function provideUndecipherableData(): array + public function provideUndecipherableData() : array { return [ [[ diff --git a/tests/Feature/Services/TwoFAccountServiceTest.php b/tests/Feature/Services/TwoFAccountServiceTest.php index d78c2bcd..4240b80a 100644 --- a/tests/Feature/Services/TwoFAccountServiceTest.php +++ b/tests/Feature/Services/TwoFAccountServiceTest.php @@ -5,9 +5,9 @@ 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 @@ -33,7 +33,7 @@ class TwoFAccountServiceTest extends FeatureTestCase /** * @test */ - public function setUp(): void + public function setUp() : void { parent::setUp(); diff --git a/tests/Unit/Exceptions/HandlerTest.php b/tests/Unit/Exceptions/HandlerTest.php index d9a8c002..39997c40 100644 --- a/tests/Unit/Exceptions/HandlerTest.php +++ b/tests/Unit/Exceptions/HandlerTest.php @@ -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 @@ -50,7 +50,7 @@ public function test_exceptions_returns_badRequest_json_response($exception) /** * Provide Valid data for validation test */ - public function provideExceptionsforBadRequest(): array + public function provideExceptionsforBadRequest() : array { return [ [ @@ -111,7 +111,7 @@ public function test_exceptions_returns_notFound_json_response($exception) /** * Provide Valid data for validation test */ - public function provideExceptionsforNotFound(): array + public function provideExceptionsforNotFound() : array { return [ [ diff --git a/tests/Unit/HelpersTest.php b/tests/Unit/HelpersTest.php index c324ffa3..3865fea6 100644 --- a/tests/Unit/HelpersTest.php +++ b/tests/Unit/HelpersTest.php @@ -12,7 +12,7 @@ class HelpersTest extends TestCase { /** * @test - * + * * @dataProvider versionNumberProvider */ public function test_cleanVersionNumber_returns_cleaned_version($dirtyVersion, $expected) @@ -49,7 +49,7 @@ public function versionNumberProvider() /** * @test - * + * * @dataProvider invalidVersionNumberProvider */ public function test_cleanVersionNumber_returns_false_with_invalid_semver($dirtyVersion) @@ -85,7 +85,7 @@ public function invalidVersionNumberProvider() /** * @test - * + * * @dataProvider toBase32PaddedStringProvider */ public function test_toBase32Format_returns_base32_formated_string($str, $expected) diff --git a/tests/Unit/Listeners/DissociateTwofaccountFromGroupTest.php b/tests/Unit/Listeners/DissociateTwofaccountFromGroupTest.php index bf807844..0d82041b 100644 --- a/tests/Unit/Listeners/DissociateTwofaccountFromGroupTest.php +++ b/tests/Unit/Listeners/DissociateTwofaccountFromGroupTest.php @@ -7,8 +7,8 @@ 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 @@ -17,21 +17,20 @@ class DissociateTwofaccountFromGroupTest extends TestCase { /** * @test - * + * * @runInSeparateProcess * @preserveGlobalState disabled */ public function test_twofaccount_is_released_on_group_deletion() { - $this->mock('alias:' . TwoFAccount::class, function (MockInterface $twoFAccount) { $twoFAccount->shouldReceive('where->update') ->once() ->andReturn(1); }); - $group = Group::factory()->make(); - $event = new GroupDeleting($group); + $group = Group::factory()->make(); + $event = new GroupDeleting($group); $listener = new DissociateTwofaccountFromGroup(); $this->assertNull($listener->handle($event)); diff --git a/tests/Unit/MigratorTest.php b/tests/Unit/MigratorTest.php index 6f8773b2..7db74f0e 100644 --- a/tests/Unit/MigratorTest.php +++ b/tests/Unit/MigratorTest.php @@ -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 @@ * @covers \App\Services\Migrators\TwoFASMigrator * @covers \App\Services\Migrators\PlainTextMigrator * @covers \App\Services\Migrators\GoogleAuthMigrator + * * @uses \App\Models\TwoFAccount */ class MigratorTest extends TestCase @@ -61,7 +59,7 @@ class MigratorTest extends TestCase */ protected $GAuthTotpBisTwofaccount; - public function setUp(): void + public function setUp() : void { parent::setUp(); @@ -111,30 +109,30 @@ public function setUp(): void $this->steamTwofaccount->period = OtpTestData::PERIOD_DEFAULT; $this->steamTwofaccount->counter = null; - $this->GAuthTotpTwofaccount = new TwoFAccount; - $this->GAuthTotpTwofaccount->service = OtpTestData::SERVICE; - $this->GAuthTotpTwofaccount->account = OtpTestData::ACCOUNT; - $this->GAuthTotpTwofaccount->icon = null; - $this->GAuthTotpTwofaccount->otp_type = 'totp'; - $this->GAuthTotpTwofaccount->secret = OtpTestData::SECRET; - $this->GAuthTotpTwofaccount->digits = OtpTestData::DIGITS_DEFAULT; - $this->GAuthTotpTwofaccount->algorithm = OtpTestData::ALGORITHM_DEFAULT; - $this->GAuthTotpTwofaccount->period = OtpTestData::PERIOD_DEFAULT; - $this->GAuthTotpTwofaccount->counter = null; + $this->GAuthTotpTwofaccount = new TwoFAccount; + $this->GAuthTotpTwofaccount->service = OtpTestData::SERVICE; + $this->GAuthTotpTwofaccount->account = OtpTestData::ACCOUNT; + $this->GAuthTotpTwofaccount->icon = null; + $this->GAuthTotpTwofaccount->otp_type = 'totp'; + $this->GAuthTotpTwofaccount->secret = OtpTestData::SECRET; + $this->GAuthTotpTwofaccount->digits = OtpTestData::DIGITS_DEFAULT; + $this->GAuthTotpTwofaccount->algorithm = OtpTestData::ALGORITHM_DEFAULT; + $this->GAuthTotpTwofaccount->period = OtpTestData::PERIOD_DEFAULT; + $this->GAuthTotpTwofaccount->counter = null; - $this->GAuthTotpBisTwofaccount = new TwoFAccount; - $this->GAuthTotpBisTwofaccount->service = OtpTestData::SERVICE . '_bis'; - $this->GAuthTotpBisTwofaccount->account = OtpTestData::ACCOUNT . '_bis'; - $this->GAuthTotpBisTwofaccount->icon = null; - $this->GAuthTotpBisTwofaccount->otp_type = 'totp'; - $this->GAuthTotpBisTwofaccount->secret = OtpTestData::SECRET; - $this->GAuthTotpBisTwofaccount->digits = OtpTestData::DIGITS_DEFAULT; - $this->GAuthTotpBisTwofaccount->algorithm = OtpTestData::ALGORITHM_DEFAULT; - $this->GAuthTotpBisTwofaccount->period = OtpTestData::PERIOD_DEFAULT; - $this->GAuthTotpBisTwofaccount->counter = null; + $this->GAuthTotpBisTwofaccount = new TwoFAccount; + $this->GAuthTotpBisTwofaccount->service = OtpTestData::SERVICE . '_bis'; + $this->GAuthTotpBisTwofaccount->account = OtpTestData::ACCOUNT . '_bis'; + $this->GAuthTotpBisTwofaccount->icon = null; + $this->GAuthTotpBisTwofaccount->otp_type = 'totp'; + $this->GAuthTotpBisTwofaccount->secret = OtpTestData::SECRET; + $this->GAuthTotpBisTwofaccount->digits = OtpTestData::DIGITS_DEFAULT; + $this->GAuthTotpBisTwofaccount->algorithm = OtpTestData::ALGORITHM_DEFAULT; + $this->GAuthTotpBisTwofaccount->period = OtpTestData::PERIOD_DEFAULT; + $this->GAuthTotpBisTwofaccount->counter = null; - $this->fakeTwofaccount = new TwoFAccount; - $this->fakeTwofaccount->id = TwoFAccount::FAKE_ID; + $this->fakeTwofaccount = new TwoFAccount; + $this->fakeTwofaccount->id = TwoFAccount::FAKE_ID; } /** @@ -179,25 +177,25 @@ public function validMigrationsProvider() 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(), @@ -315,7 +313,7 @@ public function migrationWithInvalidAccountsProvider() /** * @test - * + * * @runInSeparateProcess * @preserveGlobalState disabled */ @@ -466,18 +464,15 @@ public function encryptedMigrationDataProvider() { 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 + protected function tearDown() : void { Mockery::close(); } diff --git a/tests/Unit/TwoFAccountModelTest.php b/tests/Unit/TwoFAccountModelTest.php index 224e55e2..e11242e3 100644 --- a/tests/Unit/TwoFAccountModelTest.php +++ b/tests/Unit/TwoFAccountModelTest.php @@ -59,7 +59,7 @@ public function test_sensitive_attributes_are_stored_encrypted(string $attribute /** * Provide attributes to test for encryption */ - public function provideSensitiveAttributes(): array + public function provideSensitiveAttributes() : array { return [ [ @@ -115,7 +115,7 @@ public function test_indecipherable_attributes_returns_masked_value(string $attr /** * @test - * + * * @runInSeparateProcess * @preserveGlobalState disabled */