-
Notifications
You must be signed in to change notification settings - Fork 930
feat: Add update user password endpoint #1310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
346e5e4
4bd7557
de39cf5
2fe1716
212020a
2699445
355f163
56b29fd
30b8f15
f6be255
5df5763
b9dbd64
69af903
d85092b
96ce751
4f9f506
671c56d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,6 +287,41 @@ func TestUpdateUserProfile(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestUpdateUserPassword(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also add some tests to make sure the rbac is working here, I'd like to ensure that the user itself cannot perform this action, and neither can other non-admin users. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So from what I'm understanding we want to test:
Is that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated! |
||
t.Parallel() | ||
|
||
t.Run("DifferentPasswordConfirmation", func(t *testing.T) { | ||
t.Parallel() | ||
client := coderdtest.New(t, nil) | ||
coderdtest.CreateFirstUser(t, client) | ||
err := client.UpdateUserPassword(context.Background(), codersdk.Me, codersdk.UpdateUserPasswordRequest{ | ||
Password: "newpassword", | ||
ConfirmPassword: "wrongconfirmation", | ||
}) | ||
var apiErr *codersdk.Error | ||
require.ErrorAs(t, err, &apiErr) | ||
require.Equal(t, http.StatusBadRequest, apiErr.StatusCode()) | ||
}) | ||
|
||
t.Run("Success", func(t *testing.T) { | ||
t.Parallel() | ||
client := coderdtest.New(t, nil) | ||
coderdtest.CreateFirstUser(t, client) | ||
err := client.UpdateUserPassword(context.Background(), codersdk.Me, codersdk.UpdateUserPasswordRequest{ | ||
Password: "newpassword", | ||
ConfirmPassword: "newpassword", | ||
}) | ||
require.NoError(t, err, "update password request should be successful") | ||
|
||
// Check if the user can login using the new password | ||
_, err = client.LoginWithPassword(context.Background(), codersdk.LoginWithPasswordRequest{ | ||
Email: coderdtest.FirstUserParams.Email, | ||
Password: "newpassword", | ||
}) | ||
require.NoError(t, err, "login should be successful") | ||
}) | ||
} | ||
|
||
func TestGrantRoles(t *testing.T) { | ||
t.Parallel() | ||
t.Run("UpdateIncorrectRoles", func(t *testing.T) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.