Add data validation for PATCH to /Bios/Settings.
New data was validated only using option length.
Added code to check if new value is part of available options.
Error is thrown if the new values is not a valid option.
Tested:
By giving PATCH Request to
'redfish/v1/systems/system/bios/settings'.
Output sample showing success case:
PATCH command raw data:
{
"data":[
{
"AttributeName": "AmpPrefetchEnable",
"AttributeType": "xyz.openbmc_project.BIOSConfig.Manager.AttributeType.String",
"AttributeValue": "0x01"
}
]
}
Response:
{
"@odata.id": "/redfish/v1/Systems/system/Bios/Settings",
"@odata.type": "#Bios.v1_1_0.Bios",
"AttributeRegistry": "BiosAttributeRegistry",
"Id": "BiosSettingsV1",
"Message": "Successfully Completed Request",
"Name": "Bios Settings Version 1"
}
Output sample showing failure case:
PATCH command raw data:
{
"data":[
{
"AttributeName": "AmpPrefetchEnable",
"AttributeType": "xyz.openbmc_project.BIOSConfig.Manager.AttributeType.String",
"AttributeValue": "0x05"
}
]
}
Response:
{
"@odata.id": "/redfish/v1/Systems/system/Bios/Settings",
"@odata.type": "#Bios.v1_1_0.Bios",
"AttributeRegistry": "BiosAttributeRegistry",
"Id": "BiosSettingsV1",
"Name": "Bios Settings Version 1",
"error": {
"@Message.ExtendedInfo": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The request failed due to an internal service error. The service is still operational.",
"MessageArgs": [],
"MessageId": "Base.1.8.1.InternalError",
"MessageSeverity": "Critical",
"Resolution": "Resubmit the request. If the problem persists, consider resetting the service."
}
],
"code": "Base.1.8.1.InternalError",
"message": "The request failed due to an internal service error. The service is still operational."
}
}
Note: Valid options for knob AmpPrefetchEnable is 0x01 and 0x00 as shown below.
{
"AttributeName": "AmpPrefetchEnable",
"CurrentValue": "0x00",
"DefaultValue": "0x00",
"DisplayName": "AmpPrefetchEnable",
"HelpText": "Set to enable or disable MLC AMP prefetch (MSR 1A4h [4]).",
"MenuPath": "./",
"ReadOnly": false,
"Type": "String",
"Value": [
{
"OneOf": "0x01"
},
{
"OneOf": "0x00"
}
]
}
Signed-off-by: Arun Lal K M <arun.lal@intel.com>
Change-Id: Id66bacf2491d90aa189a8fb0f48d45243195e38c
1 file changed