2026-03-29 22:59:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
refactor: settings redesign, Spanish translations, language system, strict_types
Settings pages:
- Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections)
- Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal
- Add workspace logo upload/delete routes and controller methods
- Translate all hardcoded strings in Workspace.vue modals
Language system:
- Drop languages table, replace language_id FK with locale string column on users
- Create config/languages.php for available languages and default locale
- Add Spanish (es) translations (13 files)
- Simplify HandleInertiaRequests, ProfileController, RegisteredUserController
Code quality:
- Add declare(strict_types=1) to all PHP files
- Fix MastodonPublisher using wrong attribute (filename -> original_filename)
- Fix HasMediaTest for new has_photo/photo_url accessors
- Fix PublishToSocialPlatformTest type error revealed by strict_types
- Remove orphaned Language model from AppServiceProvider morph map
- Update User TypeScript interface (has_photo, photo_url, locale)
- Eager load media relation on workspaces to prevent N+1
- Add 8 new tests for workspace logo upload/delete
- Update workspace settings test to assert members/invitations props
All 710 tests passing.
2026-03-30 03:20:43 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
MCP: workspace settings, viewer read access, and token access (#241)
* Add workspace MCP settings and token access controls.
Ship MCP settings UI, OAuth revoke/list helpers, Passport deploy wiring,
and workspace.token:mcp gating so assistants can connect without pulling
in welcome/onboarding from the parent epic.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Type MCP client config shapes instead of string checks.
Encode http/config-root on each advanced client and tighten primary
client ids so snippet generation does not branch on magic strings.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Polish MCP settings follow-ups from review.
Translate Ukrainian MCP copy, deep-link ChatGPT into connector
creation, drop an unused asset and revoke arg, and assert PATs are
rejected on the MCP endpoint.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Harden MCP connected clients, revoke scope, and OAuth consent.
List recoverable sessions with live refresh tokens, revoke only PATs,
throttle registration alone, and block viewers from authorizing MCP.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Simplify MCP OAuth route throttling to a single middleware group.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Allow workspace viewers read-only MCP access with web policy writes.
Mirror the web app: MCP connects on view + OAuth mcp:use, write tools
enforce createPost/update/delete/manageAccounts/manageTeam, and demotion
to Viewer keeps grants. Cover role denials, consent, and disconnect.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Harden MCP tool authz with shared workspace helpers.
Route ApiKey tools through AuthorizesMcpTool, fail closed on null user
or policy argument, and resolve the current workspace before mutating.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop redundant string casts on validated request data.
Enum::from and validated() fields are already strings, so the casts
add noise without changing behavior.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Show only the current user's MCP connections in settings.
Match API keys privacy: list and disconnect your own OAuth clients,
not teammates' across the account.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Cover LoadWorkspaceFromToken gaps and harden AuthorizesMcpTool tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop redundant is_string guard before UpdatePostTool find.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Refactor AppSidebar to always show MCP link and simplify route middleware definition in ai.php. The MCP link is now consistently displayed regardless of the current workspace state, and the route middleware syntax has been streamlined.
* Refresh MCP connected clients with Inertia usePoll.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Bump laravel/mcp to 0.9.1 and add the TryPost server icon.
Requires laravel/boost 2.5 for the Icon attribute; expose images/trypost/icon.png on TryPostServer.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop no-op ReflectionClass import in TryPostServerTest.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 12:54:51 +00:00
|
|
|
use App\Enums\UserWorkspace\Role;
|
2026-05-03 21:38:17 +00:00
|
|
|
use App\Models\AccessToken;
|
|
|
|
|
use App\Models\User;
|
2026-03-29 22:59:17 +00:00
|
|
|
use App\Models\Workspace;
|
|
|
|
|
|
|
|
|
|
function createApiKeyApiToken(array $overrides = []): array
|
|
|
|
|
{
|
2026-05-03 21:38:17 +00:00
|
|
|
return createApiTestToken($overrides);
|
2026-03-29 22:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test('list api keys', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
|
MCP: workspace settings, viewer read access, and token access (#241)
* Add workspace MCP settings and token access controls.
Ship MCP settings UI, OAuth revoke/list helpers, Passport deploy wiring,
and workspace.token:mcp gating so assistants can connect without pulling
in welcome/onboarding from the parent epic.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Type MCP client config shapes instead of string checks.
Encode http/config-root on each advanced client and tighten primary
client ids so snippet generation does not branch on magic strings.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Polish MCP settings follow-ups from review.
Translate Ukrainian MCP copy, deep-link ChatGPT into connector
creation, drop an unused asset and revoke arg, and assert PATs are
rejected on the MCP endpoint.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Harden MCP connected clients, revoke scope, and OAuth consent.
List recoverable sessions with live refresh tokens, revoke only PATs,
throttle registration alone, and block viewers from authorizing MCP.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Simplify MCP OAuth route throttling to a single middleware group.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Allow workspace viewers read-only MCP access with web policy writes.
Mirror the web app: MCP connects on view + OAuth mcp:use, write tools
enforce createPost/update/delete/manageAccounts/manageTeam, and demotion
to Viewer keeps grants. Cover role denials, consent, and disconnect.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Harden MCP tool authz with shared workspace helpers.
Route ApiKey tools through AuthorizesMcpTool, fail closed on null user
or policy argument, and resolve the current workspace before mutating.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop redundant string casts on validated request data.
Enum::from and validated() fields are already strings, so the casts
add noise without changing behavior.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Show only the current user's MCP connections in settings.
Match API keys privacy: list and disconnect your own OAuth clients,
not teammates' across the account.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Cover LoadWorkspaceFromToken gaps and harden AuthorizesMcpTool tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop redundant is_string guard before UpdatePostTool find.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Refactor AppSidebar to always show MCP link and simplify route middleware definition in ai.php. The MCP link is now consistently displayed regardless of the current workspace state, and the route middleware syntax has been streamlined.
* Refresh MCP connected clients with Inertia usePoll.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Bump laravel/mcp to 0.9.1 and add the TryPost server icon.
Requires laravel/boost 2.5 for the Icon attribute; expose images/trypost/icon.png on TryPostServer.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop no-op ReflectionClass import in TryPostServerTest.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 12:54:51 +00:00
|
|
|
foreach (['Second', 'Third'] as $name) {
|
|
|
|
|
$token = $result['user']->createToken($name)->token;
|
|
|
|
|
AccessToken::query()->findOrFail($token->id)
|
|
|
|
|
->forceFill(['workspace_id' => $result['workspace']->id])
|
|
|
|
|
->saveQuietly();
|
|
|
|
|
}
|
2026-03-29 22:59:17 +00:00
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->getJson(
|
|
|
|
|
route('api.api-keys.index'),
|
|
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertJsonCount(3);
|
MCP: workspace settings, viewer read access, and token access (#241)
* Add workspace MCP settings and token access controls.
Ship MCP settings UI, OAuth revoke/list helpers, Passport deploy wiring,
and workspace.token:mcp gating so assistants can connect without pulling
in welcome/onboarding from the parent epic.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Type MCP client config shapes instead of string checks.
Encode http/config-root on each advanced client and tighten primary
client ids so snippet generation does not branch on magic strings.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Polish MCP settings follow-ups from review.
Translate Ukrainian MCP copy, deep-link ChatGPT into connector
creation, drop an unused asset and revoke arg, and assert PATs are
rejected on the MCP endpoint.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Harden MCP connected clients, revoke scope, and OAuth consent.
List recoverable sessions with live refresh tokens, revoke only PATs,
throttle registration alone, and block viewers from authorizing MCP.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Simplify MCP OAuth route throttling to a single middleware group.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Allow workspace viewers read-only MCP access with web policy writes.
Mirror the web app: MCP connects on view + OAuth mcp:use, write tools
enforce createPost/update/delete/manageAccounts/manageTeam, and demotion
to Viewer keeps grants. Cover role denials, consent, and disconnect.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Harden MCP tool authz with shared workspace helpers.
Route ApiKey tools through AuthorizesMcpTool, fail closed on null user
or policy argument, and resolve the current workspace before mutating.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop redundant string casts on validated request data.
Enum::from and validated() fields are already strings, so the casts
add noise without changing behavior.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Show only the current user's MCP connections in settings.
Match API keys privacy: list and disconnect your own OAuth clients,
not teammates' across the account.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Cover LoadWorkspaceFromToken gaps and harden AuthorizesMcpTool tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop redundant is_string guard before UpdatePostTool find.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Refactor AppSidebar to always show MCP link and simplify route middleware definition in ai.php. The MCP link is now consistently displayed regardless of the current workspace state, and the route middleware syntax has been streamlined.
* Refresh MCP connected clients with Inertia usePoll.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Bump laravel/mcp to 0.9.1 and add the TryPost server icon.
Requires laravel/boost 2.5 for the Icon attribute; expose images/trypost/icon.png on TryPostServer.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop no-op ReflectionClass import in TryPostServerTest.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 12:54:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('list api keys excludes revoked and other-workspace tokens', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
$revoked = $result['user']->createToken('Revoked')->token;
|
|
|
|
|
AccessToken::query()->findOrFail($revoked->id)
|
|
|
|
|
->forceFill([
|
|
|
|
|
'workspace_id' => $result['workspace']->id,
|
|
|
|
|
'revoked' => true,
|
|
|
|
|
])
|
|
|
|
|
->saveQuietly();
|
|
|
|
|
|
|
|
|
|
$otherWorkspace = Workspace::factory()->create([
|
|
|
|
|
'account_id' => $result['user']->account_id,
|
|
|
|
|
'user_id' => $result['user']->id,
|
|
|
|
|
]);
|
|
|
|
|
$other = $result['user']->createToken('Other workspace')->token;
|
|
|
|
|
AccessToken::query()->findOrFail($other->id)
|
|
|
|
|
->forceFill(['workspace_id' => $otherWorkspace->id])
|
|
|
|
|
->saveQuietly();
|
|
|
|
|
|
|
|
|
|
$this->withHeaders(['Authorization' => 'Bearer '.$result['plain_token']])
|
|
|
|
|
->getJson(route('api.api-keys.index'))
|
|
|
|
|
->assertOk()
|
|
|
|
|
->assertJsonCount(1)
|
|
|
|
|
->assertJsonMissing(['id' => $revoked->id])
|
|
|
|
|
->assertJsonMissing(['id' => $other->id]);
|
|
|
|
|
});
|
2026-03-29 22:59:17 +00:00
|
|
|
|
|
|
|
|
test('create api key returns plain token', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->postJson(
|
|
|
|
|
route('api.api-keys.store'),
|
2026-05-03 21:38:17 +00:00
|
|
|
['name' => 'CI/CD Token'],
|
2026-03-29 22:59:17 +00:00
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertCreated();
|
|
|
|
|
$response->assertJsonStructure([
|
2026-05-03 21:38:17 +00:00
|
|
|
'token' => ['id', 'name', 'created_at'],
|
2026-03-29 22:59:17 +00:00
|
|
|
'plain_token',
|
|
|
|
|
]);
|
|
|
|
|
|
2026-05-03 21:38:17 +00:00
|
|
|
expect($response->json('plain_token'))->toBeString();
|
2026-03-29 22:59:17 +00:00
|
|
|
});
|
|
|
|
|
|
MCP: workspace settings, viewer read access, and token access (#241)
* Add workspace MCP settings and token access controls.
Ship MCP settings UI, OAuth revoke/list helpers, Passport deploy wiring,
and workspace.token:mcp gating so assistants can connect without pulling
in welcome/onboarding from the parent epic.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Type MCP client config shapes instead of string checks.
Encode http/config-root on each advanced client and tighten primary
client ids so snippet generation does not branch on magic strings.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Polish MCP settings follow-ups from review.
Translate Ukrainian MCP copy, deep-link ChatGPT into connector
creation, drop an unused asset and revoke arg, and assert PATs are
rejected on the MCP endpoint.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Harden MCP connected clients, revoke scope, and OAuth consent.
List recoverable sessions with live refresh tokens, revoke only PATs,
throttle registration alone, and block viewers from authorizing MCP.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Simplify MCP OAuth route throttling to a single middleware group.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Allow workspace viewers read-only MCP access with web policy writes.
Mirror the web app: MCP connects on view + OAuth mcp:use, write tools
enforce createPost/update/delete/manageAccounts/manageTeam, and demotion
to Viewer keeps grants. Cover role denials, consent, and disconnect.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Harden MCP tool authz with shared workspace helpers.
Route ApiKey tools through AuthorizesMcpTool, fail closed on null user
or policy argument, and resolve the current workspace before mutating.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop redundant string casts on validated request data.
Enum::from and validated() fields are already strings, so the casts
add noise without changing behavior.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Show only the current user's MCP connections in settings.
Match API keys privacy: list and disconnect your own OAuth clients,
not teammates' across the account.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Cover LoadWorkspaceFromToken gaps and harden AuthorizesMcpTool tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop redundant is_string guard before UpdatePostTool find.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Refactor AppSidebar to always show MCP link and simplify route middleware definition in ai.php. The MCP link is now consistently displayed regardless of the current workspace state, and the route middleware syntax has been streamlined.
* Refresh MCP connected clients with Inertia usePoll.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Bump laravel/mcp to 0.9.1 and add the TryPost server icon.
Requires laravel/boost 2.5 for the Icon attribute; expose images/trypost/icon.png on TryPostServer.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop no-op ReflectionClass import in TryPostServerTest.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 12:54:51 +00:00
|
|
|
test('workspace members cannot manage api keys through the api', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
$member = User::factory()->create(['account_id' => $result['user']->account_id]);
|
|
|
|
|
$result['workspace']->members()->attach($member->id, ['role' => Role::Member->value]);
|
|
|
|
|
$member->update(['current_workspace_id' => $result['workspace']->id]);
|
|
|
|
|
$plainToken = passportToken($member, $result['workspace']);
|
|
|
|
|
|
|
|
|
|
$this->withHeaders(['Authorization' => "Bearer {$plainToken}"])
|
|
|
|
|
->getJson(route('api.api-keys.index'))
|
|
|
|
|
->assertForbidden();
|
|
|
|
|
|
|
|
|
|
$this->withHeaders(['Authorization' => "Bearer {$plainToken}"])
|
|
|
|
|
->postJson(route('api.api-keys.store'), ['name' => 'Escalation Key'])
|
|
|
|
|
->assertForbidden();
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-29 22:59:17 +00:00
|
|
|
test('create api key validation errors', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->postJson(
|
|
|
|
|
route('api.api-keys.store'),
|
|
|
|
|
[],
|
|
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertUnprocessable();
|
|
|
|
|
$response->assertJsonValidationErrors(['name']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('delete api key', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
|
2026-05-03 21:38:17 +00:00
|
|
|
$tokenToDelete = $result['user']->createToken('To delete')->token;
|
|
|
|
|
AccessToken::find($tokenToDelete->id)
|
|
|
|
|
->forceFill(['workspace_id' => $result['workspace']->id])
|
|
|
|
|
->saveQuietly();
|
2026-03-29 22:59:17 +00:00
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->deleteJson(
|
2026-05-03 21:38:17 +00:00
|
|
|
route('api.api-keys.destroy', $tokenToDelete->id),
|
2026-03-29 22:59:17 +00:00
|
|
|
[],
|
|
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertNoContent();
|
2026-05-03 21:38:17 +00:00
|
|
|
expect(AccessToken::find($tokenToDelete->id)->revoked)->toBeTrue();
|
2026-03-29 22:59:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('cannot delete api key from another workspace', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
|
|
|
|
|
$otherWorkspace = Workspace::factory()->create();
|
2026-05-03 21:38:17 +00:00
|
|
|
$otherUser = $otherWorkspace->owner ?? User::factory()->create([
|
|
|
|
|
'account_id' => $otherWorkspace->account_id,
|
2026-03-29 22:59:17 +00:00
|
|
|
]);
|
2026-05-03 21:38:17 +00:00
|
|
|
$otherToken = $otherUser->createToken('Other')->token;
|
|
|
|
|
AccessToken::find($otherToken->id)
|
|
|
|
|
->forceFill(['workspace_id' => $otherWorkspace->id])
|
|
|
|
|
->saveQuietly();
|
2026-03-29 22:59:17 +00:00
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
|
'Authorization' => 'Bearer '.$result['plain_token'],
|
|
|
|
|
])->deleteJson(
|
2026-05-03 21:38:17 +00:00
|
|
|
route('api.api-keys.destroy', $otherToken->id),
|
2026-03-29 22:59:17 +00:00
|
|
|
[],
|
|
|
|
|
['HTTP_HOST' => 'api.trypost.test']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response->assertNotFound();
|
|
|
|
|
});
|
feat: social account toggle action, API, MCP + full test coverage
- 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
2026-03-31 04:42:39 +00:00
|
|
|
|
|
|
|
|
it('validates api key expires_at must be future date', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
|
2026-05-03 21:38:17 +00:00
|
|
|
$this->withHeaders(['Authorization' => 'Bearer '.$result['plain_token']])
|
feat: social account toggle action, API, MCP + full test coverage
- 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
2026-03-31 04:42:39 +00:00
|
|
|
->postJson(route('api.api-keys.store'), [
|
|
|
|
|
'name' => 'Test Key',
|
|
|
|
|
'expires_at' => '2020-01-01',
|
|
|
|
|
])
|
|
|
|
|
->assertUnprocessable()
|
|
|
|
|
->assertJsonValidationErrors(['expires_at']);
|
|
|
|
|
});
|
|
|
|
|
|
MCP: workspace settings, viewer read access, and token access (#241)
* Add workspace MCP settings and token access controls.
Ship MCP settings UI, OAuth revoke/list helpers, Passport deploy wiring,
and workspace.token:mcp gating so assistants can connect without pulling
in welcome/onboarding from the parent epic.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Type MCP client config shapes instead of string checks.
Encode http/config-root on each advanced client and tighten primary
client ids so snippet generation does not branch on magic strings.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Polish MCP settings follow-ups from review.
Translate Ukrainian MCP copy, deep-link ChatGPT into connector
creation, drop an unused asset and revoke arg, and assert PATs are
rejected on the MCP endpoint.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Harden MCP connected clients, revoke scope, and OAuth consent.
List recoverable sessions with live refresh tokens, revoke only PATs,
throttle registration alone, and block viewers from authorizing MCP.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Simplify MCP OAuth route throttling to a single middleware group.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Allow workspace viewers read-only MCP access with web policy writes.
Mirror the web app: MCP connects on view + OAuth mcp:use, write tools
enforce createPost/update/delete/manageAccounts/manageTeam, and demotion
to Viewer keeps grants. Cover role denials, consent, and disconnect.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Harden MCP tool authz with shared workspace helpers.
Route ApiKey tools through AuthorizesMcpTool, fail closed on null user
or policy argument, and resolve the current workspace before mutating.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop redundant string casts on validated request data.
Enum::from and validated() fields are already strings, so the casts
add noise without changing behavior.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Show only the current user's MCP connections in settings.
Match API keys privacy: list and disconnect your own OAuth clients,
not teammates' across the account.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Cover LoadWorkspaceFromToken gaps and harden AuthorizesMcpTool tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop redundant is_string guard before UpdatePostTool find.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Refactor AppSidebar to always show MCP link and simplify route middleware definition in ai.php. The MCP link is now consistently displayed regardless of the current workspace state, and the route middleware syntax has been streamlined.
* Refresh MCP connected clients with Inertia usePoll.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Bump laravel/mcp to 0.9.1 and add the TryPost server icon.
Requires laravel/boost 2.5 for the Icon attribute; expose images/trypost/icon.png on TryPostServer.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop no-op ReflectionClass import in TryPostServerTest.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 12:54:51 +00:00
|
|
|
it('creates an api key without expiration', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders(['Authorization' => 'Bearer '.$result['plain_token']])
|
|
|
|
|
->postJson(route('api.api-keys.store'), [
|
|
|
|
|
'name' => 'Never Expires',
|
|
|
|
|
])
|
|
|
|
|
->assertCreated();
|
|
|
|
|
|
|
|
|
|
expect($response->json('token.expires_at'))->toBeNull()
|
|
|
|
|
->and(AccessToken::query()->findOrFail($response->json('token.id'))->expires_at)->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('creates an api key with expiration at end of day', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
$expiresAt = now()->addDays(14)->startOfDay();
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders(['Authorization' => 'Bearer '.$result['plain_token']])
|
|
|
|
|
->postJson(route('api.api-keys.store'), [
|
|
|
|
|
'name' => 'Expiring Key',
|
|
|
|
|
'expires_at' => $expiresAt->toDateString(),
|
|
|
|
|
])
|
|
|
|
|
->assertCreated();
|
|
|
|
|
|
|
|
|
|
$token = AccessToken::query()->findOrFail($response->json('token.id'));
|
|
|
|
|
|
|
|
|
|
expect($token->expires_at->toDateString())->toBe($expiresAt->toDateString())
|
|
|
|
|
->and($token->expires_at->format('H:i:s'))->toBe('23:59:59');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('allows an api key expiration of today', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
$today = now()->toDateString();
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders(['Authorization' => 'Bearer '.$result['plain_token']])
|
|
|
|
|
->postJson(route('api.api-keys.store'), [
|
|
|
|
|
'name' => 'Expires Today',
|
|
|
|
|
'expires_at' => $today,
|
|
|
|
|
])
|
|
|
|
|
->assertCreated();
|
|
|
|
|
|
|
|
|
|
$token = AccessToken::query()->findOrFail($response->json('token.id'));
|
|
|
|
|
|
|
|
|
|
expect($token->expires_at->toDateString())->toBe($today)
|
|
|
|
|
->and($token->expires_at->format('H:i:s'))->toBe('23:59:59');
|
|
|
|
|
});
|
|
|
|
|
|
feat: social account toggle action, API, MCP + full test coverage
- 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
2026-03-31 04:42:39 +00:00
|
|
|
it('validates api key name max length', function () {
|
|
|
|
|
$result = createApiKeyApiToken();
|
|
|
|
|
|
2026-05-03 21:38:17 +00:00
|
|
|
$this->withHeaders(['Authorization' => 'Bearer '.$result['plain_token']])
|
feat: social account toggle action, API, MCP + full test coverage
- 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
2026-03-31 04:42:39 +00:00
|
|
|
->postJson(route('api.api-keys.store'), [
|
|
|
|
|
'name' => str_repeat('a', 256),
|
|
|
|
|
])
|
|
|
|
|
->assertUnprocessable()
|
|
|
|
|
->assertJsonValidationErrors(['name']);
|
|
|
|
|
});
|