mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-20 03:38:06 +02:00
Fix & Complete tests
This commit is contained in:
parent
c71464b763
commit
d87eb36cd9
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user