Repository navigation
feat(api): add CreateOrganizationResource - #1987
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 10
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report for CI Build 38873543560Coverage increased (+0.07%) to 55.058%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
2a1b47f to
a54c5a7
Compare
c537a75 to
cd7d96c
Compare
a54c5a7 to
00bb31e
Compare
cd7d96c to
a19eaf4
Compare
a19eaf4 to
720735f
Compare
00bb31e to
f713892
Compare
720735f to
3e237c1
Compare
3e237c1 to
88e94de
Compare
|
End to end against a local server, with Postgres and SpiceDB in Docker. The binary under test is the whole stack (#1985, #1986, #1987, #1989, #1990, #1991). The
|
rohilsurana
left a comment
There was a problem hiding this comment.
Four questions inline. One is about the re-create path, which was already like this for project resources. The other three are about how the project RPCs and the disabled org gate treat an org resource. None of them are about who may call the new RPC.
f713892 to
a6f7b49
Compare
88e94de to
57293d0
Compare
Create a resource that belongs to an organization: the URN uses the organization id, SpiceDB links the resource to the organization, and the audit record names the organization. Project and organization resources share one create path in the service and in the handler. Callers need get on the organization; a missing organization returns not found and a disabled one failed precondition. Resource responses now include org_id.
57293d0 to
89ddff6
Compare
Summary
CreateOrganizationResourcecreates a resource that belongs to an organization and not to a project. Project and organization resources share one create path. Stacked on #1986.Changes
resource.Service.Createlooks up the parent once withgetParent: the organization when the resource has one and no project, else the project. One path then saves the row, links the parent in SpiceDB, adds the owner, and writes theresource.createdaudit record, which names the project or the organization.frn:<org id>:<namespace>:<name>.resource.Service.Deleteuses the same lookup, so its audit record works for both kinds.addParentToResourcereplacesAddProjectToResource, which onlyCreateused.CreateProjectResourceandCreateOrganizationResourcesharecreateResourcein the handler.CreateProjectResourcekeeps its project lookup, responses, and error messages.CreateOrganizationResourcereturns not found for a missing organization.geton the organization, then the plan entitlement, asCreateProjectResourcedoes on the project.getParentand the plan entitlement check read the organization withGetRaw. A disabled organization is then handled only by the organization state check inIsAuthorized: callers get failed precondition, and a platform superuser skips it, as on project resources.org_id.Technical Details
org_idto be a UUID, so an organization name is not accepted.GetRawchange does not touch existing RPCs.Test Plan
go test ./core/resource/passes. New cases: the organization path (URN, organization link, owner, audit record naming the organization), a failed organization lookup that creates nothing, the exact project link and project audit record on create, and deleting an organization resource.go test ./internal/api/v1beta1connect/passes, with theCreateProjectResourcecases unchanged. NewTestConnectHandler_CreateOrganizationResource: missing body, missing organization, bad detail, conflict, internal error, and success withorg_idand no project. NewTestCheckPlanEntitlement: a disabled organization passes.TestResourceAPIcase 5: a member creates a resource; the response has the organization, no project, and the URN; the creator can update it and another member cannot; creating it again returns the same id; after the organization is disabled, the member gets failed precondition and a platform superuser still creates one. With eitherGetRawback toGet, the superuser's create fails.TestPATScope_AllProjectsDoesNotReachOrgResources: a token scoped to all projects can update a resource in a project and cannot update a resource owned by the same organization. The PAT suite now seeds the compute permissions.go test ./test/e2e/...passes.golangci-lint runreports no issues.