mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added MetaTenant attribute for Users migration
This commit is contained in:
committed by
Dan Christian Bogos
parent
c31210feab
commit
ac24c23cbf
@@ -66,6 +66,15 @@ func userProfile2attributeProfile(user *v1UserProfile) (attr *engine.AttributePr
|
||||
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,
|
||||
|
||||
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package migrator
|
||||
|
||||
import (
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
@@ -30,11 +29,7 @@ import (
|
||||
)
|
||||
|
||||
func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
inPath := path.Join("/usr/share/cgrates", "samples", "tutmongo")
|
||||
usrCfgIn, err := config.NewCGRConfigFromFolder(inPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
usrCfgIn := config.CgrConfig()
|
||||
usrCfgIn.MigratorCgrCfg().UsersFilters = []string{"Account"}
|
||||
config.SetCgrConfig(usrCfgIn)
|
||||
users := map[int]*v1UserProfile{
|
||||
@@ -66,6 +61,17 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
},
|
||||
Weight: 10,
|
||||
},
|
||||
3: &v1UserProfile{
|
||||
Tenant: defaultTenant,
|
||||
UserName: "1001",
|
||||
Masked: false,
|
||||
Profile: map[string]string{
|
||||
"Account": "1002",
|
||||
"ReqType": "*prepaid",
|
||||
utils.Tenant: "cgrates2.org",
|
||||
},
|
||||
Weight: 10,
|
||||
},
|
||||
}
|
||||
expected := map[int]*engine.AttributeProfile{
|
||||
0: {
|
||||
@@ -118,6 +124,29 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
Blocker: false,
|
||||
Weight: 10,
|
||||
},
|
||||
3: {
|
||||
Tenant: defaultTenant,
|
||||
ID: "1001",
|
||||
Contexts: []string{utils.META_ANY},
|
||||
FilterIDs: []string{"*string:Account:1002"},
|
||||
ActivationInterval: nil,
|
||||
Attributes: []*engine.Attribute{
|
||||
{
|
||||
FieldName: utils.MetaTenant,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile("cgrates2.org", true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
},
|
||||
{
|
||||
FieldName: "ReqType",
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile("*prepaid", true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
},
|
||||
},
|
||||
Blocker: false,
|
||||
Weight: 10,
|
||||
},
|
||||
}
|
||||
for i := range expected {
|
||||
rply := userProfile2attributeProfile(users[i])
|
||||
|
||||
Reference in New Issue
Block a user