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

Unified Diff: chrome/browser/chromeos/policy/network_configuration_updater_impl_cros_unittest.cc

Issue 20041002: Make CertificateHandler a proper interface of CertificateImporter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/network_configuration_updater_impl_cros_unittest.cc
diff --git a/chrome/browser/chromeos/policy/network_configuration_updater_impl_cros_unittest.cc b/chrome/browser/chromeos/policy/network_configuration_updater_impl_cros_unittest.cc
index 1bd6eb9bf899a466f8e57296d63f99295755fb0c..b32dee12bc7c3d061ac952f877e258adce8a3f1a 100644
--- a/chrome/browser/chromeos/policy/network_configuration_updater_impl_cros_unittest.cc
+++ b/chrome/browser/chromeos/policy/network_configuration_updater_impl_cros_unittest.cc
@@ -15,7 +15,7 @@
#include "chrome/browser/policy/mock_configuration_policy_provider.h"
#include "chrome/browser/policy/policy_map.h"
#include "chrome/browser/policy/policy_service_impl.h"
-#include "chromeos/network/mock_certificate_handler.h"
+#include "chromeos/network/onc/mock_certificate_importer.h"
#include "chromeos/network/onc/onc_constants.h"
#include "chromeos/network/onc/onc_test_utils.h"
#include "chromeos/network/onc/onc_utils.h"
@@ -180,16 +180,17 @@ TEST_F(NetworkConfigurationUpdaterTest, PolicyIsValidatedAndRepaired) {
// Ignore the device policy update.
EXPECT_CALL(network_library_, LoadOncNetworks(_, _));
- StrictMock<chromeos::MockCertificateHandler>* certificate_handler =
- new StrictMock<chromeos::MockCertificateHandler>();
- EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _));
+ StrictMock<chromeos::onc::MockCertificateImporter>* certificate_importer =
+ new StrictMock<chromeos::onc::MockCertificateImporter>();
+ EXPECT_CALL(*certificate_importer, ImportCertificates(_, _, _));
NetworkConfigurationUpdaterImplCros updater(
policy_service_.get(),
&network_library_,
- make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler));
+ make_scoped_ptr<chromeos::onc::CertificateImporter>(
+ certificate_importer));
Mock::VerifyAndClearExpectations(&network_library_);
- Mock::VerifyAndClearExpectations(&certificate_handler);
+ Mock::VerifyAndClearExpectations(&certificate_importer);
// After the user policy is initialized, we always push both policies to the
// NetworkLibrary. Ignore the device policy.
@@ -198,10 +199,10 @@ TEST_F(NetworkConfigurationUpdaterTest, PolicyIsValidatedAndRepaired) {
EXPECT_CALL(network_library_, LoadOncNetworks(
IsEqualTo(network_configs_repaired),
onc::ONC_SOURCE_USER_POLICY));
- EXPECT_CALL(*certificate_handler,
+ EXPECT_CALL(*certificate_importer,
ImportCertificates(_, chromeos::onc::ONC_SOURCE_DEVICE_POLICY,
_));
- EXPECT_CALL(*certificate_handler,
+ EXPECT_CALL(*certificate_importer,
ImportCertificates(_, chromeos::onc::ONC_SOURCE_USER_POLICY,
_));
@@ -244,28 +245,29 @@ TEST_P(NetworkConfigurationUpdaterTestWithParam, InitialUpdates) {
EXPECT_CALL(network_library_, LoadOncNetworks(
IsEqualTo(device_networks), onc::ONC_SOURCE_DEVICE_POLICY));
- StrictMock<chromeos::MockCertificateHandler>* certificate_handler =
- new StrictMock<chromeos::MockCertificateHandler>();
- EXPECT_CALL(*certificate_handler, ImportCertificates(
+ StrictMock<chromeos::onc::MockCertificateImporter>* certificate_importer =
+ new StrictMock<chromeos::onc::MockCertificateImporter>();
+ EXPECT_CALL(*certificate_importer, ImportCertificates(
IsEqualTo(device_certs), onc::ONC_SOURCE_DEVICE_POLICY, _));
NetworkConfigurationUpdaterImplCros updater(
policy_service_.get(),
&network_library_,
- make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler));
+ make_scoped_ptr<chromeos::onc::CertificateImporter>(
+ certificate_importer));
Mock::VerifyAndClearExpectations(&network_library_);
- Mock::VerifyAndClearExpectations(&certificate_handler);
+ Mock::VerifyAndClearExpectations(&certificate_importer);
// After the user policy is initialized, we always push both policies to the
// NetworkLibrary.
EXPECT_CALL(network_library_, LoadOncNetworks(
IsEqualTo(device_networks), onc::ONC_SOURCE_DEVICE_POLICY));
- EXPECT_CALL(*certificate_handler, ImportCertificates(
+ EXPECT_CALL(*certificate_importer, ImportCertificates(
IsEqualTo(device_certs), onc::ONC_SOURCE_DEVICE_POLICY, _));
EXPECT_CALL(network_library_, LoadOncNetworks(
IsEqualTo(user_networks), onc::ONC_SOURCE_USER_POLICY));
- EXPECT_CALL(*certificate_handler, ImportCertificates(
+ EXPECT_CALL(*certificate_importer, ImportCertificates(
IsEqualTo(user_certs), onc::ONC_SOURCE_USER_POLICY, _));
EXPECT_CALL(network_library_, RemoveNetworkProfileObserver(_));
@@ -289,14 +291,15 @@ TEST_P(NetworkConfigurationUpdaterTestWithParam,
ASSERT_EQ(1u, cert_list.size());
EXPECT_CALL(network_library_, LoadOncNetworks(_, _)).Times(AnyNumber());
- StrictMock<chromeos::MockCertificateHandler>* certificate_handler =
- new StrictMock<chromeos::MockCertificateHandler>();
- EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _))
+ StrictMock<chromeos::onc::MockCertificateImporter>* certificate_importer =
+ new StrictMock<chromeos::onc::MockCertificateImporter>();
+ EXPECT_CALL(*certificate_importer, ImportCertificates(_, _, _))
.WillRepeatedly(SetCertificateList(empty_cert_list));
NetworkConfigurationUpdaterImplCros updater(
policy_service_.get(),
&network_library_,
- make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler));
+ make_scoped_ptr<chromeos::onc::CertificateImporter>(
+ certificate_importer));
net::CertTrustAnchorProvider* trust_provider =
updater.GetCertTrustAnchorProvider();
ASSERT_TRUE(trust_provider);
@@ -308,17 +311,17 @@ TEST_P(NetworkConfigurationUpdaterTestWithParam,
updater.SetUserPolicyService(false, "hash", policy_service_.get());
content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
Mock::VerifyAndClearExpectations(&network_library_);
- Mock::VerifyAndClearExpectations(&certificate_handler);
+ Mock::VerifyAndClearExpectations(&certificate_importer);
EXPECT_TRUE(trust_provider->GetAdditionalTrustAnchors().empty());
// Certificates with the "Web" trust flag set should be forwarded to the
// trust provider.
EXPECT_CALL(network_library_, LoadOncNetworks(_, _));
- EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _))
+ EXPECT_CALL(*certificate_importer, ImportCertificates(_, _, _))
.WillRepeatedly(SetCertificateList(empty_cert_list));
onc::ONCSource current_source = NameToONCSource(GetParam());
EXPECT_CALL(network_library_, LoadOncNetworks(_, current_source));
- EXPECT_CALL(*certificate_handler, ImportCertificates(_, current_source, _))
+ EXPECT_CALL(*certificate_importer, ImportCertificates(_, current_source, _))
.WillRepeatedly(SetCertificateList(cert_list));
// Trigger a new policy load, and spin the IO message loop to pass the
// certificates to the |trust_provider| on the IO thread.
@@ -326,7 +329,7 @@ TEST_P(NetworkConfigurationUpdaterTestWithParam,
base::RunLoop loop;
loop.RunUntilIdle();
Mock::VerifyAndClearExpectations(&network_library_);
- Mock::VerifyAndClearExpectations(&certificate_handler);
+ Mock::VerifyAndClearExpectations(&certificate_importer);
// Certificates are only provided as trust anchors if they come from user
// policy.
@@ -346,29 +349,30 @@ TEST_P(NetworkConfigurationUpdaterTestWithParam, PolicyChange) {
// Ignore the initial updates.
EXPECT_CALL(network_library_, LoadOncNetworks(_, _))
.Times(AnyNumber());
- StrictMock<chromeos::MockCertificateHandler>* certificate_handler =
- new StrictMock<chromeos::MockCertificateHandler>();
- EXPECT_CALL(*certificate_handler, ImportCertificates(_, _, _))
+ StrictMock<chromeos::onc::MockCertificateImporter>* certificate_importer =
+ new StrictMock<chromeos::onc::MockCertificateImporter>();
+ EXPECT_CALL(*certificate_importer, ImportCertificates(_, _, _))
.Times(AnyNumber());
NetworkConfigurationUpdaterImplCros updater(
policy_service_.get(),
&network_library_,
- make_scoped_ptr<chromeos::CertificateHandler>(certificate_handler));
+ make_scoped_ptr<chromeos::onc::CertificateImporter>(
+ certificate_importer));
updater.SetUserPolicyService(false, "hash", policy_service_.get());
Mock::VerifyAndClearExpectations(&network_library_);
- Mock::VerifyAndClearExpectations(&certificate_handler);
+ Mock::VerifyAndClearExpectations(&certificate_importer);
// We should update if policy changes.
EXPECT_CALL(network_library_, LoadOncNetworks(
IsEqualTo(fake_network_configs_.get()), NameToONCSource(GetParam())));
- EXPECT_CALL(*certificate_handler, ImportCertificates(
+ EXPECT_CALL(*certificate_importer, ImportCertificates(
IsEqualTo(fake_certificates_.get()), NameToONCSource(GetParam()), _));
// In the current implementation, we always apply both policies.
EXPECT_CALL(network_library_, LoadOncNetworks(
IsEqualTo(empty_network_configs_.get()),
Ne(NameToONCSource(GetParam()))));
- EXPECT_CALL(*certificate_handler, ImportCertificates(
+ EXPECT_CALL(*certificate_importer, ImportCertificates(
IsEqualTo(empty_certificates_.get()),
Ne(NameToONCSource(GetParam())),
_));
@@ -378,14 +382,14 @@ TEST_P(NetworkConfigurationUpdaterTestWithParam, PolicyChange) {
Value::CreateStringValue(kFakeONC), NULL);
UpdateProviderPolicy(policy);
Mock::VerifyAndClearExpectations(&network_library_);
- Mock::VerifyAndClearExpectations(&certificate_handler);
+ Mock::VerifyAndClearExpectations(&certificate_importer);
// Another update is expected if the policy goes away. In the current
// implementation, we always apply both policies.
EXPECT_CALL(network_library_, LoadOncNetworks(
IsEqualTo(empty_network_configs_.get()),
onc::ONC_SOURCE_DEVICE_POLICY));
- EXPECT_CALL(*certificate_handler, ImportCertificates(
+ EXPECT_CALL(*certificate_importer, ImportCertificates(
IsEqualTo(empty_certificates_.get()),
onc::ONC_SOURCE_DEVICE_POLICY,
_));
@@ -393,7 +397,7 @@ TEST_P(NetworkConfigurationUpdaterTestWithParam, PolicyChange) {
EXPECT_CALL(network_library_, LoadOncNetworks(
IsEqualTo(empty_network_configs_.get()),
onc::ONC_SOURCE_USER_POLICY));
- EXPECT_CALL(*certificate_handler, ImportCertificates(
+ EXPECT_CALL(*certificate_importer, ImportCertificates(
IsEqualTo(empty_certificates_.get()),
onc::ONC_SOURCE_USER_POLICY,
_));

Powered by Google App Engine
This is Rietveld 408576698