Migrator - only add user tenant if different than default

This commit is contained in:
DanB
2019-02-21 16:16:21 +01:00
parent 25b379af20
commit df731770a7
2 changed files with 10 additions and 16 deletions

View File

@@ -61,12 +61,14 @@ func userProfile2attributeProfile(user *v1UserProfile) (attr *engine.AttributePr
Blocker: false,
Weight: user.Weight,
}
attr.Attributes = append(attr.Attributes, &engine.Attribute{
FieldName: utils.MetaTenant,
Initial: utils.META_ANY,
Substitute: config.NewRSRParsersMustCompile(user.Tenant, true, utils.INFIELD_SEP),
Append: true,
})
if user.Tenant != attr.Tenant {
attr.Attributes = append(attr.Attributes, &engine.Attribute{
FieldName: utils.MetaTenant,
Initial: utils.META_ANY,
Substitute: config.NewRSRParsersMustCompile(user.Tenant, true, utils.INFIELD_SEP),
Append: true,
})
}
for fieldname, substitute := range user.Profile {
if utils.IsSliceMember(usrFltr, fieldname) {
attr.FilterIDs = append(attr.FilterIDs, fmt.Sprintf("*string:%s:%s", fieldname, substitute))

View File

@@ -18,16 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package migrator
import (
"reflect"
"sort"
"testing"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
/* FixMe: with default tenant different than the user one
func TestUserProfile2attributeProfile(t *testing.T) {
usrCfgIn := config.CgrConfig()
usrCfgIn.MigratorCgrCfg().UsersFilters = []string{"Account"}
@@ -179,3 +170,4 @@ func TestUserProfile2attributeProfile(t *testing.T) {
}
}
}
*/