trypost/tests/Feature
Paulo Castellano 2ca5948309
Scope MCP OAuth tokens to user + workspace (#222) (#245)
* Scope MCP OAuth tokens to user + workspace

Bind authorization-code grants to the authorizing workspace (via auth codes),
inherit workspace on refresh, resolve MCP/API requests from the token instead
of current_workspace_id, backfill existing grants, and revoke workspace tokens
when a member is removed.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Add multi-workspace MCP OAuth coverage

Cover coexistence of the same client across workspaces, settings
list/disconnect scoped to the current workspace, and API key
controllers excluding workspace-bound MCP grants.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Use constrained foreignUuid for oauth_auth_codes.workspace_id

Match the project's UUID foreign-key convention instead of a separate
foreign() call.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Localize the MCP OAuth authorize consent screen

Wire authorize.blade.php to mcp.* translation keys (including the
workspace scope copy) and cover pt-BR rendering.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix invalid Mockery import in bind workspace test

CI treats the non-compound `use Mockery` as an ErrorException and
aborts the whole parallel suite.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Inline MCP OAuth workspace backfill into the migration

Move the one-shot backfill out of a dedicated Action and wrap it in an
explicit transaction so a failure rolls back partial binds/revokes.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Nest MCP authorize i18n keys and test backfill rollback

Group consent-screen copy under mcp.authorize.*, and assert the
workspace backfill migration rolls back binds when it fails before
commit.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Hardcode TryPost in the MCP authorize page title

Drop the config('app.name') interpolation from the consent screen title.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Add workspace picker to MCP OAuth consent screen

Let users choose which workspace to bind at authorize time instead of
always using current_workspace_id; silent re-consent still falls back.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Tighten MCP authorize workspace select spacing

Match NativeSelect styling and give the label, control, and helper text room to breathe.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Convert MCP OAuth consent screen to Inertia Vue

Reuse AuthCardLayout, Button, and NativeSelect so the authorize page
matches the app UI. Keep native form posts so Passport's external
redirect still works for MCP client popups.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Polish MCP authorize layout with logo and workspace combobox

Drop the shield and AuthCardLayout double-logo, put TryPost branding
at the top, and reuse the app Combobox pattern for workspace search.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Align MCP OAuth workspace backfill with mcpOAuth scope

Reuse AccessToken::mcpOAuth() so the migration only touches mcp:use
grants on non-PAT clients, matching the rest of the codebase.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Tighten MCP OAuth workspace backfill heuristics

Only touch connected MCP sessions, bind a sole membership or a valid
current workspace, and revoke ambiguous multi-workspace grants instead
of guessing the oldest workspace.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Drop Passport connection override from auth code migration

Always use the app default database connection from .env.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Bind MCP OAuth workspace in AccessTokenRepository

Replace the AccessTokenCreated listener with the same Passport repository
override pattern used for auth codes, so workspace_id is set at persist.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Simplify AccessTokenRepository workspace binding

Drop redundant string casts and the oldest-workspace fallback; keep a
small ownedWorkspace/payloadId helper surface instead.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Extract Passport MCP authorization view from AppServiceProvider

Keep configurePassport thin by moving the Inertia consent props into an
invokable App\Passport\AuthorizationView class.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Simplify AuthorizationView and cover it with direct tests

Use collection higher-order mapping for workspaces/scopes and add focused
tests for current-workspace selection and empty-user props.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Rename BindWorkspaceToAccessTokenTest after listener removal

The suite now covers AuthCodeRepository and AccessTokenRepository
workspace binding, not an AccessTokenCreated listener.

* Fail closed when auth code has no bindable workspace

Authorization-code grants no longer fall back to the user's current
workspace, so a token cannot be minted for a different tenant than consent.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Retrigger CI after GitHub Actions infrastructure failures

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore: retrigger CI

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: harden MCP OAuth workspace binding on refresh and backfill

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: always show MCP OAuth consent to pick a workspace

Disable Passport silent re-consent and require an explicit workspace_id
from the consent form, with Passport wiring moved to its own provider.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: sort MCP connected clients by last used

Show most recently used OAuth connections first on the workspace MCP settings page.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 21:59:34 -03:00
..
Actions Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
Ai Add Ukrainian as a supported platform language (#219) 2026-08-05 19:45:30 -03:00
Api Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
App/Post refactor(posts): return the card display domain from the backend 2026-07-17 16:24:23 -03:00
Auth Allow account owners to delete workspaces (#208) 2026-08-01 13:00:38 -04:00
Automation Enforce carousel min slides in Generate and expose min_media_count on API/MCP. 2026-07-24 23:51:10 -03:00
Billing Allow account owners to delete workspaces (#208) 2026-08-01 13:00:38 -04:00
Brand Structure brand voice and make generated copy platform-aware 2026-06-12 17:09:39 -03:00
Commands fix: Pinterest video processing timeout — longer poll + retry (#246) 2026-08-06 20:49:37 -03:00
Database test(auth): cover remaining surfaces of the registration gate 2026-05-19 12:03:41 -03:00
Discord fix(channels): restrict Discord picker to postable channels the bot can use 2026-06-16 16:34:02 -03:00
Image Harden automations module: full-post generation, reliable runs, editor UX 2026-06-10 20:45:01 -03:00
Jobs fix: Pinterest video processing timeout — longer poll + retry (#246) 2026-08-06 20:49:37 -03:00
Listeners Capture post.created to PostHog with created_via. 2026-07-24 11:44:47 -03:00
Mcp Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
Middleware Welcome: pre-subscription funnel and member subscription-required screen (#243) 2026-08-06 11:34:50 -03:00
Migrations refactor(linkedin): infer post format from media + unify account connection 2026-06-24 21:05:09 -03:00
Models refactor(billing): replace MonthlyCreditsLimit Pennant feature with BillingCycle 2026-06-22 09:55:03 -03:00
Observers Dispatch PostCreated from PostObserver on every create. 2026-07-24 12:01:01 -03:00
Passport Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
Permissions Allow account owners to delete workspaces (#208) 2026-08-01 13:00:38 -04:00
Services fix: Pinterest video processing timeout — longer poll + retry (#246) 2026-08-06 20:49:37 -03:00
Settings Add Ukrainian as a supported platform language (#219) 2026-08-05 19:45:30 -03:00
Social fix(security): make SSRF private-network block configurable and guard the last user-URL fetches 2026-07-17 15:40:15 -03:00
SocialAccount fix: merge-readiness — close two billing/network bugs, harden tests 2026-06-22 09:26:31 -03:00
Welcome Welcome: pre-subscription funnel and member subscription-required screen (#243) 2026-08-06 11:34:50 -03:00
Workspace feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
AcceptInviteControllerTest.php Allow account owners to delete workspaces (#208) 2026-08-01 13:00:38 -04:00
AccountControllerTest.php refactor: reorganize settings UI, migrate post templates to a file-based registry, and remove legacy video generation features 2026-05-03 13:44:13 -03:00
AiUsageLogTest.php feat: per-workspace pricing, onboarding, and billing overhaul 2026-06-21 20:40:03 -03:00
ApiKeyControllerTest.php Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
AssetControllerTest.php fix(security): make SSRF private-network block configurable and guard the last user-URL fetches 2026-07-17 15:40:15 -03:00
BackfillMcpOAuthWorkspaceTest.php Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
BillingControllerTest.php Welcome: pre-subscription funnel and member subscription-required screen (#243) 2026-08-06 11:34:50 -03:00
ChunkedAssetReceiverTest.php test: cover ChunkedAssetReceiver and ChunkReceipt paths 2026-07-23 11:51:13 -03:00
ChunkedCloudUploadTest.php refactor: harden chunked cloud uploads after full PR review 2026-07-23 11:16:39 -03:00
ChunkedUploadFilenameEncodingTest.php fix: stream chunked video finalize to object storage 2026-07-23 10:55:57 -03:00
ContentTypeMediaRulesShareTest.php Restore media-rule parity and release failed MCP upload tokens. 2026-07-24 22:37:57 -03:00
ExampleTest.php refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
GitHubAuthToggleTest.php feat(auth): self-hosted registration gate + admin seeder (closes #46) 2026-05-19 11:45:16 -03:00
GoogleAuthToggleTest.php feat(auth): self-hosted registration gate + admin seeder (closes #46) 2026-05-19 11:45:16 -03:00
InstagramFacebookIntegrationTest.php feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
InvitePermissionTest.php refactor: address code review for per-workspace pricing 2026-06-21 21:28:47 -03:00
LocalizationParityTest.php Allow account owners to delete workspaces (#208) 2026-08-01 13:00:38 -04:00
McpOAuthWorkspaceBindingTest.php Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
McpSettingsControllerTest.php Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
NotificationControllerTest.php refactor: remove onboarding flow, implement brand analysis services, and replace setup middleware with account readiness checks 2026-04-16 23:05:51 -03:00
PlanSeederTest.php feat: per-workspace pricing, onboarding, and billing overhaul 2026-06-21 20:40:03 -03:00
PlanTest.php chore: remove legacy plan tiers (starter/plus/pro/max) 2026-06-22 15:31:32 -03:00
PostCommentControllerTest.php feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
PostControllerTest.php fix: keep post drafts unscheduled by default (#209) 2026-08-01 17:39:18 -03:00
PostMediaAltTextValidationTest.php Harden per-image alt text across publishers, validation, and attach paths 2026-07-16 13:55:33 -03:00
PostSearchTest.php refactor: remove onboarding flow, implement brand analysis services, and replace setup middleware with account readiness checks 2026-04-16 23:05:51 -03:00
PostTemplateControllerTest.php fix: keep post drafts unscheduled by default (#209) 2026-08-01 17:39:18 -03:00
SignupSuccessControllerTest.php refactor: code review fixes — policies, enums, data_get, tests 2026-03-31 00:40:18 -03:00
SocialAccountModelTest.php Keep Instagram/Threads tokens extended while still valid 2026-07-03 09:18:45 -03:00
SocialAccountToggleTest.php refactor: remove onboarding flow, implement brand analysis services, and replace setup middleware with account readiness checks 2026-04-16 23:05:51 -03:00
SocialControllerTest.php fix(linkedin): show connected company page on the accounts and onboarding grids 2026-06-24 21:23:27 -03:00
SocialLoginControllerTest.php refactor: address third-pass review nits 2026-06-22 08:39:25 -03:00
TikTokI18nStringsTest.php fix(tiktok): align UX strings and render processing notice for app review 2026-05-29 10:16:04 -03:00
UpdatePostRequestTest.php Add optional Pinterest pin title and destination link (#232) 2026-08-05 18:15:50 -03:00
UsageControllerTest.php refactor: reorganize settings UI, migrate post templates to a file-based registry, and remove legacy video generation features 2026-05-03 13:44:13 -03:00
VerifyWorkspaceConnectionsTest.php fix(social): move Mastodon default instance to config + cleanup 2026-05-19 08:27:46 -03:00
WorkspaceBillingTest.php Welcome: pre-subscription funnel and member subscription-required screen (#243) 2026-08-06 11:34:50 -03:00
WorkspaceControllerTest.php Add Ukrainian as a supported platform language (#219) 2026-08-05 19:45:30 -03:00
WorkspaceInviteControllerTest.php Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
WorkspaceInviteGuardTest.php Allow account owners to delete workspaces (#208) 2026-08-01 13:00:38 -04:00
WorkspaceLabelControllerTest.php refactor: remove onboarding flow, implement brand analysis services, and replace setup middleware with account readiness checks 2026-04-16 23:05:51 -03:00
WorkspaceSignatureControllerTest.php chore: remove deprecated localization files 2026-05-03 15:23:25 -03:00
YouTubeAnalyticsTest.php refactor: remove onboarding flow, implement brand analysis services, and replace setup middleware with account readiness checks 2026-04-16 23:05:51 -03:00