Skip to content

Cover custom org roles CRUD in org integration suite#181

Open
sdairs wants to merge 3 commits into
issue-152-bootstrap-org-integrationfrom
issue-154-custom-roles-crud
Open

Cover custom org roles CRUD in org integration suite#181
sdairs wants to merge 3 commits into
issue-152-bootstrap-org-integrationfrom
issue-154-custom-roles-crud

Conversation

@sdairs
Copy link
Copy Markdown
Collaborator

@sdairs sdairs commented May 15, 2026

Summary

Adds a Custom Roles CRUD phase to integration_org_test.rs covering the five client methods called out in #154: organization_roles_get_list, organization_role_post, organization_role_get, organization_role_patch, organization_role_delete.

  • Pre-list captures existing role ids so the post-create list assertion can prove the new role is genuinely new (not a stale leak from a previous run).
  • Create uses clickhousectl-it-role-{run_id} so concurrent CI runs don't collide. Registered with CleanupRegistry::register_role immediately, before any further interaction, so a mid-phase failure still reclaims it via teardown.
  • Get + post-create list assert the role surfaces with the expected name, RBACRoleType::Custom, and the permissions sent in the POST body.
  • Patch swaps a single policy's permission set (idempotent on retry) and verifies the change via a follow-up GET, which is what real callers will observe.
  • Delete unregisters from CleanupRegistry on success and asserts a follow-up GET returns 404. On failure the registration stays put so teardown can still try as best-effort fallback.

All steps are NonBlocking so a single live run reports every broken endpoint in the phase, not just the first. No downstream phase depends on the role existing.

Closes #154
Parent: #151

This PR is stacked on #173 (which delivered the integration_org_test.rs skeleton and CleanupRegistry::register_role). GitHub will auto-retarget to main when #173 merges.

Test plan

  • cargo build -p clickhouse-cloud-api clean
  • cargo clippy -p clickhouse-cloud-api --test integration_org_test -- -D warnings clean. Pre-existing clippy errors in integration_test.rs (too_many_arguments) and spec_coverage_test.rs (collapsible_if) are unrelated and present on the base branch.
  • cargo test -p clickhouse-cloud-api — all suites green; integration_org_test still registers exactly one ignored lifecycle test.
  • Live --ignored run via the cloud-integration workflow once this PR re-targets main.

@sdairs sdairs requested a review from iskakaushik as a code owner May 15, 2026 16:08
@sdairs sdairs had a problem deploying to cloud-integration May 15, 2026 16:08 — with GitHub Actions Failure
@sdairs sdairs had a problem deploying to cloud-integration May 15, 2026 17:59 — with GitHub Actions Failure
@sdairs sdairs temporarily deployed to cloud-integration May 15, 2026 18:48 — with GitHub Actions Inactive
@sdairs sdairs linked an issue May 15, 2026 that may be closed by this pull request
@sdairs sdairs force-pushed the issue-152-bootstrap-org-integration branch 2 times, most recently from efa7803 to 4fbc39a Compare May 16, 2026 11:24
sdairs added 3 commits May 16, 2026 12:28
Adds a Custom Roles CRUD phase to `integration_org_test.rs` that
exercises `organization_roles_get_list`, `organization_role_post`,
`organization_role_get`, `organization_role_patch` and
`organization_role_delete` end-to-end:

- Pre-list captures existing role ids for a sanity assertion that the
  created role is genuinely new.
- Create uses `clickhousectl-it-role-{run_id}` so concurrent CI runs
  don't collide. The role is registered with `CleanupRegistry` before
  any further interaction so teardown still reclaims it on mid-phase
  failure.
- Get + list-after-create check the role surfaces with the expected
  name, custom type, and permissions.
- Patch replaces the policy permissions; a follow-up GET asserts the
  change is observable to real callers.
- Delete unregisters from `CleanupRegistry` on success and verifies a
  follow-up GET returns 404. On failure the registration stays put as
  best-effort fallback for teardown.

All steps are `NonBlocking`; no downstream phase depends on the role.

Closes #154
Parent: #151
Stacked on #173.
The API rejected `organization/*` with `BAD_REQUEST: Organization * must
match the role's organization` — the wildcard form is only valid for
instance-scoped resources (the spec example is `instance/*`). For
org-scoped resources the API requires the literal org id.

Replaces `organization/*` with `format!("organization/{org_id}")` in
both the create and patch policy bodies.
The API rejects mixed-scope permissions inside a single policy ("All
permissions in a policy must target the same resource scope. Found
mixed scopes: organization, service. Split into separate policies per
scope."). The patch step was bundling an org-scoped permission and a
service-scoped permission in one policy.

Restructure the patch body to send two policies: one org-scoped (the
permission carried over from create) targeting `organization/{org_id}`,
and one service-scoped (the newly added permission) targeting
`instance/*`. The verify-via-GET step flattens permissions across all
policies, so its assertion logic is unchanged.

This also exercises the multi-policy code path, which the
single-policy version did not.
@sdairs sdairs force-pushed the issue-154-custom-roles-crud branch from d8fcc23 to 4ec3d92 Compare May 16, 2026 11:28
@sdairs sdairs temporarily deployed to cloud-integration May 16, 2026 11:28 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cover custom org roles CRUD in org integration suite

1 participant