Skip to content

Commit

Permalink
Merge pull request #21516 from vbotbuildovich/backport-pr-21452-v23.2…
Browse files Browse the repository at this point in the history
….x-483

[v23.2.x] rpk: make mechanism flag required in user update
  • Loading branch information
r-vasquez authored Jul 19, 2024
2 parents 648a041 + 86990d5 commit 32646ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/go/rpk/pkg/cli/acl/user/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ func newUpdateCommand(fs afero.Fs, p *config.Params) *cobra.Command {
}

cmd.Flags().StringVar(&newPass, "new-password", "", "New user's password.")
cmd.Flags().StringVar(&mechanism, "mechanism", adminapi.ScramSha256, "SASL mechanism to use for the user you are creating (scram-sha-256, scram-sha-512, case insensitive)")
cmd.Flags().StringVar(&mechanism, "mechanism", adminapi.ScramSha256, "SASL mechanism to use for the user you are updating (scram-sha-256, scram-sha-512, case insensitive)")
cmd.MarkFlagRequired("new-password")
cmd.MarkFlagRequired("mechanism")

return cmd
}
5 changes: 3 additions & 2 deletions tests/rptest/clients/rpk.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,11 @@ def sasl_create_user_basic_mix(self,

return self._run(cmd)

def sasl_update_user(self, user, new_password):
def sasl_update_user(self, user, new_password, new_mechanism):
cmd = [
"acl", "user", "update", user, "--new-password", new_password,
"-X", "admin.hosts=" + self._redpanda.admin_endpoints()
"--mechanism", new_mechanism, "-X",
"admin.hosts=" + self._redpanda.admin_endpoints()
]
return self._run(cmd)

Expand Down
3 changes: 2 additions & 1 deletion tests/rptest/tests/rpk_acl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def test_create_update(self):
# We check that we can list the topics:
assert topic in topic_list

out = self._rpk.sasl_update_user(self.username, new_password)
out = self._rpk.sasl_update_user(self.username, new_password,
self.mechanism)
assert f'Updated user "{self.username}" successfully' in out

with expect_exception(
Expand Down

0 comments on commit 32646ee

Please sign in to comment.