OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/chromeos/certificate_provider/certificate_provider_serv
ice.h" | 5 #include "chrome/browser/chromeos/certificate_provider/certificate_provider_serv
ice.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 if (out_certs) | 46 if (out_certs) |
47 *out_certs = certs; | 47 *out_certs = certs; |
48 } | 48 } |
49 | 49 |
50 certificate_provider::CertificateInfo CreateCertInfo( | 50 certificate_provider::CertificateInfo CreateCertInfo( |
51 const std::string& cert_filename) { | 51 const std::string& cert_filename) { |
52 certificate_provider::CertificateInfo cert_info; | 52 certificate_provider::CertificateInfo cert_info; |
53 cert_info.certificate = | 53 cert_info.certificate = |
54 net::ImportCertFromFile(net::GetTestCertsDirectory(), cert_filename); | 54 net::ImportCertFromFile(net::GetTestCertsDirectory(), cert_filename); |
55 EXPECT_TRUE(cert_info.certificate) << "Could not load " << cert_filename; | 55 EXPECT_TRUE(cert_info.certificate) << "Could not load " << cert_filename; |
56 cert_info.type = net::SSLPrivateKey::Type::RSA; | |
57 cert_info.supported_hashes.push_back(net::SSLPrivateKey::Hash::SHA256); | 56 cert_info.supported_hashes.push_back(net::SSLPrivateKey::Hash::SHA256); |
58 cert_info.max_signature_length_in_bytes = 123; | |
59 | 57 |
60 return cert_info; | 58 return cert_info; |
61 } | 59 } |
62 | 60 |
63 bool IsKeyEqualToCertInfo(const certificate_provider::CertificateInfo& info, | 61 bool IsKeyEqualToCertInfo(const certificate_provider::CertificateInfo& info, |
64 net::SSLPrivateKey* key) { | 62 net::SSLPrivateKey* key) { |
65 if (info.supported_hashes != key->GetDigestPreferences()) | 63 return info.supported_hashes == key->GetDigestPreferences(); |
66 return false; | |
67 | |
68 return key->GetType() == info.type && | |
69 key->GetMaxSignatureLengthInBytes() == | |
70 info.max_signature_length_in_bytes; | |
71 } | 64 } |
72 | 65 |
73 class TestDelegate : public CertificateProviderService::Delegate { | 66 class TestDelegate : public CertificateProviderService::Delegate { |
74 public: | 67 public: |
75 enum class RequestType { NONE, SIGN, GET_CERTIFICATES }; | 68 enum class RequestType { NONE, SIGN, GET_CERTIFICATES }; |
76 | 69 |
77 TestDelegate() {} | 70 TestDelegate() {} |
78 | 71 |
79 std::vector<std::string> CertificateProviderExtensions() override { | 72 std::vector<std::string> CertificateProviderExtensions() override { |
80 return std::vector<std::string>(provider_extensions_.begin(), | 73 return std::vector<std::string>(provider_extensions_.begin(), |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 EXPECT_EQ(net::OK, error); | 472 EXPECT_EQ(net::OK, error); |
480 | 473 |
481 // Unload the extension. | 474 // Unload the extension. |
482 service_->OnExtensionUnloaded(kExtension1); | 475 service_->OnExtensionUnloaded(kExtension1); |
483 | 476 |
484 task_runner_->RunUntilIdle(); | 477 task_runner_->RunUntilIdle(); |
485 EXPECT_EQ(net::ERR_FAILED, error); | 478 EXPECT_EQ(net::ERR_FAILED, error); |
486 } | 479 } |
487 | 480 |
488 } // namespace chromeos | 481 } // namespace chromeos |
OLD | NEW |