From 1945b8236cfdf9218e2a7272b6e805fc9fab271f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csumedha-game=E2=80=9D?= <“sumedha-game@arista.com”> Date: Fri, 20 Dec 2024 16:13:47 +0530 Subject: [PATCH 1/3] MFW-5962: Added dns filter license --- services/licensemanager/licensesmanager_test.go | 13 +++++++++++++ .../allowedstates/untangle-node-dns-filter | 1 + .../testdata/appstates/appstate_disabled.json | 2 +- .../testdata/appstates/appstate_enabled.json | 2 +- .../testdata/appstates/appstate_mixed.json | 2 +- .../appstates/appstate_service_state.json | 2 +- .../testdata/licenses/licenses.json | 16 +++++++++++++++- 7 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 services/licensemanager/testdata/allowedstates/untangle-node-dns-filter diff --git a/services/licensemanager/licensesmanager_test.go b/services/licensemanager/licensesmanager_test.go index af5b76fa..f72dc32a 100644 --- a/services/licensemanager/licensesmanager_test.go +++ b/services/licensemanager/licensesmanager_test.go @@ -124,6 +124,7 @@ func TestGetLicenseDefaults(t *testing.T) { "untangle-node-geoip", "untangle-node-captiveportal", "untangle-node-dynamic-lists", + "untangle-node-dns-filter", } assert.ElementsMatch(t, expectedKeys, serviceKeys) @@ -387,6 +388,7 @@ func (suite *LicenseManagerTestSuite) SetupSuite() { "untangle-node-geoip": {Name: "untangle-node-geoip", State: ServiceState{AllowedState: 0}}, "untangle-node-captiveportal": {Name: "untangle-node-captiveportal", State: ServiceState{AllowedState: 0}}, "untangle-node-dynamic-lists": {Name: "untangle-node-dynamic-lists", State: ServiceState{AllowedState: 0}}, + "untangle-node-dns-filter": {Name: "untangle-node-dns-filter", State: ServiceState{AllowedState: 0}}, } if startupErr := suite.lm.Startup(); startupErr != nil { @@ -499,6 +501,12 @@ func getTestConfig() *Config { Enabled: nil, Disabled: disableDynamicLists, }, + "untangle-node-dns-filter": { + Start: func() {}, + Stop: func() {}, + Enabled: nil, + Disabled: disableDnsFilter, + }, } return &Config{ @@ -545,6 +553,11 @@ func disableDynamicLists() (interface{}, []string, error) { return false, []string{"dynamic_lists", "enabled"}, nil } +// DisableDnsFilter +func disableDnsFilter() (interface{}, []string, error) { + return false, []string{"dnsfilter", "enabled"}, nil +} + func TestSetServices(t *testing.T) { config := getTestConfig() config.ServiceStateLocation = setServicesStatesMixedFile diff --git a/services/licensemanager/testdata/allowedstates/untangle-node-dns-filter b/services/licensemanager/testdata/allowedstates/untangle-node-dns-filter new file mode 100644 index 00000000..e2746c07 --- /dev/null +++ b/services/licensemanager/testdata/allowedstates/untangle-node-dns-filter @@ -0,0 +1 @@ +{"name":"untangle-node-dns-filter","allowedState":1} \ No newline at end of file diff --git a/services/licensemanager/testdata/appstates/appstate_disabled.json b/services/licensemanager/testdata/appstates/appstate_disabled.json index 65ae0ff5..9ec8e49d 100644 --- a/services/licensemanager/testdata/appstates/appstate_disabled.json +++ b/services/licensemanager/testdata/appstates/appstate_disabled.json @@ -1 +1 @@ -[{"name":"untangle-node-sitefilter","allowedState":1},{"name":"untangle-node-geoip","allowedState":1},{"name":"untangle-node-discovery","allowedState":1},{"name":"untangle-node-classd","allowedState":1},{"name":"untangle-node-dynamic-lists","allowedState":1},{"name":"untangle-node-threat-prevention","allowedState":1},{"name":"untangle-node-captiveportal","allowedState":1}] \ No newline at end of file +[{"name":"untangle-node-sitefilter","allowedState":1},{"name":"untangle-node-geoip","allowedState":1},{"name":"untangle-node-discovery","allowedState":1},{"name":"untangle-node-classd","allowedState":1},{"name":"untangle-node-dynamic-lists","allowedState":1},{"name":"untangle-node-threat-prevention","allowedState":1},{"name":"untangle-node-captiveportal","allowedState":1},{"name":"untangle-node-dns-filter","allowedState":1}] \ No newline at end of file diff --git a/services/licensemanager/testdata/appstates/appstate_enabled.json b/services/licensemanager/testdata/appstates/appstate_enabled.json index 20a9eab3..c2db3af3 100644 --- a/services/licensemanager/testdata/appstates/appstate_enabled.json +++ b/services/licensemanager/testdata/appstates/appstate_enabled.json @@ -1 +1 @@ -[{"name":"untangle-node-sitefilter","allowedState":0},{"name":"untangle-node-geoip","allowedState":0},{"name":"untangle-node-discovery","allowedState":0},{"name":"untangle-node-classd","allowedState":0},{"name":"untangle-node-dynamic-lists","allowedState":0},{"name":"untangle-node-threat-prevention","allowedState":0},{"name":"untangle-node-captiveportal","allowedState":0}] \ No newline at end of file +[{"name":"untangle-node-sitefilter","allowedState":0},{"name":"untangle-node-geoip","allowedState":0},{"name":"untangle-node-discovery","allowedState":0},{"name":"untangle-node-classd","allowedState":0},{"name":"untangle-node-dynamic-lists","allowedState":0},{"name":"untangle-node-threat-prevention","allowedState":0},{"name":"untangle-node-captiveportal","allowedState":0},{"name":"untangle-node-dns-filter","allowedState":0}] \ No newline at end of file diff --git a/services/licensemanager/testdata/appstates/appstate_mixed.json b/services/licensemanager/testdata/appstates/appstate_mixed.json index 44d2786d..f122b7a2 100644 --- a/services/licensemanager/testdata/appstates/appstate_mixed.json +++ b/services/licensemanager/testdata/appstates/appstate_mixed.json @@ -1 +1 @@ -[{"name":"untangle-node-threat-prevention","allowedState":1},{"name":"untangle-node-sitefilter","allowedState":0},{"name":"untangle-node-geoip","allowedState":0},{"name":"untangle-node-discovery","allowedState":0},{"name":"untangle-node-classd","allowedState":1},{"name":"untangle-node-dynamic-lists","allowedState":0},{"name":"untangle-node-captiveportal","allowedState":0}] \ No newline at end of file +[{"name":"untangle-node-threat-prevention","allowedState":1},{"name":"untangle-node-sitefilter","allowedState":0},{"name":"untangle-node-geoip","allowedState":0},{"name":"untangle-node-discovery","allowedState":0},{"name":"untangle-node-classd","allowedState":1},{"name":"untangle-node-dynamic-lists","allowedState":0},{"name":"untangle-node-captiveportal","allowedState":0},{"name":"untangle-node-dns-filter","allowedState":0}] \ No newline at end of file diff --git a/services/licensemanager/testdata/appstates/appstate_service_state.json b/services/licensemanager/testdata/appstates/appstate_service_state.json index 1460f8c4..ae817b2f 100644 --- a/services/licensemanager/testdata/appstates/appstate_service_state.json +++ b/services/licensemanager/testdata/appstates/appstate_service_state.json @@ -1 +1 @@ -[{"name":"untangle-node-captiveportal","allowedState":0},{"name":"untangle-node-threat-prevention","allowedState":1},{"name":"untangle-node-sitefilter","allowedState":0},{"name":"untangle-node-geoip","allowedState":0},{"name":"untangle-node-discovery","allowedState":0},{"name":"untangle-node-classd","allowedState":1},{"name":"untangle-node-dynamic-lists","allowedState":0}] \ No newline at end of file +[{"name":"untangle-node-captiveportal","allowedState":0},{"name":"untangle-node-threat-prevention","allowedState":1},{"name":"untangle-node-sitefilter","allowedState":0},{"name":"untangle-node-geoip","allowedState":0},{"name":"untangle-node-discovery","allowedState":0},{"name":"untangle-node-classd","allowedState":1},{"name":"untangle-node-dynamic-lists","allowedState":0},{"name":"untangle-node-dns-filter","allowedState":0}] \ No newline at end of file diff --git a/services/licensemanager/testdata/licenses/licenses.json b/services/licensemanager/testdata/licenses/licenses.json index 79523db7..03fb0a00 100644 --- a/services/licensemanager/testdata/licenses/licenses.json +++ b/services/licensemanager/testdata/licenses/licenses.json @@ -100,6 +100,19 @@ "name": "untangle-node-captive-portal", "javaClass": "com.untangle.uvm.node.License" }, + { + "UID": "51d50b67-460b-4450-bd29-9bf1a69f4e81", + "type": "Subscription", + "end": 1737187200, + "start": 1734422400, + "seats": 1000000, + "displayName": "DNS Filter", + "key": "b78e6899564d22686271df2ca94ccd91", + "keyVersion": 3, + "name": "untangle-node-dns-filter", + "javaClass": "com.untangle.uvm.node.License", + "valid": false + }, { "UID": "43f90add-dca5-415c-9530-06fa29c9b4d9", @@ -111,7 +124,8 @@ "key": "90ba3b5264b10af43a205b7493118b3b", "keyVersion": 3, "name": "untangle-node-dynamic-lists", - "javaClass": "com.untangle.uvm.node.License" + "javaClass": "com.untangle.uvm.node.License", + "valid": false } ] } \ No newline at end of file From 11fddc328e68a9ee3afb57a0f11d2eabd22c1ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csumedha-game=E2=80=9D?= <“sumedha-game@arista.com”> Date: Fri, 20 Dec 2024 16:24:24 +0530 Subject: [PATCH 2/3] Removed dynamic list chnage --- services/licensemanager/testdata/licenses/licenses.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/services/licensemanager/testdata/licenses/licenses.json b/services/licensemanager/testdata/licenses/licenses.json index 03fb0a00..66373ca0 100644 --- a/services/licensemanager/testdata/licenses/licenses.json +++ b/services/licensemanager/testdata/licenses/licenses.json @@ -110,8 +110,7 @@ "key": "b78e6899564d22686271df2ca94ccd91", "keyVersion": 3, "name": "untangle-node-dns-filter", - "javaClass": "com.untangle.uvm.node.License", - "valid": false + "javaClass": "com.untangle.uvm.node.License" }, { @@ -124,8 +123,7 @@ "key": "90ba3b5264b10af43a205b7493118b3b", "keyVersion": 3, "name": "untangle-node-dynamic-lists", - "javaClass": "com.untangle.uvm.node.License", - "valid": false + "javaClass": "com.untangle.uvm.node.License" } ] } \ No newline at end of file From 045e85cd2406a9cbca853b4d407cdfc4fc56bbdc Mon Sep 17 00:00:00 2001 From: singhrohit23 <154513962+singhrohit23@users.noreply.github.com> Date: Fri, 20 Dec 2024 18:08:40 +0530 Subject: [PATCH 3/3] Update licensesmanager_test.go Added Expected display anme for "DNS Filter", in expected list --- services/licensemanager/licensesmanager_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/services/licensemanager/licensesmanager_test.go b/services/licensemanager/licensesmanager_test.go index f72dc32a..d432ca3b 100644 --- a/services/licensemanager/licensesmanager_test.go +++ b/services/licensemanager/licensesmanager_test.go @@ -152,6 +152,7 @@ func TestGetLicenseDetails(t *testing.T) { "Database Services", "Device Discovery", "Captive Portal", + "DNS Filter", "Dynamic Blocklists", }