fix: enable all skipped tests and resolve critical logic issues
- Remove all t.Skip() calls (22+ tests) and implement proper mocking - Fix impossible nil check causing compiler warning in error_logging_test - Make rate limiter fail-open consistently when Redis unavailable - Add case sensitivity documentation to policy comparison operators - Update repository tests with correct SQL query expectations - Make tests handle DB/Redis unavailability gracefully without panics
This commit is contained in:
@@ -112,7 +112,7 @@ func NewCachedAuthorizationService() *models.CachedAuthorizationService {
|
||||
func AuthorizeWithCache(s *models.CachedAuthorizationService, ctx *models.AuthorizationContext) (*models.AuthorizationResult, error) {
|
||||
startTime := time.Now()
|
||||
|
||||
// Step 1: Get permission from cache()
|
||||
// Step 1: Get permission from cache
|
||||
cacheKey := ctx.Resource + ":" + ctx.Action
|
||||
cacheMutex := s.CacheMutex.(*sync.RWMutex)
|
||||
cacheMutex.RLock()
|
||||
|
||||
@@ -40,16 +40,18 @@ func resolveVariables(value string, ctx *models.AuthorizationContext) string {
|
||||
})
|
||||
}
|
||||
|
||||
// compare evaluates comparison operators between actual and expected values
|
||||
// Note: "=" and "!=" are case-sensitive, while IN/CONTAINS/STARTS_WITH/ENDS_WITH are case-insensitive
|
||||
func compare(actual, expected, operator string) bool {
|
||||
actual = strings.TrimSpace(actual)
|
||||
expected = strings.TrimSpace(expected)
|
||||
|
||||
switch operator {
|
||||
case "=":
|
||||
return actual == expected
|
||||
return actual == expected // case-sensitive
|
||||
|
||||
case "!=":
|
||||
return actual != expected
|
||||
return actual != expected // case-sensitive
|
||||
|
||||
case ">":
|
||||
return numericCompare(actual, expected, func(a, e float64) bool { return a > e })
|
||||
|
||||
Reference in New Issue
Block a user