Updated GetAttributeProfileIDs to return error when no tenant is given

This commit is contained in:
Trial97
2019-02-22 12:57:00 +02:00
committed by Dan Christian Bogos
parent f9f97ce256
commit 08ded159a0
2 changed files with 6 additions and 0 deletions

View File

@@ -41,6 +41,9 @@ func (apierV1 *ApierV1) GetAttributeProfile(arg utils.TenantID, reply *engine.At
// GetAttributeProfileIDs returns list of attributeProfile IDs registered for a tenant
func (apierV1 *ApierV1) GetAttributeProfileIDs(tenant string, attrPrfIDs *[]string) error {
if tenant == "" {
return utils.NewErrMandatoryIeMissing("Tenant")
}
prfx := utils.AttributeProfilePrefix + tenant + ":"
keys, err := apierV1.DataManager.DataDB().GetKeysForPrefix(prfx)
if err != nil {

View File

@@ -652,6 +652,9 @@ func testAttributeSProcessEventWithHeader(t *testing.T) {
func testAttributeSGetAttPrfIDs(t *testing.T) {
expected := []string{"ATTR_2", "ATTR_1", "ATTR_3", "ATTR_Header", "AttributeWithNonSubstitute"}
var result []string
if err := attrSRPC.Call("ApierV1.GetAttributeProfileIDs", "", &result); err == nil || err.Error() != utils.NewErrMandatoryIeMissing("Tenant").Error() {
t.Errorf("Expected error recived reply %+v with err=%v", result, err)
}
if err := attrSRPC.Call("ApierV1.GetAttributeProfileIDs", "cgrates.org", &result); err != nil {
t.Error(err)
} else if len(expected) != len(result) {