- Extract ToggleSocialAccount action from SocialController
- Add API endpoints: GET /social-accounts, PUT /social-accounts/{id}/toggle
- Add MCP tools: ListSocialAccountsTool, ToggleSocialAccountTool
- Fix all MCP tools: findOrFail → find + Response::error for graceful errors
- Fix MCP tools using $request->validated() without validate() call
- Fix return types to Response|ResponseFactory for error paths
- Add SocialAccountResource is_active/status fields (no tokens exposed)
- Add 43 MCP tests covering all 18 tools (CRUD, validation, cross-workspace)
- Add API response structure tests for posts, hashtags, labels, workspace
- Add API validation tests for post create/update, api-key expiry, label color
- Add API cross-workspace delete tests for hashtags and labels
- Add app validation tests for hashtag/label update, invite fields, password
- Add auth required tests for notifications, profile delete, api-keys index
- Add media reorder validation tests
73 lines
2 KiB
PHP
73 lines
2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
test('password update page is displayed', function () {
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this
|
|
->actingAs($user)
|
|
->get(route('app.user-password.edit'));
|
|
|
|
$response->assertOk();
|
|
});
|
|
|
|
test('password can be updated', function () {
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this
|
|
->actingAs($user)
|
|
->from(route('app.user-password.edit'))
|
|
->put(route('app.user-password.update'), [
|
|
'current_password' => 'password',
|
|
'password' => 'new-password',
|
|
'password_confirmation' => 'new-password',
|
|
]);
|
|
|
|
$response
|
|
->assertSessionHasNoErrors()
|
|
->assertRedirect(route('app.user-password.edit'));
|
|
|
|
expect(Hash::check('new-password', $user->refresh()->password))->toBeTrue();
|
|
});
|
|
|
|
test('correct password must be provided to update password', function () {
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this
|
|
->actingAs($user)
|
|
->from(route('app.user-password.edit'))
|
|
->put(route('app.user-password.update'), [
|
|
'current_password' => 'wrong-password',
|
|
'password' => 'new-password',
|
|
'password_confirmation' => 'new-password',
|
|
]);
|
|
|
|
$response
|
|
->assertSessionHasErrors('current_password')
|
|
->assertRedirect(route('app.user-password.edit'));
|
|
});
|
|
|
|
test('password update requires authentication', function () {
|
|
$response = $this->put(route('app.user-password.update'), []);
|
|
|
|
$response->assertRedirect(route('login'));
|
|
});
|
|
|
|
test('password must be confirmed', function () {
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this
|
|
->actingAs($user)
|
|
->from(route('app.user-password.edit'))
|
|
->put(route('app.user-password.update'), [
|
|
'current_password' => 'password',
|
|
'password' => 'new-password',
|
|
'password_confirmation' => 'wrong-confirmation',
|
|
]);
|
|
|
|
$response->assertSessionHasErrors('password');
|
|
});
|