refac: removed 7 direct and 12 indirect go modules for custom code instead

This commit is contained in:
Florian Sylvain committed 2026-10-21 23:13:46 +02:00
1 parent cfcf108488
commit c68e9a7858
73 files changed
+2455 -428

No files matched your search

+6 -6
View File
@@ -7,12 +7,12 @@ import (
"net/http/httptest"
"testing"
"github.com/go-chi/jwtauth/v5"
"RenewCMS/api/pkg/authtoken"
)
func requestWithJwtClaims(t *testing.T, token *jwtauth.JWTAuth, claimsToEncode map[string]any) *http.Request {
func requestWithJwtClaims(t *testing.T, token *authtoken.Auth, claimsToEncode map[string]any) *http.Request {
t.Helper()
_, tokenString, err := token.Encode(claimsToEncode)
tokenString, err := token.Encode(claimsToEncode)
if err != nil {
t.Fatalf("failed to encode jwt: %v", err)
}
@@ -21,11 +21,11 @@ func requestWithJwtClaims(t *testing.T, token *jwtauth.JWTAuth, claimsToEncode m
t.Fatalf("failed to decode jwt: %v", err)
}
req := httptest.NewRequest(http.MethodGet, "/", nil)
return req.WithContext(jwtauth.NewContext(req.Context(), decoded, nil))
return req.WithContext(authtoken.NewContext(req.Context(), decoded, nil))
}
func TestClaimsTokenVersion(t *testing.T) {
token := jwtauth.New("HS256", []byte("test-secret"), nil)
token := authtoken.New([]byte("test-secret"))
t.Run("returns the numeric token_version claim", func(t *testing.T) {
req := requestWithJwtClaims(t, token, map[string]any{"user_id": uint32(7), "token_version": uint32(3)})
@@ -68,7 +68,7 @@ func TestClaimsTokenVersion(t *testing.T) {
}
func TestClaimsUserId(t *testing.T) {
token := jwtauth.New("HS256", []byte("test-secret"), nil)
token := authtoken.New([]byte("test-secret"))
t.Run("returns the numeric user_id claim", func(t *testing.T) {
req := requestWithJwtClaims(t, token, map[string]any{"user_id": uint32(7)})