Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: chrome/browser/chromeos/attestation/attestation_policy_observer_unittest.cc

Issue 1511793004: attestation: Fix policy observer expiry check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nit Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/attestation/attestation_policy_observer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/browser/chromeos/attestation/attestation_key_payload.pb.h" 10 #include "chrome/browser/chromeos/attestation/attestation_key_payload.pb.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 Run(); 170 Run();
171 } 171 }
172 172
173 TEST_F(AttestationPolicyObserverTest, NewCertificate) { 173 TEST_F(AttestationPolicyObserverTest, NewCertificate) {
174 SetupMocks(MOCK_NEW_KEY, ""); 174 SetupMocks(MOCK_NEW_KEY, "");
175 Run(); 175 Run();
176 } 176 }
177 177
178 TEST_F(AttestationPolicyObserverTest, KeyExistsNotUploaded) { 178 TEST_F(AttestationPolicyObserverTest, KeyExistsNotUploaded) {
179 std::string certificate; 179 std::string certificate;
180 ASSERT_TRUE(GetFakeCertificateDER(base::TimeDelta::FromDays(kCertValid), 180 ASSERT_TRUE(GetFakeCertificatePEM(base::TimeDelta::FromDays(kCertValid),
181 &certificate)); 181 &certificate));
182 SetupMocks(MOCK_KEY_EXISTS, certificate); 182 SetupMocks(MOCK_KEY_EXISTS, certificate);
183 Run(); 183 Run();
184 } 184 }
185 185
186 TEST_F(AttestationPolicyObserverTest, KeyExistsAlreadyUploaded) { 186 TEST_F(AttestationPolicyObserverTest, KeyExistsAlreadyUploaded) {
187 std::string certificate; 187 std::string certificate;
188 ASSERT_TRUE(GetFakeCertificateDER(base::TimeDelta::FromDays(kCertValid), 188 ASSERT_TRUE(GetFakeCertificatePEM(base::TimeDelta::FromDays(kCertValid),
189 &certificate)); 189 &certificate));
190 SetupMocks(MOCK_KEY_EXISTS | MOCK_KEY_UPLOADED, certificate); 190 SetupMocks(MOCK_KEY_EXISTS | MOCK_KEY_UPLOADED, certificate);
191 Run(); 191 Run();
192 } 192 }
193 193
194 TEST_F(AttestationPolicyObserverTest, KeyExistsCertExpiringSoon) { 194 TEST_F(AttestationPolicyObserverTest, KeyExistsCertExpiringSoon) {
195 std::string certificate; 195 std::string certificate;
196 ASSERT_TRUE(GetFakeCertificateDER( 196 ASSERT_TRUE(GetFakeCertificatePEM(
197 base::TimeDelta::FromDays(kCertExpiringSoon), &certificate)); 197 base::TimeDelta::FromDays(kCertExpiringSoon), &certificate));
198 SetupMocks(MOCK_KEY_EXISTS | MOCK_KEY_UPLOADED | MOCK_NEW_KEY, certificate); 198 SetupMocks(MOCK_KEY_EXISTS | MOCK_KEY_UPLOADED | MOCK_NEW_KEY, certificate);
199 Run(); 199 Run();
200 } 200 }
201 201
202 TEST_F(AttestationPolicyObserverTest, KeyExistsCertExpired) { 202 TEST_F(AttestationPolicyObserverTest, KeyExistsCertExpired) {
203 std::string certificate; 203 std::string certificate;
204 ASSERT_TRUE(GetFakeCertificateDER(base::TimeDelta::FromDays(kCertExpired), 204 ASSERT_TRUE(GetFakeCertificatePEM(base::TimeDelta::FromDays(kCertExpired),
205 &certificate)); 205 &certificate));
206 SetupMocks(MOCK_KEY_EXISTS | MOCK_KEY_UPLOADED | MOCK_NEW_KEY, certificate); 206 SetupMocks(MOCK_KEY_EXISTS | MOCK_KEY_UPLOADED | MOCK_NEW_KEY, certificate);
207 Run(); 207 Run();
208 } 208 }
209 209
210 TEST_F(AttestationPolicyObserverTest, IgnoreUnknownCertFormat) { 210 TEST_F(AttestationPolicyObserverTest, IgnoreUnknownCertFormat) {
211 SetupMocks(MOCK_KEY_EXISTS | MOCK_KEY_UPLOADED, "unsupported"); 211 SetupMocks(MOCK_KEY_EXISTS | MOCK_KEY_UPLOADED, "unsupported");
212 Run(); 212 Run();
213 } 213 }
214 214
215 TEST_F(AttestationPolicyObserverTest, DBusFailureRetry) { 215 TEST_F(AttestationPolicyObserverTest, DBusFailureRetry) {
216 SetupMocks(MOCK_NEW_KEY, ""); 216 SetupMocks(MOCK_NEW_KEY, "");
217 // Simulate a DBus failure. 217 // Simulate a DBus failure.
218 EXPECT_CALL(cryptohome_client_, TpmAttestationDoesKeyExist(_, _, _, _)) 218 EXPECT_CALL(cryptohome_client_, TpmAttestationDoesKeyExist(_, _, _, _))
219 .WillOnce(WithArgs<3>(Invoke(DBusCallbackError))) 219 .WillOnce(WithArgs<3>(Invoke(DBusCallbackError)))
220 .WillRepeatedly(WithArgs<3>(Invoke(DBusCallbackFalse))); 220 .WillRepeatedly(WithArgs<3>(Invoke(DBusCallbackFalse)));
221 Run(); 221 Run();
222 } 222 }
223 223
224 } // namespace attestation 224 } // namespace attestation
225 } // namespace chromeos 225 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/attestation/attestation_policy_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698