[Test with CLI generator] Add CLI support for SCIM token management using cli tooling#3354
[Test with CLI generator] Add CLI support for SCIM token management using cli tooling#3354Amelia Dong (ameliadong97) wants to merge 1 commit into
Conversation
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
There was a problem hiding this comment.
Pull request overview
Adds a new top-level confluent org scim-token command group (create / delete / list) that wraps the org/v2 SCIM tokens API, generated via the CLI tooling. Includes a corresponding test-server handler, integration tests, golden fixtures, a live test, and a bump of the ccloud-sdk-go-v2/org SDK from v0.9.0 to v0.11.0 (currently shadowed by a local replace directive).
Changes:
- New
internal/orgpackage andorg scim-token {create,delete,list}subcommands, registered at the top level. - New
Clientmethods (CreateOrgScimToken,DeleteOrgScimToken,ListOrgScimTokens) plus test-server handlers/fixtures. - Integration tests, live test, golden fixtures, and lint vocabulary additions (
Organization,scim);go.modbumped to org SDK v0.11.0 with a local-pathreplace.
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/command.go | Registers the new org top-level command. |
| internal/org/command.go | New org parent command (parallel to existing organization). |
| internal/org/command_scim_token.go | scim-token parent, shared print/autocomplete helpers. |
| internal/org/command_scim_token_create.go | create subcommand (currently sends empty InlineObject). |
| internal/org/command_scim_token_delete.go | delete subcommand using shared deletion.Delete helper. |
| internal/org/command_scim_token_list.go | list subcommand with paginated client call. |
| pkg/ccloudv2/org.go | New SCIM token API wrappers on Client. |
| test/test-server/scim_token_handler.go | Test-server handlers for GET/POST/DELETE scim-tokens. |
| test/test-server/ccloudv2_router.go | Routes the new test-server endpoints. |
| test/scim_token_test.go | Integration tests for create/delete/list/autocomplete. |
| test/live/scim_token_live_test.go | Live CRUD test (uses non-existent describe and an unsupported positional arg). |
| test/fixtures/input/org/scim_token/*.json | Fixtures consumed by the test-server handler. |
| test/fixtures/output/org/scim-token/*.golden | Golden outputs for human/json/yaml/help and delete flows. |
| test/fixtures/output/org/help.golden, help.golden | Updated top-level help to include the new org command. |
| cmd/lint/main.go | Adds Organization to properNouns and scim to vocabWords. |
| go.mod / go.sum | Bumps org SDK to v0.11.0 and adds a local-filesystem replace directive. |
Comments suppressed due to low confidence (2)
test/live/scim_token_live_test.go:47
- The "Verify deletion" step invokes
org scim-token describe, but nodescribesubcommand is registered onscimTokenCommand(onlycreate,delete, andlistare added incommand_scim_token.go). When run, this step will fail because the command is unknown, not because the resource was deleted, so the test does not actually verify deletion. Either implement adescribesubcommand or change this step to verify deletion vialist(e.g. assert the token id is no longer present) or via a seconddelete --forcethat should now return non-zero.
{
Name: "Verify deletion",
Args: "org scim-token describe {{.scim_token_id}}",
UseStateVars: true,
ExitCode: 1,
},
internal/org/command_scim_token.go:64
- The
validArgsmethod is defined but never referenced — onlyvalidArgsMultipleis wired up (viadelete'sValidArgsFunction). Dead code; either remove it or use it somewhere.
func (c *scimTokenCommand) validArgs(cmd *cobra.Command, args []string) []string {
if len(args) > 0 {
return nil
}
return c.validArgsMultiple(cmd, args)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sigs.k8s.io/yaml v1.3.0 // indirect | ||
| ) | ||
|
|
||
| replace github.com/confluentinc/ccloud-sdk-go-v2/org => /Users/ameliadong/git/go/src/github.com/confluentinc/cli-terraform-generator/test-suites/specs/org |
| scimTokenName := uniqueName("scimto") | ||
|
|
||
| // Cleanup (LIFO) | ||
| s.registerCleanup(t, "org scim-token delete {{.scim_token_id}} --force", state) | ||
|
|
||
| steps := []CLILiveTest{ | ||
| { | ||
| Name: "Create org scim token", | ||
| Args: "org scim-token create " + scimTokenName + " -o json", | ||
| ExitCode: 0, | ||
| JSONFields: map[string]string{}, | ||
| JSONFieldsExist: []string{"id"}, | ||
| CaptureID: "scim_token_id", | ||
| }, | ||
| { | ||
| Name: "List org scim tokens", | ||
| Args: "org scim-token list", | ||
| UseStateVars: true, | ||
| ExitCode: 0, | ||
| Contains: []string{scimTokenName}, |
| func New(cfg *config.Config, prerunner pcmd.PreRunner) *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "org", | ||
| Short: "Manage Organization.", | ||
| } | ||
|
|
||
| cmd.AddCommand( | ||
| newScimTokenCommand(cfg, prerunner), | ||
| // cli-tfgen:cli-subcommands | ||
| ) | ||
|
|
||
| return cmd | ||
| } |
| func newScimTokenCommand(cfg *config.Config, prerunner pcmd.PreRunner) *cobra.Command { //nolint:unparam | ||
| cmd := &cobra.Command{ | ||
| Use: "scim-token", | ||
| Short: "Manage org scim tokens.", |
| "ksqlDB Server", | ||
| "ksqlDB", | ||
| "Node.js", | ||
| "Organization", |
| // Overwrite updated fields using the request body | ||
| err := json.NewDecoder(r.Body).Decode(&scimToken) | ||
| require.NoError(t, err) | ||
|
|
||
| err = json.NewEncoder(w).Encode(scimToken) | ||
| require.NoError(t, err) |
| func (c *scimTokenCommand) create(cmd *cobra.Command, args []string) error { | ||
| createReq := orgv2.InlineObject{} | ||
|
|
||
| scimToken, httpResp, err := c.V2Client.CreateOrgScimToken(createReq) | ||
| if err != nil { | ||
| return errors.CatchCCloudV2Error(err, httpResp) | ||
| } | ||
|
|
||
| return printScimToken(cmd, scimToken) | ||
| } |
| func (s *CLITestSuite) TestOrgScimTokenCreate() { | ||
| tests := []CLITest{ | ||
| {args: "org scim-token create", fixture: "org/scim-token/create.golden"}, | ||
| } | ||
|
|
||
| for _, test := range tests { | ||
| test.login = "cloud" | ||
| s.runIntegrationTest(test) | ||
| } | ||
| } | ||
|
|
||
| func (s *CLITestSuite) TestOrgScimTokenDelete() { | ||
| tests := []CLITest{ | ||
| {args: "org scim-token delete id-1 --force", fixture: "org/scim-token/delete.golden"}, | ||
| {args: "org scim-token delete id-1", input: "y\n", fixture: "org/scim-token/delete-no-force.golden"}, | ||
| {args: "org scim-token delete id-1 id-2", input: "y\n", fixture: "org/scim-token/delete-multiple.golden"}, | ||
| {args: "org scim-token delete invalid", fixture: "org/scim-token/delete-invalid.golden", exitCode: 1}, | ||
| } | ||
|
|
||
| for _, test := range tests { | ||
| test.login = "cloud" | ||
| s.runIntegrationTest(test) | ||
| } | ||
| } | ||
|
|
||
| func (s *CLITestSuite) TestOrgScimTokenList() { | ||
| tests := []CLITest{ | ||
| {args: "org scim-token list", fixture: "org/scim-token/list.golden"}, | ||
| {args: "org scim-token list -o json", fixture: "org/scim-token/list-json.golden"}, | ||
| {args: "org scim-token list -o yaml", fixture: "org/scim-token/list-yaml.golden"}, | ||
| } | ||
|
|
||
| for _, test := range tests { | ||
| test.login = "cloud" | ||
| s.runIntegrationTest(test) | ||
| } | ||
| } | ||
|
|
||
| func (s *CLITestSuite) TestOrgScimToken_Autocomplete() { | ||
| tests := []CLITest{ | ||
| {args: "__complete org scim-token delete \"\"", fixture: "org/scim-token/delete-autocomplete.golden"}, | ||
| } | ||
|
|
||
| for _, test := range tests { | ||
| test.login = "cloud" | ||
| s.runIntegrationTest(test) | ||
| } | ||
| } |
| } | ||
|
|
||
| func (c *scimTokenCommand) list(cmd *cobra.Command, _ []string) error { | ||
|
|
Release Notes
Breaking Changes
New Features
Bug Fixes
Checklist
Whatsection below whether this PR applies to Confluent Cloud, Confluent Platform, or both.Test & Reviewsection below.Blast Radiussection below.What
Blast Radius
References
Test & Review