Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub enum RedfishError {
MissingVendor,

#[error("Password change required")]
PasswordChangeRequired,
PasswordChangeRequired { account_uri: Option<String> },

#[error("Maximum amount of user accounts reached. Delete one to continue.")]
TooManyUsers,
Expand Down
8 changes: 5 additions & 3 deletions src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,16 +698,18 @@ impl RedfishHttpClient {
// If PasswordChangeRequired is in the response, return a PasswordChangeRequired error.
if let Ok(err) = serde_json::from_str::<crate::model::error::Error>(&response_body)
{
if err
if let Some(password_change_required) = err
.error
.extended
.iter()
// TODO(ajf) The actual message ID is specified in DTMF RedFish 9.5.11.2 so we
// should properly parse it into a type since the error may come from different
// MessageRegistries
.any(|ext| ext.message_id.ends_with("PasswordChangeRequired"))
.find(|ext| ext.message_id.ends_with("PasswordChangeRequired"))
{
return Err(RedfishError::PasswordChangeRequired);
return Err(RedfishError::PasswordChangeRequired {
account_uri: password_change_required.message_args.first().cloned(),
});
}
}
// If we can't decode the error JSON, just return the normal HTTPErrorCode. Some
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async fn test_forbidden_error_handling() -> anyhow::Result<()> {

match redfish.get_chassis_all().await {
Ok(_) => panic!("Request should have failed with password change required"),
Err(libredfish::RedfishError::PasswordChangeRequired) => {} // what we want
Err(libredfish::RedfishError::PasswordChangeRequired { .. }) => {} // what we want
Err(err) => panic!("Unexpected error response: {}", err),
}

Expand Down
Loading