Tools: Use ParentalControl in place of URLFilter Object

This commit is contained in:
Amin Ben Romdhane 2024-10-14 15:39:16 +02:00
parent d23a06d6df
commit c7833a508b
5 changed files with 38 additions and 709 deletions

View file

@ -383,40 +383,40 @@ static void test_api_bbfdm_get_set_json_v1_parameter(void **state)
assert_int_equal(fault, FAULT_9008); assert_int_equal(fault, FAULT_9008);
// get value ==> expected "0" error // get value ==> expected "0" error
ctx->in_param = "Device.X_IOPSYS_EU_URLFilter.Profile.1.Name"; ctx->in_param = "Device.X_IOPSYS_EU_ParentalControl.Profile.1.Name";
fault = bbf_entry_method(ctx, BBF_GET_VALUE); fault = bbf_entry_method(ctx, BBF_GET_VALUE);
assert_int_equal(fault, 0); assert_int_equal(fault, 0);
// validate parameter : name, type, value // validate parameter : name, type, value
validate_parameter(ctx, "Device.X_IOPSYS_EU_URLFilter.Profile.1.Name", "homeoffice", "xsd:string"); validate_parameter(ctx, "Device.X_IOPSYS_EU_ParentalControl.Profile.1.Name", "kids", "xsd:string");
// set value ==> expected "0" error // set value ==> expected "0" error
ctx->in_param = "Device.X_IOPSYS_EU_URLFilter.Profile.1.Name"; ctx->in_param = "Device.X_IOPSYS_EU_ParentalControl.Profile.1.Name";
ctx->in_value = "home+office test"; ctx->in_value = "home+office test";
fault = bbf_entry_method(ctx, BBF_SET_VALUE); fault = bbf_entry_method(ctx, BBF_SET_VALUE);
assert_int_equal(fault, 0); assert_int_equal(fault, 0);
// get value ==> expected "0" error // get value ==> expected "0" error
ctx->in_param = "Device.X_IOPSYS_EU_URLFilter.Profile.1.Name"; ctx->in_param = "Device.X_IOPSYS_EU_ParentalControl.Profile.1.Name";
fault = bbf_entry_method(ctx, BBF_GET_VALUE); fault = bbf_entry_method(ctx, BBF_GET_VALUE);
assert_int_equal(fault, 0); assert_int_equal(fault, 0);
// validate parameter : name, type, value // validate parameter : name, type, value
validate_parameter(ctx, "Device.X_IOPSYS_EU_URLFilter.Profile.1.Name", "home+office test", "xsd:string"); validate_parameter(ctx, "Device.X_IOPSYS_EU_ParentalControl.Profile.1.Name", "home+office test", "xsd:string");
// set value ==> expected "0" error // set value ==> expected "0" error
ctx->in_param = "Device.X_IOPSYS_EU_URLFilter.Profile.1.Name"; ctx->in_param = "Device.X_IOPSYS_EU_ParentalControl.Profile.1.Name";
ctx->in_value = "office_test"; ctx->in_value = "office_test";
fault = bbf_entry_method(ctx, BBF_SET_VALUE); fault = bbf_entry_method(ctx, BBF_SET_VALUE);
assert_int_equal(fault, 0); assert_int_equal(fault, 0);
// get value ==> expected "0" error // get value ==> expected "0" error
ctx->in_param = "Device.X_IOPSYS_EU_URLFilter.Profile.1.Name"; ctx->in_param = "Device.X_IOPSYS_EU_ParentalControl.Profile.1.Name";
fault = bbf_entry_method(ctx, BBF_GET_VALUE); fault = bbf_entry_method(ctx, BBF_GET_VALUE);
assert_int_equal(fault, 0); assert_int_equal(fault, 0);
// validate parameter : name, type, value // validate parameter : name, type, value
validate_parameter(ctx, "Device.X_IOPSYS_EU_URLFilter.Profile.1.Name", "office_test", "xsd:string"); validate_parameter(ctx, "Device.X_IOPSYS_EU_ParentalControl.Profile.1.Name", "office_test", "xsd:string");
} }
static void test_api_bbfdm_get_set_library_parameter(void **state) static void test_api_bbfdm_get_set_library_parameter(void **state)

View file

@ -0,0 +1,29 @@
config globals 'globals'
option enable '1'
config profile 'profile_1'
option name 'kids'
list host 'aa:00:aa:35:01:01'
list host 'D_wan_53_1'
option bedtime_enable '1'
list internet_access_schedule 'schedule_1'
option internet_access_policy 'Allow'
option internet_access_enable '1'
config profile_urlfilter 'profile_1_profile_urlfilter_1'
option dm_parent 'profile_1'
list filter_text 'facebook.com'
list profile_urlfilter_schedule 'schedule_1'
option profile_urlbundle 'b_kids'
option enable '1'
config urlbundle 'urlbundle_1'
option name 'b_kids'
list custom_url 'youtube.com'
config profile_bedtime_schedule 'profile_1_profile_bedtime_schedule_1'
option dm_parent 'profile_1'
option start_time '21:00'
option end_time '08:00'
list day 'Saturday'
list day 'Sunday'

View file

@ -1,36 +0,0 @@
config globals 'globals'
option enable '1'
option global_blacklist '1'
list blacklist_url 'abc.com'
list blacklist_url 'def.com'
list blacklist_url 'facebook.com'
list blacklist_url 'instagram.com'
config profile 'profile_1'
option name 'homeoffice'
list whitelist_url 'facebook.com'
list whitelist_url 'instagram.com'
config profile 'profile_2'
option name 'kids'
list blacklist_url 'youtube.com'
list blacklist_url 'game.com'
config filter 'filter_1'
option enable '1'
option profile 'profile_2'
list macaddr '00:11:22:33:44:55'
list macaddr 'AA:BB:CC:33:44:55'
list day 'Monday'
list day 'Tuesday'
list day 'Wednesday'
list day 'Thursday'
list day 'Friday'
option start_time '20:00'
option duration '64800'
config filter 'filter_2'
option enable '1'
option profile 'profile_1'
list macaddr 'CC:DD:EE:33:44:55'
list macaddr 'EE:AA:BB:11:22:33'

View file

@ -1,664 +0,0 @@
{
"json_plugin_version": 2,
"Device.{BBF_VENDOR_PREFIX}ParentalControl.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"description": "This object contains the information about all parental control features.",
"array": false,
"ProfileNumberOfEntries": {
"type": "unsignedInt",
"read": true,
"write": false,
"protocols": [
"cwmp",
"usp"
],
"datatype": "unsignedInt",
"description": "<<numentries>>",
"mapping": [
{
"type": "uci",
"uci": {
"file": "parentalcontrol",
"section": {
"type": "profile"
},
"option": {
"name": "@Count"
}
}
}
]
},
"URLBundleNumberOfEntries": {
"type": "unsignedInt",
"read": true,
"write": false,
"protocols": [
"cwmp",
"usp"
],
"datatype": "unsignedInt",
"description": "<<numentries>>",
"mapping": [
{
"type": "uci",
"uci": {
"file": "parentalcontrol",
"section": {
"type": "urlbundle"
},
"option": {
"name": "@Count"
}
}
}
]
},
"Device.{BBF_VENDOR_PREFIX}ParentalControl.URLBundle.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": true,
"array": true,
"mapping": [
{
"type": "uci",
"uci": {
"file": "parentalcontrol",
"section": {
"type": "urlbundle"
},
"dmmapfile": "dmmap_parentalcontrol"
}
}
],
"Name": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"description": "Uniquely identifiable name of the URL bundle instance.",
"datatype": "string",
"range": [
{
"max": 32
}
],
"flags": [
"Unique",
"Linker"
],
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "name"
}
]
},
"DownloadURL": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "download_url"
}
]
},
"CustomURL": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"list": {
"datatype": "string"
},
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "custom_url"
}
]
}
},
"Device.{BBF_VENDOR_PREFIX}ParentalControl.Profile.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"description": "Table contain details of the access profiles.",
"uniqueKeys": [
"Name"
],
"access": true,
"array": true,
"mapping": [
{
"type": "uci",
"uci": {
"file": "parentalcontrol",
"section": {
"type": "profile"
},
"dmmapfile": "dmmap_parentalcontrol"
}
}
],
"Alias": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "Alias",
"range": [
{
"max": 64
}
],
"flags": [
"unique"
],
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "alias"
}
]
},
"Name": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"range": [
{
"max": 64
}
],
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "name"
}
]
},
"HostList": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"description": "Comma separated list of hostnames or MAC addresses.",
"list": {
"datatype": "string"
},
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"list": "host"
}
]
},
"URLFilterNumberOfEntries": {
"type": "unsignedInt",
"read": true,
"write": false,
"protocols": [
"cwmp",
"usp"
],
"datatype": "unsignedInt",
"description": "<<numentries>>",
"mapping": [
{
"type": "uci",
"uci": {
"file": "parentalcontrol",
"section": {
"type": "profile_urlfilter"
},
"option": {
"name": "@Count"
}
}
}
]
},
"Device.{BBF_VENDOR_PREFIX}ParentalControl.Profile.{i}.URLFilter.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": true,
"array": true,
"mapping": [
{
"type": "uci",
"uci": {
"file": "parentalcontrol",
"section": {
"type": "profile_urlfilter"
},
"dmmapfile": "dmmap_parentalcontrol"
}
}
],
"Enable": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "boolean",
"description": "Enable or disable this filter instance on the CPE.",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "enable"
}
]
},
"AccessPolicy": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"default": "Allow",
"enumerations": [
"Allow",
"Deny"
],
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "access"
}
]
},
"Order": {
"type": "unsignedInt",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"description": "Priority order of applying the policy",
"datatype": "unsignedInt",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "order"
}
]
},
"FilterText": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"range": [
{
"max": 256
}
],
"description": "Comma separated list of URL or sub-part of the URL used for filter",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "filtertext"
}
]
},
"URLBundleRef": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"flags": [
"Reference"
],
"description": "Reference to URLBundle which has list of URLs defined based on Category",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "profile_urlbundle",
"linker_obj": "Device.{BBF_VENDOR_PREFIX}ParentalControl.URLBundle.*.Name"
}
]
},
"ScheduleRef": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"flags": [
"Reference"
],
"description": "Reference to the schedule attached to this url filter instance",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "profile_bedtime_schedule",
"linker_obj": "Device.Schedules.Schedule.[Alias==@key]"
}
]
}
},
"Device.{BBF_VENDOR_PREFIX}ParentalControl.Profile.{i}.BedTime.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Enable": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "boolean",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "bedtime_enable"
}
]
},
"ScheduleNumberOfEntries": {
"type": "unsignedInt",
"read": true,
"write": false,
"protocols": [
"cwmp",
"usp"
],
"datatype": "unsignedInt",
"mapping": [
{
"type": "uci",
"uci": {
"file": "parentalcontrol",
"section": {
"type": "profile_bedtime_schedule"
},
"option": {
"name": "@Count"
}
}
}
]
},
"Device.{BBF_VENDOR_PREFIX}ParentalControl.Profile.{i}.BedTime.Schedule.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": true,
"array": true,
"mapping": [
{
"type": "uci",
"uci": {
"file": "parentalcontrol",
"section": {
"type": "profile_bedtime_schedule"
},
"dmmapfile": "dmmap_parentalcontrol"
}
}
],
"Alias": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "Alias",
"range": [
{
"max": 64
}
],
"flags": [
"unique"
],
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "alias"
}
]
},
"Name": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"description": "Name of this schedule instance.",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "name"
}
]
},
"Days": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"list": {
"datatype": "string",
"enumerations": [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
]
},
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "days"
}
]
},
"StartTime": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"range": [
{
"max": 5
}
],
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "start_time"
}
]
},
"EndTime": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"range": [
{
"max": 5
}
],
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "end_time"
}
]
}
}
},
"Device.{BBF_VENDOR_PREFIX}ParentalControl.Profile.{i}.InternetAccess.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Enable": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "boolean",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "internet_access_enable"
}
]
},
"AccessPolicy": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"description": "Set Deny to stop internet access, set Allow to allow access based on Schedule",
"datatype": "string",
"default": "Allow",
"enumerations": [
"Allow",
"Deny"
],
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "internet_access_policy"
}
]
},
"ScheduleRef": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"flags": [
"Reference"
],
"description": "Comma separated list of references to the Schedules object",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"list": "internet_access_schedule",
"linker_obj": "Device.Schedules.Schedule.[Alias==@list]"
}
]
}
}
}
}
}

View file

@ -72,7 +72,7 @@
"proto": "git", "proto": "git",
"version": "devel", "version": "devel",
"dm_files": [ "dm_files": [
"urlfilter/files/etc/urlfilter/urlfilter.json", "urlfilter/files/etc/urlfilter/X_IOPSYS_EU_ParentalControl.json",
"icwmp/files/etc/bbfdm/json/CWMPManagementServer.json", "icwmp/files/etc/bbfdm/json/CWMPManagementServer.json",
"ponmngr/files/etc/ponmngr/xpon.json" "ponmngr/files/etc/ponmngr/xpon.json"
] ]