Index: chromeos/network/onc/onc_utils_unittest.cc |
diff --git a/chromeos/network/onc/onc_utils_unittest.cc b/chromeos/network/onc/onc_utils_unittest.cc |
index 97a0cb28dc0a578e901b68ab9f7043ab49c01287..7fb217944941356393d7dca13d751208df534257 100644 |
--- a/chromeos/network/onc/onc_utils_unittest.cc |
+++ b/chromeos/network/onc/onc_utils_unittest.cc |
@@ -9,6 +9,8 @@ |
#include "base/values.h" |
#include "chromeos/network/onc/onc_signature.h" |
#include "chromeos/network/onc/onc_test_utils.h" |
+#include "net/cert/x509_certificate.h" |
+#include "net/test/test_certificate_data.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace chromeos { |
@@ -89,7 +91,7 @@ TEST(ONCStringExpansion, OpenVPN) { |
TEST(ONCStringExpansion, WiFi_EAP) { |
scoped_ptr<base::DictionaryValue> wifi_onc = |
- test_utils::ReadTestDictionary("valid_wifi_clientcert.onc"); |
+ test_utils::ReadTestDictionary("wifi_clientcert_with_cert_pems.onc"); |
StringSubstitutionStub substitution; |
ExpandStringsInOncObject(kNetworkConfigurationSignature, substitution, |
@@ -100,5 +102,49 @@ TEST(ONCStringExpansion, WiFi_EAP) { |
EXPECT_EQ(actual_expanded, std::string("abc ") + kLoginId + "@my.domain.com"); |
} |
+TEST(ONCResolveServerCertRefs, ResolveServerCertRefs) { |
+ scoped_ptr<base::DictionaryValue> test_cases = |
+ test_utils::ReadTestDictionary( |
+ "network_configs_with_resolved_certs.json"); |
+ |
+ scoped_refptr<net::X509Certificate> google_cert( |
+ net::X509Certificate::CreateFromBytes( |
+ reinterpret_cast<const char*>(google_der), sizeof(google_der))); |
+ |
+ scoped_refptr<net::X509Certificate> webkit_cert( |
+ net::X509Certificate::CreateFromBytes( |
+ reinterpret_cast<const char*>(webkit_der), sizeof(webkit_der))); |
+ |
+ CertsByGUIDMap certs; |
+ certs["cert_google"] = google_cert; |
+ certs["cert_webkit"] = webkit_cert; |
+ |
+ for (base::DictionaryValue::Iterator it(*test_cases); |
+ !it.IsAtEnd(); it.Advance()) { |
+ SCOPED_TRACE("Test case: " + it.key()); |
+ |
+ const base::DictionaryValue* test_case = NULL; |
+ it.value().GetAsDictionary(&test_case); |
+ |
+ const base::ListValue* networks_with_cert_refs = NULL; |
+ test_case->GetList("WithCertRefs", &networks_with_cert_refs); |
+ |
+ const base::ListValue* expected_resolved_onc = NULL; |
+ test_case->GetList("WithResolvedRefs", &expected_resolved_onc); |
+ |
+ bool expected_success = (networks_with_cert_refs->GetSize() == |
+ expected_resolved_onc->GetSize()); |
+ |
+ scoped_ptr<base::ListValue> actual_resolved_onc( |
+ networks_with_cert_refs->DeepCopy()); |
+ |
+ bool success = ResolveServerCertRefsInNetworks(certs, |
+ actual_resolved_onc.get()); |
+ EXPECT_EQ(expected_success, success); |
+ EXPECT_TRUE(test_utils::Equals(expected_resolved_onc, |
+ actual_resolved_onc.get())); |
+ } |
+} |
+ |
} // namespace onc |
} // namespace chromeos |