Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: chromeos/network/onc/onc_utils_unittest.cc

Issue 16946002: Resolve certificate references in ONC by PEM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix trust update. Add a utils test. Remove X509 dependency from Shill parsing. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/network/onc/onc_utils.h" 5 #include "chromeos/network/onc/onc_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chromeos/network/onc/onc_signature.h" 10 #include "chromeos/network/onc/onc_signature.h"
11 #include "chromeos/network/onc/onc_test_utils.h" 11 #include "chromeos/network/onc/onc_test_utils.h"
12 #include "net/cert/x509_certificate.h"
13 #include "net/test/test_certificate_data.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 15
14 namespace chromeos { 16 namespace chromeos {
15 namespace onc { 17 namespace onc {
16 18
17 TEST(ONCDecrypterTest, BrokenEncryptionIterations) { 19 TEST(ONCDecrypterTest, BrokenEncryptionIterations) {
18 scoped_ptr<base::DictionaryValue> encrypted_onc = 20 scoped_ptr<base::DictionaryValue> encrypted_onc =
19 test_utils::ReadTestDictionary("broken-encrypted-iterations.onc"); 21 test_utils::ReadTestDictionary("broken-encrypted-iterations.onc");
20 22
21 scoped_ptr<base::DictionaryValue> decrypted_onc = 23 scoped_ptr<base::DictionaryValue> decrypted_onc =
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 95
94 StringSubstitutionStub substitution; 96 StringSubstitutionStub substitution;
95 ExpandStringsInOncObject(kNetworkConfigurationSignature, substitution, 97 ExpandStringsInOncObject(kNetworkConfigurationSignature, substitution,
96 wifi_onc.get()); 98 wifi_onc.get());
97 99
98 std::string actual_expanded; 100 std::string actual_expanded;
99 wifi_onc->GetString("WiFi.EAP.Identity", &actual_expanded); 101 wifi_onc->GetString("WiFi.EAP.Identity", &actual_expanded);
100 EXPECT_EQ(actual_expanded, std::string("abc ") + kLoginId + "@my.domain.com"); 102 EXPECT_EQ(actual_expanded, std::string("abc ") + kLoginId + "@my.domain.com");
101 } 103 }
102 104
105 TEST(ONCCalculateFingerprint, FingerprintMethodsIdentical) {
106 scoped_refptr<net::X509Certificate> cert(
107 net::X509Certificate::CreateFromBytes(
108 reinterpret_cast<const char*>(google_der),
109 sizeof(google_der)));
110
111 std::string fingerprint1 = GetHexFingerprintOfCert(*cert);
112 std::string pem_encoded_cert;
113 EXPECT_TRUE(net::X509Certificate::GetPEMEncoded(cert->os_cert_handle(),
114 &pem_encoded_cert));
115
116 std::string fingerprint2 = GetHexFingerprintOfPEMCert(pem_encoded_cert);
117 EXPECT_EQ(fingerprint1, fingerprint2);
118 }
119
103 } // namespace onc 120 } // namespace onc
104 } // namespace chromeos 121 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698