From 96b5387a7afcb092eeac24126f781fa628af2383 Mon Sep 17 00:00:00 2001 From: haisum Date: Sat, 19 Aug 2023 00:54:37 +0500 Subject: [PATCH] remove wildcard validation from mappings Signed-off-by: haisum --- v2/account_claims.go | 4 ---- v2/account_claims_test.go | 14 +++++++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/v2/account_claims.go b/v2/account_claims.go index 9524009..a62d488 100644 --- a/v2/account_claims.go +++ b/v2/account_claims.go @@ -154,10 +154,6 @@ func (m *Mapping) Validate(vr *ValidationResults) { total := uint8(0) for _, wm := range wm { wm.Subject.Validate(vr) - if wm.Subject.HasWildCards() { - vr.AddError("Subject %q in weighted mapping %q is not allowed to contains wildcard", - string(wm.Subject), ubFrom) - } total += wm.GetWeight() } if total > 100 { diff --git a/v2/account_claims_test.go b/v2/account_claims_test.go index 27b2714..899d65d 100644 --- a/v2/account_claims_test.go +++ b/v2/account_claims_test.go @@ -693,10 +693,18 @@ func TestAccountMapping(t *testing.T) { // don't block encoding!!! vr = &ValidationResults{} account.Mappings = Mapping{} - account.AddMapping("foo5", WeightedMapping{Subject: "to.*"}) + account.AddMapping("foo5.>", WeightedMapping{Subject: "to.*.>"}) account.Validate(vr) - if !vr.IsBlocking(false) { - t.Fatal("Expected errors due to wildcard in weighted mapping") + if !vr.IsEmpty() { + t.Fatal("Expected no errors") + } + + vr = &ValidationResults{} + account.Mappings = Mapping{} + account.AddMapping("foo6.>", WeightedMapping{Subject: "to.boo.>"}) + account.Validate(vr) + if !vr.IsEmpty() { + t.Fatal("Expected no errors") } }