feat(auth): enhance password reset attempt handling with new reasons and update related services
This commit is contained in:
@@ -2,13 +2,16 @@
|
||||
|
||||
namespace Tests\Feature\Staff;
|
||||
|
||||
use App\Domains\Auth\Models\ResetPasswordAttempt;
|
||||
use App\Domains\Auth\Models\User;
|
||||
use App\Domains\Authorization\Enums\RoleCode;
|
||||
use App\Domains\Catalog\Models\Category;
|
||||
use App\Domains\Notification\Events\PasswordResetRequested;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use App\Domains\Tenant\Models\WebsiteType;
|
||||
use Database\Seeders\AuthorizationSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -24,6 +27,7 @@ class StaffControllerTest extends TestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Event::fake([PasswordResetRequested::class]);
|
||||
$this->seed(AuthorizationSeeder::class);
|
||||
WebsiteType::query()->create(['codigo' => 'onticket', 'nombre' => 'OnTicket']);
|
||||
$this->tenant = Tenant::query()->create([
|
||||
@@ -59,6 +63,16 @@ class StaffControllerTest extends TestCase
|
||||
'user_id' => $staffId,
|
||||
'categoria_id' => $firstCategory->id,
|
||||
]);
|
||||
$this->assertDatabaseHas('reset_password_attempts', [
|
||||
'user_id' => $staffId,
|
||||
'reason' => ResetPasswordAttempt::REASON_STAFF_CREATED,
|
||||
'status' => ResetPasswordAttempt::STATUS_PENDING,
|
||||
]);
|
||||
Event::assertDispatched(
|
||||
PasswordResetRequested::class,
|
||||
fn (PasswordResetRequested $event): bool => $event->tenantCode === $this->tenant->codigo
|
||||
&& $event->channel === PasswordResetRequested::CHANNEL_SCANNER,
|
||||
);
|
||||
|
||||
$this->getJson('/api/v1/adminapp/tenant/staff?search=ada')
|
||||
->assertOk()
|
||||
|
||||
Reference in New Issue
Block a user