8000 feat(password): add test for validate admin use case and change logic · coder/coder@94c4311 · GitHub
[go: up one dir, main page]

Skip to content

Commit 94c4311

Browse files
committed
feat(password): add test for validate admin use case and change logic
1 parent 90ee439 commit 94c4311

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

coderd/users_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ func TestUpdateUserPassword(t *testing.T) {
11221122
Password: "newpassword",
11231123
})
11241124
require.Error(t, err, "member should not be able to update own password without providing old password")
1125-
require.ErrorContains(t, err, "Old password is required for non-admin users.")
1125+
require.ErrorContains(t, err, "Old password is required.")
11261126
})
11271127

11281128
t.Run("AuditorCantTellIfPasswordIncorrect", func(t *testing.T) {
@@ -1159,7 +1159,7 @@ func TestUpdateUserPassword(t *testing.T) {
11591159
require.Equal(t, int32(http.StatusNotFound), auditor.AuditLogs()[numLogs-1].StatusCode)
11601160
})
11611161

1162-
t.Run("AdminCanUpdateOwnPasswordWithoutOldPassword", func(t *testing.T) {
1162+
t.Run("AdminCantUpdateOwnPasswordWithoutOldPassword", func(t *testing.T) {
11631163
t.Parallel()
11641164
auditor := audit.NewMock()
11651165
client := coderdtest.New(t, &coderdtest.Options{Auditor: auditor})
@@ -1176,7 +1176,8 @@ func TestUpdateUserPassword(t *testing.T) {
11761176
})
11771177
numLogs++ // add an audit log for user update
11781178

1179-
require.NoError(t, err, "admin should be able to update own password without providing old password")
1179+
require.Error(t, err, "admin should not be able to update own password without providing old password")
1180+
require.ErrorContains(t, err, "Old password is required.")
11801181

11811182
require.Len(t, auditor.AuditLogs(), numLogs)
11821183
require.Equal(t, database.AuditActionWrite, auditor.AuditLogs()[numLogs-1].Action)
@@ -1196,7 +1197,8 @@ func TestUpdateUserPassword(t *testing.T) {
11961197
require.NoError(t, err)
11971198

11981199
err = client.UpdateUserPassword(ctx, "me", codersdk.UpdateUserPasswordRequest{
1199-
Password: "MyNewSecurePassword!",
1200+
OldPassword: "SomeSecurePassword!",
1201+
Password: "MyNewSecurePassword!",
12001202
})
12011203
require.NoError(t, err)
12021204

0 commit comments

Comments
 (0)
0