(redisAddr string)
| 301 | } |
| 302 | |
| 303 | func createTestMiddleware(redisAddr string) *GinJWTMiddleware { |
| 304 | middleware := &GinJWTMiddleware{ |
| 305 | Realm: "test zone", |
| 306 | Key: []byte("secret key"), |
| 307 | Timeout: time.Hour, |
| 308 | MaxRefresh: time.Hour * 24, |
| 309 | IdentityKey: "id", |
| 310 | Authenticator: testAuthenticator, |
| 311 | PayloadFunc: testPayloadFunc, |
| 312 | } |
| 313 | |
| 314 | // Configure Redis using functional options |
| 315 | middleware.EnableRedisStore( |
| 316 | WithRedisAddr(redisAddr), |
| 317 | WithRedisCache( |
| 318 | 1024*1024, |
| 319 | 50*time.Millisecond, |
| 320 | ), // 1MB for testing, very short TTL for testing |
| 321 | WithRedisKeyPrefix("test-jwt:"), |
| 322 | ) |
| 323 | |
| 324 | return middleware |
| 325 | } |
| 326 | |
| 327 | func testAuthenticator(c *gin.Context) (any, error) { |
| 328 | var loginVals struct { |
no test coverage detected
searching dependent graphs…