Index: chrome/browser/policy/device_management_policy_provider_unittest.cc |
diff --git a/chrome/browser/policy/device_management_policy_provider_unittest.cc b/chrome/browser/policy/device_management_policy_provider_unittest.cc |
index 74979e96e240aeb69eb4a334b869452a29b0b3a0..bd8c16f977920121eca83315f2bee7ac36d8363b 100644 |
--- a/chrome/browser/policy/device_management_policy_provider_unittest.cc |
+++ b/chrome/browser/policy/device_management_policy_provider_unittest.cc |
@@ -2,6 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/file_util.h" |
#include "base/message_loop.h" |
#include "base/scoped_temp_dir.h" |
#include "chrome/browser/browser_thread.h" |
@@ -33,7 +34,6 @@ class DeviceManagementPolicyProviderTest : public testing::Test { |
file_thread_(BrowserThread::FILE, &loop_) {} |
virtual ~DeviceManagementPolicyProviderTest() {} |
- |
virtual void SetUp() { |
profile_.reset(new TestingProfile); |
CreateNewBackend(); |
@@ -56,6 +56,10 @@ class DeviceManagementPolicyProviderTest : public testing::Test { |
loop_.RunAllPending(); |
} |
+ FilePath GetTokenPath() const { |
markusheintz_
2010/11/29 09:01:43
Why was this introduced? It looks like it is only
|
+ return provider_->GetTokenPath(); |
+ } |
+ |
void SimulateSuccessfulLoginAndRunPending() { |
loop_.RunAllPending(); |
profile_->GetTokenService()->IssueAuthTokenForTest( |
@@ -249,4 +253,26 @@ TEST_F(DeviceManagementPolicyProviderTest, InvalidTokenOnPolicyRequest) { |
SimulateSuccessfulLoginAndRunPending(); |
} |
+// If the client is successfully managed, but the admin stops managing the |
+// device, the client should notice and throw away the device token and id. |
+TEST_F(DeviceManagementPolicyProviderTest, DeviceNoLongerManaged) { |
+ InSequence s; |
+ SetRefreshDelays(provider_.get(), 0, 0, 1000 * 1000, 1000); |
+ EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce( |
+ MockDeviceManagementBackendSucceedRegister()); |
+ EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( |
+ MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true)); |
+ EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( |
+ MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true)); |
+ EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( |
+ MockDeviceManagementBackendFailPolicy( |
+ DeviceManagementBackend::kErrorServiceManagementNotSupported)); |
+ EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce( |
+ MockDeviceManagementBackendFailRegister( |
+ DeviceManagementBackend::kErrorServiceManagementNotSupported)); |
+ SimulateSuccessfulLoginAndRunPending(); |
+ FilePath token_path(GetTokenPath()); |
+ EXPECT_FALSE(file_util::PathExists(token_path)); |
+} |
+ |
} // namespace policy |