mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Migrator for user updated with *tenant
This commit is contained in:
@@ -52,7 +52,7 @@ func (ud *v1UserProfile) SetId(id string) error {
|
||||
func userProfile2attributeProfile(user *v1UserProfile) (attr *engine.AttributeProfile) {
|
||||
usrFltr := config.CgrConfig().MigratorCgrCfg().UsersFilters
|
||||
attr = &engine.AttributeProfile{
|
||||
Tenant: user.Tenant,
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: user.UserName,
|
||||
Contexts: []string{utils.META_ANY},
|
||||
FilterIDs: make([]string, 0),
|
||||
@@ -61,20 +61,17 @@ 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,
|
||||
})
|
||||
for fieldname, substitute := range user.Profile {
|
||||
if utils.IsSliceMember(usrFltr, fieldname) {
|
||||
attr.FilterIDs = append(attr.FilterIDs, fmt.Sprintf("*string:%s:%s", fieldname, substitute))
|
||||
continue
|
||||
}
|
||||
if fieldname == utils.Tenant {
|
||||
attr.Attributes = append(attr.Attributes, &engine.Attribute{
|
||||
FieldName: utils.MetaTenant,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile(substitute, true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
})
|
||||
continue
|
||||
}
|
||||
attr.Attributes = append(attr.Attributes, &engine.Attribute{
|
||||
FieldName: fieldname,
|
||||
Initial: utils.META_ANY,
|
||||
|
||||
@@ -66,9 +66,8 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
UserName: "1001",
|
||||
Masked: false,
|
||||
Profile: map[string]string{
|
||||
"Account": "1002",
|
||||
"ReqType": "*prepaid",
|
||||
utils.Tenant: "cgrates2.org",
|
||||
"Account": "1002",
|
||||
"ReqType": "*prepaid",
|
||||
},
|
||||
Weight: 10,
|
||||
},
|
||||
@@ -80,9 +79,16 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
Contexts: []string{utils.META_ANY},
|
||||
FilterIDs: make([]string, 0),
|
||||
ActivationInterval: nil,
|
||||
Attributes: make([]*engine.Attribute, 0),
|
||||
Blocker: false,
|
||||
Weight: 10,
|
||||
Attributes: []*engine.Attribute{
|
||||
{
|
||||
FieldName: utils.MetaTenant,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile(defaultTenant, true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
},
|
||||
},
|
||||
Blocker: false,
|
||||
Weight: 10,
|
||||
},
|
||||
1: {
|
||||
Tenant: defaultTenant,
|
||||
@@ -91,6 +97,12 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
FilterIDs: []string{"*string:Account:1002"},
|
||||
ActivationInterval: nil,
|
||||
Attributes: []*engine.Attribute{
|
||||
{
|
||||
FieldName: utils.MetaTenant,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile(defaultTenant, true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
},
|
||||
{
|
||||
FieldName: "Subject",
|
||||
Initial: utils.META_ANY,
|
||||
@@ -108,6 +120,12 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
FilterIDs: []string{"*string:Account:1002"},
|
||||
ActivationInterval: nil,
|
||||
Attributes: []*engine.Attribute{
|
||||
{
|
||||
FieldName: utils.MetaTenant,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile(defaultTenant, true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
},
|
||||
{
|
||||
FieldName: "ReqType",
|
||||
Initial: utils.META_ANY,
|
||||
@@ -134,7 +152,7 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
{
|
||||
FieldName: utils.MetaTenant,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile("cgrates2.org", true, utils.INFIELD_SEP),
|
||||
Substitute: config.NewRSRParsersMustCompile(defaultTenant, true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user