From e5f72875015306db03df53186d87420287610801 Mon Sep 17 00:00:00 2001 From: TeoV Date: Mon, 8 Jan 2018 13:20:45 +0200 Subject: [PATCH] Renaming ResourceS V1AllowUsage -> V1.AuthorizeResources --- apier/v1/resourcesv1.go | 6 +++--- apier/v1/resourcesv1_it_test.go | 18 +++++++++--------- engine/resources.go | 4 ++-- utils/consts.go | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apier/v1/resourcesv1.go b/apier/v1/resourcesv1.go index c6181af22..a27bd8eb3 100644 --- a/apier/v1/resourcesv1.go +++ b/apier/v1/resourcesv1.go @@ -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 diff --git a/apier/v1/resourcesv1_it_test.go b/apier/v1/resourcesv1_it_test.go index 9092d1ad7..dcd1cf59e 100644 --- a/apier/v1/resourcesv1_it_test.go +++ b/apier/v1/resourcesv1_it_test.go @@ -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") diff --git a/engine/resources.go b/engine/resources.go index e7f027f50..a95d01303 100755 --- a/engine/resources.go +++ b/engine/resources.go @@ -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...) } diff --git a/utils/consts.go b/utils/consts.go index 39d1d2aa9..ff6ace7f4 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -578,7 +578,7 @@ const ( ResourceSv1GetResourcesForEvent = "ResourceSv1.GetResourcesForEvent" ResourceSv1AllocateResource = "ResourceSv1.AllocateResource" ResourceSv1ReleaseResource = "ResourceSv1.ReleaseResource" - ResourceSv1AllowUsage = "ResourceSv1.AllowUsage" + ResourceSv1AuthorizeResources = "ResourceSv1.AuthorizeResources" ) //CSV file name