mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
integrate IPs with SessionS
This commit is contained in:
committed by
Dan Christian Bogos
parent
17f11d060b
commit
897d6f0da1
@@ -86,6 +86,7 @@ func processRequest(ctx *context.Context, reqProcessor *config.RequestProcessor,
|
|||||||
reqProcessor.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaStats),
|
reqProcessor.Flags.GetBool(utils.MetaStats),
|
||||||
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
||||||
|
reqProcessor.Flags.GetBool(utils.MetaIPs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaResources),
|
reqProcessor.Flags.GetBool(utils.MetaResources),
|
||||||
reqProcessor.Flags.Has(utils.MetaAccounts),
|
reqProcessor.Flags.Has(utils.MetaAccounts),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaRoutes),
|
reqProcessor.Flags.GetBool(utils.MetaRoutes),
|
||||||
@@ -112,6 +113,7 @@ func processRequest(ctx *context.Context, reqProcessor *config.RequestProcessor,
|
|||||||
reqProcessor.Flags.GetBool(utils.MetaStats),
|
reqProcessor.Flags.GetBool(utils.MetaStats),
|
||||||
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaResources),
|
reqProcessor.Flags.GetBool(utils.MetaResources),
|
||||||
|
reqProcessor.Flags.GetBool(utils.MetaIPs),
|
||||||
reqProcessor.Flags.Has(utils.MetaAccounts),
|
reqProcessor.Flags.Has(utils.MetaAccounts),
|
||||||
cgrEv, reqProcessor.Flags.Has(utils.MetaFD))
|
cgrEv, reqProcessor.Flags.Has(utils.MetaFD))
|
||||||
rply := new(sessions.V1InitSessionReply)
|
rply := new(sessions.V1InitSessionReply)
|
||||||
@@ -144,6 +146,7 @@ func processRequest(ctx *context.Context, reqProcessor *config.RequestProcessor,
|
|||||||
terminateArgs := sessions.NewV1TerminateSessionArgs(
|
terminateArgs := sessions.NewV1TerminateSessionArgs(
|
||||||
reqProcessor.Flags.Has(utils.MetaAccounts),
|
reqProcessor.Flags.Has(utils.MetaAccounts),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaResources),
|
reqProcessor.Flags.GetBool(utils.MetaResources),
|
||||||
|
reqProcessor.Flags.GetBool(utils.MetaIPs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaThresholds),
|
reqProcessor.Flags.GetBool(utils.MetaThresholds),
|
||||||
reqProcessor.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaStats),
|
reqProcessor.Flags.GetBool(utils.MetaStats),
|
||||||
@@ -165,6 +168,7 @@ func processRequest(ctx *context.Context, reqProcessor *config.RequestProcessor,
|
|||||||
reqProcessor.Flags.GetBool(utils.MetaStats),
|
reqProcessor.Flags.GetBool(utils.MetaStats),
|
||||||
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaResources),
|
reqProcessor.Flags.GetBool(utils.MetaResources),
|
||||||
|
reqProcessor.Flags.GetBool(utils.MetaIPs),
|
||||||
reqProcessor.Flags.Has(utils.MetaAccounts),
|
reqProcessor.Flags.Has(utils.MetaAccounts),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaRoutes),
|
reqProcessor.Flags.GetBool(utils.MetaRoutes),
|
||||||
reqProcessor.Flags.Has(utils.MetaRoutesIgnoreErrors),
|
reqProcessor.Flags.Has(utils.MetaRoutesIgnoreErrors),
|
||||||
|
|||||||
@@ -357,6 +357,7 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R
|
|||||||
reqProcessor.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaStats),
|
reqProcessor.Flags.GetBool(utils.MetaStats),
|
||||||
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
||||||
|
reqProcessor.Flags.GetBool(utils.MetaIPs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaResources),
|
reqProcessor.Flags.GetBool(utils.MetaResources),
|
||||||
reqProcessor.Flags.Has(utils.MetaAccounts),
|
reqProcessor.Flags.Has(utils.MetaAccounts),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaRoutes),
|
reqProcessor.Flags.GetBool(utils.MetaRoutes),
|
||||||
@@ -382,6 +383,7 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R
|
|||||||
reqProcessor.Flags.GetBool(utils.MetaStats),
|
reqProcessor.Flags.GetBool(utils.MetaStats),
|
||||||
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaResources),
|
reqProcessor.Flags.GetBool(utils.MetaResources),
|
||||||
|
reqProcessor.Flags.GetBool(utils.MetaIPs),
|
||||||
reqProcessor.Flags.Has(utils.MetaAccounts),
|
reqProcessor.Flags.Has(utils.MetaAccounts),
|
||||||
cgrEv, reqProcessor.Flags.Has(utils.MetaFD))
|
cgrEv, reqProcessor.Flags.Has(utils.MetaFD))
|
||||||
rply := new(sessions.V1InitSessionReply)
|
rply := new(sessions.V1InitSessionReply)
|
||||||
@@ -414,6 +416,7 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R
|
|||||||
terminateArgs := sessions.NewV1TerminateSessionArgs(
|
terminateArgs := sessions.NewV1TerminateSessionArgs(
|
||||||
reqProcessor.Flags.Has(utils.MetaAccounts),
|
reqProcessor.Flags.Has(utils.MetaAccounts),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaResources),
|
reqProcessor.Flags.GetBool(utils.MetaResources),
|
||||||
|
reqProcessor.Flags.GetBool(utils.MetaIPs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaThresholds),
|
reqProcessor.Flags.GetBool(utils.MetaThresholds),
|
||||||
reqProcessor.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaStats),
|
reqProcessor.Flags.GetBool(utils.MetaStats),
|
||||||
@@ -435,6 +438,7 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R
|
|||||||
reqProcessor.Flags.GetBool(utils.MetaStats),
|
reqProcessor.Flags.GetBool(utils.MetaStats),
|
||||||
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaResources),
|
reqProcessor.Flags.GetBool(utils.MetaResources),
|
||||||
|
reqProcessor.Flags.GetBool(utils.MetaIPs),
|
||||||
reqProcessor.Flags.Has(utils.MetaAccounts),
|
reqProcessor.Flags.Has(utils.MetaAccounts),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaRoutes),
|
reqProcessor.Flags.GetBool(utils.MetaRoutes),
|
||||||
reqProcessor.Flags.Has(utils.MetaRoutesIgnoreErrors),
|
reqProcessor.Flags.Has(utils.MetaRoutesIgnoreErrors),
|
||||||
|
|||||||
@@ -430,6 +430,7 @@ func (sa *SIPAgent) processRequest(reqProcessor *config.RequestProcessor,
|
|||||||
reqProcessor.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaStats),
|
reqProcessor.Flags.GetBool(utils.MetaStats),
|
||||||
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
reqProcessor.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
||||||
|
reqProcessor.Flags.GetBool(utils.MetaIPs),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaResources),
|
reqProcessor.Flags.GetBool(utils.MetaResources),
|
||||||
reqProcessor.Flags.Has(utils.MetaAccounts),
|
reqProcessor.Flags.Has(utils.MetaAccounts),
|
||||||
reqProcessor.Flags.GetBool(utils.MetaRoutes),
|
reqProcessor.Flags.GetBool(utils.MetaRoutes),
|
||||||
|
|||||||
@@ -183,6 +183,16 @@ func (ip *AllocatedIP) AsNavigableMap() map[string]*utils.DataNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Digest returns a string representation of the allocated IP for digest replies.
|
||||||
|
func (ip *AllocatedIP) Digest() string {
|
||||||
|
return utils.ConcatenatedKey(
|
||||||
|
ip.ProfileID,
|
||||||
|
ip.PoolID,
|
||||||
|
ip.Message,
|
||||||
|
ip.Address.String(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// IPAllocations represents IP allocations with usage tracking and TTL management.
|
// IPAllocations represents IP allocations with usage tracking and TTL management.
|
||||||
type IPAllocations struct {
|
type IPAllocations struct {
|
||||||
Tenant string
|
Tenant string
|
||||||
|
|||||||
@@ -2212,6 +2212,7 @@ type mongoStoredSession struct {
|
|||||||
NodeID string
|
NodeID string
|
||||||
CGRID string
|
CGRID string
|
||||||
Tenant string
|
Tenant string
|
||||||
|
IPAllocID string
|
||||||
ResourceID string
|
ResourceID string
|
||||||
ClientConnID string
|
ClientConnID string
|
||||||
EventStart MapEvent
|
EventStart MapEvent
|
||||||
@@ -2238,6 +2239,7 @@ func (ms *MongoStorage) SetBackupSessionsDrv(nodeID, tnt string, storedSessions
|
|||||||
NodeID: nodeID,
|
NodeID: nodeID,
|
||||||
CGRID: sess.CGRID,
|
CGRID: sess.CGRID,
|
||||||
Tenant: sess.Tenant,
|
Tenant: sess.Tenant,
|
||||||
|
IPAllocID: sess.IPAllocID,
|
||||||
ResourceID: sess.ResourceID,
|
ResourceID: sess.ResourceID,
|
||||||
ClientConnID: sess.ClientConnID,
|
ClientConnID: sess.ClientConnID,
|
||||||
EventStart: sess.EventStart,
|
EventStart: sess.EventStart,
|
||||||
@@ -2286,6 +2288,7 @@ func (ms *MongoStorage) GetSessionsBackupDrv(nodeID, tnt string) ([]*StoredSessi
|
|||||||
oneStSession := &StoredSession{
|
oneStSession := &StoredSession{
|
||||||
CGRID: result.CGRID,
|
CGRID: result.CGRID,
|
||||||
Tenant: result.Tenant,
|
Tenant: result.Tenant,
|
||||||
|
IPAllocID: result.IPAllocID,
|
||||||
ResourceID: result.ResourceID,
|
ResourceID: result.ResourceID,
|
||||||
ClientConnID: result.ClientConnID,
|
ClientConnID: result.ClientConnID,
|
||||||
EventStart: result.EventStart,
|
EventStart: result.EventStart,
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ type StoredSRun struct {
|
|||||||
type StoredSession struct {
|
type StoredSession struct {
|
||||||
CGRID string
|
CGRID string
|
||||||
Tenant string
|
Tenant string
|
||||||
|
IPAllocID string
|
||||||
ResourceID string
|
ResourceID string
|
||||||
ClientConnID string // connection ID towards the client so we can recover from passive
|
ClientConnID string // connection ID towards the client so we can recover from passive
|
||||||
EventStart MapEvent // Event which started the session
|
EventStart MapEvent // Event which started the session
|
||||||
|
|||||||
@@ -334,6 +334,7 @@ func (erS *ERService) processEvent(cgrEv *utils.CGREvent,
|
|||||||
rdrCfg.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
rdrCfg.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
||||||
rdrCfg.Flags.Has(utils.MetaStats),
|
rdrCfg.Flags.Has(utils.MetaStats),
|
||||||
rdrCfg.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
rdrCfg.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
||||||
|
rdrCfg.Flags.Has(utils.MetaIPs),
|
||||||
rdrCfg.Flags.Has(utils.MetaResources),
|
rdrCfg.Flags.Has(utils.MetaResources),
|
||||||
rdrCfg.Flags.Has(utils.MetaAccounts),
|
rdrCfg.Flags.Has(utils.MetaAccounts),
|
||||||
rdrCfg.Flags.Has(utils.MetaRoutes),
|
rdrCfg.Flags.Has(utils.MetaRoutes),
|
||||||
@@ -358,6 +359,7 @@ func (erS *ERService) processEvent(cgrEv *utils.CGREvent,
|
|||||||
rdrCfg.Flags.Has(utils.MetaStats),
|
rdrCfg.Flags.Has(utils.MetaStats),
|
||||||
rdrCfg.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
rdrCfg.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
||||||
rdrCfg.Flags.Has(utils.MetaResources),
|
rdrCfg.Flags.Has(utils.MetaResources),
|
||||||
|
rdrCfg.Flags.Has(utils.MetaIPs),
|
||||||
rdrCfg.Flags.Has(utils.MetaAccounts),
|
rdrCfg.Flags.Has(utils.MetaAccounts),
|
||||||
cgrEv, rdrCfg.Flags.Has(utils.MetaFD))
|
cgrEv, rdrCfg.Flags.Has(utils.MetaFD))
|
||||||
rply := new(sessions.V1InitSessionReply)
|
rply := new(sessions.V1InitSessionReply)
|
||||||
@@ -386,6 +388,7 @@ func (erS *ERService) processEvent(cgrEv *utils.CGREvent,
|
|||||||
terminateArgs := sessions.NewV1TerminateSessionArgs(
|
terminateArgs := sessions.NewV1TerminateSessionArgs(
|
||||||
rdrCfg.Flags.Has(utils.MetaAccounts),
|
rdrCfg.Flags.Has(utils.MetaAccounts),
|
||||||
rdrCfg.Flags.Has(utils.MetaResources),
|
rdrCfg.Flags.Has(utils.MetaResources),
|
||||||
|
rdrCfg.Flags.Has(utils.MetaIPs),
|
||||||
rdrCfg.Flags.Has(utils.MetaThresholds),
|
rdrCfg.Flags.Has(utils.MetaThresholds),
|
||||||
rdrCfg.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
rdrCfg.Flags.ParamsSlice(utils.MetaThresholds, utils.MetaIDs),
|
||||||
rdrCfg.Flags.Has(utils.MetaStats),
|
rdrCfg.Flags.Has(utils.MetaStats),
|
||||||
@@ -406,6 +409,7 @@ func (erS *ERService) processEvent(cgrEv *utils.CGREvent,
|
|||||||
rdrCfg.Flags.Has(utils.MetaStats),
|
rdrCfg.Flags.Has(utils.MetaStats),
|
||||||
rdrCfg.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
rdrCfg.Flags.ParamsSlice(utils.MetaStats, utils.MetaIDs),
|
||||||
rdrCfg.Flags.Has(utils.MetaResources),
|
rdrCfg.Flags.Has(utils.MetaResources),
|
||||||
|
rdrCfg.Flags.Has(utils.MetaIPs),
|
||||||
rdrCfg.Flags.Has(utils.MetaAccounts),
|
rdrCfg.Flags.Has(utils.MetaAccounts),
|
||||||
rdrCfg.Flags.Has(utils.MetaRoutes),
|
rdrCfg.Flags.Has(utils.MetaRoutes),
|
||||||
rdrCfg.Flags.Has(utils.MetaRoutesIgnoreErrors),
|
rdrCfg.Flags.Has(utils.MetaRoutesIgnoreErrors),
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ func testFraudAuthorizeandProcess1(t *testing.T) {
|
|||||||
APIOpts: map[string]any{},
|
APIOpts: map[string]any{},
|
||||||
}
|
}
|
||||||
args := sessions.NewV1AuthorizeArgs(false, []string{},
|
args := sessions.NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, true,
|
false, []string{}, false, []string{}, false, false, true,
|
||||||
false, false, false, cgrEv, utils.Paginator{}, false, "")
|
false, false, false, cgrEv, utils.Paginator{}, false, "")
|
||||||
|
|
||||||
var rply sessions.V1AuthorizeReply
|
var rply sessions.V1AuthorizeReply
|
||||||
@@ -324,7 +324,7 @@ func testFraudAuthorizeandProcess2(t *testing.T) {
|
|||||||
APIOpts: map[string]any{},
|
APIOpts: map[string]any{},
|
||||||
}
|
}
|
||||||
args := sessions.NewV1AuthorizeArgs(false, []string{},
|
args := sessions.NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, true,
|
false, []string{}, false, []string{}, false, false, true,
|
||||||
false, false, false, cgrEv, utils.Paginator{}, false, "")
|
false, false, false, cgrEv, utils.Paginator{}, false, "")
|
||||||
|
|
||||||
var rply sessions.V1AuthorizeReply
|
var rply sessions.V1AuthorizeReply
|
||||||
@@ -374,7 +374,7 @@ func testFraudAuthorizeandProcess3(t *testing.T) {
|
|||||||
APIOpts: map[string]any{},
|
APIOpts: map[string]any{},
|
||||||
}
|
}
|
||||||
args := sessions.NewV1AuthorizeArgs(false, []string{},
|
args := sessions.NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, true,
|
false, []string{}, false, []string{}, false, false, true,
|
||||||
false, false, false, cgrEv, utils.Paginator{}, false, "")
|
false, false, false, cgrEv, utils.Paginator{}, false, "")
|
||||||
|
|
||||||
var rply sessions.V1AuthorizeReply
|
var rply sessions.V1AuthorizeReply
|
||||||
@@ -425,7 +425,7 @@ func testFraudFinalAuthorize(t *testing.T) {
|
|||||||
APIOpts: map[string]any{},
|
APIOpts: map[string]any{},
|
||||||
}
|
}
|
||||||
args := sessions.NewV1AuthorizeArgs(false, []string{},
|
args := sessions.NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, true,
|
false, []string{}, false, []string{}, false, false, true,
|
||||||
false, false, false, cgrEv, utils.Paginator{}, false, "")
|
false, false, false, cgrEv, utils.Paginator{}, false, "")
|
||||||
|
|
||||||
expErr := `RALS_ERROR:ACCOUNT_DISABLED`
|
expErr := `RALS_ERROR:ACCOUNT_DISABLED`
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ func testSesRoutesAuthorizeEvent(t *testing.T) {
|
|||||||
APIOpts: map[string]any{utils.OptsRoutesProfileCount: 1},
|
APIOpts: map[string]any{utils.OptsRoutesProfileCount: 1},
|
||||||
}
|
}
|
||||||
args := sessions.NewV1AuthorizeArgs(false, []string{},
|
args := sessions.NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
true, false, false, cgrEv, utils.Paginator{}, false, "")
|
true, false, false, cgrEv, utils.Paginator{}, false, "")
|
||||||
|
|
||||||
var rply sessions.V1AuthorizeReply
|
var rply sessions.V1AuthorizeReply
|
||||||
@@ -177,7 +177,7 @@ func testSesRoutesAuthorizeEvent(t *testing.T) {
|
|||||||
t.Errorf("Expected: %s, received: %s", utils.ToJSON(expected), utils.ToJSON(rply))
|
t.Errorf("Expected: %s, received: %s", utils.ToJSON(expected), utils.ToJSON(rply))
|
||||||
}
|
}
|
||||||
args = sessions.NewV1AuthorizeArgs(false, []string{},
|
args = sessions.NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
true, false, false, cgrEv, utils.Paginator{}, false, "2")
|
true, false, false, cgrEv, utils.Paginator{}, false, "2")
|
||||||
|
|
||||||
rply = sessions.V1AuthorizeReply{}
|
rply = sessions.V1AuthorizeReply{}
|
||||||
@@ -217,7 +217,7 @@ func testSesRoutesAuthorizeEvent(t *testing.T) {
|
|||||||
}}
|
}}
|
||||||
// now we will set the maxCOst to be 1 in order to match route3 and route1
|
// now we will set the maxCOst to be 1 in order to match route3 and route1
|
||||||
args = sessions.NewV1AuthorizeArgs(false, []string{},
|
args = sessions.NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
true, false, false, cgrEv, utils.Paginator{}, false, "1")
|
true, false, false, cgrEv, utils.Paginator{}, false, "1")
|
||||||
|
|
||||||
rply = sessions.V1AuthorizeReply{}
|
rply = sessions.V1AuthorizeReply{}
|
||||||
@@ -231,7 +231,7 @@ func testSesRoutesAuthorizeEvent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args = sessions.NewV1AuthorizeArgs(false, []string{},
|
args = sessions.NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
true, false, true, cgrEv, utils.Paginator{}, false, "")
|
true, false, true, cgrEv, utils.Paginator{}, false, "")
|
||||||
|
|
||||||
rply = sessions.V1AuthorizeReply{}
|
rply = sessions.V1AuthorizeReply{}
|
||||||
@@ -266,7 +266,7 @@ func testSesRoutesProcessMessage(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
args := sessions.NewV1ProcessMessageArgs(false, []string{},
|
args := sessions.NewV1ProcessMessageArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
true, false, false, cgrEv, utils.Paginator{}, false, "")
|
true, false, false, cgrEv, utils.Paginator{}, false, "")
|
||||||
|
|
||||||
var rply sessions.V1ProcessMessageReply
|
var rply sessions.V1ProcessMessageReply
|
||||||
@@ -312,7 +312,7 @@ func testSesRoutesProcessMessage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args = sessions.NewV1ProcessMessageArgs(false, []string{},
|
args = sessions.NewV1ProcessMessageArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
true, false, false, cgrEv, utils.Paginator{}, false, "2")
|
true, false, false, cgrEv, utils.Paginator{}, false, "2")
|
||||||
|
|
||||||
rply = sessions.V1ProcessMessageReply{}
|
rply = sessions.V1ProcessMessageReply{}
|
||||||
@@ -352,7 +352,7 @@ func testSesRoutesProcessMessage(t *testing.T) {
|
|||||||
}}
|
}}
|
||||||
// now we will set the maxCOst to be 1 in order to match route3 and route1
|
// now we will set the maxCOst to be 1 in order to match route3 and route1
|
||||||
args = sessions.NewV1ProcessMessageArgs(false, []string{},
|
args = sessions.NewV1ProcessMessageArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
true, false, false, cgrEv, utils.Paginator{}, false, "1")
|
true, false, false, cgrEv, utils.Paginator{}, false, "1")
|
||||||
|
|
||||||
rply = sessions.V1ProcessMessageReply{}
|
rply = sessions.V1ProcessMessageReply{}
|
||||||
@@ -366,7 +366,7 @@ func testSesRoutesProcessMessage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args = sessions.NewV1ProcessMessageArgs(false, []string{},
|
args = sessions.NewV1ProcessMessageArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
true, false, true, cgrEv, utils.Paginator{}, false, "")
|
true, false, true, cgrEv, utils.Paginator{}, false, "")
|
||||||
|
|
||||||
rply = sessions.V1ProcessMessageReply{}
|
rply = sessions.V1ProcessMessageReply{}
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ type Session struct {
|
|||||||
|
|
||||||
CGRID string
|
CGRID string
|
||||||
Tenant string
|
Tenant string
|
||||||
|
IPAllocID string
|
||||||
ResourceID string
|
ResourceID string
|
||||||
ClientConnID string // connection ID towards the client so we can recover from passive
|
ClientConnID string // connection ID towards the client so we can recover from passive
|
||||||
EventStart engine.MapEvent // Event which started the session
|
EventStart engine.MapEvent // Event which started the session
|
||||||
@@ -119,6 +120,7 @@ func (s *Session) Clone() (cln *Session) {
|
|||||||
cln = &Session{
|
cln = &Session{
|
||||||
CGRID: s.CGRID,
|
CGRID: s.CGRID,
|
||||||
Tenant: s.Tenant,
|
Tenant: s.Tenant,
|
||||||
|
IPAllocID: s.IPAllocID,
|
||||||
ResourceID: s.ResourceID,
|
ResourceID: s.ResourceID,
|
||||||
ClientConnID: s.ClientConnID,
|
ClientConnID: s.ClientConnID,
|
||||||
EventStart: s.EventStart.Clone(),
|
EventStart: s.EventStart.Clone(),
|
||||||
@@ -152,6 +154,7 @@ func (s *Session) asStoredSession() *engine.StoredSession {
|
|||||||
return &engine.StoredSession{
|
return &engine.StoredSession{
|
||||||
CGRID: s.CGRID,
|
CGRID: s.CGRID,
|
||||||
Tenant: s.Tenant,
|
Tenant: s.Tenant,
|
||||||
|
IPAllocID: s.IPAllocID,
|
||||||
ResourceID: s.ResourceID,
|
ResourceID: s.ResourceID,
|
||||||
ClientConnID: s.ClientConnID,
|
ClientConnID: s.ClientConnID,
|
||||||
EventStart: s.EventStart,
|
EventStart: s.EventStart,
|
||||||
@@ -181,6 +184,7 @@ func newSessionFromStoredSession(s *engine.StoredSession) *Session {
|
|||||||
return &Session{
|
return &Session{
|
||||||
CGRID: s.CGRID,
|
CGRID: s.CGRID,
|
||||||
Tenant: s.Tenant,
|
Tenant: s.Tenant,
|
||||||
|
IPAllocID: s.IPAllocID,
|
||||||
ResourceID: s.ResourceID,
|
ResourceID: s.ResourceID,
|
||||||
ClientConnID: s.ClientConnID,
|
ClientConnID: s.ClientConnID,
|
||||||
EventStart: s.EventStart,
|
EventStart: s.EventStart,
|
||||||
|
|||||||
@@ -405,6 +405,27 @@ func (sS *SessionS) forceSTerminate(s *Session, extraUsage time.Duration, tUsage
|
|||||||
utils.SessionS, err.Error(), s.ResourceID))
|
utils.SessionS, err.Error(), s.ResourceID))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(sS.cgrCfg.SessionSCfg().IPsConns) != 0 && s.IPAllocID != "" {
|
||||||
|
var reply string
|
||||||
|
cgrEv := &utils.CGREvent{
|
||||||
|
Tenant: s.Tenant,
|
||||||
|
ID: utils.GenUUID(),
|
||||||
|
Event: s.EventStart,
|
||||||
|
APIOpts: s.OptsStart,
|
||||||
|
}
|
||||||
|
if cgrEv.APIOpts == nil {
|
||||||
|
cgrEv.APIOpts = make(map[string]any)
|
||||||
|
}
|
||||||
|
cgrEv.APIOpts[utils.OptsIPsAllocationID] = s.IPAllocID
|
||||||
|
cgrEv.SetCloneable(true)
|
||||||
|
if err := sS.connMgr.Call(context.TODO(), sS.cgrCfg.SessionSCfg().IPsConns,
|
||||||
|
utils.IPsV1ReleaseIP,
|
||||||
|
cgrEv, &reply); err != nil {
|
||||||
|
utils.Logger.Warning(
|
||||||
|
fmt.Sprintf("<%s> could not release IP allocation %q: %v",
|
||||||
|
utils.SessionS, s.IPAllocID, err))
|
||||||
|
}
|
||||||
|
}
|
||||||
sS.replicateSessions(s.CGRID, false, sS.cgrCfg.SessionSCfg().ReplicationConns)
|
sS.replicateSessions(s.CGRID, false, sS.cgrCfg.SessionSCfg().ReplicationConns)
|
||||||
if clnt := sS.biJClnt(s.ClientConnID); clnt != nil {
|
if clnt := sS.biJClnt(s.ClientConnID); clnt != nil {
|
||||||
go func() {
|
go func() {
|
||||||
@@ -1249,7 +1270,7 @@ func (sS *SessionS) filterSessionsCount(sf *utils.SessionFilter, psv bool) (coun
|
|||||||
// newSession will populate SRuns within a Session based on ChargerS output
|
// newSession will populate SRuns within a Session based on ChargerS output
|
||||||
// forSession can only be called once per Session
|
// forSession can only be called once per Session
|
||||||
// not thread-safe since it should be called in init where there is no concurrency
|
// not thread-safe since it should be called in init where there is no concurrency
|
||||||
func (sS *SessionS) newSession(cgrEv *utils.CGREvent, resID, clntConnID string,
|
func (sS *SessionS) newSession(cgrEv *utils.CGREvent, originID, clntConnID string,
|
||||||
dbtItval time.Duration, forceDuration, isMsg bool) (s *Session, err error) {
|
dbtItval time.Duration, forceDuration, isMsg bool) (s *Session, err error) {
|
||||||
if len(sS.cgrCfg.SessionSCfg().ChargerSConns) == 0 {
|
if len(sS.cgrCfg.SessionSCfg().ChargerSConns) == 0 {
|
||||||
err = errors.New("ChargerS is disabled")
|
err = errors.New("ChargerS is disabled")
|
||||||
@@ -1263,7 +1284,8 @@ func (sS *SessionS) newSession(cgrEv *utils.CGREvent, resID, clntConnID string,
|
|||||||
s = &Session{
|
s = &Session{
|
||||||
CGRID: cgrID,
|
CGRID: cgrID,
|
||||||
Tenant: cgrEv.Tenant,
|
Tenant: cgrEv.Tenant,
|
||||||
ResourceID: resID,
|
IPAllocID: originID,
|
||||||
|
ResourceID: originID,
|
||||||
EventStart: evStart.Clone(), // decouple the event from the request so we can avoid concurrency with debit and ttl
|
EventStart: evStart.Clone(), // decouple the event from the request so we can avoid concurrency with debit and ttl
|
||||||
OptsStart: engine.MapEvent(cgrEv.APIOpts).Clone(),
|
OptsStart: engine.MapEvent(cgrEv.APIOpts).Clone(),
|
||||||
ClientConnID: clntConnID,
|
ClientConnID: clntConnID,
|
||||||
@@ -1638,9 +1660,9 @@ func (sS *SessionS) restoreSessions(sessions []*Session) {
|
|||||||
|
|
||||||
// initSession handles a new session
|
// initSession handles a new session
|
||||||
// not thread-safe for Session since it is constructed here
|
// not thread-safe for Session since it is constructed here
|
||||||
func (sS *SessionS) initSession(cgrEv *utils.CGREvent, clntConnID,
|
func (sS *SessionS) initSession(cgrEv *utils.CGREvent, clntConnID, originID string,
|
||||||
resID string, dbtItval time.Duration, isMsg, forceDuration bool) (s *Session, err error) {
|
dbtItval time.Duration, isMsg, forceDuration bool) (s *Session, err error) {
|
||||||
if s, err = sS.newSession(cgrEv, resID, clntConnID, dbtItval, forceDuration, isMsg); err != nil {
|
if s, err = sS.newSession(cgrEv, originID, clntConnID, dbtItval, forceDuration, isMsg); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !isMsg {
|
if !isMsg {
|
||||||
@@ -1971,11 +1993,12 @@ func (sS *SessionS) BiRPCv1ReplicateSessions(ctx *context.Context,
|
|||||||
// NewV1AuthorizeArgs is a constructor for V1AuthorizeArgs
|
// NewV1AuthorizeArgs is a constructor for V1AuthorizeArgs
|
||||||
func NewV1AuthorizeArgs(attrs bool, attributeIDs []string,
|
func NewV1AuthorizeArgs(attrs bool, attributeIDs []string,
|
||||||
thrslds bool, thresholdIDs []string, statQueues bool, statIDs []string,
|
thrslds bool, thresholdIDs []string, statQueues bool, statIDs []string,
|
||||||
res, maxUsage, routes, routesIgnoreErrs, routesEventCost bool,
|
ips, res, maxUsage, routes, routesIgnoreErrs, routesEventCost bool,
|
||||||
cgrEv *utils.CGREvent, routePaginator utils.Paginator,
|
cgrEv *utils.CGREvent, routePaginator utils.Paginator,
|
||||||
forceDuration bool, routesMaxCost string) (args *V1AuthorizeArgs) {
|
forceDuration bool, routesMaxCost string) (args *V1AuthorizeArgs) {
|
||||||
args = &V1AuthorizeArgs{
|
args = &V1AuthorizeArgs{
|
||||||
GetAttributes: attrs,
|
GetAttributes: attrs,
|
||||||
|
AuthorizeIP: ips,
|
||||||
AuthorizeResources: res,
|
AuthorizeResources: res,
|
||||||
GetMaxUsage: maxUsage,
|
GetMaxUsage: maxUsage,
|
||||||
ProcessThresholds: thrslds,
|
ProcessThresholds: thrslds,
|
||||||
@@ -2007,6 +2030,7 @@ func NewV1AuthorizeArgs(attrs bool, attributeIDs []string,
|
|||||||
// V1AuthorizeArgs are options available in auth request
|
// V1AuthorizeArgs are options available in auth request
|
||||||
type V1AuthorizeArgs struct {
|
type V1AuthorizeArgs struct {
|
||||||
GetAttributes bool
|
GetAttributes bool
|
||||||
|
AuthorizeIP bool
|
||||||
AuthorizeResources bool
|
AuthorizeResources bool
|
||||||
GetMaxUsage bool
|
GetMaxUsage bool
|
||||||
ForceDuration bool
|
ForceDuration bool
|
||||||
@@ -2030,6 +2054,8 @@ func (args *V1AuthorizeArgs) ParseFlags(flags, sep string) {
|
|||||||
switch {
|
switch {
|
||||||
case subsystem == utils.MetaAccounts:
|
case subsystem == utils.MetaAccounts:
|
||||||
args.GetMaxUsage = true
|
args.GetMaxUsage = true
|
||||||
|
case subsystem == utils.MetaIPs:
|
||||||
|
args.AuthorizeIP = true
|
||||||
case subsystem == utils.MetaResources:
|
case subsystem == utils.MetaResources:
|
||||||
args.AuthorizeResources = true
|
args.AuthorizeResources = true
|
||||||
case subsystem == utils.MetaRoutes:
|
case subsystem == utils.MetaRoutes:
|
||||||
@@ -2059,6 +2085,7 @@ func (args *V1AuthorizeArgs) ParseFlags(flags, sep string) {
|
|||||||
// V1AuthorizeReply are options available in auth reply
|
// V1AuthorizeReply are options available in auth reply
|
||||||
type V1AuthorizeReply struct {
|
type V1AuthorizeReply struct {
|
||||||
Attributes *engine.AttrSProcessEventReply `json:",omitempty"`
|
Attributes *engine.AttrSProcessEventReply `json:",omitempty"`
|
||||||
|
AllocatedIP *engine.AllocatedIP `json:",omitempty"`
|
||||||
ResourceAllocation *string `json:",omitempty"`
|
ResourceAllocation *string `json:",omitempty"`
|
||||||
MaxUsage *time.Duration `json:",omitempty"`
|
MaxUsage *time.Duration `json:",omitempty"`
|
||||||
RouteProfiles engine.SortedRoutesList `json:",omitempty"`
|
RouteProfiles engine.SortedRoutesList `json:",omitempty"`
|
||||||
@@ -2070,49 +2097,55 @@ type V1AuthorizeReply struct {
|
|||||||
|
|
||||||
// SetMaxUsageNeeded used by agent that use the reply as NavigableMapper
|
// SetMaxUsageNeeded used by agent that use the reply as NavigableMapper
|
||||||
// only used for gob encoding
|
// only used for gob encoding
|
||||||
func (v1AuthReply *V1AuthorizeReply) SetMaxUsageNeeded(getMaxUsage bool) {
|
func (r *V1AuthorizeReply) SetMaxUsageNeeded(getMaxUsage bool) {
|
||||||
if v1AuthReply == nil {
|
if r == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v1AuthReply.needsMaxUsage = getMaxUsage
|
r.needsMaxUsage = getMaxUsage
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsNavigableMap is part of engine.NavigableMapper interface
|
// AsNavigableMap is part of engine.NavigableMapper interface
|
||||||
func (v1AuthReply *V1AuthorizeReply) AsNavigableMap() map[string]*utils.DataNode {
|
func (r *V1AuthorizeReply) AsNavigableMap() map[string]*utils.DataNode {
|
||||||
cgrReply := make(map[string]*utils.DataNode)
|
cgrReply := make(map[string]*utils.DataNode)
|
||||||
if v1AuthReply.Attributes != nil {
|
if r.Attributes != nil {
|
||||||
attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
||||||
for _, fldName := range v1AuthReply.Attributes.AlteredFields {
|
for _, fldName := range r.Attributes.AlteredFields {
|
||||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||||
if v1AuthReply.Attributes.CGREvent.HasField(fldName) {
|
if r.Attributes.CGREvent.HasField(fldName) {
|
||||||
attrs.Map[fldName] = utils.NewLeafNode(v1AuthReply.Attributes.CGREvent.Event[fldName])
|
attrs.Map[fldName] = utils.NewLeafNode(r.Attributes.CGREvent.Event[fldName])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapAttributes] = attrs
|
cgrReply[utils.CapAttributes] = attrs
|
||||||
}
|
}
|
||||||
if v1AuthReply.ResourceAllocation != nil {
|
if r.AllocatedIP != nil {
|
||||||
cgrReply[utils.CapResourceAllocation] = utils.NewLeafNode(*v1AuthReply.ResourceAllocation)
|
cgrReply[utils.CapAllocatedIP] = &utils.DataNode{
|
||||||
|
Type: utils.NMMapType,
|
||||||
|
Map: r.AllocatedIP.AsNavigableMap(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if v1AuthReply.MaxUsage != nil {
|
if r.ResourceAllocation != nil {
|
||||||
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(*v1AuthReply.MaxUsage)
|
cgrReply[utils.CapResourceAllocation] = utils.NewLeafNode(*r.ResourceAllocation)
|
||||||
} else if v1AuthReply.needsMaxUsage {
|
}
|
||||||
|
if r.MaxUsage != nil {
|
||||||
|
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(*r.MaxUsage)
|
||||||
|
} else if r.needsMaxUsage {
|
||||||
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(0)
|
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if v1AuthReply.RouteProfiles != nil {
|
if r.RouteProfiles != nil {
|
||||||
nm := v1AuthReply.RouteProfiles.AsNavigableMap()
|
nm := r.RouteProfiles.AsNavigableMap()
|
||||||
cgrReply[utils.CapRouteProfiles] = nm
|
cgrReply[utils.CapRouteProfiles] = nm
|
||||||
}
|
}
|
||||||
if v1AuthReply.ThresholdIDs != nil {
|
if r.ThresholdIDs != nil {
|
||||||
thIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*v1AuthReply.ThresholdIDs))}
|
thIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*r.ThresholdIDs))}
|
||||||
for i, v := range *v1AuthReply.ThresholdIDs {
|
for i, v := range *r.ThresholdIDs {
|
||||||
thIDs.Slice[i] = utils.NewLeafNode(v)
|
thIDs.Slice[i] = utils.NewLeafNode(v)
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapThresholds] = thIDs
|
cgrReply[utils.CapThresholds] = thIDs
|
||||||
}
|
}
|
||||||
if v1AuthReply.StatQueueIDs != nil {
|
if r.StatQueueIDs != nil {
|
||||||
stIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*v1AuthReply.StatQueueIDs))}
|
stIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*r.StatQueueIDs))}
|
||||||
for i, v := range *v1AuthReply.StatQueueIDs {
|
for i, v := range *r.StatQueueIDs {
|
||||||
stIDs.Slice[i] = utils.NewLeafNode(v)
|
stIDs.Slice[i] = utils.NewLeafNode(v)
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapStatQueues] = stIDs
|
cgrReply[utils.CapStatQueues] = stIDs
|
||||||
@@ -2157,7 +2190,7 @@ func (sS *SessionS) BiRPCv1AuthorizeEvent(ctx *context.Context,
|
|||||||
}
|
}
|
||||||
// end of RPC caching
|
// end of RPC caching
|
||||||
|
|
||||||
if !args.GetAttributes && !args.AuthorizeResources &&
|
if !args.GetAttributes && !args.AuthorizeResources && !args.AuthorizeIP &&
|
||||||
!args.GetMaxUsage && !args.GetRoutes {
|
!args.GetMaxUsage && !args.GetRoutes {
|
||||||
return utils.NewErrMandatoryIeMissing(utils.Subsystems)
|
return utils.NewErrMandatoryIeMissing(utils.Subsystems)
|
||||||
}
|
}
|
||||||
@@ -2206,6 +2239,25 @@ func (sS *SessionS) BiRPCv1AuthorizeEvent(ctx *context.Context,
|
|||||||
}
|
}
|
||||||
authReply.ResourceAllocation = &allocMsg
|
authReply.ResourceAllocation = &allocMsg
|
||||||
}
|
}
|
||||||
|
if args.AuthorizeIP {
|
||||||
|
if len(sS.cgrCfg.SessionSCfg().IPsConns) == 0 {
|
||||||
|
return utils.NewErrNotConnected(utils.IPs)
|
||||||
|
}
|
||||||
|
originID, _ := args.CGREvent.FieldAsString(utils.OriginID)
|
||||||
|
if originID == "" {
|
||||||
|
originID = utils.UUIDSha1Prefix()
|
||||||
|
}
|
||||||
|
var allocIP engine.AllocatedIP
|
||||||
|
if args.APIOpts == nil {
|
||||||
|
args.APIOpts = make(map[string]any)
|
||||||
|
}
|
||||||
|
args.CGREvent.APIOpts[utils.OptsIPsAllocationID] = originID
|
||||||
|
if err = sS.connMgr.Call(context.TODO(), sS.cgrCfg.SessionSCfg().IPsConns, utils.IPsV1AuthorizeIP,
|
||||||
|
args.CGREvent, &allocIP); err != nil {
|
||||||
|
return utils.NewErrIPs(err)
|
||||||
|
}
|
||||||
|
authReply.AllocatedIP = &allocIP
|
||||||
|
}
|
||||||
if args.GetRoutes {
|
if args.GetRoutes {
|
||||||
routesReply, err := sS.getRoutes(args.CGREvent.Clone(), args.Paginator,
|
routesReply, err := sS.getRoutes(args.CGREvent.Clone(), args.Paginator,
|
||||||
args.RoutesIgnoreErrors, args.RoutesMaxCost, false)
|
args.RoutesIgnoreErrors, args.RoutesMaxCost, false)
|
||||||
@@ -2246,6 +2298,7 @@ func (sS *SessionS) BiRPCv1AuthorizeEvent(ctx *context.Context,
|
|||||||
// V1AuthorizeReplyWithDigest contains return options for auth with digest
|
// V1AuthorizeReplyWithDigest contains return options for auth with digest
|
||||||
type V1AuthorizeReplyWithDigest struct {
|
type V1AuthorizeReplyWithDigest struct {
|
||||||
AttributesDigest *string
|
AttributesDigest *string
|
||||||
|
AllocatedIP *string
|
||||||
ResourceAllocation *string
|
ResourceAllocation *string
|
||||||
MaxUsage float64 // special treat returning time.Duration.Seconds()
|
MaxUsage float64 // special treat returning time.Duration.Seconds()
|
||||||
RoutesDigest *string
|
RoutesDigest *string
|
||||||
@@ -2267,6 +2320,9 @@ func (sS *SessionS) BiRPCv1AuthorizeEventWithDigest(ctx *context.Context,
|
|||||||
if args.AuthorizeResources {
|
if args.AuthorizeResources {
|
||||||
authReply.ResourceAllocation = initAuthRply.ResourceAllocation
|
authReply.ResourceAllocation = initAuthRply.ResourceAllocation
|
||||||
}
|
}
|
||||||
|
if args.AuthorizeIP {
|
||||||
|
authReply.AllocatedIP = utils.StringPointer(initAuthRply.AllocatedIP.Digest())
|
||||||
|
}
|
||||||
if args.GetMaxUsage {
|
if args.GetMaxUsage {
|
||||||
authReply.MaxUsage = initAuthRply.MaxUsage.Seconds()
|
authReply.MaxUsage = initAuthRply.MaxUsage.Seconds()
|
||||||
}
|
}
|
||||||
@@ -2287,9 +2343,10 @@ func (sS *SessionS) BiRPCv1AuthorizeEventWithDigest(ctx *context.Context,
|
|||||||
// NewV1InitSessionArgs is a constructor for V1InitSessionArgs
|
// NewV1InitSessionArgs is a constructor for V1InitSessionArgs
|
||||||
func NewV1InitSessionArgs(attrs bool, attributeIDs []string,
|
func NewV1InitSessionArgs(attrs bool, attributeIDs []string,
|
||||||
thrslds bool, thresholdIDs []string, stats bool, statIDs []string,
|
thrslds bool, thresholdIDs []string, stats bool, statIDs []string,
|
||||||
resrc, acnt bool, cgrEv *utils.CGREvent, forceDuration bool) (args *V1InitSessionArgs) {
|
resrc, ips, acnt bool, cgrEv *utils.CGREvent, forceDuration bool) (args *V1InitSessionArgs) {
|
||||||
args = &V1InitSessionArgs{
|
args = &V1InitSessionArgs{
|
||||||
GetAttributes: attrs,
|
GetAttributes: attrs,
|
||||||
|
AllocateIP: ips,
|
||||||
AllocateResources: resrc,
|
AllocateResources: resrc,
|
||||||
InitSession: acnt,
|
InitSession: acnt,
|
||||||
ProcessThresholds: thrslds,
|
ProcessThresholds: thrslds,
|
||||||
@@ -2312,6 +2369,7 @@ func NewV1InitSessionArgs(attrs bool, attributeIDs []string,
|
|||||||
// V1InitSessionArgs are options for session initialization request
|
// V1InitSessionArgs are options for session initialization request
|
||||||
type V1InitSessionArgs struct {
|
type V1InitSessionArgs struct {
|
||||||
GetAttributes bool
|
GetAttributes bool
|
||||||
|
AllocateIP bool
|
||||||
AllocateResources bool
|
AllocateResources bool
|
||||||
InitSession bool
|
InitSession bool
|
||||||
ForceDuration bool
|
ForceDuration bool
|
||||||
@@ -2333,6 +2391,8 @@ func (args *V1InitSessionArgs) ParseFlags(flags, sep string) {
|
|||||||
args.InitSession = true
|
args.InitSession = true
|
||||||
case subsystem == utils.MetaResources:
|
case subsystem == utils.MetaResources:
|
||||||
args.AllocateResources = true
|
args.AllocateResources = true
|
||||||
|
case subsystem == utils.MetaIPs:
|
||||||
|
args.AllocateIP = true
|
||||||
case strings.HasPrefix(subsystem, utils.MetaAttributes):
|
case strings.HasPrefix(subsystem, utils.MetaAttributes):
|
||||||
args.GetAttributes = true
|
args.GetAttributes = true
|
||||||
args.AttributeIDs = getFlagIDs(subsystem)
|
args.AttributeIDs = getFlagIDs(subsystem)
|
||||||
@@ -2351,6 +2411,7 @@ func (args *V1InitSessionArgs) ParseFlags(flags, sep string) {
|
|||||||
// V1InitSessionReply are options for initialization reply
|
// V1InitSessionReply are options for initialization reply
|
||||||
type V1InitSessionReply struct {
|
type V1InitSessionReply struct {
|
||||||
Attributes *engine.AttrSProcessEventReply `json:",omitempty"`
|
Attributes *engine.AttrSProcessEventReply `json:",omitempty"`
|
||||||
|
AllocatedIP *engine.AllocatedIP `json:",omitempty"`
|
||||||
ResourceAllocation *string `json:",omitempty"`
|
ResourceAllocation *string `json:",omitempty"`
|
||||||
MaxUsage *time.Duration `json:",omitempty"`
|
MaxUsage *time.Duration `json:",omitempty"`
|
||||||
ThresholdIDs *[]string `json:",omitempty"`
|
ThresholdIDs *[]string `json:",omitempty"`
|
||||||
@@ -2369,37 +2430,43 @@ func (v1Rply *V1InitSessionReply) SetMaxUsageNeeded(getMaxUsage bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AsNavigableMap is part of engine.NavigableMapper interface
|
// AsNavigableMap is part of engine.NavigableMapper interface
|
||||||
func (v1Rply *V1InitSessionReply) AsNavigableMap() map[string]*utils.DataNode {
|
func (r *V1InitSessionReply) AsNavigableMap() map[string]*utils.DataNode {
|
||||||
cgrReply := make(map[string]*utils.DataNode)
|
cgrReply := make(map[string]*utils.DataNode)
|
||||||
if v1Rply.Attributes != nil {
|
if r.Attributes != nil {
|
||||||
attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
||||||
for _, fldName := range v1Rply.Attributes.AlteredFields {
|
for _, fldName := range r.Attributes.AlteredFields {
|
||||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||||
if v1Rply.Attributes.CGREvent.HasField(fldName) {
|
if r.Attributes.CGREvent.HasField(fldName) {
|
||||||
attrs.Map[fldName] = utils.NewLeafNode(v1Rply.Attributes.CGREvent.Event[fldName])
|
attrs.Map[fldName] = utils.NewLeafNode(r.Attributes.CGREvent.Event[fldName])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapAttributes] = attrs
|
cgrReply[utils.CapAttributes] = attrs
|
||||||
}
|
}
|
||||||
if v1Rply.ResourceAllocation != nil {
|
if r.AllocatedIP != nil {
|
||||||
cgrReply[utils.CapResourceAllocation] = utils.NewLeafNode(*v1Rply.ResourceAllocation)
|
cgrReply[utils.CapAllocatedIP] = &utils.DataNode{
|
||||||
|
Type: utils.NMMapType,
|
||||||
|
Map: r.AllocatedIP.AsNavigableMap(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if v1Rply.MaxUsage != nil {
|
if r.ResourceAllocation != nil {
|
||||||
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(*v1Rply.MaxUsage)
|
cgrReply[utils.CapResourceAllocation] = utils.NewLeafNode(*r.ResourceAllocation)
|
||||||
} else if v1Rply.needsMaxUsage {
|
}
|
||||||
|
if r.MaxUsage != nil {
|
||||||
|
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(*r.MaxUsage)
|
||||||
|
} else if r.needsMaxUsage {
|
||||||
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(0)
|
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if v1Rply.ThresholdIDs != nil {
|
if r.ThresholdIDs != nil {
|
||||||
thIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*v1Rply.ThresholdIDs))}
|
thIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*r.ThresholdIDs))}
|
||||||
for i, v := range *v1Rply.ThresholdIDs {
|
for i, v := range *r.ThresholdIDs {
|
||||||
thIDs.Slice[i] = utils.NewLeafNode(v)
|
thIDs.Slice[i] = utils.NewLeafNode(v)
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapThresholds] = thIDs
|
cgrReply[utils.CapThresholds] = thIDs
|
||||||
}
|
}
|
||||||
if v1Rply.StatQueueIDs != nil {
|
if r.StatQueueIDs != nil {
|
||||||
stIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*v1Rply.StatQueueIDs))}
|
stIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*r.StatQueueIDs))}
|
||||||
for i, v := range *v1Rply.StatQueueIDs {
|
for i, v := range *r.StatQueueIDs {
|
||||||
stIDs.Slice[i] = utils.NewLeafNode(v)
|
stIDs.Slice[i] = utils.NewLeafNode(v)
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapStatQueues] = stIDs
|
cgrReply[utils.CapStatQueues] = stIDs
|
||||||
@@ -2444,7 +2511,7 @@ func (sS *SessionS) BiRPCv1InitiateSession(ctx *context.Context,
|
|||||||
}
|
}
|
||||||
// end of RPC caching
|
// end of RPC caching
|
||||||
|
|
||||||
if !args.GetAttributes && !args.AllocateResources && !args.InitSession {
|
if !args.GetAttributes && !args.AllocateResources && !args.AllocateIP && !args.InitSession {
|
||||||
return utils.NewErrMandatoryIeMissing(utils.Subsystems)
|
return utils.NewErrMandatoryIeMissing(utils.Subsystems)
|
||||||
}
|
}
|
||||||
originID, _ := args.CGREvent.FieldAsString(utils.OriginID)
|
originID, _ := args.CGREvent.FieldAsString(utils.OriginID)
|
||||||
@@ -2476,6 +2543,24 @@ func (sS *SessionS) BiRPCv1InitiateSession(ctx *context.Context,
|
|||||||
}
|
}
|
||||||
rply.ResourceAllocation = &allocMessage
|
rply.ResourceAllocation = &allocMessage
|
||||||
}
|
}
|
||||||
|
if args.AllocateIP {
|
||||||
|
if len(sS.cgrCfg.SessionSCfg().IPsConns) == 0 {
|
||||||
|
return utils.NewErrNotConnected(utils.IPs)
|
||||||
|
}
|
||||||
|
if originID == "" {
|
||||||
|
return utils.NewErrMandatoryIeMissing(utils.OriginID)
|
||||||
|
}
|
||||||
|
if args.APIOpts == nil {
|
||||||
|
args.APIOpts = make(map[string]any)
|
||||||
|
}
|
||||||
|
args.CGREvent.APIOpts[utils.OptsIPsAllocationID] = originID
|
||||||
|
var allocIP engine.AllocatedIP
|
||||||
|
if err = sS.connMgr.Call(context.TODO(), sS.cgrCfg.SessionSCfg().IPsConns,
|
||||||
|
utils.IPsV1AllocateIP, args.CGREvent, &allocIP); err != nil {
|
||||||
|
return utils.NewErrIPs(err)
|
||||||
|
}
|
||||||
|
rply.AllocatedIP = &allocIP
|
||||||
|
}
|
||||||
if args.InitSession {
|
if args.InitSession {
|
||||||
var err error
|
var err error
|
||||||
opts := engine.MapEvent(args.APIOpts)
|
opts := engine.MapEvent(args.APIOpts)
|
||||||
@@ -2547,6 +2632,7 @@ func (sS *SessionS) BiRPCv1InitiateSession(ctx *context.Context,
|
|||||||
// V1InitReplyWithDigest is the formated reply
|
// V1InitReplyWithDigest is the formated reply
|
||||||
type V1InitReplyWithDigest struct {
|
type V1InitReplyWithDigest struct {
|
||||||
AttributesDigest *string
|
AttributesDigest *string
|
||||||
|
AllocatedIP *string
|
||||||
ResourceAllocation *string
|
ResourceAllocation *string
|
||||||
MaxUsage float64
|
MaxUsage float64
|
||||||
Thresholds *string
|
Thresholds *string
|
||||||
@@ -2570,6 +2656,10 @@ func (sS *SessionS) BiRPCv1InitiateSessionWithDigest(ctx *context.Context,
|
|||||||
initReply.ResourceAllocation = initSessionRply.ResourceAllocation
|
initReply.ResourceAllocation = initSessionRply.ResourceAllocation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if args.AllocateIP {
|
||||||
|
initReply.AllocatedIP = utils.StringPointer(initSessionRply.AllocatedIP.Digest())
|
||||||
|
}
|
||||||
|
|
||||||
if args.InitSession {
|
if args.InitSession {
|
||||||
initReply.MaxUsage = initSessionRply.MaxUsage.Seconds()
|
initReply.MaxUsage = initSessionRply.MaxUsage.Seconds()
|
||||||
}
|
}
|
||||||
@@ -2772,12 +2862,13 @@ func (sS *SessionS) BiRPCv1UpdateSession(ctx *context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewV1TerminateSessionArgs creates a new V1TerminateSessionArgs using the given arguments
|
// NewV1TerminateSessionArgs creates a new V1TerminateSessionArgs using the given arguments
|
||||||
func NewV1TerminateSessionArgs(acnts, resrc,
|
func NewV1TerminateSessionArgs(acnts, resrc, ips,
|
||||||
thrds bool, thresholdIDs []string, stats bool,
|
thrds bool, thresholdIDs []string, stats bool,
|
||||||
statIDs []string, cgrEv *utils.CGREvent, forceDuration bool) (args *V1TerminateSessionArgs) {
|
statIDs []string, cgrEv *utils.CGREvent, forceDuration bool) (args *V1TerminateSessionArgs) {
|
||||||
args = &V1TerminateSessionArgs{
|
args = &V1TerminateSessionArgs{
|
||||||
TerminateSession: acnts,
|
TerminateSession: acnts,
|
||||||
ReleaseResources: resrc,
|
ReleaseResources: resrc,
|
||||||
|
ReleaseIP: ips,
|
||||||
ProcessThresholds: thrds,
|
ProcessThresholds: thrds,
|
||||||
ProcessStats: stats,
|
ProcessStats: stats,
|
||||||
CGREvent: cgrEv,
|
CGREvent: cgrEv,
|
||||||
@@ -2796,6 +2887,7 @@ func NewV1TerminateSessionArgs(acnts, resrc,
|
|||||||
type V1TerminateSessionArgs struct {
|
type V1TerminateSessionArgs struct {
|
||||||
TerminateSession bool
|
TerminateSession bool
|
||||||
ForceDuration bool
|
ForceDuration bool
|
||||||
|
ReleaseIP bool
|
||||||
ReleaseResources bool
|
ReleaseResources bool
|
||||||
ProcessThresholds bool
|
ProcessThresholds bool
|
||||||
ProcessStats bool
|
ProcessStats bool
|
||||||
@@ -2814,6 +2906,8 @@ func (args *V1TerminateSessionArgs) ParseFlags(flags, sep string) {
|
|||||||
args.TerminateSession = true
|
args.TerminateSession = true
|
||||||
case subsystem == utils.MetaResources:
|
case subsystem == utils.MetaResources:
|
||||||
args.ReleaseResources = true
|
args.ReleaseResources = true
|
||||||
|
case subsystem == utils.MetaIPs:
|
||||||
|
args.ReleaseIP = true
|
||||||
case strings.Contains(subsystem, utils.MetaThresholds):
|
case strings.Contains(subsystem, utils.MetaThresholds):
|
||||||
args.ProcessThresholds = true
|
args.ProcessThresholds = true
|
||||||
args.ThresholdIDs = getFlagIDs(subsystem)
|
args.ThresholdIDs = getFlagIDs(subsystem)
|
||||||
@@ -2861,7 +2955,7 @@ func (sS *SessionS) BiRPCv1TerminateSession(ctx *context.Context,
|
|||||||
nil, true, utils.NonTransactional)
|
nil, true, utils.NonTransactional)
|
||||||
}
|
}
|
||||||
// end of RPC caching
|
// end of RPC caching
|
||||||
if !args.TerminateSession && !args.ReleaseResources {
|
if !args.TerminateSession && !args.ReleaseResources && !args.ReleaseIP {
|
||||||
return utils.NewErrMandatoryIeMissing(utils.Subsystems)
|
return utils.NewErrMandatoryIeMissing(utils.Subsystems)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2935,6 +3029,23 @@ func (sS *SessionS) BiRPCv1TerminateSession(ctx *context.Context,
|
|||||||
return utils.NewErrResourceS(err)
|
return utils.NewErrResourceS(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if args.ReleaseIP {
|
||||||
|
if len(sS.cgrCfg.SessionSCfg().IPsConns) == 0 {
|
||||||
|
return utils.NewErrNotConnected(utils.IPs)
|
||||||
|
}
|
||||||
|
if originID == "" {
|
||||||
|
return utils.NewErrMandatoryIeMissing(utils.OriginID)
|
||||||
|
}
|
||||||
|
var reply string
|
||||||
|
if args.APIOpts == nil {
|
||||||
|
args.APIOpts = make(map[string]any)
|
||||||
|
}
|
||||||
|
args.CGREvent.APIOpts[utils.OptsIPsAllocationID] = originID
|
||||||
|
if err = sS.connMgr.Call(context.TODO(), sS.cgrCfg.SessionSCfg().IPsConns, utils.IPsV1ReleaseIP,
|
||||||
|
args.CGREvent, &reply); err != nil {
|
||||||
|
return utils.NewErrIPs(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
if args.ProcessThresholds {
|
if args.ProcessThresholds {
|
||||||
_, err := sS.processThreshold(args.CGREvent, args.ThresholdIDs, true)
|
_, err := sS.processThreshold(args.CGREvent, args.ThresholdIDs, true)
|
||||||
if err != nil &&
|
if err != nil &&
|
||||||
@@ -3004,11 +3115,12 @@ func (sS *SessionS) BiRPCv1ProcessCDR(ctx *context.Context,
|
|||||||
|
|
||||||
// NewV1ProcessMessageArgs is a constructor for MessageArgs used by ProcessMessage
|
// NewV1ProcessMessageArgs is a constructor for MessageArgs used by ProcessMessage
|
||||||
func NewV1ProcessMessageArgs(attrs bool, attributeIDs []string,
|
func NewV1ProcessMessageArgs(attrs bool, attributeIDs []string,
|
||||||
thds bool, thresholdIDs []string, stats bool, statIDs []string, resrc, acnts,
|
thds bool, thresholdIDs []string, stats bool, statIDs []string, resrc, ips, acnts,
|
||||||
routes, routesIgnoreErrs, routesEventCost bool, cgrEv *utils.CGREvent,
|
routes, routesIgnoreErrs, routesEventCost bool, cgrEv *utils.CGREvent,
|
||||||
routePaginator utils.Paginator, forceDuration bool, routesMaxCost string) (args *V1ProcessMessageArgs) {
|
routePaginator utils.Paginator, forceDuration bool, routesMaxCost string) (args *V1ProcessMessageArgs) {
|
||||||
args = &V1ProcessMessageArgs{
|
args = &V1ProcessMessageArgs{
|
||||||
AllocateResources: resrc,
|
AllocateResources: resrc,
|
||||||
|
AllocateIP: ips,
|
||||||
Debit: acnts,
|
Debit: acnts,
|
||||||
GetAttributes: attrs,
|
GetAttributes: attrs,
|
||||||
ProcessThresholds: thds,
|
ProcessThresholds: thds,
|
||||||
@@ -3039,6 +3151,7 @@ func NewV1ProcessMessageArgs(attrs bool, attributeIDs []string,
|
|||||||
// V1ProcessMessageArgs are the options passed to ProcessMessage API
|
// V1ProcessMessageArgs are the options passed to ProcessMessage API
|
||||||
type V1ProcessMessageArgs struct {
|
type V1ProcessMessageArgs struct {
|
||||||
GetAttributes bool
|
GetAttributes bool
|
||||||
|
AllocateIP bool
|
||||||
AllocateResources bool
|
AllocateResources bool
|
||||||
Debit bool
|
Debit bool
|
||||||
ForceDuration bool
|
ForceDuration bool
|
||||||
@@ -3064,6 +3177,8 @@ func (args *V1ProcessMessageArgs) ParseFlags(flags, sep string) {
|
|||||||
args.Debit = true
|
args.Debit = true
|
||||||
case subsystem == utils.MetaResources:
|
case subsystem == utils.MetaResources:
|
||||||
args.AllocateResources = true
|
args.AllocateResources = true
|
||||||
|
case subsystem == utils.MetaIPs:
|
||||||
|
args.AllocateIP = true
|
||||||
case subsystem == utils.MetaRoutes:
|
case subsystem == utils.MetaRoutes:
|
||||||
args.GetRoutes = true
|
args.GetRoutes = true
|
||||||
case subsystem == utils.MetaRoutesIgnoreErrors:
|
case subsystem == utils.MetaRoutesIgnoreErrors:
|
||||||
@@ -3091,6 +3206,7 @@ func (args *V1ProcessMessageArgs) ParseFlags(flags, sep string) {
|
|||||||
// V1ProcessMessageReply is the reply for the ProcessMessage API
|
// V1ProcessMessageReply is the reply for the ProcessMessage API
|
||||||
type V1ProcessMessageReply struct {
|
type V1ProcessMessageReply struct {
|
||||||
MaxUsage *time.Duration `json:",omitempty"`
|
MaxUsage *time.Duration `json:",omitempty"`
|
||||||
|
AllocatedIP *engine.AllocatedIP `json:",omitempty"`
|
||||||
ResourceAllocation *string `json:",omitempty"`
|
ResourceAllocation *string `json:",omitempty"`
|
||||||
Attributes *engine.AttrSProcessEventReply `json:",omitempty"`
|
Attributes *engine.AttrSProcessEventReply `json:",omitempty"`
|
||||||
RouteProfiles engine.SortedRoutesList `json:",omitempty"`
|
RouteProfiles engine.SortedRoutesList `json:",omitempty"`
|
||||||
@@ -3102,47 +3218,53 @@ type V1ProcessMessageReply struct {
|
|||||||
|
|
||||||
// SetMaxUsageNeeded used by agent that use the reply as NavigableMapper
|
// SetMaxUsageNeeded used by agent that use the reply as NavigableMapper
|
||||||
// only used for gob encoding
|
// only used for gob encoding
|
||||||
func (v1Rply *V1ProcessMessageReply) SetMaxUsageNeeded(getMaxUsage bool) {
|
func (r *V1ProcessMessageReply) SetMaxUsageNeeded(getMaxUsage bool) {
|
||||||
if v1Rply == nil {
|
if r == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v1Rply.needsMaxUsage = getMaxUsage
|
r.needsMaxUsage = getMaxUsage
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsNavigableMap is part of engine.NavigableMapper interface
|
// AsNavigableMap is part of engine.NavigableMapper interface
|
||||||
func (v1Rply *V1ProcessMessageReply) AsNavigableMap() map[string]*utils.DataNode {
|
func (r *V1ProcessMessageReply) AsNavigableMap() map[string]*utils.DataNode {
|
||||||
cgrReply := make(map[string]*utils.DataNode)
|
cgrReply := make(map[string]*utils.DataNode)
|
||||||
if v1Rply.MaxUsage != nil {
|
if r.MaxUsage != nil {
|
||||||
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(*v1Rply.MaxUsage)
|
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(*r.MaxUsage)
|
||||||
} else if v1Rply.needsMaxUsage {
|
} else if r.needsMaxUsage {
|
||||||
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(0)
|
cgrReply[utils.CapMaxUsage] = utils.NewLeafNode(0)
|
||||||
}
|
}
|
||||||
if v1Rply.ResourceAllocation != nil {
|
if r.ResourceAllocation != nil {
|
||||||
cgrReply[utils.CapResourceAllocation] = utils.NewLeafNode(*v1Rply.ResourceAllocation)
|
cgrReply[utils.CapResourceAllocation] = utils.NewLeafNode(*r.ResourceAllocation)
|
||||||
}
|
}
|
||||||
if v1Rply.Attributes != nil {
|
if r.AllocatedIP != nil {
|
||||||
|
cgrReply[utils.CapAllocatedIP] = &utils.DataNode{
|
||||||
|
Type: utils.NMMapType,
|
||||||
|
Map: r.AllocatedIP.AsNavigableMap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if r.Attributes != nil {
|
||||||
attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
||||||
for _, fldName := range v1Rply.Attributes.AlteredFields {
|
for _, fldName := range r.Attributes.AlteredFields {
|
||||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||||
if v1Rply.Attributes.CGREvent.HasField(fldName) {
|
if r.Attributes.CGREvent.HasField(fldName) {
|
||||||
attrs.Map[fldName] = utils.NewLeafNode(v1Rply.Attributes.CGREvent.Event[fldName])
|
attrs.Map[fldName] = utils.NewLeafNode(r.Attributes.CGREvent.Event[fldName])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapAttributes] = attrs
|
cgrReply[utils.CapAttributes] = attrs
|
||||||
}
|
}
|
||||||
if v1Rply.RouteProfiles != nil {
|
if r.RouteProfiles != nil {
|
||||||
cgrReply[utils.CapRouteProfiles] = v1Rply.RouteProfiles.AsNavigableMap()
|
cgrReply[utils.CapRouteProfiles] = r.RouteProfiles.AsNavigableMap()
|
||||||
}
|
}
|
||||||
if v1Rply.ThresholdIDs != nil {
|
if r.ThresholdIDs != nil {
|
||||||
thIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*v1Rply.ThresholdIDs))}
|
thIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*r.ThresholdIDs))}
|
||||||
for i, v := range *v1Rply.ThresholdIDs {
|
for i, v := range *r.ThresholdIDs {
|
||||||
thIDs.Slice[i] = utils.NewLeafNode(v)
|
thIDs.Slice[i] = utils.NewLeafNode(v)
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapThresholds] = thIDs
|
cgrReply[utils.CapThresholds] = thIDs
|
||||||
}
|
}
|
||||||
if v1Rply.StatQueueIDs != nil {
|
if r.StatQueueIDs != nil {
|
||||||
stIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*v1Rply.StatQueueIDs))}
|
stIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(*r.StatQueueIDs))}
|
||||||
for i, v := range *v1Rply.StatQueueIDs {
|
for i, v := range *r.StatQueueIDs {
|
||||||
stIDs.Slice[i] = utils.NewLeafNode(v)
|
stIDs.Slice[i] = utils.NewLeafNode(v)
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapStatQueues] = stIDs
|
cgrReply[utils.CapStatQueues] = stIDs
|
||||||
@@ -3218,6 +3340,24 @@ func (sS *SessionS) BiRPCv1ProcessMessage(ctx *context.Context,
|
|||||||
}
|
}
|
||||||
rply.ResourceAllocation = &allocMessage
|
rply.ResourceAllocation = &allocMessage
|
||||||
}
|
}
|
||||||
|
if args.AllocateIP {
|
||||||
|
if len(sS.cgrCfg.SessionSCfg().IPsConns) == 0 {
|
||||||
|
return utils.NewErrNotConnected(utils.IPs)
|
||||||
|
}
|
||||||
|
if originID == "" {
|
||||||
|
return utils.NewErrMandatoryIeMissing(utils.OriginID)
|
||||||
|
}
|
||||||
|
if args.APIOpts == nil {
|
||||||
|
args.APIOpts = make(map[string]any)
|
||||||
|
}
|
||||||
|
args.CGREvent.APIOpts[utils.OptsIPsAllocationID] = originID
|
||||||
|
var allocIP engine.AllocatedIP
|
||||||
|
if err = sS.connMgr.Call(context.TODO(), sS.cgrCfg.SessionSCfg().IPsConns, utils.IPsV1AllocateIP,
|
||||||
|
args.CGREvent, &allocIP); err != nil {
|
||||||
|
return utils.NewErrIPs(err)
|
||||||
|
}
|
||||||
|
rply.AllocatedIP = &allocIP
|
||||||
|
}
|
||||||
if args.GetRoutes {
|
if args.GetRoutes {
|
||||||
routesReply, err := sS.getRoutes(args.CGREvent.Clone(), args.Paginator,
|
routesReply, err := sS.getRoutes(args.CGREvent.Clone(), args.Paginator,
|
||||||
args.RoutesIgnoreErrors, args.RoutesMaxCost, false)
|
args.RoutesIgnoreErrors, args.RoutesMaxCost, false)
|
||||||
@@ -3278,6 +3418,7 @@ type V1ProcessEventReply struct {
|
|||||||
MaxUsage map[string]time.Duration `json:",omitempty"`
|
MaxUsage map[string]time.Duration `json:",omitempty"`
|
||||||
Cost map[string]float64 `json:",omitempty"` // Cost is the cost received from Rater, ignoring accounting part
|
Cost map[string]float64 `json:",omitempty"` // Cost is the cost received from Rater, ignoring accounting part
|
||||||
ResourceAllocation map[string]string `json:",omitempty"`
|
ResourceAllocation map[string]string `json:",omitempty"`
|
||||||
|
AllocatedIP map[string]*engine.AllocatedIP `json:",omitempty"`
|
||||||
Attributes map[string]*engine.AttrSProcessEventReply `json:",omitempty"`
|
Attributes map[string]*engine.AttrSProcessEventReply `json:",omitempty"`
|
||||||
RouteProfiles map[string]engine.SortedRoutesList `json:",omitempty"`
|
RouteProfiles map[string]engine.SortedRoutesList `json:",omitempty"`
|
||||||
ThresholdIDs map[string][]string `json:",omitempty"`
|
ThresholdIDs map[string][]string `json:",omitempty"`
|
||||||
@@ -3286,25 +3427,41 @@ type V1ProcessEventReply struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AsNavigableMap is part of engine.NavigableMapper interface
|
// AsNavigableMap is part of engine.NavigableMapper interface
|
||||||
func (v1Rply *V1ProcessEventReply) AsNavigableMap() map[string]*utils.DataNode {
|
func (r *V1ProcessEventReply) AsNavigableMap() map[string]*utils.DataNode {
|
||||||
cgrReply := make(map[string]*utils.DataNode)
|
cgrReply := make(map[string]*utils.DataNode)
|
||||||
if v1Rply.MaxUsage != nil {
|
if r.MaxUsage != nil {
|
||||||
usage := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
usage := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
||||||
for k, v := range v1Rply.MaxUsage {
|
for k, v := range r.MaxUsage {
|
||||||
usage.Map[k] = utils.NewLeafNode(v)
|
usage.Map[k] = utils.NewLeafNode(v)
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapMaxUsage] = usage
|
cgrReply[utils.CapMaxUsage] = usage
|
||||||
}
|
}
|
||||||
if v1Rply.ResourceAllocation != nil {
|
if r.ResourceAllocation != nil {
|
||||||
res := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
res := &utils.DataNode{
|
||||||
for k, v := range v1Rply.ResourceAllocation {
|
Type: utils.NMMapType,
|
||||||
|
Map: make(map[string]*utils.DataNode),
|
||||||
|
}
|
||||||
|
for k, v := range r.ResourceAllocation {
|
||||||
res.Map[k] = utils.NewLeafNode(v)
|
res.Map[k] = utils.NewLeafNode(v)
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapResourceAllocation] = res
|
cgrReply[utils.CapResourceAllocation] = res
|
||||||
}
|
}
|
||||||
if v1Rply.Attributes != nil {
|
if r.AllocatedIP != nil {
|
||||||
|
ips := &utils.DataNode{
|
||||||
|
Type: utils.NMMapType,
|
||||||
|
Map: make(map[string]*utils.DataNode),
|
||||||
|
}
|
||||||
|
for k, v := range r.AllocatedIP {
|
||||||
|
ips.Map[k] = &utils.DataNode{
|
||||||
|
Type: utils.NMMapType,
|
||||||
|
Map: v.AsNavigableMap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cgrReply[utils.CapAllocatedIP] = ips
|
||||||
|
}
|
||||||
|
if r.Attributes != nil {
|
||||||
atts := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
atts := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
||||||
for k, att := range v1Rply.Attributes {
|
for k, att := range r.Attributes {
|
||||||
attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
||||||
for _, fldName := range att.AlteredFields {
|
for _, fldName := range att.AlteredFields {
|
||||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||||
@@ -3316,16 +3473,16 @@ func (v1Rply *V1ProcessEventReply) AsNavigableMap() map[string]*utils.DataNode {
|
|||||||
}
|
}
|
||||||
cgrReply[utils.CapAttributes] = atts
|
cgrReply[utils.CapAttributes] = atts
|
||||||
}
|
}
|
||||||
if v1Rply.RouteProfiles != nil {
|
if r.RouteProfiles != nil {
|
||||||
routes := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
routes := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
||||||
for k, route := range v1Rply.RouteProfiles {
|
for k, route := range r.RouteProfiles {
|
||||||
routes.Map[k] = route.AsNavigableMap()
|
routes.Map[k] = route.AsNavigableMap()
|
||||||
}
|
}
|
||||||
cgrReply[utils.CapRouteProfiles] = routes
|
cgrReply[utils.CapRouteProfiles] = routes
|
||||||
}
|
}
|
||||||
if v1Rply.ThresholdIDs != nil {
|
if r.ThresholdIDs != nil {
|
||||||
th := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
th := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
||||||
for k, thr := range v1Rply.ThresholdIDs {
|
for k, thr := range r.ThresholdIDs {
|
||||||
thIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(thr))}
|
thIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(thr))}
|
||||||
for i, v := range thr {
|
for i, v := range thr {
|
||||||
thIDs.Slice[i] = utils.NewLeafNode(v)
|
thIDs.Slice[i] = utils.NewLeafNode(v)
|
||||||
@@ -3334,9 +3491,9 @@ func (v1Rply *V1ProcessEventReply) AsNavigableMap() map[string]*utils.DataNode {
|
|||||||
}
|
}
|
||||||
cgrReply[utils.CapThresholds] = th
|
cgrReply[utils.CapThresholds] = th
|
||||||
}
|
}
|
||||||
if v1Rply.StatQueueIDs != nil {
|
if r.StatQueueIDs != nil {
|
||||||
st := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
st := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
||||||
for k, sts := range v1Rply.StatQueueIDs {
|
for k, sts := range r.StatQueueIDs {
|
||||||
stIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(sts))}
|
stIDs := &utils.DataNode{Type: utils.NMSliceType, Slice: make([]*utils.DataNode, len(sts))}
|
||||||
for i, v := range sts {
|
for i, v := range sts {
|
||||||
stIDs.Slice[i] = utils.NewLeafNode(v)
|
stIDs.Slice[i] = utils.NewLeafNode(v)
|
||||||
@@ -3345,15 +3502,15 @@ func (v1Rply *V1ProcessEventReply) AsNavigableMap() map[string]*utils.DataNode {
|
|||||||
}
|
}
|
||||||
cgrReply[utils.CapStatQueues] = st
|
cgrReply[utils.CapStatQueues] = st
|
||||||
}
|
}
|
||||||
if v1Rply.Cost != nil {
|
if r.Cost != nil {
|
||||||
costs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
costs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
||||||
for k, cost := range v1Rply.Cost {
|
for k, cost := range r.Cost {
|
||||||
costs.Map[k] = utils.NewLeafNode(cost)
|
costs.Map[k] = utils.NewLeafNode(cost)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v1Rply.STIRIdentity != nil {
|
if r.STIRIdentity != nil {
|
||||||
stir := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
stir := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)}
|
||||||
for k, v := range v1Rply.STIRIdentity {
|
for k, v := range r.STIRIdentity {
|
||||||
stir.Map[k] = utils.NewLeafNode(v)
|
stir.Map[k] = utils.NewLeafNode(v)
|
||||||
}
|
}
|
||||||
cgrReply[utils.OptsStirIdentity] = stir
|
cgrReply[utils.OptsStirIdentity] = stir
|
||||||
@@ -3613,6 +3770,65 @@ func (sS *SessionS) BiRPCv1ProcessEvent(ctx *context.Context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for *ips
|
||||||
|
if argsFlagsWithParams.GetBool(utils.MetaIPs) {
|
||||||
|
if len(sS.cgrCfg.SessionSCfg().IPsConns) == 0 {
|
||||||
|
return utils.NewErrNotConnected(utils.IPs)
|
||||||
|
}
|
||||||
|
rply.AllocatedIP = make(map[string]*engine.AllocatedIP)
|
||||||
|
if ipsOpt := argsFlagsWithParams[utils.MetaIPs]; len(ipsOpt) != 0 {
|
||||||
|
for runID, cgrEv := range getDerivedEvents(events, ipsOpt.Has(utils.MetaDerivedReply)) {
|
||||||
|
originID := engine.MapEvent(cgrEv.Event).GetStringIgnoreErrors(utils.OriginID)
|
||||||
|
if originID == "" {
|
||||||
|
return utils.NewErrMandatoryIeMissing(utils.OriginID)
|
||||||
|
}
|
||||||
|
if args.APIOpts == nil {
|
||||||
|
args.APIOpts = make(map[string]any)
|
||||||
|
}
|
||||||
|
args.CGREvent.APIOpts[utils.OptsIPsAllocationID] = originID
|
||||||
|
cgrEv.SetCloneable(true)
|
||||||
|
var allocIP engine.AllocatedIP
|
||||||
|
switch {
|
||||||
|
case ipsOpt.Has(utils.MetaAuthorize):
|
||||||
|
if err = sS.connMgr.Call(context.TODO(), sS.cgrCfg.SessionSCfg().IPsConns, utils.IPsV1AuthorizeIP,
|
||||||
|
args.CGREvent, &allocIP); err != nil {
|
||||||
|
if blockError {
|
||||||
|
return utils.NewErrIPs(err)
|
||||||
|
}
|
||||||
|
utils.Logger.Warning(
|
||||||
|
fmt.Sprintf("<%s> error: <%s> processing event %+v for RunID <%s> with IPs.",
|
||||||
|
utils.SessionS, err.Error(), cgrEv, runID))
|
||||||
|
withErrors = true
|
||||||
|
}
|
||||||
|
case ipsOpt.Has(utils.MetaAllocate):
|
||||||
|
if err = sS.connMgr.Call(context.TODO(), sS.cgrCfg.SessionSCfg().IPsConns, utils.IPsV1AllocateIP,
|
||||||
|
args.CGREvent, &allocIP); err != nil {
|
||||||
|
if blockError {
|
||||||
|
return utils.NewErrIPs(err)
|
||||||
|
}
|
||||||
|
utils.Logger.Warning(
|
||||||
|
fmt.Sprintf("<%s> error: <%s> processing event %+v for RunID <%s> with IPs.",
|
||||||
|
utils.SessionS, err.Error(), cgrEv, runID))
|
||||||
|
withErrors = true
|
||||||
|
}
|
||||||
|
case ipsOpt.Has(utils.MetaRelease):
|
||||||
|
var reply string
|
||||||
|
if err = sS.connMgr.Call(context.TODO(), sS.cgrCfg.SessionSCfg().IPsConns, utils.IPsV1ReleaseIP,
|
||||||
|
args.CGREvent, &reply); err != nil {
|
||||||
|
if blockError {
|
||||||
|
return utils.NewErrIPs(err)
|
||||||
|
}
|
||||||
|
utils.Logger.Warning(
|
||||||
|
fmt.Sprintf("<%s> error: <%s> processing event %+v for RunID <%s> with IPs.",
|
||||||
|
utils.SessionS, err.Error(), cgrEv, runID))
|
||||||
|
withErrors = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rply.AllocatedIP[runID] = &allocIP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check what we need to do for RALs (*authorize/*initiate/*update/*terminate)
|
// check what we need to do for RALs (*authorize/*initiate/*update/*terminate)
|
||||||
dbtItvl := sS.cgrCfg.SessionSCfg().DebitInterval
|
dbtItvl := sS.cgrCfg.SessionSCfg().DebitInterval
|
||||||
if argsFlagsWithParams.GetBool(utils.MetaRALs) {
|
if argsFlagsWithParams.GetBool(utils.MetaRALs) {
|
||||||
|
|||||||
@@ -949,7 +949,7 @@ func TestSessionSNewV1AuthorizeArgs(t *testing.T) {
|
|||||||
CGREvent: cgrEv,
|
CGREvent: cgrEv,
|
||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply := NewV1AuthorizeArgs(true, nil, false, nil, false, nil, true, false, false, false, false, cgrEv, utils.Paginator{}, true, "")
|
rply := NewV1AuthorizeArgs(true, nil, false, nil, false, nil, false, true, false, false, false, false, cgrEv, utils.Paginator{}, true, "")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -965,7 +965,7 @@ func TestSessionSNewV1AuthorizeArgs(t *testing.T) {
|
|||||||
CGREvent: cgrEv,
|
CGREvent: cgrEv,
|
||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply = NewV1AuthorizeArgs(true, nil, false, nil, true, nil, false, true, false, true, true, cgrEv, utils.Paginator{}, true, "")
|
rply = NewV1AuthorizeArgs(true, nil, false, nil, true, nil, false, false, true, false, true, true, cgrEv, utils.Paginator{}, true, "")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v,\n received: %+v", expected, rply)
|
t.Errorf("Expecting %+v,\n received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -988,7 +988,7 @@ func TestSessionSNewV1AuthorizeArgs(t *testing.T) {
|
|||||||
StatIDs: []string{"test3", "test4"},
|
StatIDs: []string{"test3", "test4"},
|
||||||
}
|
}
|
||||||
rply = NewV1AuthorizeArgs(true, attributeIDs, false, thresholdIDs,
|
rply = NewV1AuthorizeArgs(true, attributeIDs, false, thresholdIDs,
|
||||||
true, statIDs, false, true, false, true, true, cgrEv, utils.Paginator{}, false, "")
|
true, statIDs, false, false, true, false, true, true, cgrEv, utils.Paginator{}, false, "")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v,\n received: %+v", expected, rply)
|
t.Errorf("Expecting %+v,\n received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1007,7 +1007,7 @@ func TestSessionSNewV1AuthorizeArgs(t *testing.T) {
|
|||||||
StatIDs: []string{"test3", "test4"},
|
StatIDs: []string{"test3", "test4"},
|
||||||
}
|
}
|
||||||
rply = NewV1AuthorizeArgs(true, attributeIDs, false, thresholdIDs,
|
rply = NewV1AuthorizeArgs(true, attributeIDs, false, thresholdIDs,
|
||||||
true, statIDs, false, true, false, true, false, cgrEv, utils.Paginator{}, false, "100")
|
true, statIDs, false, false, true, false, true, false, cgrEv, utils.Paginator{}, false, "100")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v,\n received: %+v", expected, rply)
|
t.Errorf("Expecting %+v,\n received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1155,7 +1155,7 @@ func TestSessionSNewV1TerminateSessionArgs(t *testing.T) {
|
|||||||
CGREvent: cgrEv,
|
CGREvent: cgrEv,
|
||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply := NewV1TerminateSessionArgs(true, false, true, nil, false, nil, cgrEv, true)
|
rply := NewV1TerminateSessionArgs(true, false, false, true, nil, false, nil, cgrEv, true)
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1163,7 +1163,7 @@ func TestSessionSNewV1TerminateSessionArgs(t *testing.T) {
|
|||||||
CGREvent: cgrEv,
|
CGREvent: cgrEv,
|
||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply = NewV1TerminateSessionArgs(false, false, false, nil, false, nil, cgrEv, true)
|
rply = NewV1TerminateSessionArgs(false, false, false, false, nil, false, nil, cgrEv, true)
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1176,7 +1176,7 @@ func TestSessionSNewV1TerminateSessionArgs(t *testing.T) {
|
|||||||
StatIDs: []string{"test1", "test2"},
|
StatIDs: []string{"test1", "test2"},
|
||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply = NewV1TerminateSessionArgs(false, false, false, thresholdIDs, false, statIDs, cgrEv, true)
|
rply = NewV1TerminateSessionArgs(false, false, false, false, thresholdIDs, false, statIDs, cgrEv, true)
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1201,7 +1201,7 @@ func TestSessionSNewV1ProcessMessageArgs(t *testing.T) {
|
|||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply := NewV1ProcessMessageArgs(true, nil, false, nil, false,
|
rply := NewV1ProcessMessageArgs(true, nil, false, nil, false,
|
||||||
nil, true, true, true, false, false, cgrEv, utils.Paginator{}, true, "")
|
nil, true, false, true, true, false, false, cgrEv, utils.Paginator{}, true, "")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1215,7 +1215,7 @@ func TestSessionSNewV1ProcessMessageArgs(t *testing.T) {
|
|||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply = NewV1ProcessMessageArgs(true, nil, false, nil, false,
|
rply = NewV1ProcessMessageArgs(true, nil, false, nil, false,
|
||||||
nil, true, false, true, true, true, cgrEv, utils.Paginator{}, true, "")
|
nil, true, false, false, true, true, true, cgrEv, utils.Paginator{}, true, "")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1237,7 +1237,7 @@ func TestSessionSNewV1ProcessMessageArgs(t *testing.T) {
|
|||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply = NewV1ProcessMessageArgs(true, attributeIDs, false, thresholdIDs, false, statIDs,
|
rply = NewV1ProcessMessageArgs(true, attributeIDs, false, thresholdIDs, false, statIDs,
|
||||||
true, false, true, true, true, cgrEv, utils.Paginator{}, true, "")
|
true, false, false, true, true, true, cgrEv, utils.Paginator{}, true, "")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1251,7 +1251,7 @@ func TestSessionSNewV1ProcessMessageArgs(t *testing.T) {
|
|||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply = NewV1ProcessMessageArgs(true, nil, false, nil, false,
|
rply = NewV1ProcessMessageArgs(true, nil, false, nil, false,
|
||||||
nil, true, false, true, true, false, cgrEv, utils.Paginator{}, true, "100")
|
nil, true, false, false, true, true, false, cgrEv, utils.Paginator{}, true, "100")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1282,7 +1282,7 @@ func TestSessionSNewV1InitSessionArgs(t *testing.T) {
|
|||||||
CGREvent: cgrEv,
|
CGREvent: cgrEv,
|
||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply := NewV1InitSessionArgs(true, attributeIDs, true, thresholdIDs, true, statIDs, true, true, cgrEv, true)
|
rply := NewV1InitSessionArgs(true, attributeIDs, true, thresholdIDs, true, statIDs, true, false, true, cgrEv, true)
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1305,7 +1305,7 @@ func TestSessionSNewV1InitSessionArgs(t *testing.T) {
|
|||||||
CGREvent: cgrEv,
|
CGREvent: cgrEv,
|
||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply = NewV1InitSessionArgs(true, nil, true, nil, true, nil, true, true, cgrEv, true)
|
rply = NewV1InitSessionArgs(true, nil, true, nil, true, nil, true, false, true, cgrEv, true)
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1318,7 +1318,7 @@ func TestSessionSNewV1InitSessionArgs(t *testing.T) {
|
|||||||
CGREvent: cgrEv,
|
CGREvent: cgrEv,
|
||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply = NewV1InitSessionArgs(true, nil, false, nil, true, nil, false, true, cgrEv, true)
|
rply = NewV1InitSessionArgs(true, nil, false, nil, true, nil, false, false, true, cgrEv, true)
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
t.Errorf("Expecting %+v, received: %+v", expected, rply)
|
||||||
}
|
}
|
||||||
@@ -1745,7 +1745,7 @@ func TestSessionSNewV1AuthorizeArgsWithOpts(t *testing.T) {
|
|||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
cgrArgs, _ := utils.GetRoutePaginatorFromOpts(cgrEv.APIOpts)
|
cgrArgs, _ := utils.GetRoutePaginatorFromOpts(cgrEv.APIOpts)
|
||||||
rply := NewV1AuthorizeArgs(true, nil, false, nil, false, nil, true, false,
|
rply := NewV1AuthorizeArgs(true, nil, false, nil, false, nil, false, true, false,
|
||||||
false, false, false, cgrEv, cgrArgs, true, "")
|
false, false, false, cgrEv, cgrArgs, true, "")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply))
|
t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply))
|
||||||
@@ -1762,7 +1762,7 @@ func TestSessionSNewV1AuthorizeArgsWithOpts(t *testing.T) {
|
|||||||
CGREvent: cgrEv,
|
CGREvent: cgrEv,
|
||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply = NewV1AuthorizeArgs(true, nil, false, nil, true, nil, false, true,
|
rply = NewV1AuthorizeArgs(true, nil, false, nil, true, nil, false, false, true,
|
||||||
false, true, true, cgrEv, cgrArgs, true, "")
|
false, true, true, cgrEv, cgrArgs, true, "")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply))
|
t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply))
|
||||||
@@ -1789,7 +1789,7 @@ func TestSessionSNewV1AuthorizeArgsWithOpts2(t *testing.T) {
|
|||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
cgrArgs, _ := utils.GetRoutePaginatorFromOpts(cgrEv.APIOpts)
|
cgrArgs, _ := utils.GetRoutePaginatorFromOpts(cgrEv.APIOpts)
|
||||||
rply := NewV1AuthorizeArgs(true, nil, false, nil, false, nil, true, false, false,
|
rply := NewV1AuthorizeArgs(true, nil, false, nil, false, nil, false, true, false, false,
|
||||||
false, false, cgrEv, cgrArgs, true, "")
|
false, false, cgrEv, cgrArgs, true, "")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply))
|
t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply))
|
||||||
@@ -1806,7 +1806,7 @@ func TestSessionSNewV1AuthorizeArgsWithOpts2(t *testing.T) {
|
|||||||
CGREvent: cgrEv,
|
CGREvent: cgrEv,
|
||||||
ForceDuration: true,
|
ForceDuration: true,
|
||||||
}
|
}
|
||||||
rply = NewV1AuthorizeArgs(true, nil, false, nil, true, nil, false, true, false,
|
rply = NewV1AuthorizeArgs(true, nil, false, nil, true, nil, false, false, true, false,
|
||||||
true, true, cgrEv, cgrArgs, true, "")
|
true, true, cgrEv, cgrArgs, true, "")
|
||||||
if !reflect.DeepEqual(expected, rply) {
|
if !reflect.DeepEqual(expected, rply) {
|
||||||
t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply))
|
t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply))
|
||||||
|
|||||||
@@ -1478,7 +1478,7 @@ func TestNewSession(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expectedErr := "ChargerS is disabled"
|
expectedErr := "ChargerS is disabled"
|
||||||
if _, err := sessions.newSession(cgrEv, "resourceID", "clientConnID",
|
if _, err := sessions.newSession(cgrEv, "originID", "clientConnID",
|
||||||
time.Second, false, false); err == nil || err.Error() != expectedErr {
|
time.Second, false, false); err == nil || err.Error() != expectedErr {
|
||||||
t.Errorf("Expected %+v, received %+v", expectedErr, err)
|
t.Errorf("Expected %+v, received %+v", expectedErr, err)
|
||||||
}
|
}
|
||||||
@@ -1488,7 +1488,8 @@ func TestNewSession(t *testing.T) {
|
|||||||
expectedSess := &Session{
|
expectedSess := &Session{
|
||||||
CGRID: "da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
CGRID: "da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
||||||
Tenant: "cgrates.org",
|
Tenant: "cgrates.org",
|
||||||
ResourceID: "resourceID",
|
ResourceID: "originID",
|
||||||
|
IPAllocID: "originID",
|
||||||
ClientConnID: "clientConnID",
|
ClientConnID: "clientConnID",
|
||||||
EventStart: map[string]any{
|
EventStart: map[string]any{
|
||||||
utils.CGRID: "da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
utils.CGRID: "da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
||||||
@@ -1511,7 +1512,7 @@ func TestNewSession(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Chargeable: true,
|
Chargeable: true,
|
||||||
}
|
}
|
||||||
if rcv, err := sessions.newSession(cgrEv, "resourceID", "clientConnID",
|
if rcv, err := sessions.newSession(cgrEv, "originID", "clientConnID",
|
||||||
time.Second, false, false); err != nil {
|
time.Second, false, false); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
} else if !reflect.DeepEqual(rcv, expectedSess) {
|
} else if !reflect.DeepEqual(rcv, expectedSess) {
|
||||||
@@ -1520,7 +1521,7 @@ func TestNewSession(t *testing.T) {
|
|||||||
|
|
||||||
//error in mocking the call from connMgr
|
//error in mocking the call from connMgr
|
||||||
cgrEv.ID = utils.EmptyString
|
cgrEv.ID = utils.EmptyString
|
||||||
if _, err := sessions.newSession(cgrEv, "resourceID", "clientConnID",
|
if _, err := sessions.newSession(cgrEv, "originID", "clientConnID",
|
||||||
time.Second, false, false); err == nil || err.Error() != utils.NewErrChargerS(utils.ErrNotImplemented).Error() {
|
time.Second, false, false); err == nil || err.Error() != utils.NewErrChargerS(utils.ErrNotImplemented).Error() {
|
||||||
t.Errorf("Expected %+v, received %+v", utils.NewErrChargerS(utils.ErrNotImplemented), err)
|
t.Errorf("Expected %+v, received %+v", utils.NewErrChargerS(utils.ErrNotImplemented), err)
|
||||||
}
|
}
|
||||||
@@ -1529,7 +1530,7 @@ func TestNewSession(t *testing.T) {
|
|||||||
"da39a3ee5e6b4b0d3255bfef95601890afd80709": {},
|
"da39a3ee5e6b4b0d3255bfef95601890afd80709": {},
|
||||||
}
|
}
|
||||||
//sessions already exists
|
//sessions already exists
|
||||||
if _, err := sessions.newSession(cgrEv, "resourceID", "clientConnID",
|
if _, err := sessions.newSession(cgrEv, "originID", "clientConnID",
|
||||||
time.Second, false, false); err == nil || err.Error() != utils.ErrExists.Error() {
|
time.Second, false, false); err == nil || err.Error() != utils.ErrExists.Error() {
|
||||||
t.Errorf("Expected %+v, received %+v", utils.ErrExists, err)
|
t.Errorf("Expected %+v, received %+v", utils.ErrExists, err)
|
||||||
}
|
}
|
||||||
@@ -2547,7 +2548,7 @@ func TestBiRPCv1AuthorizeEvent(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
args := NewV1AuthorizeArgs(false, []string{},
|
args := NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
false, false, false, nil, utils.Paginator{}, false, "")
|
false, false, false, nil, utils.Paginator{}, false, "")
|
||||||
|
|
||||||
rply := &V1AuthorizeReply{
|
rply := &V1AuthorizeReply{
|
||||||
@@ -2588,7 +2589,7 @@ func TestBiRPCv1AuthorizeEvent(t *testing.T) {
|
|||||||
//Get Attributes
|
//Get Attributes
|
||||||
sessions.cgrCfg.CacheCfg().Partitions[utils.CacheRPCResponses].Limit = 0
|
sessions.cgrCfg.CacheCfg().Partitions[utils.CacheRPCResponses].Limit = 0
|
||||||
args = NewV1AuthorizeArgs(true, []string{},
|
args = NewV1AuthorizeArgs(true, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
true, false, false, cgrEvent, utils.Paginator{}, false, "")
|
true, false, false, cgrEvent, utils.Paginator{}, false, "")
|
||||||
args.CGREvent.ID = "TestID"
|
args.CGREvent.ID = "TestID"
|
||||||
args.CGREvent.Tenant = "cgrates.org"
|
args.CGREvent.Tenant = "cgrates.org"
|
||||||
@@ -2671,7 +2672,7 @@ func TestBiRPCv1AuthorizeEvent2(t *testing.T) {
|
|||||||
APIOpts: map[string]any{},
|
APIOpts: map[string]any{},
|
||||||
}
|
}
|
||||||
args := NewV1AuthorizeArgs(false, []string{},
|
args := NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, true,
|
false, []string{}, false, []string{}, false, false, true,
|
||||||
false, false, false, cgrEvent, utils.Paginator{}, false, "")
|
false, false, false, cgrEvent, utils.Paginator{}, false, "")
|
||||||
|
|
||||||
rply := &V1AuthorizeReply{
|
rply := &V1AuthorizeReply{
|
||||||
@@ -2695,7 +2696,7 @@ func TestBiRPCv1AuthorizeEvent2(t *testing.T) {
|
|||||||
|
|
||||||
//AuthorizeResources
|
//AuthorizeResources
|
||||||
args = NewV1AuthorizeArgs(false, []string{},
|
args = NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, true, false,
|
false, []string{}, false, []string{}, false, true, false,
|
||||||
false, false, false, cgrEvent, utils.Paginator{}, false, "")
|
false, false, false, cgrEvent, utils.Paginator{}, false, "")
|
||||||
expected = "NOT_CONNECTED: ResourceS"
|
expected = "NOT_CONNECTED: ResourceS"
|
||||||
if err := sessions.BiRPCv1AuthorizeEvent(context.Background(), args, rply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1AuthorizeEvent(context.Background(), args, rply); err == nil || err.Error() != expected {
|
||||||
@@ -2715,7 +2716,7 @@ func TestBiRPCv1AuthorizeEvent2(t *testing.T) {
|
|||||||
|
|
||||||
//GetRoutes
|
//GetRoutes
|
||||||
args = NewV1AuthorizeArgs(false, []string{},
|
args = NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
true, false, false, cgrEvent, utils.Paginator{}, false, "")
|
true, false, false, cgrEvent, utils.Paginator{}, false, "")
|
||||||
expected = "NOT_CONNECTED: RouteS"
|
expected = "NOT_CONNECTED: RouteS"
|
||||||
if err := sessions.BiRPCv1AuthorizeEvent(context.Background(), args, rply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1AuthorizeEvent(context.Background(), args, rply); err == nil || err.Error() != expected {
|
||||||
@@ -2729,7 +2730,7 @@ func TestBiRPCv1AuthorizeEvent2(t *testing.T) {
|
|||||||
|
|
||||||
//ProcessThresholds
|
//ProcessThresholds
|
||||||
args = NewV1AuthorizeArgs(false, []string{},
|
args = NewV1AuthorizeArgs(false, []string{},
|
||||||
true, []string{"TestID"}, false, []string{}, false, false,
|
true, []string{"TestID"}, false, []string{}, false, false, false,
|
||||||
true, false, false, cgrEvent, utils.Paginator{}, false, "")
|
true, false, false, cgrEvent, utils.Paginator{}, false, "")
|
||||||
if err := sessions.BiRPCv1AuthorizeEvent(context.Background(), args, rply); err == nil || err != utils.ErrPartiallyExecuted {
|
if err := sessions.BiRPCv1AuthorizeEvent(context.Background(), args, rply); err == nil || err != utils.ErrPartiallyExecuted {
|
||||||
t.Errorf("Expected %+v, received %+v", utils.ErrPartiallyExecuted, err)
|
t.Errorf("Expected %+v, received %+v", utils.ErrPartiallyExecuted, err)
|
||||||
@@ -2737,7 +2738,7 @@ func TestBiRPCv1AuthorizeEvent2(t *testing.T) {
|
|||||||
|
|
||||||
//ProcessStats
|
//ProcessStats
|
||||||
args = NewV1AuthorizeArgs(false, []string{},
|
args = NewV1AuthorizeArgs(false, []string{},
|
||||||
false, []string{}, true, []string{"TestID"}, false, false,
|
false, []string{}, true, []string{"TestID"}, false, false, false,
|
||||||
true, false, false, cgrEvent, utils.Paginator{}, false, "")
|
true, false, false, cgrEvent, utils.Paginator{}, false, "")
|
||||||
if err := sessions.BiRPCv1AuthorizeEvent(context.Background(), args, rply); err == nil || err != utils.ErrPartiallyExecuted {
|
if err := sessions.BiRPCv1AuthorizeEvent(context.Background(), args, rply); err == nil || err != utils.ErrPartiallyExecuted {
|
||||||
t.Errorf("Expected %+v, received %+v", utils.ErrPartiallyExecuted, err)
|
t.Errorf("Expected %+v, received %+v", utils.ErrPartiallyExecuted, err)
|
||||||
@@ -2834,7 +2835,7 @@ func TestBiRPCv1AuthorizeEventWithDigest(t *testing.T) {
|
|||||||
APIOpts: map[string]any{},
|
APIOpts: map[string]any{},
|
||||||
}
|
}
|
||||||
args := NewV1AuthorizeArgs(true, []string{},
|
args := NewV1AuthorizeArgs(true, []string{},
|
||||||
true, []string{}, true, []string{}, true, true,
|
true, []string{}, true, []string{}, false, true, true,
|
||||||
true, false, false, cgrEvent, utils.Paginator{}, false, "")
|
true, false, false, cgrEvent, utils.Paginator{}, false, "")
|
||||||
|
|
||||||
authReply := new(V1AuthorizeReplyWithDigest)
|
authReply := new(V1AuthorizeReplyWithDigest)
|
||||||
@@ -2942,7 +2943,7 @@ func TestBiRPCv1InitiateSession1(t *testing.T) {
|
|||||||
APIOpts: map[string]any{},
|
APIOpts: map[string]any{},
|
||||||
}
|
}
|
||||||
args := NewV1InitSessionArgs(true, []string{},
|
args := NewV1InitSessionArgs(true, []string{},
|
||||||
false, []string{}, false, []string{}, true, false,
|
false, []string{}, false, []string{}, true, false, false,
|
||||||
nil, true)
|
nil, true)
|
||||||
|
|
||||||
rply := &V1InitSessionReply{}
|
rply := &V1InitSessionReply{}
|
||||||
@@ -2959,7 +2960,7 @@ func TestBiRPCv1InitiateSession1(t *testing.T) {
|
|||||||
//get from cache error
|
//get from cache error
|
||||||
cgrEvent.ID = "INITIATE_SESSION_ACTIVE"
|
cgrEvent.ID = "INITIATE_SESSION_ACTIVE"
|
||||||
args = NewV1InitSessionArgs(true, []string{},
|
args = NewV1InitSessionArgs(true, []string{},
|
||||||
false, []string{}, false, []string{}, true, false,
|
false, []string{}, false, []string{}, true, false, false,
|
||||||
cgrEvent, true)
|
cgrEvent, true)
|
||||||
caches := engine.NewCacheS(cfg, dm, nil)
|
caches := engine.NewCacheS(cfg, dm, nil)
|
||||||
//value's error will be nil, so the error of the initiate sessions will be the same
|
//value's error will be nil, so the error of the initiate sessions will be the same
|
||||||
@@ -2993,7 +2994,7 @@ func TestBiRPCv1InitiateSession1(t *testing.T) {
|
|||||||
sessions.cgrCfg.SessionSCfg().ResourceSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResources)}
|
sessions.cgrCfg.SessionSCfg().ResourceSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResources)}
|
||||||
|
|
||||||
args = NewV1InitSessionArgs(true, []string{},
|
args = NewV1InitSessionArgs(true, []string{},
|
||||||
false, []string{}, false, []string{}, true, false,
|
false, []string{}, false, []string{}, true, false, false,
|
||||||
cgrEvent, true)
|
cgrEvent, true)
|
||||||
delete(args.CGREvent.Event, utils.OriginID)
|
delete(args.CGREvent.Event, utils.OriginID)
|
||||||
expected = "MANDATORY_IE_MISSING: [OriginID]"
|
expected = "MANDATORY_IE_MISSING: [OriginID]"
|
||||||
@@ -3010,7 +3011,7 @@ func TestBiRPCv1InitiateSession1(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
args = NewV1InitSessionArgs(true, []string{},
|
args = NewV1InitSessionArgs(true, []string{},
|
||||||
false, []string{}, false, []string{}, true, false,
|
false, []string{}, false, []string{}, true, false, false,
|
||||||
cgrEvent, true)
|
cgrEvent, true)
|
||||||
expected = "RESOURCES_ERROR:NOT_IMPLEMENTED"
|
expected = "RESOURCES_ERROR:NOT_IMPLEMENTED"
|
||||||
if err := sessions.BiRPCv1InitiateSession(context.Background(), args, rply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1InitiateSession(context.Background(), args, rply); err == nil || err.Error() != expected {
|
||||||
@@ -3019,7 +3020,7 @@ func TestBiRPCv1InitiateSession1(t *testing.T) {
|
|||||||
|
|
||||||
//missing subsystems
|
//missing subsystems
|
||||||
args = NewV1InitSessionArgs(false, []string{},
|
args = NewV1InitSessionArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
cgrEvent, true)
|
cgrEvent, true)
|
||||||
expected = "MANDATORY_IE_MISSING: [Subsystems]"
|
expected = "MANDATORY_IE_MISSING: [Subsystems]"
|
||||||
if err := sessions.BiRPCv1InitiateSession(context.Background(), args, rply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1InitiateSession(context.Background(), args, rply); err == nil || err.Error() != expected {
|
||||||
@@ -3091,7 +3092,7 @@ func TestBiRPCv1InitiateSession2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args := NewV1InitSessionArgs(false, []string{},
|
args := NewV1InitSessionArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, true,
|
false, []string{}, false, []string{}, false, false, true,
|
||||||
cgrEvent, true)
|
cgrEvent, true)
|
||||||
|
|
||||||
rply := &V1InitSessionReply{}
|
rply := &V1InitSessionReply{}
|
||||||
@@ -3120,7 +3121,7 @@ func TestBiRPCv1InitiateSession2(t *testing.T) {
|
|||||||
|
|
||||||
//here we process the thresholds
|
//here we process the thresholds
|
||||||
args = NewV1InitSessionArgs(false, []string{},
|
args = NewV1InitSessionArgs(false, []string{},
|
||||||
true, []string{}, true, []string{}, false, true,
|
true, []string{}, true, []string{}, false, false, true,
|
||||||
cgrEvent, true)
|
cgrEvent, true)
|
||||||
sessions = NewSessionS(cfg, dm, connMgr)
|
sessions = NewSessionS(cfg, dm, connMgr)
|
||||||
if err := sessions.BiRPCv1InitiateSession(context.Background(), args, rply); err == nil || err != utils.ErrPartiallyExecuted {
|
if err := sessions.BiRPCv1InitiateSession(context.Background(), args, rply); err == nil || err != utils.ErrPartiallyExecuted {
|
||||||
@@ -3139,7 +3140,7 @@ func TestBiRPCv1InitiateSession2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
sessions = NewSessionS(cfg, dm, connMgr)
|
sessions = NewSessionS(cfg, dm, connMgr)
|
||||||
args = NewV1InitSessionArgs(false, []string{},
|
args = NewV1InitSessionArgs(false, []string{},
|
||||||
true, []string{}, true, []string{}, false, true,
|
true, []string{}, true, []string{}, false, false, true,
|
||||||
cgrEvent, true)
|
cgrEvent, true)
|
||||||
expected = "EXISTS"
|
expected = "EXISTS"
|
||||||
if err := sessions.BiRPCv1InitiateSession(context.Background(), args, rply); err == nil || err != utils.ErrPartiallyExecuted {
|
if err := sessions.BiRPCv1InitiateSession(context.Background(), args, rply); err == nil || err != utils.ErrPartiallyExecuted {
|
||||||
@@ -3236,7 +3237,7 @@ func TestBiRPCv1InitiateSessionWithDigest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args := NewV1InitSessionArgs(true, []string{},
|
args := NewV1InitSessionArgs(true, []string{},
|
||||||
true, []string{}, true, []string{}, true, true,
|
true, []string{}, true, []string{}, true, false, true,
|
||||||
cgrEvent, true)
|
cgrEvent, true)
|
||||||
|
|
||||||
authReply := new(V1InitReplyWithDigest)
|
authReply := new(V1InitReplyWithDigest)
|
||||||
@@ -3473,7 +3474,7 @@ func TestBiRPCv1TerminateSession1(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
args := NewV1TerminateSessionArgs(true, false, false, nil, false, nil, nil, true)
|
args := NewV1TerminateSessionArgs(true, false, false, false, nil, false, nil, nil, true)
|
||||||
var reply string
|
var reply string
|
||||||
expected := "MANDATORY_IE_MISSING: [CGREvent]"
|
expected := "MANDATORY_IE_MISSING: [CGREvent]"
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
@@ -3481,7 +3482,7 @@ func TestBiRPCv1TerminateSession1(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cgrEvent.ID = utils.EmptyString
|
cgrEvent.ID = utils.EmptyString
|
||||||
args = NewV1TerminateSessionArgs(false, false, false, nil, false, nil, cgrEvent, true)
|
args = NewV1TerminateSessionArgs(false, false, false, false, nil, false, nil, cgrEvent, true)
|
||||||
expected = "MANDATORY_IE_MISSING: [Subsystems]"
|
expected = "MANDATORY_IE_MISSING: [Subsystems]"
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
t.Errorf("Exepected %+v, received %+v", expected, err)
|
t.Errorf("Exepected %+v, received %+v", expected, err)
|
||||||
@@ -3502,7 +3503,7 @@ func TestBiRPCv1TerminateSession1(t *testing.T) {
|
|||||||
engine.Cache = tmp
|
engine.Cache = tmp
|
||||||
|
|
||||||
cgrEvent.Event[utils.OriginID] = utils.EmptyString
|
cgrEvent.Event[utils.OriginID] = utils.EmptyString
|
||||||
args = NewV1TerminateSessionArgs(true, false, false, nil, false, nil, cgrEvent, true)
|
args = NewV1TerminateSessionArgs(true, false, false, false, nil, false, nil, cgrEvent, true)
|
||||||
expected = "MANDATORY_IE_MISSING: [OriginID]"
|
expected = "MANDATORY_IE_MISSING: [OriginID]"
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
t.Errorf("Exepected %+v, received %+v", expected, err)
|
t.Errorf("Exepected %+v, received %+v", expected, err)
|
||||||
@@ -3511,7 +3512,7 @@ func TestBiRPCv1TerminateSession1(t *testing.T) {
|
|||||||
|
|
||||||
cgrEvent.APIOpts = make(map[string]any)
|
cgrEvent.APIOpts = make(map[string]any)
|
||||||
cgrEvent.APIOpts[utils.OptsDebitInterval] = "invalid_time_format"
|
cgrEvent.APIOpts[utils.OptsDebitInterval] = "invalid_time_format"
|
||||||
args = NewV1TerminateSessionArgs(true, false, false, nil, false, nil, cgrEvent, true)
|
args = NewV1TerminateSessionArgs(true, false, false, false, nil, false, nil, cgrEvent, true)
|
||||||
expected = "RALS_ERROR:time: invalid duration \"invalid_time_format\""
|
expected = "RALS_ERROR:time: invalid duration \"invalid_time_format\""
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
t.Errorf("Exepected %+v, received %+v", expected, err)
|
t.Errorf("Exepected %+v, received %+v", expected, err)
|
||||||
@@ -3523,13 +3524,13 @@ func TestBiRPCv1TerminateSession1(t *testing.T) {
|
|||||||
sessions.aSessions = map[string]*Session{
|
sessions.aSessions = map[string]*Session{
|
||||||
"CGR_ID": {},
|
"CGR_ID": {},
|
||||||
}
|
}
|
||||||
args = NewV1TerminateSessionArgs(true, false, false, nil, false, nil, cgrEvent, true)
|
args = NewV1TerminateSessionArgs(true, false, false, false, nil, false, nil, cgrEvent, true)
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err != nil {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
cgrEvent.Event[utils.CGRID] = "CHANGED_CGRID"
|
cgrEvent.Event[utils.CGRID] = "CHANGED_CGRID"
|
||||||
|
|
||||||
args = NewV1TerminateSessionArgs(true, false, false, nil, false, nil, cgrEvent, true)
|
args = NewV1TerminateSessionArgs(true, false, false, false, nil, false, nil, cgrEvent, true)
|
||||||
sessions.cgrCfg.SessionSCfg().ChargerSConns = []string{}
|
sessions.cgrCfg.SessionSCfg().ChargerSConns = []string{}
|
||||||
expected = "RALS_ERROR:ChargerS is disabled"
|
expected = "RALS_ERROR:ChargerS is disabled"
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
@@ -3539,7 +3540,7 @@ func TestBiRPCv1TerminateSession1(t *testing.T) {
|
|||||||
|
|
||||||
//update session error
|
//update session error
|
||||||
cgrEvent.Event[utils.Usage] = "invalid_dur_time"
|
cgrEvent.Event[utils.Usage] = "invalid_dur_time"
|
||||||
args = NewV1TerminateSessionArgs(true, false, false, nil, false, nil, cgrEvent, true)
|
args = NewV1TerminateSessionArgs(true, false, false, false, nil, false, nil, cgrEvent, true)
|
||||||
expected = "time: invalid duration \"invalid_dur_time\""
|
expected = "time: invalid duration \"invalid_dur_time\""
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
t.Errorf("Exepected %+v, received %+v", expected, err)
|
t.Errorf("Exepected %+v, received %+v", expected, err)
|
||||||
@@ -3567,7 +3568,7 @@ func TestBiRPCv1TerminateSession1(t *testing.T) {
|
|||||||
sessions = NewSessionS(cfg, dm, connMgr)
|
sessions = NewSessionS(cfg, dm, connMgr)
|
||||||
caches = engine.NewCacheS(cfg, dm, nil)
|
caches = engine.NewCacheS(cfg, dm, nil)
|
||||||
engine.Cache = caches
|
engine.Cache = caches
|
||||||
args = NewV1TerminateSessionArgs(true, false, false, nil, false, nil, cgrEvent, true)
|
args = NewV1TerminateSessionArgs(true, false, false, false, nil, false, nil, cgrEvent, true)
|
||||||
expected = "RALS_ERROR:NOT_IMPLEMENTED"
|
expected = "RALS_ERROR:NOT_IMPLEMENTED"
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
t.Errorf("Exepected %+v, received %+v", expected, err)
|
t.Errorf("Exepected %+v, received %+v", expected, err)
|
||||||
@@ -3610,7 +3611,7 @@ func TestBiRPCv1TerminateSession2(t *testing.T) {
|
|||||||
},
|
},
|
||||||
APIOpts: map[string]any{},
|
APIOpts: map[string]any{},
|
||||||
}
|
}
|
||||||
args := NewV1TerminateSessionArgs(false, true, false, nil, false, nil, cgrEvent, true)
|
args := NewV1TerminateSessionArgs(false, true, false, false, nil, false, nil, cgrEvent, true)
|
||||||
var reply string
|
var reply string
|
||||||
expected := "RESOURCES_ERROR:NOT_IMPLEMENTED"
|
expected := "RESOURCES_ERROR:NOT_IMPLEMENTED"
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
@@ -3618,14 +3619,14 @@ func TestBiRPCv1TerminateSession2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cgrEvent.Event[utils.OriginID] = utils.EmptyString
|
cgrEvent.Event[utils.OriginID] = utils.EmptyString
|
||||||
args = NewV1TerminateSessionArgs(false, true, false, nil, false, nil, cgrEvent, true)
|
args = NewV1TerminateSessionArgs(false, true, false, false, nil, false, nil, cgrEvent, true)
|
||||||
expected = "MANDATORY_IE_MISSING: [OriginID]"
|
expected = "MANDATORY_IE_MISSING: [OriginID]"
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
t.Errorf("Exepected %+v, received %+v", expected, err)
|
t.Errorf("Exepected %+v, received %+v", expected, err)
|
||||||
}
|
}
|
||||||
cgrEvent.Event[utils.OriginID] = "ORIGIN_ID"
|
cgrEvent.Event[utils.OriginID] = "ORIGIN_ID"
|
||||||
|
|
||||||
args = NewV1TerminateSessionArgs(false, true, false, nil, false, nil, cgrEvent, true)
|
args = NewV1TerminateSessionArgs(false, true, false, false, nil, false, nil, cgrEvent, true)
|
||||||
expected = "NOT_CONNECTED: ResourceS"
|
expected = "NOT_CONNECTED: ResourceS"
|
||||||
sessions.cgrCfg.SessionSCfg().ResourceSConns = []string{}
|
sessions.cgrCfg.SessionSCfg().ResourceSConns = []string{}
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
@@ -3634,7 +3635,7 @@ func TestBiRPCv1TerminateSession2(t *testing.T) {
|
|||||||
sessions.cgrCfg.SessionSCfg().ResourceSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResources)}
|
sessions.cgrCfg.SessionSCfg().ResourceSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResources)}
|
||||||
|
|
||||||
cgrEvent.Tenant = "CHANGED_ID"
|
cgrEvent.Tenant = "CHANGED_ID"
|
||||||
args = NewV1TerminateSessionArgs(false, true, true, nil, true, nil, cgrEvent, true)
|
args = NewV1TerminateSessionArgs(false, true, false, true, nil, true, nil, cgrEvent, true)
|
||||||
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err != utils.ErrPartiallyExecuted {
|
if err := sessions.BiRPCv1TerminateSession(context.Background(), args, &reply); err == nil || err != utils.ErrPartiallyExecuted {
|
||||||
t.Errorf("Exepected %+v, received %+v", utils.ErrPartiallyExecuted, err)
|
t.Errorf("Exepected %+v, received %+v", utils.ErrPartiallyExecuted, err)
|
||||||
}
|
}
|
||||||
@@ -3721,7 +3722,7 @@ func TestBiRPCv1ProcessMessage1(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args := NewV1ProcessMessageArgs(false, []string{},
|
args := NewV1ProcessMessageArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, false, false,
|
false, []string{}, false, []string{}, false, false, false,
|
||||||
true, false, false, nil, utils.Paginator{}, false, "1")
|
true, false, false, nil, utils.Paginator{}, false, "1")
|
||||||
reply := V1ProcessMessageReply{}
|
reply := V1ProcessMessageReply{}
|
||||||
expected := "MANDATORY_IE_MISSING: [CGREvent]"
|
expected := "MANDATORY_IE_MISSING: [CGREvent]"
|
||||||
@@ -3731,7 +3732,7 @@ func TestBiRPCv1ProcessMessage1(t *testing.T) {
|
|||||||
|
|
||||||
cgrEvent.ID = utils.EmptyString
|
cgrEvent.ID = utils.EmptyString
|
||||||
args = NewV1ProcessMessageArgs(true, []string{},
|
args = NewV1ProcessMessageArgs(true, []string{},
|
||||||
false, []string{}, false, []string{}, true, false,
|
false, []string{}, false, []string{}, true, false, false,
|
||||||
false, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
false, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
||||||
expected = "ATTRIBUTES_ERROR:NOT_IMPLEMENTED"
|
expected = "ATTRIBUTES_ERROR:NOT_IMPLEMENTED"
|
||||||
if err := sessions.BiRPCv1ProcessMessage(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1ProcessMessage(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
@@ -3740,7 +3741,7 @@ func TestBiRPCv1ProcessMessage1(t *testing.T) {
|
|||||||
|
|
||||||
cgrEvent.ID = "test_id"
|
cgrEvent.ID = "test_id"
|
||||||
args = NewV1ProcessMessageArgs(true, []string{},
|
args = NewV1ProcessMessageArgs(true, []string{},
|
||||||
false, []string{}, false, []string{}, true, false,
|
false, []string{}, false, []string{}, true, false, false,
|
||||||
false, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
false, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
||||||
expected = "NOT_CONNECTED: ResourceS"
|
expected = "NOT_CONNECTED: ResourceS"
|
||||||
if err := sessions.BiRPCv1ProcessMessage(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1ProcessMessage(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
@@ -3756,7 +3757,7 @@ func TestBiRPCv1ProcessMessage1(t *testing.T) {
|
|||||||
}
|
}
|
||||||
engine.Cache = caches
|
engine.Cache = caches
|
||||||
args = NewV1ProcessMessageArgs(true, []string{},
|
args = NewV1ProcessMessageArgs(true, []string{},
|
||||||
false, []string{}, false, []string{}, true, false,
|
false, []string{}, false, []string{}, true, false, false,
|
||||||
false, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
false, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
||||||
engine.Cache.SetWithoutReplicate(utils.CacheRPCResponses, utils.ConcatenatedKey(utils.SessionSv1ProcessMessage, args.CGREvent.ID),
|
engine.Cache.SetWithoutReplicate(utils.CacheRPCResponses, utils.ConcatenatedKey(utils.SessionSv1ProcessMessage, args.CGREvent.ID),
|
||||||
value, nil, true, utils.NonTransactional)
|
value, nil, true, utils.NonTransactional)
|
||||||
@@ -3830,7 +3831,7 @@ func TestBiRPCv1ProcessMessage2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args := NewV1ProcessMessageArgs(false, []string{},
|
args := NewV1ProcessMessageArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, true, false,
|
false, []string{}, false, []string{}, true, false, false,
|
||||||
true, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
true, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
||||||
reply := V1ProcessMessageReply{}
|
reply := V1ProcessMessageReply{}
|
||||||
expected := "MANDATORY_IE_MISSING: [OriginID]"
|
expected := "MANDATORY_IE_MISSING: [OriginID]"
|
||||||
@@ -3840,7 +3841,7 @@ func TestBiRPCv1ProcessMessage2(t *testing.T) {
|
|||||||
cgrEvent.Event[utils.OriginID] = "ID"
|
cgrEvent.Event[utils.OriginID] = "ID"
|
||||||
|
|
||||||
args = NewV1ProcessMessageArgs(false, []string{},
|
args = NewV1ProcessMessageArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, true, false,
|
false, []string{}, false, []string{}, true, false, false,
|
||||||
false, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
false, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
||||||
reply = V1ProcessMessageReply{}
|
reply = V1ProcessMessageReply{}
|
||||||
expected = "RESOURCES_ERROR:NOT_IMPLEMENTED"
|
expected = "RESOURCES_ERROR:NOT_IMPLEMENTED"
|
||||||
@@ -3850,7 +3851,7 @@ func TestBiRPCv1ProcessMessage2(t *testing.T) {
|
|||||||
|
|
||||||
cgrEvent.Event[utils.OriginID] = "ORIGIN_ID"
|
cgrEvent.Event[utils.OriginID] = "ORIGIN_ID"
|
||||||
args = NewV1ProcessMessageArgs(false, []string{},
|
args = NewV1ProcessMessageArgs(false, []string{},
|
||||||
false, []string{}, false, []string{}, true, true,
|
false, []string{}, false, []string{}, true, false, true,
|
||||||
true, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
true, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
||||||
expected = "NOT_CONNECTED: RouteS"
|
expected = "NOT_CONNECTED: RouteS"
|
||||||
if err := sessions.BiRPCv1ProcessMessage(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
if err := sessions.BiRPCv1ProcessMessage(context.Background(), args, &reply); err == nil || err.Error() != expected {
|
||||||
@@ -3864,7 +3865,7 @@ func TestBiRPCv1ProcessMessage2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args = NewV1ProcessMessageArgs(false, []string{},
|
args = NewV1ProcessMessageArgs(false, []string{},
|
||||||
true, []string{}, true, []string{}, true, true,
|
true, []string{}, true, []string{}, true, false, true,
|
||||||
true, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
true, false, false, cgrEvent, utils.Paginator{}, false, "1")
|
||||||
sessions.cgrCfg.SessionSCfg().ChargerSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaChargers)}
|
sessions.cgrCfg.SessionSCfg().ChargerSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaChargers)}
|
||||||
|
|
||||||
|
|||||||
@@ -1336,6 +1336,7 @@ const (
|
|||||||
MetaGigawords = "*gigawords"
|
MetaGigawords = "*gigawords"
|
||||||
CapAttributes = "Attributes"
|
CapAttributes = "Attributes"
|
||||||
CapResourceAllocation = "ResourceAllocation"
|
CapResourceAllocation = "ResourceAllocation"
|
||||||
|
CapAllocatedIP = "AllocatedIP"
|
||||||
CapMaxUsage = "MaxUsage"
|
CapMaxUsage = "MaxUsage"
|
||||||
CapRoutes = "Routes"
|
CapRoutes = "Routes"
|
||||||
CapRouteProfiles = "RouteProfiles"
|
CapRouteProfiles = "RouteProfiles"
|
||||||
|
|||||||
@@ -194,6 +194,10 @@ func NewErrResourceS(err error) error {
|
|||||||
return fmt.Errorf("RESOURCES_ERROR:%s", err)
|
return fmt.Errorf("RESOURCES_ERROR:%s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewErrIPs(err error) error {
|
||||||
|
return fmt.Errorf("IPS_ERROR:%s", err)
|
||||||
|
}
|
||||||
|
|
||||||
func NewErrRouteS(err error) error {
|
func NewErrRouteS(err error) error {
|
||||||
return fmt.Errorf("ROUTES_ERROR:%s", err)
|
return fmt.Errorf("ROUTES_ERROR:%s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user