Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4f8f7aa

Browse files
committed
Fix failing tests for user proxy preferences
- Fix userProxySettings handler to return 404 when no proxy is set- Add database authorization tests for user proxy methods
1 parent0543dc7 commit4f8f7aa

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

‎coderd/database/dbauthz/dbauthz_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4896,6 +4896,24 @@ func (s *MethodTestSuite) TestNotifications() {
48964896
}).Asserts(rbac.ResourceNotificationPreference.WithOwner(user.ID.String()),policy.ActionUpdate)
48974897
}))
48984898

4899+
s.Run("GetUserPreferredProxy",s.Subtest(func(db database.Store,check*expects) {
4900+
user:=dbgen.User(s.T(),db, database.User{})
4901+
check.Args(user.ID).
4902+
Asserts(rbac.ResourceUser.WithOwner(user.ID.String()),policy.ActionReadPersonal)
4903+
}))
4904+
s.Run("UpdateUserPreferredProxy",s.Subtest(func(db database.Store,check*expects) {
4905+
user:=dbgen.User(s.T(),db, database.User{})
4906+
check.Args(database.UpdateUserPreferredProxyParams{
4907+
UserID:user.ID,
4908+
PreferredProxy:"proxy1",
4909+
}).Asserts(rbac.ResourceUser.WithOwner(user.ID.String()),policy.ActionUpdatePersonal)
4910+
}))
4911+
s.Run("DeleteUserPreferredProxy",s.Subtest(func(db database.Store,check*expects) {
4912+
user:=dbgen.User(s.T(),db, database.User{})
4913+
check.Args(user.ID).
4914+
Asserts(rbac.ResourceUser.WithOwner(user.ID.String()),policy.ActionUpdatePersonal)
4915+
}))
4916+
48994917
s.Run("GetInboxNotificationsByUserID",s.Subtest(func(db database.Store,check*expects) {
49004918
u:=dbgen.User(s.T(),db, database.User{})
49014919

‎coderd/users.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,15 +1082,18 @@ func (api *API) userProxySettings(rw http.ResponseWriter, r *http.Request) {
10821082

10831083
preferredProxy,err:=api.Database.GetUserPreferredProxy(ctx,user.ID)
10841084
iferr!=nil {
1085-
if!errors.Is(err,sql.ErrNoRows) {
1086-
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
1087-
Message:"Error reading user proxy settings.",
1088-
Detail:err.Error(),
1085+
iferrors.Is(err,sql.ErrNoRows) {
1086+
httpapi.Write(ctx,rw,http.StatusNotFound, codersdk.Response{
1087+
Message:"User proxy settings not found.",
10891088
})
10901089
return
10911090
}
10921091

1093-
preferredProxy=""
1092+
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
1093+
Message:"Error reading user proxy settings.",
1094+
Detail:err.Error(),
1095+
})
1096+
return
10941097
}
10951098

10961099
httpapi.Write(ctx,rw,http.StatusOK, codersdk.UserProxySettings{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp