Files
portal-api/tests/Feature/Api/Admin/UpdatePasswordTest.php
baodev0andClaude Opus 5.5 46aa138eec feat(admin): IP pool allocation, billing exports, service attachments
- IP pool: sheet import (xlsx/csv) matched by address, bulk allocate/revoke
  with notification email (ip_allocated/ip_revoked), ip_pool_logs history.
- Orders/invoices: Excel export on branded template (BrandedReportWriter),
  shared billing filters, order item service info in list responses.
- Web design quote Excel export; activity log export.
- Service attachments with copy-to-invoice; deployment invoice attachments.
- Customer email attachments stored on disk and attached by path.
- Admin password change endpoint; user.fullname backfill migration;
  orders.user_id backfill from logs.
- Disable deploy workflow until CI/CD is set up.
- Ignore stored customer email and service attachment uploads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 19:58:36 +07:00

62 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Api\Admin;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
use Tests\TestCase;
class UpdatePasswordTest extends TestCase
{
use RefreshDatabase;
public function test_admin_can_change_own_password(): void
{
$user = User::factory()->create(['password' => Hash::make('OldPassword1')]);
$this->actingAs($user, 'admin')
->putJson('/api/v1/administrator/password', [
'current_password' => 'OldPassword1',
'password' => 'NewPassword2',
'password_confirmation' => 'NewPassword2',
])
->assertOk()
->assertJsonPath('error', false);
$this->assertTrue(Hash::check('NewPassword2', $user->fresh()->password));
}
public function test_admin_must_provide_the_correct_current_password(): void
{
$user = User::factory()->create(['password' => Hash::make('OldPassword1')]);
$this->actingAs($user, 'admin')
->putJson('/api/v1/administrator/password', [
'current_password' => 'WrongPassword',
'password' => 'NewPassword2',
'password_confirmation' => 'NewPassword2',
])
->assertUnprocessable()
->assertJsonValidationErrors('current_password');
$this->assertTrue(Hash::check('OldPassword1', $user->fresh()->password));
}
public function test_new_password_must_be_confirmed_and_different(): void
{
$user = User::factory()->create(['password' => Hash::make('OldPassword1')]);
$this->actingAs($user, 'admin')
->putJson('/api/v1/administrator/password', [
'current_password' => 'OldPassword1',
'password' => 'OldPassword1',
'password_confirmation' => 'DifferentPassword2',
])
->assertUnprocessable()
->assertJsonValidationErrors('password');
}
}