diff --git a/dev/test_data.sql b/dev/test_data.sql index 3b4ec085e..a9a6b7a62 100644 --- a/dev/test_data.sql +++ b/dev/test_data.sql @@ -19,7 +19,8 @@ INSERT INTO rh_account (id, name, org_id) VALUES INSERT INTO baseline (id, rh_account_id, name, config, description) VALUES (1, 1, 'baseline_1-1', '{"to_time": "2010-09-22T00:00:00+00:00"}', 'desc'), (2, 1, 'baseline_1-2', '{"to_time": "2021-01-01T00:00:00+00:00"}', NULL), -(3, 1, 'baseline_1-3', '{"to_time": "2000-01-01T00:00:00+00:00"}', NULL); +(3, 1, 'baseline_1-3', '{"to_time": "2000-01-01T00:00:00+00:00"}', NULL), +(4, 3, 'baseline_3-4', '{"to_time": "2000-01-01T00:00:00+00:00"}', NULL); INSERT INTO system_platform (id, inventory_id, display_name, rh_account_id, reporter_id, vmaas_json, json_checksum, last_evaluation, last_upload, packages_installed, packages_updatable, third_party, baseline_id, baseline_uptodate) VALUES (1, '00000000-0000-0000-0000-000000000001','00000000-0000-0000-0000-000000000001', 1, 1, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-09-22 12:00:00-04', '2020-09-22 12:00:00-04',0,0, true, 1, true), @@ -45,6 +46,9 @@ INSERT INTO system_platform (id, inventory_id, display_name, rh_account_id, vma (15, '00000000-0000-0000-0000-000000000015','00000000-0000-0000-0000-000000000015', 3, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-09-22 12:00:00-04', '2018-01-22 12:00:00-04', 0,0, '{"update_list": {"suricata-6.0.3-2.fc35.i686": {"available_updates": [{"erratum": "RHSA-2021:3801", "basearch": "i686", "releasever": "ser1", "repository": "group_oisf:suricata-6.0", "package": "suricata-6.0.4-2.fc35.i686"}]}}, "basearch": "i686", "releasever": "ser1"}'); +INSERT INTO system_platform (id, inventory_id, display_name, rh_account_id, vmaas_json, json_checksum, last_evaluation, last_upload, packages_installed, packages_updatable, yum_updates, baseline_id) VALUES +(16, '00000000-0000-0000-0000-000000000016','00000000-0000-0000-0000-000000000016', 3, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-09-22 12:00:00-04', '2018-01-22 12:00:00-04', 1,0, NULL, 4); + INSERT INTO advisory_metadata (id, name, description, synopsis, summary, solution, advisory_type_id, public_date, modified_date, url, severity_id, cve_list, release_versions) VALUES (1, 'RH-1', 'adv-1-des', 'adv-1-syn', 'adv-1-sum', 'adv-1-sol', 1, '2016-09-22 12:00:00-04', '2017-09-22 12:00:00-04', 'url1', NULL, NULL, '["7.0","7Server"]'), @@ -155,7 +159,8 @@ INSERT INTO system_package (rh_account_id, system_id, package_id, name_id, updat (3, 13, 1, 101, null), (3, 13, 2, 102, '[{"evra": "76.0.1-1.fc31.x86_64", "advisory": "RH-2", "status": "Installable"},{"evra": "77.0.1-1.fc31.x86_64", "advisory": "RH-1", "status": "Applicable"}]'), (3, 13, 3, 103, null), -(3, 13, 4, 104, null); +(3, 13, 4, 104, null), +(3, 16, 1, 101, '[{"evra": "5.10.13-200.fc31.x86_64", "advisory": "RH-100", "status": "Installable"}]'); INSERT INTO timestamp_kv (name, value) VALUES ('last_eval_repo_based', '2018-04-05T01:23:45+02:00'); diff --git a/docs/admin/openapi.json b/docs/admin/openapi.json index 9a4c1211a..b4bc73899 100644 --- a/docs/admin/openapi.json +++ b/docs/admin/openapi.json @@ -81,7 +81,7 @@ ], "responses": { "200": { - "description": "", + "description": "OK", "content": {} }, "500": { @@ -123,7 +123,7 @@ ], "responses": { "200": { - "description": "", + "description": "OK", "content": {} }, "500": { @@ -165,7 +165,7 @@ ], "responses": { "200": { - "description": "", + "description": "OK", "content": {} }, "500": { @@ -207,7 +207,7 @@ ], "responses": { "200": { - "description": "", + "description": "OK", "content": {} }, "500": { diff --git a/docs/v3/openapi.json b/docs/v3/openapi.json index 294d7d709..9653125c4 100644 --- a/docs/v3/openapi.json +++ b/docs/v3/openapi.json @@ -6066,6 +6066,9 @@ "available_evra": { "type": "string" }, + "baseline_id": { + "type": "integer" + }, "baseline_name": { "type": "string" }, @@ -6081,6 +6084,12 @@ "installed_evra": { "type": "string" }, + "os": { + "type": "string" + }, + "rhsm": { + "type": "string" + }, "tags": { "type": "array", "items": { diff --git a/manager/controllers/package_systems.go b/manager/controllers/package_systems.go index 94155671f..61b186f08 100644 --- a/manager/controllers/package_systems.go +++ b/manager/controllers/package_systems.go @@ -40,6 +40,8 @@ type PackageSystemItemV2 struct { //nolint:lll type PackageSystemItemV3 struct { PackageSystemItemCommon + BaselineIDAttr + OSAttributes UpdateStatus string `json:"update_status" csv:"update_status" query:"update_status(spkg.update_data)" gorm:"column:update_status"` } diff --git a/manager/controllers/package_systems_export_test.go b/manager/controllers/package_systems_export_test.go index 8657675b0..efb03ccd3 100644 --- a/manager/controllers/package_systems_export_test.go +++ b/manager/controllers/package_systems_export_test.go @@ -17,7 +17,7 @@ func TestPackageSystemsExportHandlerJSON(t *testing.T) { var output []PackageSystemItemV3 CheckResponse(t, w, http.StatusOK, &output) - assert.Equal(t, 2, len(output)) + assert.Equal(t, 3, len(output)) assert.Equal(t, "00000000-0000-0000-0000-000000000012", output[0].ID) assert.Equal(t, "5.6.13-200.fc31.x86_64", output[0].InstalledEVRA) assert.Equal(t, "5.10.13-200.fc31.x86_64", output[0].AvailableEVRA) @@ -35,15 +35,15 @@ func TestPackageSystemsExportHandlerCSV(t *testing.T) { body := w.Body.String() lines := strings.Split(body, "\n") - assert.Equal(t, 4, len(lines)) + assert.Equal(t, 5, len(lines)) assert.Equal(t, "id,display_name,installed_evra,available_evra,updatable,tags,"+ - "baseline_name,baseline_uptodate,update_status", lines[0]) + "baseline_name,baseline_uptodate,baseline_id,os,rhsm,update_status", lines[0]) assert.Equal(t, "00000000-0000-0000-0000-000000000012,00000000-0000-0000-0000-000000000012,"+ "5.6.13-200.fc31.x86_64,5.10.13-200.fc31.x86_64,true,"+ - "\"[{'key':'k1','namespace':'ns1','value':'val1'}]\",,,Installable", + "\"[{'key':'k1','namespace':'ns1','value':'val1'}]\",,,0,RHEL 8.1,8.1,Installable", lines[1]) assert.Equal(t, "00000000-0000-0000-0000-000000000013,00000000-0000-0000-0000-000000000013,"+ - "5.6.13-200.fc31.x86_64,,false,\"[{'key':'k1','namespace':'ns1','value':'val1'}]\",,,None", lines[2]) + "5.6.13-200.fc31.x86_64,,false,\"[{'key':'k1','namespace':'ns1','value':'val1'}]\",,,0,RHEL 8.2,8.2,None", lines[2]) } func TestPackageSystemsExportInvalidName(t *testing.T) { diff --git a/manager/controllers/package_systems_test.go b/manager/controllers/package_systems_test.go index 7a7968272..67e1a97a8 100644 --- a/manager/controllers/package_systems_test.go +++ b/manager/controllers/package_systems_test.go @@ -12,7 +12,7 @@ import ( func TestPackageSystems(t *testing.T) { output := testPackageSystems(t, "/kernel/systems?sort=id", 3) - assert.Equal(t, 2, len(output.Data)) + assert.Equal(t, 3, len(output.Data)) assert.Equal(t, "00000000-0000-0000-0000-000000000012", output.Data[0].ID) assert.Equal(t, "00000000-0000-0000-0000-000000000012", output.Data[0].DisplayName) assert.Equal(t, "5.6.13-200.fc31.x86_64", output.Data[0].InstalledEVRA) @@ -24,7 +24,7 @@ func TestPackageSystems(t *testing.T) { func TestPackageIDsSystems(t *testing.T) { output := testPackageIDsSystems(t, "/kernel/systems?sort=id", 3) - assert.Equal(t, 2, len(output.IDs)) + assert.Equal(t, 3, len(output.IDs)) assert.Equal(t, "00000000-0000-0000-0000-000000000012", output.IDs[0]) } diff --git a/manager/controllers/packages_export_test.go b/manager/controllers/packages_export_test.go index 8bf0f096f..ea2882a1d 100644 --- a/manager/controllers/packages_export_test.go +++ b/manager/controllers/packages_export_test.go @@ -30,5 +30,5 @@ func TestPackageExportCSV(t *testing.T) { assert.Equal(t, 6, len(lines)) assert.Equal(t, "name,summary,systems_installed,systems_installable,systems_applicable", lines[0]) - assert.Equal(t, "kernel,The Linux kernel,2,1,1", lines[1]) + assert.Equal(t, "kernel,The Linux kernel,3,2,2", lines[1]) } diff --git a/manager/controllers/packages_test.go b/manager/controllers/packages_test.go index f44cfe5f7..7c209f2d3 100644 --- a/manager/controllers/packages_test.go +++ b/manager/controllers/packages_test.go @@ -58,7 +58,7 @@ func TestPackagesFilterSummary(t *testing.T) { } func TestPackagesFilterSAP(t *testing.T) { - output := doTestPackages(t, "/?filter[system_profile][is_sap][eq]=true") + output := doTestPackages(t, "/?filter[system_profile][sap_system]=true") assert.Equal(t, 4, len(output.Data)) assert.Equal(t, "kernel", output.Data[3].Name) assert.Equal(t, 2, output.Data[3].SystemsInstalled) diff --git a/manager/controllers/systems_auth_test.go b/manager/controllers/systems_auth_test.go index 0e639d507..7ad9984e2 100644 --- a/manager/controllers/systems_auth_test.go +++ b/manager/controllers/systems_auth_test.go @@ -21,6 +21,6 @@ func TestMissingAccount(t *testing.T) { testAccountSystemCounts(t, 0, 0) testAccountSystemCounts(t, 1, 8) testAccountSystemCounts(t, 2, 3) - testAccountSystemCounts(t, 3, 4) + testAccountSystemCounts(t, 3, 5) testAccountSystemCounts(t, 4, 0) } diff --git a/manager/controllers/systems_ids_test.go b/manager/controllers/systems_ids_test.go index faba9811d..73d13e086 100644 --- a/manager/controllers/systems_ids_test.go +++ b/manager/controllers/systems_ids_test.go @@ -94,7 +94,7 @@ func TestSystemsIDsWorkloads3(t *testing.T) { func TestSystemsIDsPackagesCount(t *testing.T) { output := testSystemsIDs(t, "/?sort=-packages_installed,id", 3) - assert.Equal(t, 4, len(output.IDs)) + assert.Equal(t, 5, len(output.IDs)) assert.Equal(t, "00000000-0000-0000-0000-000000000012", output.IDs[0]) } diff --git a/manager/controllers/systems_test.go b/manager/controllers/systems_test.go index ab627c674..847ade431 100644 --- a/manager/controllers/systems_test.go +++ b/manager/controllers/systems_test.go @@ -133,7 +133,7 @@ func TestSystemsWorkloads3(t *testing.T) { func TestSystemsPackagesCount(t *testing.T) { output := testSystems(t, "/?sort=-packages_installed,id", 3) - assert.Equal(t, 4, len(output.Data)) + assert.Equal(t, 5, len(output.Data)) assert.Equal(t, "00000000-0000-0000-0000-000000000012", output.Data[0].ID) assert.Equal(t, "system", output.Data[0].Type) assert.Equal(t, "00000000-0000-0000-0000-000000000012", output.Data[0].Attributes.DisplayName) diff --git a/tasks/system_culling/system_culling_test.go b/tasks/system_culling/system_culling_test.go index 1470d3eb9..1d395715f 100644 --- a/tasks/system_culling/system_culling_test.go +++ b/tasks/system_culling/system_culling_test.go @@ -90,7 +90,7 @@ func TestMarkSystemsStale(t *testing.T) { } nMarked, err := markSystemsStale(database.Db, 500) assert.Nil(t, err) - assert.Equal(t, 15, nMarked) + assert.Equal(t, 16, nMarked) assert.NoError(t, database.Db.Find(&systems).Error) for i, s := range systems { diff --git a/tasks/vmaas_sync/metrics_test.go b/tasks/vmaas_sync/metrics_test.go index 0297793ae..3356cbf43 100644 --- a/tasks/vmaas_sync/metrics_test.go +++ b/tasks/vmaas_sync/metrics_test.go @@ -29,7 +29,7 @@ func TestSystemsCounts(t *testing.T) { assert.Equal(t, 2, counts[systemsCntLabels{staleOff, lastUploadLast1D}]) assert.Equal(t, 5, counts[systemsCntLabels{staleOff, lastUploadLast7D}]) assert.Equal(t, 8, counts[systemsCntLabels{staleOff, lastUploadLast30D}]) - assert.Equal(t, 15, counts[systemsCntLabels{staleOff, lastUploadAll}]) + assert.Equal(t, 16, counts[systemsCntLabels{staleOff, lastUploadAll}]) assert.Equal(t, 0, counts[systemsCntLabels{staleOn, lastUploadLast1D}]) assert.Equal(t, 0, counts[systemsCntLabels{staleOn, lastUploadLast7D}]) assert.Equal(t, 0, counts[systemsCntLabels{staleOn, lastUploadLast30D}])