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.h" | 7 #include "base/message_loop.h" |
8 #include "base/prefs/testing_pref_service.h" | 8 #include "base/prefs/testing_pref_service.h" |
9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
10 #include "chrome/browser/chromeos/cros/mock_cert_library.h" | 10 #include "chrome/browser/chromeos/cros/mock_cert_library.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 .Times(1) | 54 .Times(1) |
55 .WillOnce(Return("")); | 55 .WillOnce(Return("")); |
56 EXPECT_CALL(mock_cert_library, EncryptWithSystemSalt(StrEq("test-token"))) | 56 EXPECT_CALL(mock_cert_library, EncryptWithSystemSalt(StrEq("test-token"))) |
57 .Times(1) | 57 .Times(1) |
58 .WillOnce(Return("encrypted")); | 58 .WillOnce(Return("encrypted")); |
59 EXPECT_CALL(mock_cert_library, DecryptWithSystemSalt(StrEq("encrypted"))) | 59 EXPECT_CALL(mock_cert_library, DecryptWithSystemSalt(StrEq("encrypted"))) |
60 .Times(1) | 60 .Times(1) |
61 .WillOnce(Return("test-token")); | 61 .WillOnce(Return("test-token")); |
62 | 62 |
63 DeviceOAuth2TokenService oauth2_service( | 63 DeviceOAuth2TokenService oauth2_service( |
64 new net::TestURLRequestContextGetter( | 64 new net::TestURLRequestContextGetter(message_loop_.message_loop_proxy()), |
Mattias Nissler (ping if slow)
2013/04/19 17:45:19
I don't see how this fixes the problem, can you en
David Roche
2013/04/19 22:05:03
So, the key is in URLRequestContextGetter::OnDestr
| |
65 content::BrowserThread::GetMessageLoopProxyForThread( | |
66 content::BrowserThread::IO)), | |
67 scoped_testing_local_state_.Get()); | 65 scoped_testing_local_state_.Get()); |
68 | 66 |
69 ASSERT_EQ("", oauth2_service.GetRefreshToken()); | 67 ASSERT_EQ("", oauth2_service.GetRefreshToken()); |
70 oauth2_service.SetAndSaveRefreshToken("test-token"); | 68 oauth2_service.SetAndSaveRefreshToken("test-token"); |
71 ASSERT_EQ("test-token", oauth2_service.GetRefreshToken()); | 69 ASSERT_EQ("test-token", oauth2_service.GetRefreshToken()); |
72 | 70 |
73 // This call won't invoke decrypt again, since the value is cached. | 71 // This call won't invoke decrypt again, since the value is cached. |
74 ASSERT_EQ("test-token", oauth2_service.GetRefreshToken()); | 72 ASSERT_EQ("test-token", oauth2_service.GetRefreshToken()); |
75 } | 73 } |
76 | 74 |
77 } // namespace chromeos | 75 } // namespace chromeos |
OLD | NEW |