Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/reference/qcloud_iam_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ manage role assignments.

* [qcloud iam](qcloud_iam.md) - Manage IAM resources in Qdrant Cloud
* [qcloud iam user assign-role](qcloud_iam_user_assign-role.md) - Assign one or more roles to a user
* [qcloud iam user delete](qcloud_iam_user_delete.md) - Delete a user
* [qcloud iam user describe](qcloud_iam_user_describe.md) - Describe a user and their assigned roles
* [qcloud iam user list](qcloud_iam_user_list.md) - List users in the account
* [qcloud iam user remove-role](qcloud_iam_user_remove-role.md) - Remove one or more roles from a user
Expand Down
54 changes: 54 additions & 0 deletions docs/reference/qcloud_iam_user_delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## qcloud iam user delete

Delete a user

### Synopsis

Delete a user from Qdrant Cloud.

Accepts either a user ID (UUID) or an email address to identify the user.
Deleting a user is permanent and cannot be undone. Deletion fails if the user
still owns any accounts; ownership of those accounts must be transferred first.

A confirmation prompt is shown unless --force is passed.

```
qcloud iam user delete <user-id-or-email> [flags]
```

### Examples

```
# Delete a user by email (with confirmation prompt)
qcloud iam user delete user@example.com

# Delete a user by ID
qcloud iam user delete 7b2ea926-724b-4de2-b73a-8675c42a6ebe

# Delete without confirmation
qcloud iam user delete user@example.com --force
```

### Options

```
-f, --force Skip confirmation prompt
-h, --help help for delete
```

### Options inherited from parent commands

```
--account-id string Qdrant Cloud Account ID (env: QDRANT_CLOUD_ACCOUNT_ID)
--api-key string Management API Key (env: QDRANT_CLOUD_API_KEY)
-c, --config string Config file path (env: QDRANT_CLOUD_CONFIG, default ~/.config/qcloud/config.yaml)
--context string Override the active context (env: QDRANT_CLOUD_CONTEXT)
--debug Enable debug logging to stderr
--endpoint string gRPC API endpoint (env: QDRANT_CLOUD_ENDPOINT, default grpc.cloud.qdrant.io:443)
--json Output as JSON
```

### SEE ALSO

* [qcloud iam user](qcloud_iam_user.md) - Manage users in Qdrant Cloud

18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ require (
github.com/dustin/go-humanize v1.0.1
github.com/google/uuid v1.6.0
github.com/jedib0t/go-pretty/v6 v6.8.1
github.com/qdrant/qdrant-cloud-public-api v0.146.0
github.com/qdrant/qdrant-cloud-public-api v0.158.0
github.com/robfig/cron/v3 v3.0.1
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
google.golang.org/grpc v1.81.1
google.golang.org/grpc v1.82.0
google.golang.org/protobuf v1.36.11
gopkg.in/yaml.v3 v3.0.1
)

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260415201107-50325440f8f2.1 // indirect
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260709200747-435963d16310.1 // indirect
code.gitea.io/sdk/gitea v0.22.1 // indirect
github.com/42wim/httpsig v1.2.3 // indirect
github.com/Masterminds/semver/v3 v3.4.0 // indirect
Expand Down Expand Up @@ -48,12 +48,12 @@ require (
github.com/ulikunitz/xz v0.5.15 // indirect
gitlab.com/gitlab-org/api/client-go v1.9.1 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.50.0 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/crypto v0.54.0 // indirect
golang.org/x/net v0.57.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/text v0.36.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.40.0 // indirect
golang.org/x/time v0.14.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260427160629-7cedc36a6bc4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260427160629-7cedc36a6bc4 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260713224248-f5fc221cf8c4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260713224248-f5fc221cf8c4 // indirect
)
40 changes: 20 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260415201107-50325440f8f2.1 h1:s6hzCXtND/ICdGPTMGk7C+/BFlr2Jg5GyH0NKf4XGXg=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260415201107-50325440f8f2.1/go.mod h1:tvtbpgaVXZX4g6Pn+AnzFycuRK3MOz5HJfEGeEllXYM=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260709200747-435963d16310.1 h1:fXh8CsdNpjRr8R5vFdqtIxPt/Lno2IIJlYOdZBIZn0w=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260709200747-435963d16310.1/go.mod h1:tvtbpgaVXZX4g6Pn+AnzFycuRK3MOz5HJfEGeEllXYM=
code.gitea.io/sdk/gitea v0.22.1 h1:7K05KjRORyTcTYULQ/AwvlVS6pawLcWyXZcTr7gHFyA=
code.gitea.io/sdk/gitea v0.22.1/go.mod h1:yyF5+GhljqvA30sRDreoyHILruNiy4ASufugzYg0VHM=
github.com/42wim/httpsig v1.2.3 h1:xb0YyWhkYj57SPtfSttIobJUPJZB9as1nsfo7KWVcEs=
Expand Down Expand Up @@ -69,8 +69,8 @@ github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/qdrant/qdrant-cloud-public-api v0.146.0 h1:3lgKU9hy5HEkmqy6rNfpfW6qHP7ND7ty/fgO7IAt+v8=
github.com/qdrant/qdrant-cloud-public-api v0.146.0/go.mod h1:EdLkQBSoYs6Q57T1oEou+1akCMcNWiJSSioRCzibpvY=
github.com/qdrant/qdrant-cloud-public-api v0.158.0 h1:NUo++Q5+s50H8lQcYUJly42Kfed/+3fsSJ/w+6/5omc=
github.com/qdrant/qdrant-cloud-public-api v0.158.0/go.mod h1:mrRXvd4THos5p7iwVUYAJoM18q3jMjLbn+OOF2NchOk=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
Expand Down Expand Up @@ -120,38 +120,38 @@ go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q=
golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY=
golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY=
golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
google.golang.org/genproto/googleapis/api v0.0.0-20260427160629-7cedc36a6bc4 h1:yOzSCGPx+cp5VO7IxvZ9SBFF7j1tZVcNtlHR2iYKtVo=
google.golang.org/genproto/googleapis/api v0.0.0-20260427160629-7cedc36a6bc4/go.mod h1:Q9HWtNeE7tM9npdIsEvqXj1QJIvVoeAV3rtXtS715Cw=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260427160629-7cedc36a6bc4 h1:tEkOQcXgF6dH1G+MVKZrfpYvozGrzb91k6ha7jireSM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260427160629-7cedc36a6bc4/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/grpc v1.81.1 h1:VnnIIZ88UzOOKLukQi+ImGz8O1Wdp8nAGGnvOfEIWQQ=
google.golang.org/grpc v1.81.1/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I=
google.golang.org/genproto/googleapis/api v0.0.0-20260713224248-f5fc221cf8c4 h1:lI0NbdWVmT6lOJJNDd7vyeTdfxP/7ouCLSJUKNNXa0k=
google.golang.org/genproto/googleapis/api v0.0.0-20260713224248-f5fc221cf8c4/go.mod h1:WRrQ7/7N19PypuT0fxLOL5Lq0waoiRri4FbtHDEKrGE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260713224248-f5fc221cf8c4 h1:7RtFDizMtT9eZzHzKxifoMGfcDBBy+LYZlgfg24ZmOM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260713224248-f5fc221cf8c4/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU=
google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/iam/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ manage role assignments.`,
newUserDescribeCommand(s),
newUserAssignRoleCommand(s),
newUserRemoveRoleCommand(s),
newUserDeleteCommand(s),
)
return cmd
}
77 changes: 77 additions & 0 deletions internal/cmd/iam/user_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package iam

import (
"fmt"

"github.com/spf13/cobra"

iamv1 "github.com/qdrant/qdrant-cloud-public-api/gen/go/qdrant/cloud/iam/v1"

"github.com/qdrant/qcloud-cli/internal/cmd/base"
"github.com/qdrant/qcloud-cli/internal/cmd/util"
"github.com/qdrant/qcloud-cli/internal/state"
)

func newUserDeleteCommand(s *state.State) *cobra.Command {
return base.Cmd{
Long: `Delete a user from Qdrant Cloud.

Accepts either a user ID (UUID) or an email address to identify the user.
Deleting a user is permanent and cannot be undone. Deletion fails if the user
still owns any accounts; ownership of those accounts must be transferred first.

A confirmation prompt is shown unless --force is passed.`,
Example: `# Delete a user by email (with confirmation prompt)
qcloud iam user delete user@example.com

# Delete a user by ID
qcloud iam user delete 7b2ea926-724b-4de2-b73a-8675c42a6ebe

# Delete without confirmation
qcloud iam user delete user@example.com --force`,
ValidArgsFunction: userCompletion(s),
BaseCobraCommand: func() *cobra.Command {
cmd := &cobra.Command{
Use: "delete <user-id-or-email>",
Short: "Delete a user",
Args: util.ExactArgs(1, "a user ID or email"),
}
cmd.Flags().BoolP("force", "f", false, "Skip confirmation prompt")
return cmd
},
Run: func(s *state.State, cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
force, _ := cmd.Flags().GetBool("force")

client, err := s.Client(ctx)
if err != nil {
return err
}

accountID, err := s.AccountID()
if err != nil {
return err
}

user, err := resolveUser(cmd, client, accountID, args[0])
if err != nil {
return err
}

if !util.ConfirmAction(force, cmd.ErrOrStderr(), fmt.Sprintf("Delete user %s (%s)?", user.GetEmail(), user.GetId())) {
fmt.Fprintln(cmd.OutOrStdout(), "Aborted.")
return nil
}

_, err = client.IAM().DeleteUser(ctx, &iamv1.DeleteUserRequest{
UserId: user.GetId(),
})
if err != nil {
return fmt.Errorf("failed to delete user: %w", err)
}

fmt.Fprintf(cmd.OutOrStdout(), "User %s deleted.\n", user.GetEmail())
return nil
},
}.CobraCommand(s)
}
89 changes: 89 additions & 0 deletions internal/cmd/iam/user_delete_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package iam_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

iamv1 "github.com/qdrant/qdrant-cloud-public-api/gen/go/qdrant/cloud/iam/v1"

"github.com/qdrant/qcloud-cli/internal/testutil"
)

func TestUserDelete_WithForce_ByEmail(t *testing.T) {
env := testutil.NewTestEnv(t)

env.IAMServer.ListUsersCalls.Returns(&iamv1.ListUsersResponse{
Items: []*iamv1.User{{Id: testUserID, Email: "alice@example.com"}},
}, nil)
env.IAMServer.DeleteUserCalls.Returns(&iamv1.DeleteUserResponse{}, nil)

stdout, _, err := testutil.Exec(t, env, "iam", "user", "delete", "alice@example.com", "--force")
require.NoError(t, err)
assert.Contains(t, stdout, "alice@example.com")
assert.Contains(t, stdout, "deleted")

req, ok := env.IAMServer.DeleteUserCalls.Last()
require.True(t, ok)
assert.Equal(t, testUserID, req.GetUserId())
}

func TestUserDelete_ByID(t *testing.T) {
env := testutil.NewTestEnv(t)

env.IAMServer.ListUsersCalls.Returns(&iamv1.ListUsersResponse{
Items: []*iamv1.User{{Id: testUserID, Email: "alice@example.com"}},
}, nil)
env.IAMServer.DeleteUserCalls.Returns(&iamv1.DeleteUserResponse{}, nil)

_, _, err := testutil.Exec(t, env, "iam", "user", "delete", testUserID, "--force")
require.NoError(t, err)

req, ok := env.IAMServer.DeleteUserCalls.Last()
require.True(t, ok)
assert.Equal(t, testUserID, req.GetUserId())
}

func TestUserDelete_Aborted(t *testing.T) {
env := testutil.NewTestEnv(t)

env.IAMServer.ListUsersCalls.Returns(&iamv1.ListUsersResponse{
Items: []*iamv1.User{{Id: testUserID, Email: "alice@example.com"}},
}, nil)

stdout, _, err := testutil.Exec(t, env, "iam", "user", "delete", "alice@example.com")
require.NoError(t, err)
assert.Contains(t, stdout, "Aborted.")
assert.Equal(t, 0, env.IAMServer.DeleteUserCalls.Count())
}

func TestUserDelete_ResolveUserError(t *testing.T) {
env := testutil.NewTestEnv(t)

env.IAMServer.ListUsersCalls.Returns(nil, fmt.Errorf("connection refused"))

_, _, err := testutil.Exec(t, env, "iam", "user", "delete", "alice@example.com", "--force")
require.Error(t, err)
assert.Contains(t, err.Error(), "connection refused")
}

func TestUserDelete_BackendError(t *testing.T) {
env := testutil.NewTestEnv(t)

env.IAMServer.ListUsersCalls.Returns(&iamv1.ListUsersResponse{
Items: []*iamv1.User{{Id: testUserID, Email: "alice@example.com"}},
}, nil)
env.IAMServer.DeleteUserCalls.Returns(nil, fmt.Errorf("internal server error"))

_, _, err := testutil.Exec(t, env, "iam", "user", "delete", "alice@example.com", "--force")
require.Error(t, err)
}

func TestUserDelete_MissingArg(t *testing.T) {
env := testutil.NewTestEnv(t)

_, _, err := testutil.Exec(t, env, "iam", "user", "delete")
require.Error(t, err)
}
7 changes: 7 additions & 0 deletions internal/testutil/fake_iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type FakeIAMService struct {
UpdateRoleCalls MethodSpy[*iamv1.UpdateRoleRequest, *iamv1.UpdateRoleResponse]
DeleteRoleCalls MethodSpy[*iamv1.DeleteRoleRequest, *iamv1.DeleteRoleResponse]
ListPermissionsCalls MethodSpy[*iamv1.ListPermissionsRequest, *iamv1.ListPermissionsResponse]
DeleteUserCalls MethodSpy[*iamv1.DeleteUserRequest, *iamv1.DeleteUserResponse]
}

// GetAuthenticatedUser records the call and dispatches via GetAuthenticatedUserCalls.
Expand Down Expand Up @@ -82,3 +83,9 @@ func (f *FakeIAMService) ListPermissions(ctx context.Context, req *iamv1.ListPer
f.ListPermissionsCalls.record(req)
return f.ListPermissionsCalls.dispatch(ctx, req, f.UnimplementedIAMServiceServer.ListPermissions)
}

// DeleteUser records the call and dispatches via DeleteUserCalls.
func (f *FakeIAMService) DeleteUser(ctx context.Context, req *iamv1.DeleteUserRequest) (*iamv1.DeleteUserResponse, error) {
f.DeleteUserCalls.record(req)
return f.DeleteUserCalls.dispatch(ctx, req, f.UnimplementedIAMServiceServer.DeleteUser)
}