feat: add read-only Social Accounts API
Add GET /api/accounts (list with optional ?network= and ?type= filters) and
GET /api/accounts/{socialAccount} (show) endpoints. Include plain-text password
field for AI agent consumption.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
20c33f1c23
commit
5c24b6fbe0
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use App\Models\SocialAccount;
|
||||
|
||||
test('it lists all social accounts including password', function () {
|
||||
SocialAccount::factory()->count(3)->create();
|
||||
|
||||
$response = $this->getJson('/api/accounts');
|
||||
|
||||
$response->assertOk()->assertJsonCount(3, 'data');
|
||||
expect($response->json('data.0'))->toHaveKey('password');
|
||||
});
|
||||
|
||||
test('it filters accounts by network', function () {
|
||||
SocialAccount::factory()->create(['network' => 'twitter']);
|
||||
SocialAccount::factory()->create(['network' => 'instagram']);
|
||||
|
||||
$response = $this->getJson('/api/accounts?network=twitter');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonCount(1, 'data')
|
||||
->assertJsonPath('data.0.network', 'twitter');
|
||||
});
|
||||
|
||||
test('it filters accounts by type', function () {
|
||||
SocialAccount::factory()->create(['type' => 'post']);
|
||||
SocialAccount::factory()->create(['type' => 'like']);
|
||||
|
||||
$response = $this->getJson('/api/accounts?type=post');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonCount(1, 'data')
|
||||
->assertJsonPath('data.0.type', 'post');
|
||||
});
|
||||
|
||||
test('it shows a single account with password', function () {
|
||||
$account = SocialAccount::factory()->create(['password' => 'super-secret']);
|
||||
|
||||
$response = $this->getJson("/api/accounts/{$account->id}");
|
||||
|
||||
$response->assertOk()->assertJsonPath('data.password', 'super-secret');
|
||||
});
|
||||
|
||||
test('it returns 404 for a missing account', function () {
|
||||
$this->getJson('/api/accounts/999')->assertNotFound();
|
||||
});
|
||||
Reference in New Issue
Block a user