mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Return the usage in case of Auth Session for postpaid sessions
This commit is contained in:
committed by
Dan Christian Bogos
parent
61ff2e2f57
commit
d99d229295
@@ -207,12 +207,7 @@ func testSSv1ItAuth(t *testing.T) {
|
||||
if err := sSv1BiRpc.Call(utils.SessionSv1AuthorizeEvent, args, &rply); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// in case of prepaid and pseudoprepade we expect a MaxUsage of 5min
|
||||
// and in case of postpaid and rated we expect -1
|
||||
if ((sSV1RequestType == utils.META_PREPAID ||
|
||||
sSV1RequestType == utils.META_PSEUDOPREPAID) && *rply.MaxUsage != authUsage) ||
|
||||
((sSV1RequestType == utils.META_POSTPAID ||
|
||||
sSV1RequestType == utils.META_RATED) && *rply.MaxUsage != -1) {
|
||||
if *rply.MaxUsage != authUsage {
|
||||
t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage)
|
||||
}
|
||||
if *rply.ResourceAllocation == "" {
|
||||
@@ -296,10 +291,7 @@ func testSSv1ItAuthWithDigest(t *testing.T) {
|
||||
}
|
||||
// in case of prepaid and pseudoprepade we expect a MaxUsage of 5min
|
||||
// and in case of postpaid and rated we expect -1
|
||||
if ((sSV1RequestType == utils.META_PREPAID ||
|
||||
sSV1RequestType == utils.META_PSEUDOPREPAID) && *rply.MaxUsage != authUsage.Seconds()) ||
|
||||
((sSV1RequestType == utils.META_POSTPAID ||
|
||||
sSV1RequestType == utils.META_RATED) && *rply.MaxUsage != -1) {
|
||||
if *rply.MaxUsage != authUsage.Seconds() {
|
||||
t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage)
|
||||
}
|
||||
if *rply.ResourceAllocation == "" {
|
||||
|
||||
@@ -1290,7 +1290,9 @@ func (sS *SessionS) initSessionDebitLoops(s *Session) {
|
||||
// authSession calculates maximum usage allowed for given session
|
||||
func (sS *SessionS) authSession(tnt string, evStart *engine.SafEvent) (maxUsage time.Duration, err error) {
|
||||
cgrID := GetSetCGRID(evStart)
|
||||
if _, err = evStart.GetDuration(utils.Usage); err != nil {
|
||||
var eventUsage time.Duration
|
||||
eventUsage, err = evStart.GetDuration(utils.Usage)
|
||||
if err != nil {
|
||||
if err != utils.ErrNotFound {
|
||||
return
|
||||
}
|
||||
@@ -1330,15 +1332,15 @@ func (sS *SessionS) authSession(tnt string, evStart *engine.SafEvent) (maxUsage
|
||||
var rplyMaxUsage time.Duration
|
||||
if !utils.IsSliceMember(prepaidReqs,
|
||||
sr.Event.GetStringIgnoreErrors(utils.RequestType)) {
|
||||
rplyMaxUsage = time.Duration(-1)
|
||||
rplyMaxUsage = eventUsage
|
||||
} else if err = sS.ralS.Call(utils.ResponderGetMaxSessionTime,
|
||||
&engine.CallDescriptorWithArgDispatcher{CallDescriptor: sr.CD,
|
||||
ArgDispatcher: s.ArgDispatcher}, &rplyMaxUsage); err != nil {
|
||||
return
|
||||
}
|
||||
if !maxUsageSet ||
|
||||
maxUsage == time.Duration(-1) ||
|
||||
(rplyMaxUsage < maxUsage && rplyMaxUsage != time.Duration(-1)) {
|
||||
maxUsage == eventUsage ||
|
||||
(rplyMaxUsage < maxUsage && rplyMaxUsage != eventUsage) {
|
||||
maxUsage = rplyMaxUsage
|
||||
maxUsageSet = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user