From 8173069359cdc2319b140964995f742bba2b31df Mon Sep 17 00:00:00 2001 From: Mike Raineri Date: Wed, 20 Mar 2024 14:16:19 -0400 Subject: [PATCH 1/2] Updated write requirement logic to account for Recommended requirements Signed-off-by: Mike Raineri --- redfish_interop_validator/interop.py | 40 +++++++++++++++------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/redfish_interop_validator/interop.py b/redfish_interop_validator/interop.py index 1112691..f4da25c 100644 --- a/redfish_interop_validator/interop.py +++ b/redfish_interop_validator/interop.py @@ -206,44 +206,46 @@ def validateWriteRequirement(profile_entry, parent_object_payload, resource_head """ my_logger.verbose1('Is property writeable \n\t' + str(profile_entry)) + if profile_entry == "Mandatory" or profile_entry == "Supported": + result_not_supported = testResultEnum.FAIL + expected_str = "Must Be Writable" + elif profile_entry == "Recommended": + if config['WarnRecommended']: + result_not_supported = testResultEnum.WARN + else: + result_not_supported = testResultEnum.NA + expected_str = "Should Be Writable" + else: + result_not_supported = testResultEnum.NA + expected_str = profile_entry + # Check for Allow header, warn if missing if resource_headers and 'Allow' in resource_headers: writeable = 'PATCH' in resource_headers['Allow'] if not writeable: - my_logger.error('PATCH in Allow header not available, property is not writeable ' + str(profile_entry)) - return msgInterop('WriteRequirement', profile_entry, - 'Is Writeable' if profile_entry == "Mandatory" else profile_entry, - '-', testResultEnum.FAIL), True + if profile_entry == "Mandatory": + my_logger.error('PATCH in Allow header not available, property is not writeable ' + str(profile_entry)) + return msgInterop('WriteRequirement', profile_entry, expected_str, 'PATCH not supported', result_not_supported), True else: my_logger.warning('Unable to test writeable property, no Allow header available ' + str(profile_entry)) - return msgInterop('WriteRequirement', profile_entry, - 'Is Writeable' if profile_entry == "Mandatory" else profile_entry, - '-', testResultEnum.NOT_TESTED), True + return msgInterop('WriteRequirement', profile_entry, expected_str, 'No Allow response header', testResultEnum.NOT_TESTED), True redfish_payload, _ = parent_object_payload # Get Writeable Properties if '@Redfish.WriteableProperties' not in redfish_payload: my_logger.warning('Unable to test writeable property, no @Redfish.WriteableProperties available at the property level ' + str(profile_entry)) - return msgInterop('WriteRequirement', profile_entry, - 'Is Writeable' if profile_entry == "Mandatory" else profile_entry, - '-', testResultEnum.NOT_TESTED), True + return msgInterop('WriteRequirement', profile_entry, expected_str, '@Redfish.WriteableProperties not in response', testResultEnum.NOT_TESTED), True writeable_properties = redfish_payload['@Redfish.WriteableProperties'] if not isinstance(writeable_properties, list): my_logger.warning('Unable to test writeable property, @Redfish.WriteableProperties is not an array ' + str(profile_entry)) - return msgInterop('WriteRequirement', profile_entry, - 'Is Writeable' if profile_entry == "Mandatory" else profile_entry, - '-', testResultEnum.WARN), True + return msgInterop('WriteRequirement', profile_entry, expected_str, '@Redfish.WriteableProperties not an array', testResultEnum.WARN), True is_writeable = item_name in writeable_properties - if profile_entry == 'Mandatory' or profile_entry == 'Supported': - return msgInterop('WriteRequirement', profile_entry, 'Is Writeable', '-', is_writeable), is_writeable - - else: - return msgInterop('WriteRequirement', profile_entry, '-', '-', testResultEnum.OK), True - + return msgInterop('WriteRequirement', profile_entry, expected_str, 'Writable' if is_writeable else 'Not Writable', + testResultEnum.OK if is_writeable else result_not_supported), True def checkComparison(val, compareType, target): """ From db5b89ec66a9d74614da880c393427515fa6241d Mon Sep 17 00:00:00 2001 From: Mike Raineri Date: Wed, 20 Mar 2024 14:35:01 -0400 Subject: [PATCH 2/2] Updated output from testing Signed-off-by: Mike Raineri --- redfish_interop_validator/interop.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/redfish_interop_validator/interop.py b/redfish_interop_validator/interop.py index f4da25c..34cfc5f 100644 --- a/redfish_interop_validator/interop.py +++ b/redfish_interop_validator/interop.py @@ -214,10 +214,10 @@ def validateWriteRequirement(profile_entry, parent_object_payload, resource_head result_not_supported = testResultEnum.WARN else: result_not_supported = testResultEnum.NA - expected_str = "Should Be Writable" + expected_str = "Recommended" else: result_not_supported = testResultEnum.NA - expected_str = profile_entry + expected_str = "Any" # Check for Allow header, warn if missing if resource_headers and 'Allow' in resource_headers: @@ -245,7 +245,7 @@ def validateWriteRequirement(profile_entry, parent_object_payload, resource_head is_writeable = item_name in writeable_properties return msgInterop('WriteRequirement', profile_entry, expected_str, 'Writable' if is_writeable else 'Not Writable', - testResultEnum.OK if is_writeable else result_not_supported), True + testResultEnum.PASS if is_writeable else result_not_supported), True def checkComparison(val, compareType, target): """