OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/settings/device_oauth2_token_service.h" | 5 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/prefs/testing_pref_service.h" | 8 #include "base/prefs/testing_pref_service.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "chrome/browser/chromeos/settings/token_encryptor.h" | 10 #include "chrome/browser/chromeos/settings/token_encryptor.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 SystemSaltGetter::Shutdown(); | 111 SystemSaltGetter::Shutdown(); |
112 DBusThreadManager::Shutdown(); | 112 DBusThreadManager::Shutdown(); |
113 base::RunLoop().RunUntilIdle(); | 113 base::RunLoop().RunUntilIdle(); |
114 } | 114 } |
115 | 115 |
116 // Utility method to set a value in Local State for the device refresh token | 116 // Utility method to set a value in Local State for the device refresh token |
117 // (it must have a non-empty value or it won't be used). | 117 // (it must have a non-empty value or it won't be used). |
118 void SetDeviceRefreshTokenInLocalState(const std::string& refresh_token) { | 118 void SetDeviceRefreshTokenInLocalState(const std::string& refresh_token) { |
119 scoped_testing_local_state_.Get()->SetManagedPref( | 119 scoped_testing_local_state_.Get()->SetManagedPref( |
120 prefs::kDeviceRobotAnyApiRefreshToken, | 120 prefs::kDeviceRobotAnyApiRefreshToken, |
121 Value::CreateStringValue(refresh_token)); | 121 base::Value::CreateStringValue(refresh_token)); |
122 } | 122 } |
123 | 123 |
124 std::string GetValidTokenInfoResponse(const std::string email) { | 124 std::string GetValidTokenInfoResponse(const std::string email) { |
125 return "{ \"email\": \"" + email + "\"," | 125 return "{ \"email\": \"" + email + "\"," |
126 " \"user_id\": \"1234567890\" }"; | 126 " \"user_id\": \"1234567890\" }"; |
127 } | 127 } |
128 | 128 |
129 // A utility method to return fake URL results, for testing the refresh token | 129 // A utility method to return fake URL results, for testing the refresh token |
130 // validation logic. For a successful validation attempt, this method will be | 130 // validation logic. For a successful validation attempt, this method will be |
131 // called three times for the steps listed below (steps 1 and 2 happen in | 131 // called three times for the steps listed below (steps 1 and 2 happen in |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 kValidatorUrlFetcherId, | 385 kValidatorUrlFetcherId, |
386 net::HTTP_OK, | 386 net::HTTP_OK, |
387 GetValidTokenInfoResponse("service_acct@g.com")); | 387 GetValidTokenInfoResponse("service_acct@g.com")); |
388 | 388 |
389 // All fetches were successful, but consumer still given error since | 389 // All fetches were successful, but consumer still given error since |
390 // the token owner doesn't match the policy value. | 390 // the token owner doesn't match the policy value. |
391 AssertConsumerTokensAndErrors(0, 1); | 391 AssertConsumerTokensAndErrors(0, 1); |
392 } | 392 } |
393 | 393 |
394 } // namespace chromeos | 394 } // namespace chromeos |
OLD | NEW |