mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added test for ResourceSv1GetResource
This commit is contained in:
committed by
Dan Christian Bogos
parent
62d8f0a755
commit
96fa9f7991
@@ -8,7 +8,7 @@ cgrates.org,ATTR_API_CHRG_AUTH,*auth,*string:~*req.APIKey:chrg12345,,,*req.APIMe
|
||||
cgrates.org,ATTR_API_THR_AUTH,*auth,*string:~*req.APIKey:thr12345,,,*req.APIMethods,*constant,ThresholdSv1.Ping&ThresholdSv1.GetThresholdsForEvent&ThresholdSv1.ProcessEvent&ThresholdSv1.GetThreshold&ThresholdSv1.GetThresholdIDs,false,20
|
||||
cgrates.org,ATTR_API_SUP_AUTH,*auth,*string:~*req.APIKey:sup12345,,,*req.APIMethods,*constant,SupplierSv1.Ping&SupplierSv1.GetSuppliers&SupplierSv1.GetSupplierProfilesForEvent,false,20
|
||||
cgrates.org,ATTR_API_STAT_AUTH,*auth,*string:~*req.APIKey:stat12345,,,*req.APIMethods,*constant,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics,false,20
|
||||
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:~*req.APIKey:res12345,,,*req.APIMethods,*constant,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources,false,20
|
||||
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:~*req.APIKey:res12345,,,*req.APIMethods,*constant,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources&ResourceSv1.GetResource,false,20
|
||||
cgrates.org,ATTR_API_SES_AUTH,*auth,*string:~*req.APIKey:ses12345,,,*req.APIMethods,*constant,SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&SessionSv1.ProcessEvent,false,20
|
||||
cgrates.org,ATTR_API_RSP_AUTH,*auth,*string:~*req.APIKey:rsp12345,,,*req.APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&Responder.Shutdown&Responder.Ping,false,20
|
||||
cgrates.org,ATTR_API_CHC_AUTH,*auth,*string:~*req.APIKey:chc12345,,,*req.APIMethods,*constant,CacheSv1.Ping&CacheSv1.GetCacheStats&CacheSv1.LoadCache&CacheSv1.PrecacheStatus&CacheSv1.GetItemIDs&CacheSv1.HasItem&CacheSv1.GetItemExpiryTime&CacheSv1.ReloadCache&CacheSv1.RemoveItem&CacheSv1.FlushCache&CacheSv1.Clear,false,20
|
||||
|
||||
|
@@ -8,7 +8,7 @@ cgrates.org,ATTR_API_CHRG_AUTH,*auth,*string:~*req.APIKey:chrg12345,,,*req.APIMe
|
||||
cgrates.org,ATTR_API_THR_AUTH,*auth,*string:~*req.APIKey:thr12345,,,*req.APIMethods,*constant,ThresholdSv1.Ping&ThresholdSv1.GetThresholdsForEvent&ThresholdSv1.ProcessEvent&ThresholdSv1.GetThreshold&ThresholdSv1.GetThresholdIDs,false,20
|
||||
cgrates.org,ATTR_API_SUP_AUTH,*auth,*string:~*req.APIKey:sup12345,,,*req.APIMethods,*constant,SupplierSv1.Ping&SupplierSv1.GetSuppliers&SupplierSv1.GetSupplierProfilesForEvent,false,20
|
||||
cgrates.org,ATTR_API_STAT_AUTH,*auth,*string:~*req.APIKey:stat12345,,,*req.APIMethods,*constant,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics,false,20
|
||||
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:~*req.APIKey:res12345,,,*req.APIMethods,*constant,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources,false,20
|
||||
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:~*req.APIKey:res12345,,,*req.APIMethods,*constant,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources&ResourceSv1.GetResource,false,20
|
||||
cgrates.org,ATTR_API_SES_AUTH,*auth,*string:~*req.APIKey:ses12345,,,*req.APIMethods,*constant,SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&SessionSv1.ProcessEvent,false,20
|
||||
cgrates.org,ATTR_API_RSP_AUTH,*auth,*string:~*req.APIKey:rsp12345,,,*req.APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&Responder.Shutdown&Responder.Ping,false,20
|
||||
cgrates.org,ATTR_API_CHC_AUTH,*auth,*string:~*req.APIKey:chc12345,,,*req.APIMethods,*constant,CacheSv1.Ping&CacheSv1.GetCacheStats&CacheSv1.LoadCache&CacheSv1.PrecacheStatus&CacheSv1.GetItemIDs&CacheSv1.HasItem&CacheSv1.GetItemExpiryTime&CacheSv1.ReloadCache&CacheSv1.RemoveItem&CacheSv1.FlushCache&CacheSv1.Clear,false,20
|
||||
|
||||
|
@@ -152,7 +152,7 @@ func (dS *DispatcherService) ResourceSv1GetResource(args *utils.TenantIDWithArgD
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ResourceSv1GetResources, tnt,
|
||||
if err = dS.authorize(utils.ResourceSv1GetResource, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -161,5 +161,5 @@ func (dS *DispatcherService) ResourceSv1GetResource(args *utils.TenantIDWithArgD
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaResources, routeID, utils.ResourceSv1GetResources, args, reply)
|
||||
}, utils.MetaResources, routeID, utils.ResourceSv1GetResource, args, reply)
|
||||
}
|
||||
|
||||
@@ -301,4 +301,20 @@ func testDspResTestAuthKey3(t *testing.T) {
|
||||
t.Errorf("Unexpected resource: %+v", utils.ToJSON(r))
|
||||
}
|
||||
}
|
||||
var r *engine.Resource
|
||||
argsGetResource := &utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ResGroup1"},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("res12345"),
|
||||
},
|
||||
}
|
||||
if err := dispEngine.RPC.Call(utils.ResourceSv1GetResource, argsGetResource, &r); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// make sure Resource1 have no more active resources
|
||||
if r.ID == "ResGroup1" &&
|
||||
(len(r.Usages) != 1 || len(r.TTLIdx) != 0) {
|
||||
t.Errorf("Unexpected resource: %+v", utils.ToJSON(r))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2992,8 +2992,8 @@ func TestEventCostgetChargesForPath(t *testing.T) {
|
||||
eBalanceCharge := &BalanceCharge{AccountID: "AccountID"}
|
||||
if rcv, err := eventCost.getChargesForPath([]string{"Increments[0]", utils.Accounting}, chargingInterval); err != nil {
|
||||
t.Errorf("Expecting: nil, received: %+v", err)
|
||||
} else if !reflect.DeepEqual(eBalanceCharge,rcv){
|
||||
t.Errorf("Expecting: %+v, received: %+v",eBalanceCharge, rcv)
|
||||
} else if !reflect.DeepEqual(eBalanceCharge, rcv) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eBalanceCharge, rcv)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -368,9 +368,8 @@ func (spS *SupplierService) resourceUsage(resIDs []string, tenant string) (tUsag
|
||||
for _, resID := range resIDs {
|
||||
var res Resource
|
||||
if err = spS.connMgr.Call(spS.cgrcfg.SupplierSCfg().ResourceSConns, nil, utils.ResourceSv1GetResource,
|
||||
&utils.TenantIDWithArgDispatcher{TenantID: &utils.TenantID{ Tenant: tenant, ID: resID}}, &res);
|
||||
err != nil && err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
&utils.TenantIDWithArgDispatcher{TenantID: &utils.TenantID{Tenant: tenant, ID: resID}}, &res); err != nil && err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<SupplierS> error: %s getting resource for ID : %s", err.Error(), resID))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -1388,7 +1388,7 @@ type RatingPlanCostArg struct {
|
||||
*ArgDispatcher
|
||||
}
|
||||
type SessionIDsWithArgsDispatcher struct {
|
||||
IDs []string
|
||||
IDs []string
|
||||
Tenant string
|
||||
*ArgDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1265,7 +1265,6 @@ const (
|
||||
const (
|
||||
ResourceSv1AuthorizeResources = "ResourceSv1.AuthorizeResources"
|
||||
ResourceSv1GetResourcesForEvent = "ResourceSv1.GetResourcesForEvent"
|
||||
ResourceSv1GetResources = "ResourceSv1.GetResources"
|
||||
ResourceSv1AllocateResources = "ResourceSv1.AllocateResources"
|
||||
ResourceSv1ReleaseResources = "ResourceSv1.ReleaseResources"
|
||||
ResourceSv1Ping = "ResourceSv1.Ping"
|
||||
|
||||
Reference in New Issue
Block a user