mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
This commit is contained in:
committed by
Dan Christian Bogos
parent
c3f4846055
commit
734a551903
@@ -418,6 +418,12 @@ func (fsev FSEvent) V1AuthorizeArgs() (args *sessions.V1AuthorizeArgs) {
|
||||
}
|
||||
if strings.Index(subsystems, utils.MetaSuppliers) != -1 {
|
||||
args.GetSuppliers = true
|
||||
if strings.Index(subsystems, utils.MetaSuppliersEventCost) != -1 {
|
||||
args.SuppliersMaxCost = utils.MetaEventCost
|
||||
}
|
||||
if strings.Index(subsystems, utils.MetaSuppliersIgnoreErrors) != -1 {
|
||||
args.SuppliersIgnoreErrors = true
|
||||
}
|
||||
}
|
||||
if strings.Index(subsystems, utils.MetaAttributes) != -1 {
|
||||
args.GetAttributes = true
|
||||
|
||||
@@ -336,7 +336,8 @@ variable_rtp_audio_out_skip_packet_count: 0
|
||||
variable_rtp_audio_out_dtmf_packet_count: 0
|
||||
variable_rtp_audio_out_cng_packet_count: 0
|
||||
variable_rtp_audio_rtcp_packet_count: 1450
|
||||
variable_rtp_audio_rtcp_octet_count: 45940`
|
||||
variable_rtp_audio_rtcp_octet_count: 45940
|
||||
variable_cgr_subsystems: *resources%3B*attributes%3B*sessions%3B*suppliers%3B*suppliers_event_cost%3B*suppliers_ignore_errors%3B*accounts`
|
||||
|
||||
func TestEventCreation(t *testing.T) {
|
||||
body := `Event-Name: RE_SCHEDULE
|
||||
@@ -988,6 +989,10 @@ func TestFsEvV1AuthorizeArgs(t *testing.T) {
|
||||
Time: &sTime,
|
||||
Event: ev.AsMapStringInterface(timezone),
|
||||
},
|
||||
GetSuppliers: true,
|
||||
GetAttributes: true,
|
||||
SuppliersIgnoreErrors: true,
|
||||
SuppliersMaxCost: utils.MetaEventCost,
|
||||
}
|
||||
rcv := ev.V1AuthorizeArgs()
|
||||
if !reflect.DeepEqual(expected.CGREvent.Tenant, rcv.CGREvent.Tenant) {
|
||||
@@ -1004,6 +1009,10 @@ func TestFsEvV1AuthorizeArgs(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", expected.GetSuppliers, rcv.GetSuppliers)
|
||||
} else if !reflect.DeepEqual(expected.GetAttributes, rcv.GetAttributes) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", expected.GetAttributes, rcv.GetAttributes)
|
||||
} else if !reflect.DeepEqual(expected.SuppliersMaxCost, rcv.SuppliersMaxCost) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", expected.SuppliersMaxCost, rcv.SuppliersMaxCost)
|
||||
} else if !reflect.DeepEqual(expected.SuppliersIgnoreErrors, rcv.SuppliersIgnoreErrors) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", expected.SuppliersIgnoreErrors, rcv.SuppliersIgnoreErrors)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -242,6 +242,12 @@ func (kev KamEvent) V1AuthorizeArgs() (args *sessions.V1AuthorizeArgs) {
|
||||
}
|
||||
if strings.Index(subsystems, utils.MetaSuppliers) != -1 {
|
||||
args.GetSuppliers = true
|
||||
if strings.Index(subsystems, utils.MetaSuppliersEventCost) != -1 {
|
||||
args.SuppliersMaxCost = utils.MetaEventCost
|
||||
}
|
||||
if strings.Index(subsystems, utils.MetaSuppliersIgnoreErrors) != -1 {
|
||||
args.SuppliersIgnoreErrors = true
|
||||
}
|
||||
}
|
||||
if strings.Index(subsystems, utils.MetaAttributes) != -1 {
|
||||
args.GetAttributes = true
|
||||
|
||||
@@ -175,7 +175,8 @@ func TestKamEvV1AuthorizeArgs(t *testing.T) {
|
||||
"cgr_destination": "1002", "cgr_answertime": "1419839310",
|
||||
"cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200"}
|
||||
utils.CGR_DISCONNECT_CAUSE: "200",
|
||||
KamCGRSubsystems: "*accounts;**suppliers_event_cost;*suppliers_ignore_errors"}
|
||||
sTime, err := utils.ParseTimeDetectLayout(kamEv[utils.AnswerTime], timezone)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -189,6 +190,9 @@ func TestKamEvV1AuthorizeArgs(t *testing.T) {
|
||||
Time: &sTime,
|
||||
Event: kamEv.AsMapStringInterface(),
|
||||
},
|
||||
GetSuppliers: true,
|
||||
SuppliersIgnoreErrors: true,
|
||||
SuppliersMaxCost: utils.MetaEventCost,
|
||||
}
|
||||
rcv := kamEv.V1AuthorizeArgs()
|
||||
if !reflect.DeepEqual(expected.CGREvent.Tenant, rcv.CGREvent.Tenant) {
|
||||
@@ -205,6 +209,10 @@ func TestKamEvV1AuthorizeArgs(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", expected.GetSuppliers, rcv.GetSuppliers)
|
||||
} else if !reflect.DeepEqual(expected.GetAttributes, rcv.GetAttributes) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", expected.GetAttributes, rcv.GetAttributes)
|
||||
} else if !reflect.DeepEqual(expected.SuppliersMaxCost, rcv.SuppliersMaxCost) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", expected.SuppliersMaxCost, rcv.SuppliersMaxCost)
|
||||
} else if !reflect.DeepEqual(expected.SuppliersIgnoreErrors, rcv.SuppliersIgnoreErrors) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", expected.SuppliersIgnoreErrors, rcv.SuppliersIgnoreErrors)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,5 @@
|
||||
DST_1002,1002
|
||||
DST_FS,10
|
||||
DST_DE_MOBILE,+49151
|
||||
DST_DE_MOBILE,+49161
|
||||
DST_DE_MOBILE,+49171
|
||||
|
||||
|
||||
|
||||
|
@@ -56,7 +56,8 @@ func (lcs *LeastCostSorter) SortSuppliers(prflID string, suppls []*Supplier,
|
||||
utils.SupplierS, prflID, s.ID))
|
||||
continue
|
||||
}
|
||||
if extraOpts.maxCost != 0 && costData[utils.Cost].(float64) > extraOpts.maxCost {
|
||||
if extraOpts.maxCost != 0 &&
|
||||
costData[utils.Cost].(float64) > extraOpts.maxCost {
|
||||
continue
|
||||
}
|
||||
srtData := map[string]interface{}{
|
||||
@@ -65,10 +66,11 @@ func (lcs *LeastCostSorter) SortSuppliers(prflID string, suppls []*Supplier,
|
||||
for k, v := range costData {
|
||||
srtData[k] = v
|
||||
}
|
||||
sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, &SortedSupplier{
|
||||
SupplierID: s.ID,
|
||||
SortingData: srtData,
|
||||
SupplierParameters: s.SupplierParameters})
|
||||
sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers,
|
||||
&SortedSupplier{
|
||||
SupplierID: s.ID,
|
||||
SortingData: srtData,
|
||||
SupplierParameters: s.SupplierParameters})
|
||||
}
|
||||
if len(sortedSuppls.SortedSuppliers) == 0 {
|
||||
return nil, utils.ErrNotFound
|
||||
|
||||
@@ -533,6 +533,8 @@ const (
|
||||
LoaderS = "LoaderS"
|
||||
Pong = "Pong"
|
||||
MetaEventCost = "*event_cost"
|
||||
MetaSuppliersEventCost = "*suppliers_event_cost"
|
||||
MetaSuppliersIgnoreErrors = "*suppliers_ignore_errors"
|
||||
)
|
||||
|
||||
//MetaMetrics
|
||||
|
||||
Reference in New Issue
Block a user