mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-05-18 21:20:51 +02:00
Apply Laravel Pint fixes
This commit is contained in:
parent
80723d94ba
commit
dce3d16c37
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Extensions;
|
||||
|
||||
use Illuminate\Auth\EloquentUserProvider;
|
||||
use App\Models\WebAuthnAuthenticatable;
|
||||
use Illuminate\Auth\EloquentUserProvider;
|
||||
use Laragear\WebAuthn\Auth\WebAuthnUserProvider;
|
||||
|
||||
class WebauthnTwoFAuthUserProvider extends WebAuthnUserProvider
|
||||
@ -13,10 +13,9 @@ class WebauthnTwoFAuthUserProvider extends WebAuthnUserProvider
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|\App\Models\WebAuthnAuthenticatable|\App\Models\User $user
|
||||
* @param array $credentials
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validateCredentials($user, array $credentials): bool
|
||||
public function validateCredentials($user, array $credentials) : bool
|
||||
{
|
||||
if ($user instanceof WebAuthnAuthenticatable && $this->isSignedChallenge($credentials)) {
|
||||
return $this->validateWebAuthn();
|
||||
|
@ -17,7 +17,6 @@
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@ -5,7 +5,6 @@
|
||||
use App\Models\Group;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class GroupPolicy
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Extensions\RemoteUserProvider;
|
||||
use App\Extensions\WebauthnCredentialBroker;
|
||||
use App\Facades\Settings;
|
||||
use App\Models\Group;
|
||||
use App\Models\TwoFAccount;
|
||||
use App\Policies\GroupPolicy;
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Events\GroupDeleting;
|
||||
use App\Events\GroupDeleted;
|
||||
use App\Events\GroupDeleting;
|
||||
use App\Events\ScanForNewReleaseCalled;
|
||||
use App\Events\TwoFAccountDeleted;
|
||||
use App\Listeners\CleanIconStorage;
|
||||
|
@ -23,7 +23,7 @@ class GroupService
|
||||
*/
|
||||
public static function assign($ids, User $user, Group $group = null) : void
|
||||
{
|
||||
if (!$group) {
|
||||
if (! $group) {
|
||||
$group = self::defaultGroup($user);
|
||||
}
|
||||
|
||||
@ -39,8 +39,9 @@ public static function assign($ids, User $user, Group $group = null) : void
|
||||
$group->loadCount('twofaccounts');
|
||||
|
||||
Log::info(sprintf('Twofaccounts #%s assigned to group %s (ID #%s)', implode(',', $ids), var_export($group->name, true), $group->id));
|
||||
} else {
|
||||
Log::info('Cannot find a group to assign the TwoFAccounts to');
|
||||
}
|
||||
else Log::info('Cannot find a group to assign the TwoFAccounts to');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,17 +16,31 @@ class GroupControllerTest extends FeatureTestCase
|
||||
/**
|
||||
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
protected $user, $anotherUser;
|
||||
protected $user;
|
||||
|
||||
protected $anotherUser;
|
||||
|
||||
/**
|
||||
* @var App\Models\Group
|
||||
*/
|
||||
protected $userGroupA, $userGroupB, $anotherUserGroupA, $anotherUserGroupB;
|
||||
protected $userGroupA;
|
||||
|
||||
protected $userGroupB;
|
||||
|
||||
protected $anotherUserGroupA;
|
||||
|
||||
protected $anotherUserGroupB;
|
||||
|
||||
/**
|
||||
* @var App\Models\TwoFAccount
|
||||
*/
|
||||
protected $twofaccountA, $twofaccountB, $twofaccountC, $twofaccountD;
|
||||
protected $twofaccountA;
|
||||
|
||||
protected $twofaccountB;
|
||||
|
||||
protected $twofaccountC;
|
||||
|
||||
protected $twofaccountD;
|
||||
|
||||
private const NEW_GROUP_NAME = 'MyNewGroup';
|
||||
|
||||
@ -120,7 +134,6 @@ public function test_store_invalid_data_returns_validation_error()
|
||||
->assertStatus(422);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@ -425,7 +438,7 @@ public function test_destroy_missing_group_returns_not_found()
|
||||
public function test_destroy_group_of_another_user_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->anotherUser, 'api-guard')
|
||||
->json('DELETE', '/api/v1/groups/'.$this->userGroupA->id)
|
||||
->json('DELETE', '/api/v1/groups/' . $this->userGroupA->id)
|
||||
->assertForbidden()
|
||||
->assertJsonStructure([
|
||||
'message',
|
||||
|
@ -17,9 +17,6 @@ class IconControllerTest extends FeatureTestCase
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
@ -15,7 +15,9 @@ class QrCodeControllerTest extends FeatureTestCase
|
||||
/**
|
||||
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
protected $user, $anotherUser;
|
||||
protected $user;
|
||||
|
||||
protected $anotherUser;
|
||||
|
||||
/**
|
||||
* @var App\Models\TwoFAccount
|
||||
|
@ -14,7 +14,9 @@ class SettingControllerTest extends FeatureTestCase
|
||||
/**
|
||||
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
protected $user, $admin;
|
||||
protected $user;
|
||||
|
||||
protected $admin;
|
||||
|
||||
private const SETTING_JSON_STRUCTURE = [
|
||||
'key',
|
||||
|
@ -25,17 +25,31 @@ class TwoFAccountControllerTest extends FeatureTestCase
|
||||
/**
|
||||
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
protected $user, $anotherUser;
|
||||
protected $user;
|
||||
|
||||
protected $anotherUser;
|
||||
|
||||
/**
|
||||
* @var App\Models\Group
|
||||
*/
|
||||
protected $userGroupA, $userGroupB, $anotherUserGroupA, $anotherUserGroupB;
|
||||
protected $userGroupA;
|
||||
|
||||
protected $userGroupB;
|
||||
|
||||
protected $anotherUserGroupA;
|
||||
|
||||
protected $anotherUserGroupB;
|
||||
|
||||
/**
|
||||
* @var App\Models\TwoFAccount
|
||||
*/
|
||||
protected $twofaccountA, $twofaccountB, $twofaccountC, $twofaccountD;
|
||||
protected $twofaccountA;
|
||||
|
||||
protected $twofaccountB;
|
||||
|
||||
protected $twofaccountC;
|
||||
|
||||
protected $twofaccountD;
|
||||
|
||||
private const VALID_RESOURCE_STRUCTURE_WITHOUT_SECRET = [
|
||||
'id',
|
||||
@ -1050,7 +1064,7 @@ public function test_get_otp_by_posting_invalid_parameters_returns_validation_er
|
||||
public function test_get_otp_of_another_user_twofaccount_is_forbidden()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
->json('GET', '/api/v1/twofaccounts/'.$this->twofaccountC->id.'/otp')
|
||||
->json('GET', '/api/v1/twofaccounts/' . $this->twofaccountC->id . '/otp')
|
||||
->assertForbidden()
|
||||
->assertJsonStructure([
|
||||
'message',
|
||||
|
@ -17,6 +17,7 @@
|
||||
class GroupStoreRequestTest extends FeatureTestCase
|
||||
{
|
||||
use WithoutMiddleware;
|
||||
|
||||
/**
|
||||
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Tests\Feature\Http\Auth;
|
||||
|
||||
use App\Facades\Settings;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Tests\FeatureTestCase;
|
||||
|
@ -138,29 +138,29 @@ public function test_delete_user_returns_success()
|
||||
->assertNoContent();
|
||||
|
||||
$this->assertDatabaseMissing('users', [
|
||||
'id' => $this->user->id
|
||||
'id' => $this->user->id,
|
||||
]);
|
||||
$this->assertDatabaseHas('users', [
|
||||
'id' => $admin->id
|
||||
'id' => $admin->id,
|
||||
]);
|
||||
$this->assertDatabaseCount('users', 1);
|
||||
$this->assertDatabaseMissing('twofaccounts', [
|
||||
'user_id' => $this->user->id
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
$this->assertDatabaseMissing('groups', [
|
||||
'user_id' => $this->user->id
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
$this->assertDatabaseMissing('webauthn_credentials', [
|
||||
'authenticatable_id' => $this->user->id
|
||||
'authenticatable_id' => $this->user->id,
|
||||
]);
|
||||
$this->assertDatabaseMissing('webauthn_recoveries', [
|
||||
'email' => $this->user->email
|
||||
'email' => $this->user->email,
|
||||
]);
|
||||
$this->assertDatabaseMissing('oauth_access_tokens', [
|
||||
'user_id' => $this->user->id
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
$this->assertDatabaseMissing('password_resets', [
|
||||
'email' => $this->user->email
|
||||
'email' => $this->user->email,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ public function test_delete_user_in_demo_mode_returns_unauthorized()
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('users', [
|
||||
'id' => $this->user->id
|
||||
'id' => $this->user->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ public function test_delete_user_passing_wrong_password_returns_bad_request()
|
||||
->assertStatus(400);
|
||||
|
||||
$this->assertDatabaseHas('users', [
|
||||
'id' => $this->user->id
|
||||
'id' => $this->user->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ public function test_delete_the_only_admin_returns_bad_request()
|
||||
->assertStatus(400);
|
||||
|
||||
$this->assertDatabaseHas('users', [
|
||||
'id' => $admin->id
|
||||
'id' => $admin->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public function test_infos_returns_only_base_collection()
|
||||
'PHP version',
|
||||
'Operating system',
|
||||
'interface',
|
||||
]
|
||||
],
|
||||
])
|
||||
->assertJsonMissing([
|
||||
'user_preferences',
|
||||
@ -107,7 +107,7 @@ public function test_infos_returns_admin_settings_when_signed_in_as_admin()
|
||||
'useEncryption',
|
||||
'lastRadarScan',
|
||||
'checkForUpdate',
|
||||
]
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ public function test_infos_returns_proxy_collection_when_signed_in_behind_proxy(
|
||||
'common' => [
|
||||
'Auth proxy header for user',
|
||||
'Auth proxy header for email',
|
||||
]
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,18 @@ class TwoFAccountModelTest extends FeatureTestCase
|
||||
/**
|
||||
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
protected $user, $anotherUser;
|
||||
protected $user;
|
||||
|
||||
protected $anotherUser;
|
||||
|
||||
/**
|
||||
* @var \App\Models\TwoFAccount
|
||||
*/
|
||||
protected $customTotpTwofaccount, $customHotpTwofaccount, $customSteamTotpTwofaccount;
|
||||
protected $customTotpTwofaccount;
|
||||
|
||||
protected $customHotpTwofaccount;
|
||||
|
||||
protected $customSteamTotpTwofaccount;
|
||||
|
||||
/**
|
||||
* Helpers $helpers;
|
||||
|
@ -24,12 +24,16 @@ class TwoFAccountServiceTest extends FeatureTestCase
|
||||
/**
|
||||
* @var \App\Models\TwoFAccount
|
||||
*/
|
||||
protected $customTotpTwofaccount, $customHotpTwofaccount;
|
||||
protected $customTotpTwofaccount;
|
||||
|
||||
protected $customHotpTwofaccount;
|
||||
|
||||
/**
|
||||
* @var \App\Models\Group
|
||||
*/
|
||||
protected $userGroupA, $userGroupB;
|
||||
protected $userGroupA;
|
||||
|
||||
protected $userGroupB;
|
||||
|
||||
/**
|
||||
* @test
|
||||
|
@ -27,9 +27,6 @@ class GroupControllerTest extends TestCase
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Events\GroupDeleted;
|
||||
use App\Events\GroupDeleting;
|
||||
use App\Models\User;
|
||||
use App\Models\Group;
|
||||
use App\Models\TwoFAccount;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@ -29,7 +28,7 @@ public function test_model_configuration()
|
||||
['id' => 'int', 'twofaccounts_count' => 'integer'],
|
||||
[
|
||||
'deleting' => GroupDeleting::class,
|
||||
'deleted' => GroupDeleted::class
|
||||
'deleted' => GroupDeleted::class,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
use App\Events\GroupDeleted;
|
||||
use App\Listeners\ResetUsersPreference;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Mockery\MockInterface;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,6 @@
|
||||
use App\Exceptions\UnsupportedMigrationException;
|
||||
use App\Factories\MigratorFactory;
|
||||
use App\Models\TwoFAccount;
|
||||
use App\Models\User;
|
||||
use App\Services\LogoService;
|
||||
use App\Services\Migrators\AegisMigrator;
|
||||
use App\Services\Migrators\GoogleAuthMigrator;
|
||||
@ -59,7 +58,9 @@ class MigratorTest extends TestCase
|
||||
/**
|
||||
* App\Models\TwoFAccount $GAuthTotpBisTwofaccount
|
||||
*/
|
||||
protected $GAuthTotpBisTwofaccount, $fakeTwofaccount;
|
||||
protected $GAuthTotpBisTwofaccount;
|
||||
|
||||
protected $fakeTwofaccount;
|
||||
|
||||
public function setUp() : void
|
||||
{
|
||||
@ -77,7 +78,6 @@ public function setUp() : void
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
$this->totpTwofaccount = new TwoFAccount;
|
||||
$this->totpTwofaccount->legacy_uri = OtpTestData::TOTP_FULL_CUSTOM_URI_NO_IMG;
|
||||
$this->totpTwofaccount->service = OtpTestData::SERVICE;
|
||||
|
Loading…
Reference in New Issue
Block a user