mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add verification for ignoreFilters opt when matching thresholds
This commit is contained in:
committed by
Dan Christian Bogos
parent
777580a06e
commit
93bd58d9db
@@ -154,17 +154,15 @@ func testDspThPing(t *testing.T) {
|
||||
func testDspThTestAuthKey(t *testing.T) {
|
||||
var ids []string
|
||||
nowTime := time.Now()
|
||||
args := &engine.ThresholdsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &nowTime,
|
||||
Event: map[string]interface{}{
|
||||
utils.AccountField: "1002"},
|
||||
args := &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &nowTime,
|
||||
Event: map[string]interface{}{
|
||||
utils.AccountField: "1002"},
|
||||
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "12345",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "12345",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -183,17 +181,15 @@ func testDspThTestAuthKey2(t *testing.T) {
|
||||
var ids []string
|
||||
eIDs := []string{"THD_ACNT_1002"}
|
||||
nowTime := time.Now()
|
||||
args := &engine.ThresholdsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &nowTime,
|
||||
Event: map[string]interface{}{
|
||||
utils.AccountField: "1002"},
|
||||
args := &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &nowTime,
|
||||
Event: map[string]interface{}{
|
||||
utils.AccountField: "1002"},
|
||||
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "thr12345",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "thr12345",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -335,8 +335,15 @@ func (tS *ThresholdService) matchingThresholdsForEvent(tnt string, args *utils.C
|
||||
return
|
||||
}
|
||||
}
|
||||
ignFilters := tS.cgrcfg.ThresholdSCfg().Opts.ProfileIgnoreFilters
|
||||
if opt, has := args.APIOpts[utils.OptsThresholdsProfileIgnoreFilters]; has {
|
||||
if ignFilters, err = utils.IfaceAsBool(opt); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
tIDs := utils.NewStringSet(thdIDs)
|
||||
if len(tIDs) == 0 {
|
||||
ignFilters = false
|
||||
tIDs, err = MatchingItemIDsForEvent(evNm,
|
||||
tS.cgrcfg.ThresholdSCfg().StringIndexedFields,
|
||||
tS.cgrcfg.ThresholdSCfg().PrefixIndexedFields,
|
||||
@@ -370,15 +377,17 @@ func (tS *ThresholdService) matchingThresholdsForEvent(tnt string, args *utils.C
|
||||
tPrfl.unlock()
|
||||
continue
|
||||
}
|
||||
var pass bool
|
||||
if pass, err = tS.filterS.Pass(tnt, tPrfl.FilterIDs,
|
||||
evNm); err != nil {
|
||||
tPrfl.unlock()
|
||||
ts.unlock()
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
tPrfl.unlock()
|
||||
continue
|
||||
if !ignFilters {
|
||||
var pass bool
|
||||
if pass, err = tS.filterS.Pass(tnt, tPrfl.FilterIDs,
|
||||
evNm); err != nil {
|
||||
tPrfl.unlock()
|
||||
ts.unlock()
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
tPrfl.unlock()
|
||||
continue
|
||||
}
|
||||
}
|
||||
lkID := guardian.Guardian.GuardIDs(utils.EmptyString,
|
||||
config.CgrConfig().GeneralCfg().LockingTimeout,
|
||||
|
||||
Reference in New Issue
Block a user