mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-19 22:28:45 +05:00
Fixes #1173
This commit is contained in:
committed by
Dan Christian Bogos
parent
9098714251
commit
34f11aa3f2
@@ -59,6 +59,16 @@ func (apierV1 *ApierV1) SetAttributeProfile(alsPrf *engine.AttributeProfile, rep
|
||||
if missing := utils.MissingStructFields(alsPrf, []string{"Tenant", "ID"}); len(missing) != 0 {
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
if len(alsPrf.Attributes) != 0 {
|
||||
for _, attr := range alsPrf.Attributes {
|
||||
for _, sub := range attr.Substitute {
|
||||
if missing := utils.MissingStructFields(sub, []string{"Rules", "AllFiltersMatch"}); len(missing) != 0 {
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if err := apierV1.DataManager.SetAttributeProfile(alsPrf, true); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ var sTestsAlsPrf = []func(t *testing.T){
|
||||
testAttributeSUpdateAlsPrf,
|
||||
testAttributeSRemAlsPrf,
|
||||
testAttributeSSetAlsPrf2,
|
||||
testAttributeSSetAlsPrf3,
|
||||
testAttributeSPing,
|
||||
testAttributeSKillEngine,
|
||||
}
|
||||
@@ -756,7 +757,35 @@ func testAttributeSSetAlsPrf2(t *testing.T) {
|
||||
if !reflect.DeepEqual(alsPrf, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", alsPrf, reply)
|
||||
}
|
||||
}
|
||||
|
||||
func testAttributeSSetAlsPrf3(t *testing.T) {
|
||||
alsPrf = &engine.AttributeProfile{
|
||||
Tenant: "golant",
|
||||
ID: "ATTR_972587832508_SESSIONAUTH",
|
||||
Contexts: []string{utils.MetaSessionS},
|
||||
FilterIDs: []string{"*string:Account:972587832508"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
|
||||
},
|
||||
Attributes: []*engine.Attribute{
|
||||
&engine.Attribute{
|
||||
FieldName: utils.Subject,
|
||||
Initial: utils.ANY,
|
||||
Substitute: utils.RSRParsers{
|
||||
&utils.RSRParser{},
|
||||
},
|
||||
Append: false,
|
||||
},
|
||||
},
|
||||
Blocker: false,
|
||||
Weight: 10,
|
||||
}
|
||||
var result string
|
||||
if err := attrSRPC.Call("ApierV1.SetAttributeProfile", alsPrf, &result); err == nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testAttributeSPing(t *testing.T) {
|
||||
|
||||
@@ -1105,7 +1105,6 @@ func (dm *DataManager) SetAttributeProfile(ap *AttributeProfile, withIndex bool)
|
||||
if err = dm.CacheDataFromDB(utils.AttributeProfilePrefix, []string{ap.TenantID()}, true); err != nil {
|
||||
return
|
||||
}
|
||||
//to be implemented in tests
|
||||
if withIndex {
|
||||
if oldAP != nil {
|
||||
for _, ctx := range oldAP.Contexts {
|
||||
|
||||
Reference in New Issue
Block a user