From 9a39f3ae9da8d34bf57c46c5f5456335a2081c42 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 5 Dec 2022 10:05:12 +0100 Subject: [PATCH 1/6] fix bug --- ereuse_devicehub/templates/inventory/snapshots_list.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ereuse_devicehub/templates/inventory/snapshots_list.html b/ereuse_devicehub/templates/inventory/snapshots_list.html index 1804f364..47ff3ced 100644 --- a/ereuse_devicehub/templates/inventory/snapshots_list.html +++ b/ereuse_devicehub/templates/inventory/snapshots_list.html @@ -92,7 +92,7 @@ {% if snap.get_device() %} - + {{ snap.get_device() }} {% endif %} From 9736ee323a71da4a8bad789df0b38c97b9bacbe7 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 12 Dec 2022 14:20:07 +0100 Subject: [PATCH 2/6] test settings version --- tests/test_snapshot.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index 9e408f26..40614ce3 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -1413,3 +1413,36 @@ def test_bug_4028_components(user: UserClient): for c in m.Device.query.filter(): assert c.binding or c.placeholder + + +@pytest.mark.mvp +@pytest.mark.usefixtures(conftest.app_context.__name__) +def test_settings_version(user: UserClient): + """Tests when we have one computer and then we change the disk, then + the new disk need to have placeholder too.""" + s = yaml2json('real-eee-1001pxd.snapshot.12') + s['settings_version']= 'Basic Metadata (BM)' + snap1, _ = user.post(s, res=Snapshot) + dev1 = m.Device.query.filter_by(id=snap1['device']['id']).one() + assert m.Placeholder.query.count() * 2 == m.Device.query.count() + components1 = [c for c in dev1.components] + for c in s['components']: + if c['type'] == 'HardDrive': + c['serialNumber'] = 'E2024242CV86MF' + + s['uuid'] = str(uuid4()) + snap2, _ = user.post(s, res=Snapshot) + dev2 = m.Device.query.filter_by(id=snap2['device']['id']).one() + components2 = [c for c in dev2.components] + + assert '' not in [c.phid() for c in components1] + assert '' not in [c.phid() for c in components2] + assert len(components1) == len(components2) + assert m.Placeholder.query.count() == 16 + assert m.Placeholder.query.count() * 2 == m.Device.query.count() + for c in m.Placeholder.query.filter(): + assert c.binding + assert c.device + + for c in m.Device.query.filter(): + assert c.binding or c.placeholder From 254a32d9890321ec6d91a85c50c63f8f76e19655 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 12 Dec 2022 14:20:18 +0100 Subject: [PATCH 3/6] test settings version --- tests/test_snapshot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index 40614ce3..dad60950 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -1421,7 +1421,7 @@ def test_settings_version(user: UserClient): """Tests when we have one computer and then we change the disk, then the new disk need to have placeholder too.""" s = yaml2json('real-eee-1001pxd.snapshot.12') - s['settings_version']= 'Basic Metadata (BM)' + s['settings_version'] = 'Basic Metadata (BM)' snap1, _ = user.post(s, res=Snapshot) dev1 = m.Device.query.filter_by(id=snap1['device']['id']).one() assert m.Placeholder.query.count() * 2 == m.Device.query.count() From 63c7b2923398a18d971935a521e4405dfd0bdc89 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 14 Dec 2022 17:41:35 +0100 Subject: [PATCH 4/6] https instead of http --- ereuse_devicehub/workbench/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/workbench/__init__.py b/ereuse_devicehub/workbench/__init__.py index bd4530a4..7a54c4a2 100644 --- a/ereuse_devicehub/workbench/__init__.py +++ b/ereuse_devicehub/workbench/__init__.py @@ -1,14 +1,14 @@ isos = { "demo": { 'iso': "USODY_2022.8.0-Demo.iso", - 'url': 'http://releases.usody.com/demo/', + 'url': 'https://releases.usody.com/demo/', }, "register": { 'iso': "USODY_2022.8.0-beta.iso", - 'url': 'http://releases.usody.com/2022/', + 'url': 'https://releases.usody.com/2022/', }, "erease": { 'iso': "USODY_14.0.0.iso", - 'url': 'http://releases.usody.com/v14/', + 'url': 'https://releases.usody.com/v14/', }, } From 0f7c9504b0ae6529eba3954b5596d93778f0fdf9 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 15 Dec 2022 10:18:22 +0100 Subject: [PATCH 5/6] fix settings_version --- ereuse_devicehub/parser/models.py | 4 ++- ereuse_devicehub/parser/parser.py | 1 + ereuse_devicehub/parser/schemas.py | 1 + ...QMPKKX51K67R68VO2X9RNZL08JPL_snapshot.json | 1 + tests/test_snapshot.py | 32 ++++--------------- 5 files changed, 13 insertions(+), 26 deletions(-) diff --git a/ereuse_devicehub/parser/models.py b/ereuse_devicehub/parser/models.py index 38ddbaf7..8caa0620 100644 --- a/ereuse_devicehub/parser/models.py +++ b/ereuse_devicehub/parser/models.py @@ -90,7 +90,9 @@ class SnapshotsLog(Thing): settings_version = self.snapshot.settings_version or '' settings_version = "".join([x[0] for x in settings_version.split(' ') if x]) - return "{} ({})".format(self.version, settings_version) + if settings_version: + return "{} ({})".format(self.version, settings_version) + return "{}".format(self.version) class PlaceholdersLog(Thing): diff --git a/ereuse_devicehub/parser/parser.py b/ereuse_devicehub/parser/parser.py index 49e7dee6..0dfe8a57 100644 --- a/ereuse_devicehub/parser/parser.py +++ b/ereuse_devicehub/parser/parser.py @@ -343,6 +343,7 @@ class ParseSnapshotLsHw: "components": self.components, "uuid": snapshot['uuid'], "version": "14.0.0", + "settings_version": snapshot.get("settings_version"), "endTime": snapshot["timestamp"], "elapsed": 1, "sid": snapshot["sid"], diff --git a/ereuse_devicehub/parser/schemas.py b/ereuse_devicehub/parser/schemas.py index 1a84b8bc..fbdc671d 100644 --- a/ereuse_devicehub/parser/schemas.py +++ b/ereuse_devicehub/parser/schemas.py @@ -22,6 +22,7 @@ class Snapshot_lite(Thing): sid = String(required=True) type = String(required=True) timestamp = String(required=True) + settings_version = String(required=False) data = Nested(Snapshot_lite_data, required=True) @validates_schema diff --git a/tests/files/2022-03-31_17h18m51s_ZQMPKKX51K67R68VO2X9RNZL08JPL_snapshot.json b/tests/files/2022-03-31_17h18m51s_ZQMPKKX51K67R68VO2X9RNZL08JPL_snapshot.json index 2a4c85a7..c8034fe6 100644 --- a/tests/files/2022-03-31_17h18m51s_ZQMPKKX51K67R68VO2X9RNZL08JPL_snapshot.json +++ b/tests/files/2022-03-31_17h18m51s_ZQMPKKX51K67R68VO2X9RNZL08JPL_snapshot.json @@ -6,6 +6,7 @@ "software": "Workbench", "version": "2022.03.00", "schema_api": "1.0.0", + "settings_version": "Basic Metadata", "data": { "lspci": "", "lshw": { diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index dad60950..2ee04e76 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -1420,29 +1420,11 @@ def test_bug_4028_components(user: UserClient): def test_settings_version(user: UserClient): """Tests when we have one computer and then we change the disk, then the new disk need to have placeholder too.""" - s = yaml2json('real-eee-1001pxd.snapshot.12') - s['settings_version'] = 'Basic Metadata (BM)' - snap1, _ = user.post(s, res=Snapshot) - dev1 = m.Device.query.filter_by(id=snap1['device']['id']).one() - assert m.Placeholder.query.count() * 2 == m.Device.query.count() - components1 = [c for c in dev1.components] - for c in s['components']: - if c['type'] == 'HardDrive': - c['serialNumber'] = 'E2024242CV86MF' + s = file_json("2022-03-31_17h18m51s_ZQMPKKX51K67R68VO2X9RNZL08JPL_snapshot.json") + body, res = user.post(s, uri="/api/inventory/") + assert m.Computer.query.first().dhid == body['dhid'] + snapshot = Snapshot.query.first() + log = SnapshotsLog.query.first() - s['uuid'] = str(uuid4()) - snap2, _ = user.post(s, res=Snapshot) - dev2 = m.Device.query.filter_by(id=snap2['device']['id']).one() - components2 = [c for c in dev2.components] - - assert '' not in [c.phid() for c in components1] - assert '' not in [c.phid() for c in components2] - assert len(components1) == len(components2) - assert m.Placeholder.query.count() == 16 - assert m.Placeholder.query.count() * 2 == m.Device.query.count() - for c in m.Placeholder.query.filter(): - assert c.binding - assert c.device - - for c in m.Device.query.filter(): - assert c.binding or c.placeholder + assert log.get_version() == "14.0 (BM)" + assert snapshot.settings_version == "Basic Metadata" From 1924d7fe71e2a4188aa9fcc1beb99ce80a32a772 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 15 Dec 2022 10:20:17 +0100 Subject: [PATCH 6/6] wb settins --- ereuse_devicehub/templates/workbench/wbSettings.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/templates/workbench/wbSettings.ini b/ereuse_devicehub/templates/workbench/wbSettings.ini index b28d64a0..213240c1 100644 --- a/ereuse_devicehub/templates/workbench/wbSettings.ini +++ b/ereuse_devicehub/templates/workbench/wbSettings.ini @@ -14,7 +14,7 @@ WB_SMART_TEST = short WB_ERASE = EraseBasic WB_ERASE_STEPS = 1 WB_ERASE_LEADING_ZEROS = False -VERSION = "Basic Erasure (BE)" +VERSION = Basic Erasure (BE) {% elif baseline_erease %} DH_HOST = {{ api_host }} @@ -28,11 +28,11 @@ WB_SMART_TEST = short WB_ERASE = EraseSectors WB_ERASE_STEPS = {{ erase_steps }} WB_ERASE_LEADING_ZEROS = True -VERSION = {%if erase_steps < 3 %}"Baseline Secure Erasure (BSE)"{% else %}"Enhanced Secure Erasure (ESE)"{% endif %} +VERSION = {%if erase_steps < 3 %}Baseline Secure Erasure (BSE){% else %}Enhanced Secure Erasure (ESE){% endif %} {% else %} SNAPSHOTS_PATH = /mnt LOGS_PATH = /mnt -VERSION = "Basic Metadata (BM)" +VERSION = Basic Metadata (BM) {% endif %} \ No newline at end of file