Skip to content

Commit a3394d2

Browse files
test(auth): validate cache key selector is valid CEL
Add CEL syntax validation to the subscription cache key test. The cache key selector is evaluated by Authorino as a CEL expression at runtime, so a syntax error would cause subscription-info cache lookups to fail silently. Uses cel-go parser to verify the expression parses without errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3e19d3e commit a3394d2

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

maas-controller/go.mod

100644100755
File mode changed.

maas-controller/go.sum

100644100755
File mode changed.

maas-controller/pkg/controller/maas/maasauthpolicy_controller_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,4 +485,21 @@ func TestMaaSAuthPolicyReconciler_SubscriptionCacheKey(t *testing.T) {
485485
}
486486
})
487487
}
488+
489+
// Verify the cache key selector is a syntactically valid CEL expression.
490+
// Authorino evaluates this string as CEL at runtime, so a syntax error here
491+
// would cause all subscription-info cache lookups to fail silently.
492+
t.Run("is valid CEL expression", func(t *testing.T) {
493+
env, err := cel.NewEnv()
494+
if err != nil {
495+
t.Fatalf("failed to create CEL environment: %v", err)
496+
}
497+
ast, issues := env.Parse(cacheKeySelector)
498+
if issues != nil && issues.Err() != nil {
499+
t.Errorf("cache key selector is not a valid CEL expression:\n selector: %s\n parse error: %v", cacheKeySelector, issues.Err())
500+
}
501+
if ast == nil {
502+
t.Errorf("CEL parse returned nil AST for selector: %s", cacheKeySelector)
503+
}
504+
})
488505
}

0 commit comments

Comments
 (0)