Apply Laravel Pint fixes

This commit is contained in:
Bubka
2022-11-22 15:15:52 +01:00
parent d84dd6659e
commit d6fd8e3c52
178 changed files with 2409 additions and 2899 deletions

View File

@ -3,8 +3,8 @@
namespace Tests\Feature\Models;
use App\Models\TwoFAccount;
use Tests\FeatureTestCase;
use Tests\Classes\OtpTestData;
use Tests\FeatureTestCase;
/**
* @covers \App\Models\TwoFAccount
@ -16,13 +16,11 @@ class TwoFAccountModelTest extends FeatureTestCase
*/
protected $customTotpTwofaccount;
/**
* App\Models\TwoFAccount $customTotpTwofaccount
*/
protected $customHotpTwofaccount;
/**
* @test
*/
@ -30,49 +28,48 @@ class TwoFAccountModelTest extends FeatureTestCase
{
parent::setUp();
$this->customTotpTwofaccount = new TwoFAccount;
$this->customTotpTwofaccount = new TwoFAccount;
$this->customTotpTwofaccount->legacy_uri = OtpTestData::TOTP_FULL_CUSTOM_URI;
$this->customTotpTwofaccount->service = OtpTestData::SERVICE;
$this->customTotpTwofaccount->account = OtpTestData::ACCOUNT;
$this->customTotpTwofaccount->icon = OtpTestData::ICON;
$this->customTotpTwofaccount->otp_type = 'totp';
$this->customTotpTwofaccount->secret = OtpTestData::SECRET;
$this->customTotpTwofaccount->digits = OtpTestData::DIGITS_CUSTOM;
$this->customTotpTwofaccount->algorithm = OtpTestData::ALGORITHM_CUSTOM;
$this->customTotpTwofaccount->period = OtpTestData::PERIOD_CUSTOM;
$this->customTotpTwofaccount->counter = null;
$this->customTotpTwofaccount->service = OtpTestData::SERVICE;
$this->customTotpTwofaccount->account = OtpTestData::ACCOUNT;
$this->customTotpTwofaccount->icon = OtpTestData::ICON;
$this->customTotpTwofaccount->otp_type = 'totp';
$this->customTotpTwofaccount->secret = OtpTestData::SECRET;
$this->customTotpTwofaccount->digits = OtpTestData::DIGITS_CUSTOM;
$this->customTotpTwofaccount->algorithm = OtpTestData::ALGORITHM_CUSTOM;
$this->customTotpTwofaccount->period = OtpTestData::PERIOD_CUSTOM;
$this->customTotpTwofaccount->counter = null;
$this->customTotpTwofaccount->save();
$this->customHotpTwofaccount = new TwoFAccount;
$this->customHotpTwofaccount = new TwoFAccount;
$this->customHotpTwofaccount->legacy_uri = OtpTestData::HOTP_FULL_CUSTOM_URI;
$this->customHotpTwofaccount->service = OtpTestData::SERVICE;
$this->customHotpTwofaccount->account = OtpTestData::ACCOUNT;
$this->customHotpTwofaccount->icon = OtpTestData::ICON;
$this->customHotpTwofaccount->otp_type = 'hotp';
$this->customHotpTwofaccount->secret = OtpTestData::SECRET;
$this->customHotpTwofaccount->digits = OtpTestData::DIGITS_CUSTOM;
$this->customHotpTwofaccount->algorithm = OtpTestData::ALGORITHM_CUSTOM;
$this->customHotpTwofaccount->period = null;
$this->customHotpTwofaccount->counter = OtpTestData::COUNTER_CUSTOM;
$this->customHotpTwofaccount->service = OtpTestData::SERVICE;
$this->customHotpTwofaccount->account = OtpTestData::ACCOUNT;
$this->customHotpTwofaccount->icon = OtpTestData::ICON;
$this->customHotpTwofaccount->otp_type = 'hotp';
$this->customHotpTwofaccount->secret = OtpTestData::SECRET;
$this->customHotpTwofaccount->digits = OtpTestData::DIGITS_CUSTOM;
$this->customHotpTwofaccount->algorithm = OtpTestData::ALGORITHM_CUSTOM;
$this->customHotpTwofaccount->period = null;
$this->customHotpTwofaccount->counter = OtpTestData::COUNTER_CUSTOM;
$this->customHotpTwofaccount->save();
$this->customSteamTotpTwofaccount = new TwoFAccount;
$this->customSteamTotpTwofaccount = new TwoFAccount;
$this->customSteamTotpTwofaccount->legacy_uri = OtpTestData::STEAM_TOTP_URI;
$this->customSteamTotpTwofaccount->service = OtpTestData::STEAM;
$this->customSteamTotpTwofaccount->account = OtpTestData::ACCOUNT;
$this->customSteamTotpTwofaccount->otp_type = 'steamtotp';
$this->customSteamTotpTwofaccount->secret = OtpTestData::STEAM_SECRET;
$this->customSteamTotpTwofaccount->digits = OtpTestData::DIGITS_STEAM;
$this->customSteamTotpTwofaccount->algorithm = OtpTestData::ALGORITHM_DEFAULT;
$this->customSteamTotpTwofaccount->period = OtpTestData::PERIOD_DEFAULT;
$this->customSteamTotpTwofaccount->counter = null;
$this->customSteamTotpTwofaccount->service = OtpTestData::STEAM;
$this->customSteamTotpTwofaccount->account = OtpTestData::ACCOUNT;
$this->customSteamTotpTwofaccount->otp_type = 'steamtotp';
$this->customSteamTotpTwofaccount->secret = OtpTestData::STEAM_SECRET;
$this->customSteamTotpTwofaccount->digits = OtpTestData::DIGITS_STEAM;
$this->customSteamTotpTwofaccount->algorithm = OtpTestData::ALGORITHM_DEFAULT;
$this->customSteamTotpTwofaccount->period = OtpTestData::PERIOD_DEFAULT;
$this->customSteamTotpTwofaccount->counter = null;
$this->customSteamTotpTwofaccount->save();
}
/**
* @test
*/
* @test
*/
public function test_fill_with_custom_totp_uri_returns_correct_value()
{
$twofaccount = new TwoFAccount;
@ -87,10 +84,9 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->assertEquals(OtpTestData::PERIOD_CUSTOM, $twofaccount->period);
$this->assertEquals(null, $twofaccount->counter);
$this->assertEquals(OtpTestData::ALGORITHM_CUSTOM, $twofaccount->algorithm);
$this->assertStringEndsWith('.png',$twofaccount->icon);
$this->assertStringEndsWith('.png', $twofaccount->icon);
}
/**
* @test
*/
@ -111,7 +107,6 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->assertEquals(null, $twofaccount->icon);
}
/**
* @test
*/
@ -129,10 +124,9 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->assertEquals(null, $twofaccount->period);
$this->assertEquals(OtpTestData::COUNTER_CUSTOM, $twofaccount->counter);
$this->assertEquals(OtpTestData::ALGORITHM_CUSTOM, $twofaccount->algorithm);
$this->assertStringEndsWith('.png',$twofaccount->icon);
$this->assertStringEndsWith('.png', $twofaccount->icon);
}
/**
* @test
*/
@ -153,7 +147,6 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->assertEquals(null, $twofaccount->icon);
}
/**
* @test
*/
@ -164,20 +157,19 @@ class TwoFAccountModelTest extends FeatureTestCase
$twofaccount->save();
$this->assertDatabaseHas('twofaccounts', [
'otp_type' => 'totp',
'legacy_uri' => OtpTestData::TOTP_SHORT_URI,
'service' => null,
'account' => OtpTestData::ACCOUNT,
'secret' => OtpTestData::SECRET,
'digits' => OtpTestData::DIGITS_DEFAULT,
'period' => OtpTestData::PERIOD_DEFAULT,
'counter' => null,
'algorithm' => OtpTestData::ALGORITHM_DEFAULT,
'icon' => null,
'otp_type' => 'totp',
'legacy_uri' => OtpTestData::TOTP_SHORT_URI,
'service' => null,
'account' => OtpTestData::ACCOUNT,
'secret' => OtpTestData::SECRET,
'digits' => OtpTestData::DIGITS_DEFAULT,
'period' => OtpTestData::PERIOD_DEFAULT,
'counter' => null,
'algorithm' => OtpTestData::ALGORITHM_DEFAULT,
'icon' => null,
]);
}
/**
* @test
*/
@ -188,7 +180,6 @@ class TwoFAccountModelTest extends FeatureTestCase
$twofaccount->fillWithURI(OtpTestData::INVALID_OTPAUTH_URI);
}
/**
* @test
*/
@ -196,10 +187,9 @@ class TwoFAccountModelTest extends FeatureTestCase
{
$this->expectException(\Illuminate\Validation\ValidationException::class);
$twofaccount = new TwoFAccount;
$twofaccount->fillWithURI('otpauth://totp/?secret='.OtpTestData::SECRET);
$twofaccount->fillWithURI('otpauth://totp/?secret=' . OtpTestData::SECRET);
}
/**
* @test
*/
@ -216,10 +206,9 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->assertEquals(OtpTestData::PERIOD_CUSTOM, $twofaccount->period);
$this->assertEquals(null, $twofaccount->counter);
$this->assertEquals(OtpTestData::ALGORITHM_CUSTOM, $twofaccount->algorithm);
$this->assertStringEndsWith('.png',$twofaccount->icon);
$this->assertStringEndsWith('.png', $twofaccount->icon);
}
/**
* @test
*/
@ -239,7 +228,6 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->assertEquals(null, $twofaccount->icon);
}
/**
* @test
*/
@ -256,10 +244,9 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->assertEquals(null, $twofaccount->period);
$this->assertEquals(OtpTestData::COUNTER_CUSTOM, $twofaccount->counter);
$this->assertEquals(OtpTestData::ALGORITHM_CUSTOM, $twofaccount->algorithm);
$this->assertStringEndsWith('.png',$twofaccount->icon);
$this->assertStringEndsWith('.png', $twofaccount->icon);
}
/**
* @test
*/
@ -279,7 +266,6 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->assertEquals(null, $twofaccount->icon);
}
/**
* @test
*/
@ -290,20 +276,19 @@ class TwoFAccountModelTest extends FeatureTestCase
$twofaccount->save();
$this->assertDatabaseHas('twofaccounts', [
'otp_type' => 'totp',
'legacy_uri' => OtpTestData::TOTP_SHORT_URI,
'service' => null,
'account' => OtpTestData::ACCOUNT,
'secret' => OtpTestData::SECRET,
'digits' => OtpTestData::DIGITS_DEFAULT,
'period' => OtpTestData::PERIOD_DEFAULT,
'counter' => null,
'algorithm' => OtpTestData::ALGORITHM_DEFAULT,
'icon' => null,
'otp_type' => 'totp',
'legacy_uri' => OtpTestData::TOTP_SHORT_URI,
'service' => null,
'account' => OtpTestData::ACCOUNT,
'secret' => OtpTestData::SECRET,
'digits' => OtpTestData::DIGITS_DEFAULT,
'period' => OtpTestData::PERIOD_DEFAULT,
'counter' => null,
'algorithm' => OtpTestData::ALGORITHM_DEFAULT,
'icon' => null,
]);
}
/**
* @test
*/
@ -314,7 +299,6 @@ class TwoFAccountModelTest extends FeatureTestCase
$twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_PARAMETERS_FOR_UNSUPPORTED_OTP_TYPE);
}
/**
* @test
*/
@ -323,13 +307,12 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->expectException(\App\Exceptions\InvalidOtpParameterException::class);
$twofaccount = new TwoFAccount;
$twofaccount->fillWithOtpParameters([
'account' => OtpTestData::ACCOUNT,
'otp_type' => 'totp',
'digits' => 'notsupported',
'account' => OtpTestData::ACCOUNT,
'otp_type' => 'totp',
'digits' => 'notsupported',
]);
}
/**
* @test
*/
@ -344,7 +327,6 @@ class TwoFAccountModelTest extends FeatureTestCase
]);
}
/**
* @test
*/
@ -365,7 +347,6 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->assertEquals(null, $twofaccount->icon);
}
/**
* @test
*/
@ -386,7 +367,6 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->assertEquals(null, $twofaccount->icon);
}
/**
* @test
*/
@ -397,19 +377,18 @@ class TwoFAccountModelTest extends FeatureTestCase
$twofaccount->save();
$this->assertDatabaseHas('twofaccounts', [
'otp_type' => 'totp',
'service' => null,
'account' => OtpTestData::ACCOUNT,
'secret' => OtpTestData::SECRET,
'digits' => OtpTestData::DIGITS_DEFAULT,
'period' => OtpTestData::PERIOD_DEFAULT,
'counter' => null,
'algorithm' => OtpTestData::ALGORITHM_DEFAULT,
'icon' => null,
'otp_type' => 'totp',
'service' => null,
'account' => OtpTestData::ACCOUNT,
'secret' => OtpTestData::SECRET,
'digits' => OtpTestData::DIGITS_DEFAULT,
'period' => OtpTestData::PERIOD_DEFAULT,
'counter' => null,
'algorithm' => OtpTestData::ALGORITHM_DEFAULT,
'icon' => null,
]);
}
/**
* @test
*/
@ -418,13 +397,13 @@ class TwoFAccountModelTest extends FeatureTestCase
$twofaccount = new TwoFAccount;
$otp_from_model = $this->customTotpTwofaccount->getOTP();
$otp_from_uri = $twofaccount->fillWithURI(OtpTestData::TOTP_FULL_CUSTOM_URI)->getOTP();
$otp_from_uri = $twofaccount->fillWithURI(OtpTestData::TOTP_FULL_CUSTOM_URI)->getOTP();
if ($otp_from_model->generated_at === $otp_from_uri->generated_at) {
$this->assertEquals($otp_from_model, $otp_from_uri);
}
$otp_from_model = $this->customTotpTwofaccount->getOTP();
$otp_from_model = $this->customTotpTwofaccount->getOTP();
$otp_from_parameters = $twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_CUSTOM_TOTP)->getOTP();
if ($otp_from_model->generated_at === $otp_from_parameters->generated_at) {
@ -432,7 +411,6 @@ class TwoFAccountModelTest extends FeatureTestCase
}
}
/**
* @test
*/
@ -441,7 +419,7 @@ class TwoFAccountModelTest extends FeatureTestCase
$twofaccount = new TwoFAccount;
$otp_from_model = $this->customHotpTwofaccount->getOTP();
$otp_from_uri = $twofaccount->fillWithURI(OtpTestData::HOTP_FULL_CUSTOM_URI)->getOTP();
$otp_from_uri = $twofaccount->fillWithURI(OtpTestData::HOTP_FULL_CUSTOM_URI)->getOTP();
$this->assertEquals($otp_from_model, $otp_from_uri);
@ -450,7 +428,6 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->assertEquals($otp_from_model, $otp_from_parameters);
}
/**
* @test
*/
@ -459,13 +436,13 @@ class TwoFAccountModelTest extends FeatureTestCase
$twofaccount = new TwoFAccount;
$otp_from_model = $this->customSteamTotpTwofaccount->getOTP();
$otp_from_uri = $twofaccount->fillWithURI(OtpTestData::STEAM_TOTP_URI)->getOTP();
$otp_from_uri = $twofaccount->fillWithURI(OtpTestData::STEAM_TOTP_URI)->getOTP();
if ($otp_from_model->generated_at === $otp_from_uri->generated_at) {
$this->assertEquals($otp_from_model, $otp_from_uri);
}
$otp_from_model = $this->customSteamTotpTwofaccount->getOTP();
$otp_from_model = $this->customSteamTotpTwofaccount->getOTP();
$otp_from_parameters = $twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_STEAM_TOTP)->getOTP();
if ($otp_from_model->generated_at === $otp_from_parameters->generated_at) {
@ -473,7 +450,6 @@ class TwoFAccountModelTest extends FeatureTestCase
}
}
/**
* @test
*/
@ -482,10 +458,9 @@ class TwoFAccountModelTest extends FeatureTestCase
$twofaccount = new TwoFAccount;
$this->expectException(\App\Exceptions\InvalidSecretException::class);
$otp_from_uri = $twofaccount->fillWithURI('otpauth://totp/'.OtpTestData::ACCOUNT.'?secret=0')->getOTP();
$otp_from_uri = $twofaccount->fillWithURI('otpauth://totp/' . OtpTestData::ACCOUNT . '?secret=0')->getOTP();
}
/**
* @test
*/
@ -495,44 +470,41 @@ class TwoFAccountModelTest extends FeatureTestCase
$this->expectException(\App\Exceptions\UndecipherableException::class);
$otp_from_uri = $twofaccount->fillWithOtpParameters([
'account' => OtpTestData::ACCOUNT,
'otp_type' => 'totp',
'secret' => __('errors.indecipherable'),
'account' => OtpTestData::ACCOUNT,
'otp_type' => 'totp',
'secret' => __('errors.indecipherable'),
])->getOTP();
}
/**
* @test
*/
public function test_getURI_for_custom_totp_model_returns_uri()
{
$uri = $this->customTotpTwofaccount->getURI();
$this->assertStringContainsString('otpauth://totp/', $uri);
$this->assertStringContainsString(OtpTestData::SERVICE, $uri);
$this->assertStringContainsString(OtpTestData::ACCOUNT, $uri);
$this->assertStringContainsString('secret='.OtpTestData::SECRET, $uri);
$this->assertStringContainsString('digits='.OtpTestData::DIGITS_CUSTOM, $uri);
$this->assertStringContainsString('period='.OtpTestData::PERIOD_CUSTOM, $uri);
$this->assertStringContainsString('algorithm='.OtpTestData::ALGORITHM_CUSTOM, $uri);
$this->assertStringContainsString('secret=' . OtpTestData::SECRET, $uri);
$this->assertStringContainsString('digits=' . OtpTestData::DIGITS_CUSTOM, $uri);
$this->assertStringContainsString('period=' . OtpTestData::PERIOD_CUSTOM, $uri);
$this->assertStringContainsString('algorithm=' . OtpTestData::ALGORITHM_CUSTOM, $uri);
}
/**
* @test
*/
public function test_getURI_for_custom_hotp_model_returns_uri()
{
$uri = $this->customHotpTwofaccount->getURI();
$this->assertStringContainsString('otpauth://hotp/', $uri);
$this->assertStringContainsString(OtpTestData::SERVICE, $uri);
$this->assertStringContainsString(OtpTestData::ACCOUNT, $uri);
$this->assertStringContainsString('secret='.OtpTestData::SECRET, $uri);
$this->assertStringContainsString('digits='.OtpTestData::DIGITS_CUSTOM, $uri);
$this->assertStringContainsString('counter='.OtpTestData::COUNTER_CUSTOM, $uri);
$this->assertStringContainsString('algorithm='.OtpTestData::ALGORITHM_CUSTOM, $uri);
$this->assertStringContainsString('secret=' . OtpTestData::SECRET, $uri);
$this->assertStringContainsString('digits=' . OtpTestData::DIGITS_CUSTOM, $uri);
$this->assertStringContainsString('counter=' . OtpTestData::COUNTER_CUSTOM, $uri);
$this->assertStringContainsString('algorithm=' . OtpTestData::ALGORITHM_CUSTOM, $uri);
}
}
}