Commit aa67ada1 authored by Alexander Hendrich's avatar Alexander Hendrich Committed by Commit Bot

Display ONC value validation errors

This CL adds detailed warning/errors messages from the ONC value
validation to chrome://policy.

Bug: 855057
Change-Id: I6d6bca90d074bc6b5c6be3b416fe25f216b5b7cb
Reviewed-on: https://chromium-review.googlesource.com/1118555Reviewed-by: default avatarPavol Marko <pmarko@chromium.org>
Reviewed-by: default avatarLutz Justen <ljusten@chromium.org>
Commit-Queue: Alexander Hendrich <hendrich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582224}
parent 3b8db25c
...@@ -223,10 +223,22 @@ bool NetworkConfigurationPolicyHandler::CheckPolicySettings( ...@@ -223,10 +223,22 @@ bool NetworkConfigurationPolicyHandler::CheckPolicySettings(
root_dict = validator.ValidateAndRepairObject( root_dict = validator.ValidateAndRepairObject(
&chromeos::onc::kToplevelConfigurationSignature, *root_dict, &chromeos::onc::kToplevelConfigurationSignature, *root_dict,
&validation_result); &validation_result);
// Pass error/warning message and non-localized debug_info to
// PolicyErrorMap.
std::vector<base::StringPiece> messages;
for (const chromeos::onc::Validator::ValidationIssue& issue :
validator.validation_issues()) {
messages.push_back(issue.message);
}
std::string debug_info = base::JoinString(messages, "\n");
if (validation_result == chromeos::onc::Validator::VALID_WITH_WARNINGS) if (validation_result == chromeos::onc::Validator::VALID_WITH_WARNINGS)
errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_IMPORT_PARTIAL); errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_IMPORT_PARTIAL,
debug_info);
else if (validation_result == chromeos::onc::Validator::INVALID) else if (validation_result == chromeos::onc::Validator::INVALID)
errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_IMPORT_FAILED); errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_IMPORT_FAILED,
debug_info);
if (!validator.validation_issues().empty()) { if (!validator.validation_issues().empty()) {
std::vector<std::string> messages; std::vector<std::string> messages;
......
...@@ -213,11 +213,15 @@ ...@@ -213,11 +213,15 @@
<message name="IDS_POLICY_NETWORK_CONFIG_PARSE_FAILED" desc="The text displayed in the status column when the corresponding network configuration policy failed to parse."> <message name="IDS_POLICY_NETWORK_CONFIG_PARSE_FAILED" desc="The text displayed in the status column when the corresponding network configuration policy failed to parse.">
Network configuration failed to be parsed. Network configuration failed to be parsed.
</message> </message>
<message name="IDS_POLICY_NETWORK_CONFIG_IMPORT_PARTIAL" desc="The text displayed in the status column when the corresponding network configuration policy is not standard conform and was imported partially."> <message name="IDS_POLICY_NETWORK_CONFIG_IMPORT_PARTIAL" desc="The text displayed in the status column when the corresponding network configuration policy is not standard conform and was imported partially. DEBUG_INFO contains non-localized detailed information about existing warnings.">
The network configuration doesn't comply to the ONC standard. Parts of the configuration may not be imported. The network configuration doesn't comply to the ONC standard. Parts of the configuration may not be imported.
Additional details:
<ph name="DEBUG_INFO">$1<ex>WARNING: Field name 'SomeRandomField' is unknown. (at toplevel)</ex></ph>
</message> </message>
<message name="IDS_POLICY_NETWORK_CONFIG_IMPORT_FAILED" desc="The text displayed in the status column when the corresponding network configuration policy is invalid."> <message name="IDS_POLICY_NETWORK_CONFIG_IMPORT_FAILED" desc="The text displayed in the status column when the corresponding network configuration policy is invalid. DEBUG_INFO contains non-localized detailed information about existing errors/warnings.">
The network configuration is invalid and couldn't be imported. The network configuration is invalid and couldn't be imported.
Additional details:
<ph name="DEBUG_INFO">$1<ex>ERROR: Field name 'SomeRandomField' is unknown. (at toplevel)</ex></ph>
</message> </message>
<message name="IDS_POLICY_SCOPE_ERROR" desc="Text displayed in the status column when a policy is set in an unsupported scope."> <message name="IDS_POLICY_SCOPE_ERROR" desc="Text displayed in the status column when a policy is set in an unsupported scope.">
Policy scope is not supported. Policy scope is not supported.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment