Skip to content

Commit 0efd24f

Browse files
committed
feat(password): add test for validate password method
1 parent b4b8b06 commit 0efd24f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

coderd/users_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,24 @@ func TestUpdateUserPassword(t *testing.T) {
11581158
require.Equal(t, database.AuditActionWrite, auditor.AuditLogs()[numLogs-1].Action)
11591159
})
11601160

1161+
t.Run("ValidateUserPassword", func(t *testing.T) {
1162+
t.Parallel()
1163+
auditor := audit.NewMock()
1164+
client := coderdtest.New(t, &coderdtest.Options{Auditor: auditor})
1165+
1166+
_ = coderdtest.CreateFirstUser(t, client)
1167+
1168+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
1169+
defer cancel()
1170+
1171+
resp, err := client.ValidateUserPassword(ctx, codersdk.ValidateUserPasswordRequest{
1172+
Password: "MySecurePassword!",
1173+
})
1174+
1175+
require.NoError(t, err, "users shoud be able to validate complexity of a potential new password")
1176+
require.True(t, resp.Valid)
1177+
})
1178+
11611179
t.Run("ChangingPasswordDeletesKeys", func(t *testing.T) {
11621180
t.Parallel()
11631181

0 commit comments

Comments
 (0)