diff --git a/management/server/http/api/openapi.yml b/management/server/http/api/openapi.yml index b20c7b364c4..b5fdd304eae 100644 --- a/management/server/http/api/openapi.yml +++ b/management/server/http/api/openapi.yml @@ -842,16 +842,11 @@ components: description: Posture check for the version of NetBird type: object properties: - enabled: - description: NetBird's version check status - type: boolean - example: false min_version: description: Minimum acceptable NetBird version type: string example: "0.25.0" required: - - enabled - min_version PostureCheckUpdate: type: object diff --git a/management/server/http/api/types.gen.go b/management/server/http/api/types.gen.go index 3b7702e8f41..b6291c9f245 100644 --- a/management/server/http/api/types.gen.go +++ b/management/server/http/api/types.gen.go @@ -265,9 +265,6 @@ type GroupRequest struct { // NBVersionCheck Posture check for the version of NetBird type NBVersionCheck struct { - // Enabled NetBird's version check status - Enabled bool `json:"enabled"` - // MinVersion Minimum acceptable NetBird version MinVersion string `json:"min_version"` } diff --git a/management/server/http/posture_checks_handler.go b/management/server/http/posture_checks_handler.go index 47b3d07eaf5..e40f4a751ca 100644 --- a/management/server/http/posture_checks_handler.go +++ b/management/server/http/posture_checks_handler.go @@ -181,7 +181,6 @@ func (p *PostureChecksHandler) savePostureChecks( if nbVersionCheck := req.Checks.NbVersionCheck; nbVersionCheck != nil { postureChecks.Checks = append(postureChecks.Checks, &posture.NBVersionCheck{ - Enabled: nbVersionCheck.Enabled, MinVersion: nbVersionCheck.MinVersion, }) @@ -219,7 +218,6 @@ func toPostureChecksResponse(postureChecks *posture.Checks) *api.PostureCheck { case posture.NBVersionCheckName: versionCheck := check.(*posture.NBVersionCheck) checks.NbVersionCheck = &api.NBVersionCheck{ - Enabled: versionCheck.Enabled, MinVersion: versionCheck.MinVersion, } } diff --git a/management/server/http/posture_checks_handler_test.go b/management/server/http/posture_checks_handler_test.go index 28b0e23e5ef..a89d14565d7 100644 --- a/management/server/http/posture_checks_handler_test.go +++ b/management/server/http/posture_checks_handler_test.go @@ -108,7 +108,6 @@ func TestGetPostureCheck(t *testing.T) { Name: "name", Checks: []posture.Check{ &posture.NBVersionCheck{ - Enabled: true, MinVersion: "1.0.0", }, }, @@ -175,9 +174,7 @@ func TestPostureCheckUpdate(t *testing.T) { "description": "default", "checks": { "nb_version_check": { - "enabled": true, - "min_version": "1.2.3", - "max_version": "2.0.0" + "min_version": "1.2.3" } } }`)), @@ -189,7 +186,6 @@ func TestPostureCheckUpdate(t *testing.T) { Description: str("default"), Checks: api.Checks{ NbVersionCheck: &api.NBVersionCheck{ - Enabled: true, MinVersion: "1.2.3", }, }, @@ -204,7 +200,6 @@ func TestPostureCheckUpdate(t *testing.T) { "name": "default", "checks": { "non_existing_check": { - "enabled": true, "min_version": "1.2.0" } } @@ -220,7 +215,6 @@ func TestPostureCheckUpdate(t *testing.T) { []byte(`{ "checks": { "nb_version_check": { - "enabled": true, "min_version": "1.2.0" } } @@ -236,9 +230,7 @@ func TestPostureCheckUpdate(t *testing.T) { []byte(`{ "name": "default", "checks": { - "nb_version_check": { - "enabled": true, - } + "nb_version_check": {} } }`)), expectedStatus: http.StatusBadRequest, @@ -253,7 +245,6 @@ func TestPostureCheckUpdate(t *testing.T) { "name": "default", "checks": { "nb_version_check": { - "enabled": true, "min_version": "1.9.0" } } @@ -266,7 +257,6 @@ func TestPostureCheckUpdate(t *testing.T) { Description: str(""), Checks: api.Checks{ NbVersionCheck: &api.NBVersionCheck{ - Enabled: true, MinVersion: "1.9.0", }, }, @@ -281,7 +271,6 @@ func TestPostureCheckUpdate(t *testing.T) { "name": "default", "checks": { "non_existing_check": { - "enabled": true, "min_version": "1.2.0" } } @@ -297,7 +286,7 @@ func TestPostureCheckUpdate(t *testing.T) { []byte(`{ "checks": { "nb_version_check": { - "enabled": true, + "min_version": "1.2.0" } } }`)), @@ -312,9 +301,7 @@ func TestPostureCheckUpdate(t *testing.T) { []byte(`{ "name": "default", "checks": { - "nb_version_check": { - "enabled": false, - } + "nb_version_check": {} } }`)), expectedStatus: http.StatusBadRequest, @@ -327,7 +314,6 @@ func TestPostureCheckUpdate(t *testing.T) { Name: "postureCheck", Checks: []posture.Check{ &posture.NBVersionCheck{ - Enabled: true, MinVersion: "1.0.0", }, }, diff --git a/management/server/posture/checks_test.go b/management/server/posture/checks_test.go index 906517a0c60..cae82caab6a 100644 --- a/management/server/posture/checks_test.go +++ b/management/server/posture/checks_test.go @@ -22,7 +22,6 @@ func TestChecks_MarshalJSON(t *testing.T) { AccountID: "acc1", Checks: []Check{ &NBVersionCheck{ - Enabled: true, MinVersion: "1.0.0", }, }, @@ -34,7 +33,6 @@ func TestChecks_MarshalJSON(t *testing.T) { "Description": "desc1", "Checks": { "NBVersionCheck": { - "Enabled": true, "MinVersion": "1.0.0" } } @@ -60,7 +58,6 @@ func TestChecks_MarshalJSON(t *testing.T) { "Description": "", "Checks": { "NBVersionCheck": { - "Enabled": false, "MinVersion": "" } } @@ -112,7 +109,6 @@ func TestChecks_UnmarshalJSON(t *testing.T) { Description: "desc1", Checks: []Check{ &NBVersionCheck{ - Enabled: true, MinVersion: "1.0.0", }, }, diff --git a/management/server/posture/version.go b/management/server/posture/version.go index 71b15c82925..46672a967df 100644 --- a/management/server/posture/version.go +++ b/management/server/posture/version.go @@ -9,17 +9,12 @@ import ( ) type NBVersionCheck struct { - Enabled bool MinVersion string } var _ Check = (*NBVersionCheck)(nil) func (n *NBVersionCheck) Check(peer nbpeer.Peer) error { - if !n.Enabled { - return nil - } - peerNBVersion, err := version.NewVersion(peer.Meta.WtVersion) if err != nil { return err diff --git a/management/server/posture/version_test.go b/management/server/posture/version_test.go index ffe1873929d..c590fd2aeb3 100644 --- a/management/server/posture/version_test.go +++ b/management/server/posture/version_test.go @@ -23,7 +23,6 @@ func TestNBVersionCheck_Check(t *testing.T) { }, }, check: NBVersionCheck{ - Enabled: true, MinVersion: "1.0.0", }, wantErr: false, @@ -36,7 +35,6 @@ func TestNBVersionCheck_Check(t *testing.T) { }, }, check: NBVersionCheck{ - Enabled: true, MinVersion: "2.0", }, wantErr: false, @@ -49,7 +47,6 @@ func TestNBVersionCheck_Check(t *testing.T) { }, }, check: NBVersionCheck{ - Enabled: true, MinVersion: "2.0", }, wantErr: false, @@ -62,7 +59,6 @@ func TestNBVersionCheck_Check(t *testing.T) { }, }, check: NBVersionCheck{ - Enabled: true, MinVersion: "1.0.0", }, wantErr: true, @@ -75,24 +71,10 @@ func TestNBVersionCheck_Check(t *testing.T) { }, }, check: NBVersionCheck{ - Enabled: true, MinVersion: "0.2", }, wantErr: true, }, - { - name: "Older Peer NB version With Check Disabled", - input: peer.Peer{ - Meta: peer.PeerSystemMeta{ - WtVersion: "0.0.9", - }, - }, - check: NBVersionCheck{ - Enabled: false, - MinVersion: "1.0.0", - }, - wantErr: false, - }, { name: "Invalid Peer NB version", input: peer.Peer{ @@ -101,7 +83,6 @@ func TestNBVersionCheck_Check(t *testing.T) { }, }, check: NBVersionCheck{ - Enabled: true, MinVersion: "1.0.0", }, wantErr: true,