refac: removed 7 direct and 12 indirect go modules for custom code instead
This commit is contained in:
1 parent
cfcf108488
commit
c68e9a7858
73 files changed
+2455
-428
No files matched your search
@@ -15,11 +15,11 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"RenewCMS/api/pkg/authtoken"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/jwtauth/v5"
|
||||
)
|
||||
|
||||
func newEditArticleBodyRouter(articleRepo *mockArticleRepo, token *jwtauth.JWTAuth) *chi.Mux {
|
||||
func newEditArticleBodyRouter(articleRepo *mockArticleRepo, token *authtoken.Auth) *chi.Mux {
|
||||
userRepo := newVerifiedUserRepo()
|
||||
getUserUseCase := useCases.NewGetUserUseCase(userRepo)
|
||||
|
||||
@@ -36,9 +36,9 @@ func newEditArticleBodyRouter(articleRepo *mockArticleRepo, token *jwtauth.JWTAu
|
||||
r.Route("/v1", func(r chi.Router) {
|
||||
r.Route("/article", func(r chi.Router) {
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(jwtauth.Verifier(token))
|
||||
r.Use(authtoken.Verifier(token))
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(jwtauth.Authenticator(token))
|
||||
r.Use(authtoken.Authenticator)
|
||||
r.Use(middleware.RequireVerifiedUser(getUserUseCase))
|
||||
r.Patch("/{id}", articleHandler.UpdateArticleBody)
|
||||
})
|
||||
@@ -55,9 +55,9 @@ func newEditArticleBodyTestRepo() *mockArticleRepo {
|
||||
return repo
|
||||
}
|
||||
|
||||
func setEditArticleBodyJwtCookie(t *testing.T, req *http.Request, token *jwtauth.JWTAuth) {
|
||||
func setEditArticleBodyJwtCookie(t *testing.T, req *http.Request, token *authtoken.Auth) {
|
||||
t.Helper()
|
||||
_, tokenString, err := token.Encode(map[string]any{"user_id": uint32(1)})
|
||||
tokenString, err := token.Encode(map[string]any{"user_id": uint32(1)})
|
||||
if err != nil {
|
||||
t.Fatalf("failed to encode jwt: %v", err)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func newEditArticleBodyRequest(method, target string, body string) *http.Request
|
||||
|
||||
func TestEditArticleBodyHttp(t *testing.T) {
|
||||
validator.InitValidator()
|
||||
token := jwtauth.New("HS256", []byte("test-secret"), nil)
|
||||
token := authtoken.New([]byte("test-secret"))
|
||||
|
||||
t.Run("Editing an existing article's body updates only the body", func(t *testing.T) {
|
||||
repo := newEditArticleBodyTestRepo()
|
||||
|
||||
Reference in new issue
Block a user