diff --git a/app/Models/TwoFAccount.php b/app/Models/TwoFAccount.php index 0661f108..a080bc50 100644 --- a/app/Models/TwoFAccount.php +++ b/app/Models/TwoFAccount.php @@ -552,7 +552,6 @@ class TwoFAccount extends Model implements Sortable $this->icon = Icons::buildFromRemoteImage($this->generator->getParameter('image')); } - $uuu = Auth::user()?->preferences; if (! $this->icon && ! $skipIconFetching && Auth::user()?->preferences['getOfficialIcons']) { $this->icon = Icons::buildFromOfficialLogo($this->service); } diff --git a/tests/Api/v1/Controllers/TwoFAccountControllerTest.php b/tests/Api/v1/Controllers/TwoFAccountControllerTest.php index 0a14bac8..e2130b64 100644 --- a/tests/Api/v1/Controllers/TwoFAccountControllerTest.php +++ b/tests/Api/v1/Controllers/TwoFAccountControllerTest.php @@ -243,8 +243,10 @@ class TwoFAccountControllerTest extends FeatureTestCase Http::preventStrayRequests(); Http::fake([ - CommonDataProvider::TFA_URL => Http::response(HttpRequestTestData::SVG_LOGO_BODY, 200), - TfaLogoLib::TFA_JSON_URL => Http::response(HttpRequestTestData::TFA_JSON_BODY, 200), + CommonDataProvider::TFA_URL => Http::response(HttpRequestTestData::SVG_LOGO_BODY, 200), + CommonDataProvider::SELFH_URL => Http::response(HttpRequestTestData::SVG_LOGO_BODY, 200), + CommonDataProvider::DASHBOARDICONS_URL => Http::response(HttpRequestTestData::SVG_LOGO_BODY, 200), + TfaLogoLib::TFA_JSON_URL => Http::response(HttpRequestTestData::TFA_JSON_BODY, 200), OtpTestData::EXTERNAL_IMAGE_URL_DECODED => Http::response((new FileFactory)->image('file.png', 10, 10)->tempFile, 200), OtpTestData::EXTERNAL_INFECTED_IMAGE_URL_DECODED => Http::response((new FileFactory)->createWithContent('infected.svg', OtpTestData::ICON_SVG_DATA_INFECTED)->tempFile, 200), 'example.com/*' => Http::response(null, 400), @@ -929,8 +931,10 @@ class TwoFAccountControllerTest extends FeatureTestCase } #[Test] - public function test_migrate_identify_duplicates_in_authenticated_user_twofaccounts_only() + public function test_migrate_identifies_duplicates_in_authenticated_user_twofaccounts_only() { + $this->user['preferences->getOfficialIcons'] = false; + $twofaccount = TwoFAccount::factory()->for($this->anotherUser)->create([ 'otp_type' => 'totp', 'account' => OtpTestData::ACCOUNT, diff --git a/tests/Feature/Http/Auth/WebAuthnRegisterControllerTest.php b/tests/Feature/Http/Auth/WebAuthnRegisterControllerTest.php index 01a24e96..13b733d1 100644 --- a/tests/Feature/Http/Auth/WebAuthnRegisterControllerTest.php +++ b/tests/Feature/Http/Auth/WebAuthnRegisterControllerTest.php @@ -3,11 +3,11 @@ namespace Tests\Feature\Http\Auth; use App\Http\Controllers\Auth\WebAuthnRegisterController; +use App\Http\Requests\WebauthnAttestationRequest; +use App\Http\Requests\WebauthnAttestedRequest; use App\Models\User; use Illuminate\Support\Facades\Config; use Laragear\WebAuthn\Enums\UserVerification; -use Laragear\WebAuthn\Http\Requests\AttestationRequest; -use Laragear\WebAuthn\Http\Requests\AttestedRequest; use Laragear\WebAuthn\JsonTransport; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; @@ -36,7 +36,7 @@ class WebAuthnRegisterControllerTest extends FeatureTestCase { Config::set('webauthn.user_verification', UserVerification::DISCOURAGED); - $request = $this->mock(AttestationRequest::class); + $request = $this->mock(WebauthnAttestationRequest::class); $request->expects('fastRegistration')->andReturnSelf(); $request->expects('toCreate')->andReturn(new JsonTransport); @@ -51,7 +51,7 @@ class WebAuthnRegisterControllerTest extends FeatureTestCase { Config::set('webauthn.user_verification', UserVerification::REQUIRED); - $request = $this->mock(AttestationRequest::class); + $request = $this->mock(WebauthnAttestationRequest::class); $request->expects('secureRegistration')->andReturnSelf(); $request->expects('toCreate')->andReturn(new JsonTransport); @@ -64,7 +64,7 @@ class WebAuthnRegisterControllerTest extends FeatureTestCase #[Test] public function test_register_uses_attested_request() : void { - $request = $this->mock(AttestedRequest::class); + $request = $this->mock(WebauthnAttestedRequest::class); $request->expects('save')->andReturn(); $request->expects('user')->andReturn($this->user); diff --git a/tests/Feature/Http/Requests/WebauthnRenameRequestTest.php b/tests/Feature/Http/Requests/WebauthnRenameRequestTest.php index 76a929dd..6414cd54 100644 --- a/tests/Feature/Http/Requests/WebauthnRenameRequestTest.php +++ b/tests/Feature/Http/Requests/WebauthnRenameRequestTest.php @@ -5,6 +5,7 @@ namespace Tests\Feature\Http\Requests; use App\Http\Requests\WebauthnRenameRequest; use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Validator; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -26,6 +27,11 @@ class WebauthnRenameRequestTest extends TestCase ->once() ->andReturn(true); + Gate::shouldReceive('allows') + ->with('manage-webauthn-credentials') + ->once() + ->andReturn(true); + $request = new WebauthnRenameRequest; $this->assertTrue($request->authorize()); diff --git a/tests/Feature/Services/IconServiceTest.php b/tests/Feature/Services/IconServiceTest.php index 6021899f..dbca0824 100644 --- a/tests/Feature/Services/IconServiceTest.php +++ b/tests/Feature/Services/IconServiceTest.php @@ -43,7 +43,7 @@ class IconServiceTest extends FeatureTestCase CommonDataProvider::TFA_URL => Http::response(HttpRequestTestData::SVG_LOGO_BODY, 200), CommonDataProvider::SELFH_URL => Http::response(HttpRequestTestData::SVG_LOGO_BODY, 200), CommonDataProvider::DASHBOARDICONS_URL => Http::response(HttpRequestTestData::SVG_LOGO_BODY, 200), - TfaLogoLib::TFA_JSON_URL => Http::response(HttpRequestTestData::TFA_JSON_BODY, 200), + TfaLogoLib::TFA_JSON_URL => Http::response(HttpRequestTestData::TFA_JSON_BODY, 200), ]); Http::fake([ OtpTestData::EXTERNAL_IMAGE_URL_DECODED => Http::response((new FileFactory)->image('file.png', 10, 10)->tempFile, 200),