Return the usage in case of Auth Session for postpaid sessions

This commit is contained in:
TeoV
2019-07-11 15:51:05 +03:00
committed by Dan Christian Bogos
parent 61ff2e2f57
commit d99d229295
2 changed files with 8 additions and 14 deletions

View File

@@ -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 == "" {

View File

@@ -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
}