diff --git a/agents/agentreq.go b/agents/agentreq.go index f8b1f3c7f..ec031badd 100644 --- a/agents/agentreq.go +++ b/agents/agentreq.go @@ -165,6 +165,8 @@ func (ar *AgentRequest) FieldAsInterface(fldPath []string) (val interface{}, err } else { val = ar.Cfg } + case utils.MetaTenant: + return ar.Tenant, nil } if err != nil { return diff --git a/agents/agentreq_test.go b/agents/agentreq_test.go index c51e3f377..bde80194c 100644 --- a/agents/agentreq_test.go +++ b/agents/agentreq_test.go @@ -957,6 +957,7 @@ func TestAgReqFieldAsInterface(t *testing.T) { agReq.CGRRequest.Set(&utils.FullPath{Path: utils.ToR, PathSlice: []string{utils.ToR}}, &utils.DataNode{Type: utils.NMSliceType, Slice: []*utils.DataNode{{Type: utils.NMDataType, Value: &utils.DataLeaf{Data: utils.MetaVoice}}}}) agReq.CGRRequest.Set(&utils.FullPath{Path: utils.AccountField, PathSlice: []string{utils.AccountField}}, utils.NewLeafNode("1001")) agReq.CGRRequest.Set(&utils.FullPath{Path: utils.Destination, PathSlice: []string{utils.Destination}}, utils.NewLeafNode("1002")) + agReq.CGRRequest.Set(&utils.FullPath{Path: utils.Tenant, PathSlice: []string{utils.Tenant}}, utils.NewLeafNode("cgrates.org")) path := []string{utils.MetaCgreq, utils.Usage} var expVal interface{} @@ -990,6 +991,14 @@ func TestAgReqFieldAsInterface(t *testing.T) { } else if !reflect.DeepEqual(rply, expVal) { t.Errorf("Expected %v , received: %v", utils.ToJSON(expVal), utils.ToJSON(rply)) } + + path = []string{utils.MetaTenant} + expVal = "cgrates.org" + if rply, err := agReq.FieldAsInterface(path); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(rply, expVal) { + t.Errorf("Expected %v , received: %v", utils.ToJSON(expVal), utils.ToJSON(rply)) + } } func TestAgReqFieldAsInterfaceForOneFldPathCgrReq(t *testing.T) {