From 137624815ce15ee914f803d4a4e274eba45db959 Mon Sep 17 00:00:00 2001 From: devhaozi <115467771+devhaozi@users.noreply.github.com> Date: Wed, 14 May 2025 19:19:53 +0000 Subject: [PATCH 1/2] chore(l10n): update backend pot files --- pkg/embed/locales/backend.pot | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/pkg/embed/locales/backend.pot b/pkg/embed/locales/backend.pot index e48a1dea..60320583 100644 --- a/pkg/embed/locales/backend.pot +++ b/pkg/embed/locales/backend.pot @@ -1234,7 +1234,7 @@ msgstr "" msgid "Zip is a library for handling ZIP files" msgstr "" -#: internal/http/middleware/must_login.go:95 +#: internal/data/user_token.go:129 msgid "api signature expired" msgstr "" @@ -1299,7 +1299,7 @@ msgstr "" msgid "check server connection failed" msgstr "" -#: internal/http/middleware/must_login.go:123 +#: internal/http/middleware/must_login.go:83 msgid "client ip/ua changed, please login again" msgstr "" @@ -1687,17 +1687,25 @@ msgstr "" msgid "get service port failed, please check if it is installed" msgstr "" -#: internal/data/user.go:160 -#: internal/data/user.go:178 +#: internal/data/user.go:169 +#: internal/data/user.go:187 #: internal/service/user.go:96 msgid "invalid 2FA code" msgstr "" +#: internal/data/user_token.go:101 +msgid "invalid Authorization algorithm, must be HMAC-SHA256" +msgstr "" + +#: internal/data/user_token.go:98 +msgid "invalid Authorization header: %v" +msgstr "" + #: internal/http/middleware/entrance.go:101 msgid "invalid access entrance" msgstr "" -#: internal/http/middleware/must_login.go:85 +#: internal/data/user_token.go:124 msgid "invalid api signature" msgstr "" @@ -1709,6 +1717,7 @@ msgstr "" msgid "invalid request domain: %s" msgstr "" +#: internal/data/user_token.go:139 #: internal/http/middleware/entrance.go:63 msgid "invalid request ip: %s" msgstr "" @@ -1717,7 +1726,7 @@ msgstr "" msgid "invalid request user agent: %s" msgstr "" -#: internal/http/middleware/must_login.go:137 +#: internal/http/middleware/must_login.go:97 msgid "invalid user id, please login again" msgstr "" @@ -1803,7 +1812,7 @@ msgstr "" msgid "phpMyAdmin port not found" msgstr "" -#: internal/data/user.go:92 +#: internal/data/user.go:96 #: internal/service/file.go:135 #: internal/service/file.go:222 #: internal/service/file.go:251 @@ -1847,7 +1856,7 @@ msgstr "" msgid "runtime directory does not exist" msgstr "" -#: internal/http/middleware/must_login.go:108 +#: internal/http/middleware/must_login.go:68 msgid "session expired, please login again" msgstr "" @@ -1937,9 +1946,9 @@ msgstr "" msgid "upload file error: %v" msgstr "" -#: internal/data/user.go:107 -#: internal/data/user.go:114 -#: internal/data/user.go:124 +#: internal/data/user.go:116 +#: internal/data/user.go:123 +#: internal/data/user.go:133 msgid "username or password error" msgstr "" From 924e69070a7adfdadc210dde9cb32786f7373723 Mon Sep 17 00:00:00 2001 From: devhaozi <115467771+devhaozi@users.noreply.github.com> Date: Wed, 14 May 2025 19:20:06 +0000 Subject: [PATCH 2/2] chore: update mocks --- mocks/biz/UserTokenRepo.go | 61 +++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/mocks/biz/UserTokenRepo.go b/mocks/biz/UserTokenRepo.go index f4e2de91..aa685cef 100644 --- a/mocks/biz/UserTokenRepo.go +++ b/mocks/biz/UserTokenRepo.go @@ -3,9 +3,12 @@ package biz import ( - mock "github.com/stretchr/testify/mock" + http "net/http" + biz "github.com/tnb-labs/panel/internal/biz" + mock "github.com/stretchr/testify/mock" + time "time" ) @@ -313,6 +316,62 @@ func (_c *UserTokenRepo_Update_Call) RunAndReturn(run func(uint, []string, time. return _c } +// ValidateReq provides a mock function with given fields: req +func (_m *UserTokenRepo) ValidateReq(req *http.Request) (uint, error) { + ret := _m.Called(req) + + if len(ret) == 0 { + panic("no return value specified for ValidateReq") + } + + var r0 uint + var r1 error + if rf, ok := ret.Get(0).(func(*http.Request) (uint, error)); ok { + return rf(req) + } + if rf, ok := ret.Get(0).(func(*http.Request) uint); ok { + r0 = rf(req) + } else { + r0 = ret.Get(0).(uint) + } + + if rf, ok := ret.Get(1).(func(*http.Request) error); ok { + r1 = rf(req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UserTokenRepo_ValidateReq_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ValidateReq' +type UserTokenRepo_ValidateReq_Call struct { + *mock.Call +} + +// ValidateReq is a helper method to define mock.On call +// - req *http.Request +func (_e *UserTokenRepo_Expecter) ValidateReq(req interface{}) *UserTokenRepo_ValidateReq_Call { + return &UserTokenRepo_ValidateReq_Call{Call: _e.mock.On("ValidateReq", req)} +} + +func (_c *UserTokenRepo_ValidateReq_Call) Run(run func(req *http.Request)) *UserTokenRepo_ValidateReq_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*http.Request)) + }) + return _c +} + +func (_c *UserTokenRepo_ValidateReq_Call) Return(_a0 uint, _a1 error) *UserTokenRepo_ValidateReq_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *UserTokenRepo_ValidateReq_Call) RunAndReturn(run func(*http.Request) (uint, error)) *UserTokenRepo_ValidateReq_Call { + _c.Call.Return(run) + return _c +} + // NewUserTokenRepo creates a new instance of UserTokenRepo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewUserTokenRepo(t interface {