File: ephemeral_network_configuration_handler_unittest.cc

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (495 lines) | stat: -rw-r--r-- 20,937 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chromeos/ash/components/network/ephemeral_network_configuration_handler.h"

#include <memory>

#include "ash/constants/ash_features.h"
#include "base/time/time.h"
#include "chromeos/ash/components/login/login_state/login_state.h"
#include "chromeos/ash/components/network/mock_managed_network_configuration_handler.h"
#include "chromeos/ash/components/network/policy_util.h"
#include "chromeos/dbus/power/fake_power_manager_client.h"
#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/dbus/power_manager/idle.pb.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace ash {

using testing::Return;

class EphemeralNetworkConfigurationHandlerTest : public testing::Test {
 public:
  EphemeralNetworkConfigurationHandlerTest() {
    policy_util::SetEphemeralNetworkPoliciesEnabled();

    LoginState::Initialize();
    LoginState::Get()->set_always_logged_in(false);
  }

  ~EphemeralNetworkConfigurationHandlerTest() override {
    ephemeral_network_configuration_handler_.reset();

    LoginState::Shutdown();
  }

  EphemeralNetworkConfigurationHandlerTest(
      const EphemeralNetworkConfigurationHandlerTest&) = delete;
  EphemeralNetworkConfigurationHandlerTest& operator=(
      const EphemeralNetworkConfigurationHandlerTest&) = delete;

 protected:
  void NotifyScreenIdleOffChanged(bool off) {
    power_manager::ScreenIdleState proto;
    proto.set_off(off);
    fake_power_manager_client_.SendScreenIdleStateChanged(proto);
  }

  MockManagedNetworkConfigurationHandler
      mock_managed_network_configuration_handler_;
  chromeos::FakePowerManagerClient fake_power_manager_client_;
  std::unique_ptr<EphemeralNetworkConfigurationHandler>
      ephemeral_network_configuration_handler_;
};

// If an ephemeral network config action is active, the device is on the sign-in
// screen (logged-in state .*_NONE) and network policy has already been applied,
// the EphemeralNetworkConfigurationHandler triggrers
// TriggerEphemeralNetworkConfigActions once on construction.
TEST_F(EphemeralNetworkConfigurationHandlerTest,
       PolicyAlreadyApplied_SignInScreen_Active) {
  LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_NONE,
                                      LoginState::LOGGED_IN_USER_NONE);
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(true));

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions());

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/true);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  testing::Mock::VerifyAndClearExpectations(
      &mock_managed_network_configuration_handler_);

  // A follow-up policy change doesn't trigger
  // TriggerEphemeralNetworkConfigActions anymore (it is set to Times(1) above).
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());
}

// If an ephemeral network config action is active, the device is on the sign-in
// screen (logged-in state .*_NONE) and network policy is applied, the
// EphemeralNetworkConfigurationHandler triggrers
// TriggerEphemeralNetworkConfigActions once.
TEST_F(EphemeralNetworkConfigurationHandlerTest,
       InitialPolicyChange_SignInScreen_Active) {
  LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_NONE,
                                      LoginState::LOGGED_IN_USER_NONE);

  // At EphemeralNetworkConfigurationHandler construction time the policies have
  // not been applied yet.
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(false));

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/true);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  // Apply policies enabling ephemeral network policy actions.
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(true));

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions());
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());

  testing::Mock::VerifyAndClearExpectations(
      &mock_managed_network_configuration_handler_);

  // A follow-up policy change doesn't trigger
  // TriggerEphemeralNetworkConfigActions anymore (it is set to Times(1) above).
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());
}

// If the device enterprise-enrolls on the sign-in screen, no ephemeral network
// config actions are triggered even if the ephemeral network policies are
// enabled according to the newly applied device policy.
TEST_F(EphemeralNetworkConfigurationHandlerTest,
       InitialPolicyChange_SignInScreen_Enrollment) {
  LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_NONE,
                                      LoginState::LOGGED_IN_USER_NONE);

  // At EphemeralNetworkConfigurationHandler construction time the policies have
  // not been applied yet.
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(false));

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/false);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);

  // Mark as enterprise-enrolled and apply policies enabling ephemeral network
  // policy actions.
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(true));

  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());

  testing::Mock::VerifyAndClearExpectations(
      &mock_managed_network_configuration_handler_);

  // A follow-up policy change also doesn't trigger
  // TriggerEphemeralNetworkConfigActions.
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());
}

// The device is not on the sign-in screen, so the
// EphemeralNetworkConfigurationHandler does not triggrer
// TriggerEphemeralNetworkConfigActions on network policy application.
TEST_F(EphemeralNetworkConfigurationHandlerTest,
       InitialPolicyChange_NotSigninScreen_Active) {
  LoginState::Get()->SetLoggedInState(
      LoginState::LOGGED_IN_ACTIVE, LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);

  // At EphemeralNetworkConfigurationHandler construction time the policies have
  // not been applied yet.
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(false));

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/true);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(true));

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());
}

// No "ephemeral network config" policy is active, so the
// EphemeralNetworkConfigurationHandler does not triggrer
// TriggerEphemeralNetworkConfigActions on network policy application.
TEST_F(EphemeralNetworkConfigurationHandlerTest,
       InitialPolicyChange_SignInScreen_NotActive) {
  LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_NONE,
                                      LoginState::LOGGED_IN_USER_NONE);
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(false));
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              UserCreatedNetworkConfigurationsAreEphemeral())
      .WillRepeatedly(Return(false));

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/true);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());
}

// When the device wakes up from suspend and a "ephemeral network config"
// (RecommendedValuesAreEphemeral) policy is active,
// TriggerEphemeralNetworkConfigActions is triggered.
TEST_F(EphemeralNetworkConfigurationHandlerTest,
       SuspendDoneReal_Active_Recommended) {
  LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_NONE,
                                      LoginState::LOGGED_IN_USER_NONE);

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/true);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(true));

  // Initial policy application
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(1);
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());

  testing::Mock::VerifyAndClearExpectations(
      &mock_managed_network_configuration_handler_);

  // Wake up from suspend on sign-in screen
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(1);
  fake_power_manager_client_.SendSuspendDone(base::Minutes(10));

  testing::Mock::VerifyAndClearExpectations(
      &mock_managed_network_configuration_handler_);

  // After entering an active session, waking up from suspend doesn't trigger
  // TriggerEphemeralNetworkConfigActions - it should only happen on the sign-in
  // screen.
  LoginState::Get()->SetLoggedInState(
      LoginState::LOGGED_IN_ACTIVE, LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  fake_power_manager_client_.SendSuspendDone(base::Minutes(10));
}

// When the device wakes up from suspend and a "ephemeral network config"
// (UserCreatedNetworkConfigurationsAreEphemeral)  policy is active,
// TriggerEphemeralNetworkConfigActions is triggered.
TEST_F(EphemeralNetworkConfigurationHandlerTest,
       SuspendDoneReal_Active_Unmanaged) {
  LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_NONE,
                                      LoginState::LOGGED_IN_USER_NONE);

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/true);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              UserCreatedNetworkConfigurationsAreEphemeral())
      .WillRepeatedly(Return(true));

  // Initial policy application
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(1);
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());

  testing::Mock::VerifyAndClearExpectations(
      &mock_managed_network_configuration_handler_);

  // Wake up from suspend on sign-in screen
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(1);
  fake_power_manager_client_.SendSuspendDone(base::Minutes(10));

  testing::Mock::VerifyAndClearExpectations(
      &mock_managed_network_configuration_handler_);

  // After entering an active session, waking up from suspend doesn't trigger
  // TriggerEphemeralNetworkConfigActions - it should only happen on the sign-in
  // screen.
  LoginState::Get()->SetLoggedInState(
      LoginState::LOGGED_IN_ACTIVE, LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  fake_power_manager_client_.SendSuspendDone(base::Minutes(10));
}

// When a "spurious" (sleep time 0) suspend done event comes,
// TriggerEphemeralNetworkConfigActions is not triggered.
TEST_F(EphemeralNetworkConfigurationHandlerTest, SuspendDoneSpurious_Active) {
  LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_NONE,
                                      LoginState::LOGGED_IN_USER_NONE);

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/true);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(true));
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  fake_power_manager_client_.SendSuspendDone(base::TimeDelta());
}

// When the device wakes up from suspend and no "ephemeral network config"
// policy is active, TriggerEphemeralNetworkConfigActions is not triggered.
TEST_F(EphemeralNetworkConfigurationHandlerTest, SuspendDoneReal_NotActive) {
  LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_NONE,
                                      LoginState::LOGGED_IN_USER_NONE);

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/true);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(false));
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              UserCreatedNetworkConfigurationsAreEphemeral())
      .WillRepeatedly(Return(false));
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  fake_power_manager_client_.SendSuspendDone(base::Minutes(10));
}

// When the device wakes up from suspend and no policy is present yet,
// TriggerEphemeralNetworkConfigActions is not triggered.
TEST_F(EphemeralNetworkConfigurationHandlerTest, SuspendDoneReal_NoPolicy) {
  LoginState::Get()->SetLoggedInState(
      LoginState::LOGGED_IN_ACTIVE, LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/true);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  fake_power_manager_client_.SendSuspendDone(base::Minutes(10));
}

// When the screen is turned off and a "ephemeral network config"
// (RecommendedValuesAreEphemeral) policy is active,
// TriggerEphemeralNetworkConfigActions is triggered.
TEST_F(EphemeralNetworkConfigurationHandlerTest, ScreenIdleState_Active) {
  LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_NONE,
                                      LoginState::LOGGED_IN_USER_NONE);

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/true);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(true));

  // Initial policy application
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(1);
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());

  testing::Mock::VerifyAndClearExpectations(
      &mock_managed_network_configuration_handler_);

  // Screen turns off due to inactivity.
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(1);
  NotifyScreenIdleOffChanged(/*off=*/true);

  testing::Mock::VerifyAndClearExpectations(
      &mock_managed_network_configuration_handler_);

  // Other notifications (such as turn screen on) don't have an effect.
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);

  NotifyScreenIdleOffChanged(/*off=*/false);

  testing::Mock::VerifyAndClearExpectations(
      &mock_managed_network_configuration_handler_);

  // But turning screen off on the sign-in screen has a repeated effect.
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(1);
  NotifyScreenIdleOffChanged(/*off=*/true);

  testing::Mock::VerifyAndClearExpectations(
      &mock_managed_network_configuration_handler_);

  // After entering an active session, the screen turning off does not trigger
  // TriggerEphemeralNetworkConfigActions - it should only happen on the sign-in
  // screen.
  LoginState::Get()->SetLoggedInState(
      LoginState::LOGGED_IN_ACTIVE, LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  NotifyScreenIdleOffChanged(/*off=*/true);
}

// When the screen is turned off due to inactivity no "ephemeral network config"
// policy is active, TriggerEphemeralNetworkConfigActions is not triggered.
TEST_F(EphemeralNetworkConfigurationHandlerTest, ScreenIdleState_NotActive) {
  LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_NONE,
                                      LoginState::LOGGED_IN_USER_NONE);

  ephemeral_network_configuration_handler_ =
      EphemeralNetworkConfigurationHandler::TryCreate(
          &mock_managed_network_configuration_handler_,
          /*was_enterprise_managed_at_startup=*/true);
  ASSERT_TRUE(ephemeral_network_configuration_handler_);

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              RecommendedValuesAreEphemeral())
      .WillRepeatedly(Return(false));
  EXPECT_CALL(mock_managed_network_configuration_handler_,
              UserCreatedNetworkConfigurationsAreEphemeral())
      .WillRepeatedly(Return(false));
  ephemeral_network_configuration_handler_->TriggerPoliciesChangedForTesting(
      /*userhash=*/std::string());

  EXPECT_CALL(mock_managed_network_configuration_handler_,
              TriggerEphemeralNetworkConfigActions())
      .Times(0);
  NotifyScreenIdleOffChanged(/*off=*/true);
}

}  // namespace ash