Renaming ResourceS V1AllowUsage -> V1.AuthorizeResources

This commit is contained in:
TeoV
2018-01-08 13:20:45 +02:00
committed by Dan Christian Bogos
parent 170e70281d
commit e5f7287501
4 changed files with 15 additions and 15 deletions

View File

@@ -43,9 +43,9 @@ func (rsv1 *ResourceSv1) GetResourcesForEvent(args utils.ArgRSv1ResourceUsage, r
return rsv1.rls.V1ResourcesForEvent(args, reply)
}
// AllowUsage checks if there are limits imposed for event
func (rsv1 *ResourceSv1) AllowUsage(args utils.ArgRSv1ResourceUsage, allowed *bool) error {
return rsv1.rls.V1AllowUsage(args, allowed)
// AuthorizeResources checks if there are limits imposed for event
func (rsv1 *ResourceSv1) AuthorizeResources(args utils.ArgRSv1ResourceUsage, allowed *bool) error {
return rsv1.rls.V1AuthorizeResources(args, allowed)
}
// V1InitiateResourceUsage records usage for an event

View File

@@ -51,7 +51,7 @@ var sTestsRLSV1 = []func(t *testing.T){
testV1RsGetResourcesForEvent,
testV1RsTTL0,
testV1RsAllocateResource,
testV1RsAllowUsage,
testV1RsAuthorizeResources,
testV1RsReleaseResource,
testV1RsDBStore,
testV1RsGetResourceProfileBeforeSet,
@@ -356,8 +356,8 @@ func testV1RsAllocateResource(t *testing.T) {
}
}
func testV1RsAllowUsage(t *testing.T) {
var allowed bool
func testV1RsAuthorizeResources(t *testing.T) {
var authorized bool
argsRU := utils.ArgRSv1ResourceUsage{
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
CGREvent: utils.CGREvent{
@@ -369,10 +369,10 @@ func testV1RsAllowUsage(t *testing.T) {
},
Units: 6,
}
if err := rlsV1Rpc.Call(utils.ResourceSv1AllowUsage, argsRU, &allowed); err != nil {
if err := rlsV1Rpc.Call(utils.ResourceSv1AuthorizeResources, argsRU, &authorized); err != nil {
t.Error(err)
} else if !allowed { // already 3 usages active before allow call, we should have now more than allowed
t.Error("resource is not allowed")
} else if !authorized { // already 3 usages active before allow call, we should have now more than allowed
t.Error("resource is not authorized")
}
argsRU = utils.ArgRSv1ResourceUsage{
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
@@ -386,9 +386,9 @@ func testV1RsAllowUsage(t *testing.T) {
Units: 7,
}
if err := rlsV1Rpc.Call(utils.ResourceSv1AllowUsage, argsRU, &allowed); err != nil {
if err := rlsV1Rpc.Call(utils.ResourceSv1AuthorizeResources, argsRU, &authorized); err != nil {
t.Error(err)
} else if allowed { // already 3 usages active before allow call, we should have now more than allowed
} else if authorized { // already 3 usages active before allow call, we should have now more than allowed
t.Error("resource should not be allowed")
}
}
@@ -423,7 +423,7 @@ func testV1RsReleaseResource(t *testing.T) {
Units: 7,
}
var allowed bool
if err := rlsV1Rpc.Call(utils.ResourceSv1AllowUsage, argsRU, &allowed); err != nil {
if err := rlsV1Rpc.Call(utils.ResourceSv1AuthorizeResources, argsRU, &allowed); err != nil {
t.Error(err)
} else if !allowed {
t.Error("resource should be allowed")

View File

@@ -530,8 +530,8 @@ func (rS *ResourceService) V1ResourcesForEvent(args utils.ArgRSv1ResourceUsage,
return
}
// V1AllowUsage queries service to find if an Usage is allowed
func (rS *ResourceService) V1AllowUsage(args utils.ArgRSv1ResourceUsage, allow *bool) (err error) {
// V1AuthorizeResources queries service to find if an Usage is allowed
func (rS *ResourceService) V1AuthorizeResources(args utils.ArgRSv1ResourceUsage, allow *bool) (err error) {
if missing := utils.MissingStructFields(&args, []string{"CGREvent.Tenant", "UsageID"}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
}

View File

@@ -578,7 +578,7 @@ const (
ResourceSv1GetResourcesForEvent = "ResourceSv1.GetResourcesForEvent"
ResourceSv1AllocateResource = "ResourceSv1.AllocateResource"
ResourceSv1ReleaseResource = "ResourceSv1.ReleaseResource"
ResourceSv1AllowUsage = "ResourceSv1.AllowUsage"
ResourceSv1AuthorizeResources = "ResourceSv1.AuthorizeResources"
)
//CSV file name