[TaskEnvironment] Mass-migrate away from ScopedTaskEnvironment (1/2)
(well half of them because git cl upload wouldn't let me do
them all at once...)
This is step #1 of the mass migration. Some of these will be
backported to SingleThreadTaskEnvironment in a later phase.
scoped_task_environment.h will also only move in a follow-up CL.
[email protected]
Bug: 992483
Change-Id: I44bc376deee9b6c95bafac8d54165174d86a5001
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1756247
Reviewed-by: Gabriel Charette <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Commit-Queue: Gabriel Charette <[email protected]>
Cr-Commit-Position: refs/heads/master@{#688086}
diff --git a/chromeos/network/client_cert_resolver_unittest.cc b/chromeos/network/client_cert_resolver_unittest.cc
index 99e37416..ae495ff9 100644
--- a/chromeos/network/client_cert_resolver_unittest.cc
+++ b/chromeos/network/client_cert_resolver_unittest.cc
@@ -117,9 +117,9 @@
service_test_ = ShillServiceClient::Get()->GetTestInterface();
profile_test_ = ShillProfileClient::Get()->GetTestInterface();
profile_test_->AddProfile(kUserProfilePath, kUserHash);
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
service_test_->ClearServices();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
NetworkCertLoader::Initialize();
network_cert_loader_ = NetworkCertLoader::Get();
@@ -238,7 +238,7 @@
network_config_handler_.get(), nullptr /* network_device_handler */,
nullptr /* prohibited_technologies_handler */);
// Run all notifications before starting the cert loader to reduce run time.
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
client_cert_resolver_->Init(network_state_handler_.get(),
managed_config_handler_.get());
@@ -409,7 +409,7 @@
return certs;
}
- base::test::ScopedTaskEnvironment scoped_task_environment_;
+ base::test::TaskEnvironment task_environment_;
int network_properties_changed_count_ = 0;
std::string test_cert_id_;
std::unique_ptr<base::SimpleTestClock> test_clock_;
@@ -444,12 +444,12 @@
SetupTestCerts("client_1", false /* do not import the issuer */);
StartNetworkCertLoader();
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
network_properties_changed_count_ = 0;
SetupNetworkHandlers();
ASSERT_NO_FATAL_FAILURE(
SetupPolicyMatchingIssuerPEM(::onc::ONC_SOURCE_USER_POLICY, ""));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Verify that no client certificate was configured.
std::string pkcs11_id;
@@ -462,16 +462,16 @@
TEST_F(ClientCertResolverTest, MatchIssuerCNWithoutIssuerInstalled) {
SetupTestCerts("client_1", false /* do not import the issuer */);
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetupNetworkHandlers();
ASSERT_NO_FATAL_FAILURE(
SetupPolicyMatchingIssuerCN(::onc::ONC_SOURCE_USER_POLICY));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
network_properties_changed_count_ = 0;
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Verify that the resolver positively matched the pattern in the policy with
// the test client cert and configured the network.
@@ -487,17 +487,17 @@
ASSERT_NO_FATAL_FAILURE(SetupTestCertWithBadPrintableString());
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetupNetworkHandlers();
ASSERT_NO_FATAL_FAILURE(
SetupPolicyMatchingSubjectOrgForBadPrintableStringCert(
::onc::ONC_SOURCE_USER_POLICY));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
network_properties_changed_count_ = 0;
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Verify that the resolver positively matched the pattern in the policy with
// the test client cert and configured the network.
@@ -510,16 +510,16 @@
TEST_F(ClientCertResolverTest, ResolveOnCertificatesLoaded) {
SetupTestCerts("client_1", true /* import issuer */);
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetupNetworkHandlers();
ASSERT_NO_FATAL_FAILURE(
SetupPolicyMatchingIssuerPEM(::onc::ONC_SOURCE_USER_POLICY, ""));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
network_properties_changed_count_ = 0;
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Verify that the resolver positively matched the pattern in the policy with
// the test client cert and configured the network.
@@ -532,16 +532,16 @@
TEST_F(ClientCertResolverTest, ResolveAfterPolicyApplication) {
SetupTestCerts("client_1", true /* import issuer */);
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
StartNetworkCertLoader();
SetupNetworkHandlers();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Policy application will trigger the ClientCertResolver.
network_properties_changed_count_ = 0;
ASSERT_NO_FATAL_FAILURE(
SetupPolicyMatchingIssuerPEM(::onc::ONC_SOURCE_USER_POLICY, ""));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Verify that the resolver positively matched the pattern in the policy with
// the test client cert and configured the network.
@@ -554,18 +554,18 @@
TEST_F(ClientCertResolverTest, ExpiringCertificate) {
SetupTestCerts("client_1", true /* import issuer */);
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetupNetworkHandlers();
ASSERT_NO_FATAL_FAILURE(
SetupPolicyMatchingIssuerPEM(::onc::ONC_SOURCE_USER_POLICY, ""));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetWifiState(shill::kStateOnline);
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Verify that the resolver positively matched the pattern in the policy with
// the test client cert and configured the network.
@@ -579,7 +579,7 @@
network_properties_changed_count_ = 0;
test_clock_->SetNow(base::Time::Max());
SetWifiState(shill::kStateOffline);
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
GetServiceProperty(shill::kEapCertIdProperty, &pkcs11_id);
EXPECT_EQ(std::string(), pkcs11_id);
EXPECT_EQ(1, network_properties_changed_count_);
@@ -592,18 +592,18 @@
TEST_F(ClientCertResolverTest, SameCertAfterNetworkConnectionStateChanged) {
SetupTestCerts("client_1", true /* import issuer */);
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetupNetworkHandlers();
ASSERT_NO_FATAL_FAILURE(
SetupPolicyMatchingIssuerPEM(::onc::ONC_SOURCE_USER_POLICY, ""));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetWifiState(shill::kStateOnline);
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Verify that the resolver positively matched the pattern in the policy with
// the test client cert and configured the network.
@@ -616,7 +616,7 @@
// observers with |network_properties_changed| = true.
network_properties_changed_count_ = 0;
SetWifiState(shill::kStateOffline);
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
GetServiceProperty(shill::kEapCertIdProperty, &pkcs11_id);
EXPECT_EQ(test_cert_id_, pkcs11_id);
EXPECT_EQ(0, network_properties_changed_count_);
@@ -625,15 +625,15 @@
TEST_F(ClientCertResolverTest, UserPolicyUsesSystemToken) {
SetupTestCertInSystemToken("client_1");
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetupNetworkHandlers();
ASSERT_NO_FATAL_FAILURE(
SetupPolicyMatchingIssuerCN(::onc::ONC_SOURCE_USER_POLICY));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
ASSERT_EQ(1U, network_cert_loader_->client_certs().size());
EXPECT_TRUE(network_cert_loader_->client_certs()[0].is_device_wide());
@@ -647,7 +647,7 @@
TEST_F(ClientCertResolverTest, UserPolicyUsesSystemTokenSync) {
SetupTestCertInSystemToken("client_1");
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
client_cert::ClientCertConfig client_cert_config;
SetupCertificateConfigMatchingIssuerCN(::onc::ONC_SOURCE_USER_POLICY,
@@ -665,15 +665,15 @@
TEST_F(ClientCertResolverTest, DevicePolicyUsesSystemToken) {
SetupTestCertInSystemToken("client_1");
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetupNetworkHandlers();
ASSERT_NO_FATAL_FAILURE(
SetupPolicyMatchingIssuerCN(::onc::ONC_SOURCE_USER_POLICY));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
ASSERT_EQ(1U, network_cert_loader_->client_certs().size());
EXPECT_TRUE(network_cert_loader_->client_certs()[0].is_device_wide());
@@ -687,7 +687,7 @@
TEST_F(ClientCertResolverTest, DevicePolicyUsesSystemTokenSync) {
SetupTestCertInSystemToken("client_1");
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
client_cert::ClientCertConfig client_cert_config;
SetupCertificateConfigMatchingIssuerCN(::onc::ONC_SOURCE_DEVICE_POLICY,
@@ -705,16 +705,16 @@
TEST_F(ClientCertResolverTest, DevicePolicyDoesNotUseUserToken) {
SetupTestCerts("client_1", false /* do not import the issuer */);
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetupNetworkHandlers();
ASSERT_NO_FATAL_FAILURE(
SetupPolicyMatchingIssuerCN(::onc::ONC_SOURCE_DEVICE_POLICY));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
network_properties_changed_count_ = 0;
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
ASSERT_EQ(1U, network_cert_loader_->client_certs().size());
EXPECT_FALSE(network_cert_loader_->client_certs()[0].is_device_wide());
@@ -729,7 +729,7 @@
TEST_F(ClientCertResolverTest, DevicePolicyDoesNotUseUserTokenSync) {
SetupTestCerts("client_1", false /* do not import the issuer */);
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
client_cert::ClientCertConfig client_cert_config;
SetupCertificateConfigMatchingIssuerCN(::onc::ONC_SOURCE_DEVICE_POLICY,
@@ -747,16 +747,16 @@
TEST_F(ClientCertResolverTest, PopulateIdentityFromCert) {
SetupTestCerts("client_3", true /* import issuer */);
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetupNetworkHandlers();
ASSERT_NO_FATAL_FAILURE(SetupPolicyMatchingIssuerPEM(
::onc::ONC_SOURCE_USER_POLICY, "${CERT_SAN_EMAIL}"));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
network_properties_changed_count_ = 0;
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Verify that the resolver read the subjectAltName email field from the
// cert, and wrote it into the shill service entry.
@@ -770,7 +770,7 @@
// substituted into the shill service entry.
ASSERT_NO_FATAL_FAILURE(SetupPolicyMatchingIssuerPEM(
::onc::ONC_SOURCE_USER_POLICY, "upn-${CERT_SAN_UPN}-suffix"));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
GetServiceProperty(shill::kEapIdentityProperty, &identity);
EXPECT_EQ("[email protected]", identity);
@@ -781,7 +781,7 @@
ASSERT_NO_FATAL_FAILURE(SetupPolicyMatchingIssuerPEM(
::onc::ONC_SOURCE_USER_POLICY,
"subject-cn-${CERT_SUBJECT_COMMON_NAME}-suffix"));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
GetServiceProperty(shill::kEapIdentityProperty, &identity);
EXPECT_EQ("subject-cn-Client Cert F-suffix", identity);
@@ -798,7 +798,7 @@
SetupNetworkHandlers();
ASSERT_NO_FATAL_FAILURE(
SetupPolicyMatchingIssuerPEM(::onc::ONC_SOURCE_USER_POLICY, ""));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Pretend that policy was applied, this shall queue a resolving task.
static_cast<NetworkPolicyObserver*>(client_cert_resolver_.get())
@@ -815,7 +815,7 @@
->OnCertificatesLoaded();
EXPECT_TRUE(client_cert_resolver_->IsAnyResolveTaskRunning());
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
EXPECT_FALSE(client_cert_resolver_->IsAnyResolveTaskRunning());
// Verify that the resolver positively matched the pattern in the policy with
// the test client cert and configured the network.
@@ -846,11 +846,11 @@
} ])";
SetupWifi();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
StartNetworkCertLoader();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
SetupNetworkHandlers();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Make sure that expiring client certs don't cause issues.
test_clock_->SetNow(base::Time::Min());
@@ -859,7 +859,7 @@
network_properties_changed_count_ = 0;
ASSERT_NO_FATAL_FAILURE(SetManagedNetworkPolicy(::onc::ONC_SOURCE_USER_POLICY,
test_policy_network));
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// The referenced client cert does not exist yet, so expect that it has not
// been resolved.
@@ -876,14 +876,13 @@
ASSERT_TRUE(onc_parsed_certificates);
onc::CertificateImporterImpl importer(
- scoped_task_environment_.GetMainThreadTaskRunner(),
- test_nsscertdb_.get());
+ task_environment_.GetMainThreadTaskRunner(), test_nsscertdb_.get());
base::RunLoop import_loop;
importer.ImportClientCertificates(
onc_parsed_certificates->client_certificates(),
base::BindOnce(&OnImportCompleted, import_loop.QuitClosure()));
import_loop.Run();
- scoped_task_environment_.RunUntilIdle();
+ task_environment_.RunUntilIdle();
// Find the imported cert and get its id.
net::ScopedCERTCertificateList private_slot_certs = ListCertsOnPrivateSlot();