Skip to content

Commit

Permalink
[FIX] relaxed requirement for the operator key when deleting an user …
Browse files Browse the repository at this point in the history
…if --revoke was not specified.

Fixes #652
  • Loading branch information
aricart committed May 30, 2024
1 parent 01db6f2 commit 067a8ed
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/deleteuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ func (p *DeleteUserParams) Validate(ctx ActionCtx) error {
}
}

if err := p.SignerParams.Resolve(ctx); err != nil {
return err
if p.revoke {
if err := p.SignerParams.Resolve(ctx); err != nil {
return err
}
}

return nil
Expand Down
21 changes: 21 additions & 0 deletions cmd/deleteuser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,24 @@ func Test_DeleteUserFromDiffAccountInteractive(t *testing.T) {
_, err = os.Stat(ts.KeyStore.GetUserCredsPath("A", "a"))
require.True(t, os.IsNotExist(err))
}

func Test_RevokeUserRequiresOperatorKey(t *testing.T) {
ts := NewTestStore(t, "O")
defer ts.Done(t)

ts.AddAccount(t, "A")
ts.AddUser(t, "A", "U")

_, err := ts.Store.ReadUserClaim("A", "U")
require.NoError(t, err)

opk, err := ts.Store.GetRootPublicKey()
require.NoError(t, err)
require.NoError(t, ts.KeyStore.Remove(opk))

_, _, err = ExecuteCmd(createDeleteUserCmd(), "--name", "U", "--revoke")
require.Error(t, err)

_, _, err = ExecuteCmd(createDeleteUserCmd(), "--name", "U")
require.NoError(t, err)
}

0 comments on commit 067a8ed

Please sign in to comment.