Index: chromeos/network/onc/onc_validator_unittest.cc |
diff --git a/chromeos/network/onc/onc_validator_unittest.cc b/chromeos/network/onc/onc_validator_unittest.cc |
index 105e9a0441f690ad79ccc0bc59df426a4b52bfbd..db37fd5c7f0da4c2ce25d73470f86515b0b7eaac 100644 |
--- a/chromeos/network/onc/onc_validator_unittest.cc |
+++ b/chromeos/network/onc/onc_validator_unittest.cc |
@@ -30,6 +30,15 @@ class ONCValidatorTest : public ::testing::Test { |
scoped_ptr<base::DictionaryValue> onc_object, |
const OncValueSignature* signature, |
bool managed_onc) { |
+ Validate(strict, onc_object.Pass(), signature, managed_onc, |
+ ONC_SOURCE_NONE); |
+ } |
+ |
+ void Validate(bool strict, |
+ scoped_ptr<base::DictionaryValue> onc_object, |
+ const OncValueSignature* signature, |
+ bool managed_onc, |
+ ONCSource onc_source) { |
scoped_ptr<Validator> validator; |
if (strict) { |
// Create a strict validator that complains about every error. |
@@ -38,6 +47,7 @@ class ONCValidatorTest : public ::testing::Test { |
// Create a liberal validator that ignores or repairs non-critical errors. |
validator.reset(new Validator(false, false, false, managed_onc)); |
} |
+ validator->SetOncSource(onc_source); |
original_object_ = onc_object.Pass(); |
repaired_object_ = validator->ValidateAndRepairObject(signature, |
*original_object_, |
@@ -72,7 +82,7 @@ namespace { |
struct OncParams { |
// |location_of_object| is a string to identify the object to be tested. It |
// may be used as a filename or as a dictionary key. |
- OncParams(std::string location_of_object, |
+ OncParams(const std::string& location_of_object, |
const OncValueSignature* onc_signature, |
bool is_managed_onc) |
: location(location_of_object), |
@@ -100,6 +110,27 @@ TEST_F(ONCValidatorTest, EmptyUnencryptedConfiguration) { |
ExpectValid(); |
} |
+// Ensure that VPN is rejected in device policies. |
+TEST_F(ONCValidatorTest, VPNInDevicePolicyInvalid) { |
+ Validate(true, test_utils::ReadTestDictionary("valid_openvpn.onc"), |
+ &kNetworkConfigurationSignature, true, ONC_SOURCE_DEVICE_POLICY); |
+ ExpectInvalid(); |
+} |
+ |
+// Ensure that client certificate patterns are rejected in device policies. |
+TEST_F(ONCValidatorTest, ClientCertPatternInDevicePolicyInvalid) { |
+ Validate(true, test_utils::ReadTestDictionary("valid_wifi_clientcert.onc"), |
+ &kNetworkConfigurationSignature, true, ONC_SOURCE_DEVICE_POLICY); |
+ ExpectInvalid(); |
+} |
+ |
+// Check that at least one configuration is accepted for device policies. |
+TEST_F(ONCValidatorTest, ValidNetworkInDevicePolicy) { |
+ Validate(true, test_utils::ReadTestDictionary("valid_wifi_psk.onc"), |
+ &kNetworkConfigurationSignature, true, ONC_SOURCE_DEVICE_POLICY); |
+ ExpectValid(); |
+} |
+ |
// This test case is about validating valid ONC objects without any errors. Both |
// the strict and the liberal validator accept the object. |
class ONCValidatorValidTest : public ONCValidatorTest, |
@@ -133,10 +164,9 @@ INSTANTIATE_TEST_CASE_P( |
OncParams("managed_toplevel2.onc", |
&kToplevelConfigurationSignature, |
true), |
- // Test a configuration generated by CPanel. |
- OncParams("managed_toplevel_cpanel.onc", |
+ OncParams("toplevel_wifi_wpa_psk.onc", |
&kToplevelConfigurationSignature, |
- true), |
+ false), |
OncParams("encrypted.onc", |
&kToplevelConfigurationSignature, |
true), |