Skip to content

Commit

Permalink
Update subflags for *rals from SessionSv1.ProcessEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
TeoV authored and danbogos committed Mar 26, 2020
1 parent 9fcf7b2 commit 1d9461a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
7 changes: 4 additions & 3 deletions apier/v1/sessions_process_event_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func testSSv1ItProcessEventAuth(t *testing.T) {
authUsage := 5 * time.Minute
args := &sessions.V1ProcessEventArgs{
Flags: []string{utils.ConcatenatedKey(utils.MetaResources, utils.MetaAuthorize),
utils.ConcatenatedKey(utils.MetaRALs, utils.MetaAuth),
utils.ConcatenatedKey(utils.MetaRALs, utils.MetaAuthorize),
utils.MetaSuppliers, utils.MetaAttributes},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
Expand Down Expand Up @@ -236,7 +236,7 @@ func testSSv1ItProcessEventAuth(t *testing.T) {
func testSSv1ItProcessEventInitiateSession(t *testing.T) {
initUsage := 5 * time.Minute
args := &sessions.V1ProcessEventArgs{
Flags: []string{utils.ConcatenatedKey(utils.MetaRALs, utils.MetaInit),
Flags: []string{utils.ConcatenatedKey(utils.MetaRALs, utils.MetaInitiate),
utils.ConcatenatedKey(utils.MetaResources, utils.MetaAllocate), utils.MetaAttributes},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
Expand Down Expand Up @@ -689,7 +689,8 @@ func testSSv1ItProcessEventWithCDR(t *testing.T) {

func testSSv1ItGetCDRsFromProcessEvent(t *testing.T) {
var cdrCnt int64
req := &utils.RPCCDRsFilterWithArgDispatcher{RPCCDRsFilter: &utils.RPCCDRsFilter{OriginIDs: []string{"testSSv1ItProcessEventWithCDR"}}}
req := &utils.RPCCDRsFilterWithArgDispatcher{RPCCDRsFilter: &utils.RPCCDRsFilter{
OriginIDs: []string{"testSSv1ItProcessEventWithCDR"}}}
if err := sSApierRpc.Call(utils.CDRsV1GetCDRsCount, req, &cdrCnt); err != nil {
t.Error("Unexpected error: ", err.Error())
} else if cdrCnt != 3 { // 3 for each CDR
Expand Down
4 changes: 2 additions & 2 deletions docs/sessions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ Instead of arguments, the options for enabling various functionaity will come in
\*rals
Process the event with :ref:`RALs`. Auxiliary flags available:

**\*auth**
**\*authorize**
Authorize the event.

**\*init**
**\*initiate**
Initialize a session out of event.

**\*update**
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca h1:Ejj4m0Ccl8dMMVn
github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca/go.mod h1:q7c996DUu8OrJRnewVSQzM+y/bRcxZAHoo+zCD8bFBo=
github.com/cgrates/radigo v0.0.0-20200324152710-35e651804ad1 h1:QvA6Nbwq9kTd7hsvu1xo5kwia68cLwnp0sYCq1u40TU=
github.com/cgrates/radigo v0.0.0-20200324152710-35e651804ad1/go.mod h1:HZbsg3Y+xw4lsfCqX9rzj429wrg0XOug6pFT3B6VHZY=
github.com/cgrates/rpcclient v0.0.0-20200107134035-188454eb71b3 h1:esWCSaLD2j+zfK9JpyPXFSe3c97MQFhfKp9jDiss1mU=
github.com/cgrates/rpcclient v0.0.0-20200107134035-188454eb71b3/go.mod h1:xXLqAKVvcdWeDYwHJYwDgAI3ZOg5LZYxzb72kLjsLZU=
github.com/cgrates/rpcclient v0.0.0-20200326100105-a579e2c47453 h1:kgIdi3qR/meiWILdmDRuDi1fFgd6A3lutGV6HLiTDyc=
github.com/cgrates/rpcclient v0.0.0-20200326100105-a579e2c47453/go.mod h1:xXLqAKVvcdWeDYwHJYwDgAI3ZOg5LZYxzb72kLjsLZU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand Down
3 changes: 3 additions & 0 deletions packages/debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ cgrates (0.11.0~dev) UNRELEASED; urgency=medium
* [Loader] Added support to load CSV files from URL
* [Loader] Added configurable gapi_credentials
* [Loader] Added configurable gapi_token
* [Agents] Add authentication mechanism for Radius (PAP, CHAP,
MSCHAPV2)
* [SessionS] Update subflags for *rals ( *authorize and *initiate )

-- Alexandru Tripon <[email protected]> Wed, 19 Feb 2020 13:25:52 +0200

Expand Down
6 changes: 3 additions & 3 deletions sessions/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3042,23 +3042,23 @@ func (sS *SessionS) BiRPCv1ProcessEvent(clnt rpcclient.ClientConnector,
}
}
}
// check what we need to do for RALs (*auth/*init/*update/*terminate)
// check what we need to do for RALs (*authorize/*initiate/*update/*terminate)
if argsFlagsWithParams.HasKey(utils.MetaRALs) {
if ralsOpts := argsFlagsWithParams.ParamsSlice(utils.MetaRALs); len(ralsOpts) != 0 {
//check for subflags and convert them into utils.FlagsWithParams
ralsFlagsWithParams, err := utils.FlagsWithParamsFromSlice(ralsOpts)
//for the moment only the the flag will be executed
switch {
//check for auth session
case ralsFlagsWithParams.HasKey(utils.MetaAuth):
case ralsFlagsWithParams.HasKey(utils.MetaAuthorize):
maxUsage, err := sS.authEvent(args.CGREvent.Tenant,
engine.MapEvent(args.CGREvent.Event))
if err != nil {
return utils.NewErrRALs(err)
}
rply.MaxUsage = &maxUsage
// check for init session
case ralsFlagsWithParams.HasKey(utils.MetaInit):
case ralsFlagsWithParams.HasKey(utils.MetaInitiate):
if ev.HasField(utils.CGRDebitInterval) { // dynamic DebitInterval via CGRDebitInterval
if dbtItvl, err = ev.GetDuration(utils.CGRDebitInterval); err != nil {
return utils.NewErrRALs(err)
Expand Down

0 comments on commit 1d9461a

Please sign in to comment.