Skip to content

Commit dee90b0

Browse files
authored
Merge pull request #201 from DMTF/Fix200-Write-Requirement-Fix
Write requirement fix when requirements are recommended
2 parents b24b414 + db5b89e commit dee90b0

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

redfish_interop_validator/interop.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -206,44 +206,46 @@ def validateWriteRequirement(profile_entry, parent_object_payload, resource_head
206206
"""
207207
my_logger.verbose1('Is property writeable \n\t' + str(profile_entry))
208208

209+
if profile_entry == "Mandatory" or profile_entry == "Supported":
210+
result_not_supported = testResultEnum.FAIL
211+
expected_str = "Must Be Writable"
212+
elif profile_entry == "Recommended":
213+
if config['WarnRecommended']:
214+
result_not_supported = testResultEnum.WARN
215+
else:
216+
result_not_supported = testResultEnum.NA
217+
expected_str = "Recommended"
218+
else:
219+
result_not_supported = testResultEnum.NA
220+
expected_str = "Any"
221+
209222
# Check for Allow header, warn if missing
210223
if resource_headers and 'Allow' in resource_headers:
211224
writeable = 'PATCH' in resource_headers['Allow']
212225
if not writeable:
213-
my_logger.error('PATCH in Allow header not available, property is not writeable ' + str(profile_entry))
214-
return msgInterop('WriteRequirement', profile_entry,
215-
'Is Writeable' if profile_entry == "Mandatory" else profile_entry,
216-
'-', testResultEnum.FAIL), True
226+
if profile_entry == "Mandatory":
227+
my_logger.error('PATCH in Allow header not available, property is not writeable ' + str(profile_entry))
228+
return msgInterop('WriteRequirement', profile_entry, expected_str, 'PATCH not supported', result_not_supported), True
217229
else:
218230
my_logger.warning('Unable to test writeable property, no Allow header available ' + str(profile_entry))
219-
return msgInterop('WriteRequirement', profile_entry,
220-
'Is Writeable' if profile_entry == "Mandatory" else profile_entry,
221-
'-', testResultEnum.NOT_TESTED), True
231+
return msgInterop('WriteRequirement', profile_entry, expected_str, 'No Allow response header', testResultEnum.NOT_TESTED), True
222232

223233
redfish_payload, _ = parent_object_payload
224234

225235
# Get Writeable Properties
226236
if '@Redfish.WriteableProperties' not in redfish_payload:
227237
my_logger.warning('Unable to test writeable property, no @Redfish.WriteableProperties available at the property level ' + str(profile_entry))
228-
return msgInterop('WriteRequirement', profile_entry,
229-
'Is Writeable' if profile_entry == "Mandatory" else profile_entry,
230-
'-', testResultEnum.NOT_TESTED), True
238+
return msgInterop('WriteRequirement', profile_entry, expected_str, '@Redfish.WriteableProperties not in response', testResultEnum.NOT_TESTED), True
231239

232240
writeable_properties = redfish_payload['@Redfish.WriteableProperties']
233241
if not isinstance(writeable_properties, list):
234242
my_logger.warning('Unable to test writeable property, @Redfish.WriteableProperties is not an array ' + str(profile_entry))
235-
return msgInterop('WriteRequirement', profile_entry,
236-
'Is Writeable' if profile_entry == "Mandatory" else profile_entry,
237-
'-', testResultEnum.WARN), True
243+
return msgInterop('WriteRequirement', profile_entry, expected_str, '@Redfish.WriteableProperties not an array', testResultEnum.WARN), True
238244

239245
is_writeable = item_name in writeable_properties
240246

241-
if profile_entry == 'Mandatory' or profile_entry == 'Supported':
242-
return msgInterop('WriteRequirement', profile_entry, 'Is Writeable', '-', is_writeable), is_writeable
243-
244-
else:
245-
return msgInterop('WriteRequirement', profile_entry, '-', '-', testResultEnum.OK), True
246-
247+
return msgInterop('WriteRequirement', profile_entry, expected_str, 'Writable' if is_writeable else 'Not Writable',
248+
testResultEnum.PASS if is_writeable else result_not_supported), True
247249

248250
def checkComparison(val, compareType, target):
249251
"""

0 commit comments

Comments
 (0)