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

Side by Side Diff: chrome/browser/chromeos/attestation/attestation_policy_observer_unittest.cc

Issue 17265013: Remove platform-specific implementations of RSAPrivateKey and SignatureCreator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix colliding serial numbers 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
« no previous file with comments | « no previous file | crypto/crypto.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/browser/chromeos/attestation/attestation_key_payload.pb.h" 10 #include "chrome/browser/chromeos/attestation/attestation_key_payload.pb.h"
11 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" 11 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h"
12 #include "chrome/browser/chromeos/settings/cros_settings.h" 12 #include "chrome/browser/chromeos/settings/cros_settings.h"
13 #include "chrome/browser/chromeos/settings/cros_settings_names.h" 13 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
14 #include "chrome/browser/chromeos/settings/device_settings_service.h" 14 #include "chrome/browser/chromeos/settings/device_settings_service.h"
15 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" 15 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
16 #include "chrome/browser/policy/cloud/mock_cloud_policy_client.h" 16 #include "chrome/browser/policy/cloud/mock_cloud_policy_client.h"
17 #include "chromeos/attestation/mock_attestation_flow.h" 17 #include "chromeos/attestation/mock_attestation_flow.h"
18 #include "chromeos/dbus/mock_cryptohome_client.h" 18 #include "chromeos/dbus/mock_cryptohome_client.h"
19 #include "content/public/test/test_browser_thread.h" 19 #include "content/public/test/test_browser_thread.h"
20 #include "crypto/rsa_private_key.h" 20 #include "crypto/rsa_private_key.h"
21 #include "net/cert/x509_certificate.h" 21 #include "net/cert/x509_certificate.h"
22 #include "net/cert/x509_util_nss.h" 22 #include "net/cert/x509_util.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 using testing::_; 25 using testing::_;
26 using testing::Invoke; 26 using testing::Invoke;
27 using testing::StrictMock; 27 using testing::StrictMock;
28 using testing::WithArgs; 28 using testing::WithArgs;
29 29
30 namespace chromeos { 30 namespace chromeos {
31 namespace attestation { 31 namespace attestation {
32 32
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 break; 213 break;
214 default: 214 default:
215 NOTREACHED(); 215 NOTREACHED();
216 } 216 }
217 scoped_ptr<crypto::RSAPrivateKey> test_key( 217 scoped_ptr<crypto::RSAPrivateKey> test_key(
218 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo( 218 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(
219 std::vector<uint8>(&kTestKeyData[0], 219 std::vector<uint8>(&kTestKeyData[0],
220 &kTestKeyData[arraysize(kTestKeyData)]))); 220 &kTestKeyData[arraysize(kTestKeyData)])));
221 if (!test_key.get()) 221 if (!test_key.get())
222 return false; 222 return false;
223 net::X509Certificate::OSCertHandle handle = 223 return net::x509_util::CreateSelfSignedCert(test_key.get(),
224 net::x509_util::CreateSelfSignedCert(test_key->public_key(), 224 "CN=subject",
225 test_key->key(), 225 12345,
226 "CN=subject", 226 valid_start,
227 12345, 227 valid_expiry,
228 valid_start, 228 certificate);
229 valid_expiry);
230
231 if (!handle)
232 return false;
233 bool result = net::X509Certificate::GetDEREncoded(handle, certificate);
234 net::X509Certificate::FreeOSCertHandle(handle);
235 return result;
236 } 229 }
237 230
238 base::MessageLoop message_loop_; 231 base::MessageLoop message_loop_;
239 content::TestBrowserThread ui_thread_; 232 content::TestBrowserThread ui_thread_;
240 ScopedTestDeviceSettingsService test_device_settings_service_; 233 ScopedTestDeviceSettingsService test_device_settings_service_;
241 ScopedTestCrosSettings test_cros_settings_; 234 ScopedTestCrosSettings test_cros_settings_;
242 CrosSettingsProvider* device_settings_provider_; 235 CrosSettingsProvider* device_settings_provider_;
243 StubCrosSettingsProvider stub_settings_provider_; 236 StubCrosSettingsProvider stub_settings_provider_;
244 StrictMock<MockCryptohomeClient> cryptohome_client_; 237 StrictMock<MockCryptohomeClient> cryptohome_client_;
245 StrictMock<MockAttestationFlow> attestation_flow_; 238 StrictMock<MockAttestationFlow> attestation_flow_;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 Run(); 283 Run();
291 } 284 }
292 285
293 TEST_F(AttestationPolicyObserverTest, IgnoreUnknownCertFormat) { 286 TEST_F(AttestationPolicyObserverTest, IgnoreUnknownCertFormat) {
294 SetupMocks(MOCK_KEY_EXISTS | MOCK_KEY_UPLOADED, "unsupported"); 287 SetupMocks(MOCK_KEY_EXISTS | MOCK_KEY_UPLOADED, "unsupported");
295 Run(); 288 Run();
296 } 289 }
297 290
298 } // namespace attestation 291 } // namespace attestation
299 } // namespace chromeos 292 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | crypto/crypto.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698