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

Side by Side Diff: chromeos/dbus/fake_easy_unlock_client_unittest.cc

Issue 577443004: Revert of Minor cleanup in EasyUnlockClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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 | « chromeos/dbus/fake_easy_unlock_client.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromeos/dbus/fake_easy_unlock_client.h" 5 #include "chromeos/dbus/fake_easy_unlock_client.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 client.PerformECDHKeyAgreement(private_key, 196 client.PerformECDHKeyAgreement(private_key,
197 public_key, 197 public_key,
198 base::Bind(&RecordData, &shared_key)); 198 base::Bind(&RecordData, &shared_key));
199 EXPECT_TRUE(shared_key.empty()); 199 EXPECT_TRUE(shared_key.empty());
200 } 200 }
201 201
202 TEST(FakeEasyUnlockClientTest, CreateSecureMessage) { 202 TEST(FakeEasyUnlockClientTest, CreateSecureMessage) {
203 chromeos::FakeEasyUnlockClient client; 203 chromeos::FakeEasyUnlockClient client;
204 204
205 std::string message; 205 std::string message;
206
207 chromeos::EasyUnlockClient::CreateSecureMessageOptions options;
208 options.key = "KEY";
209 options.associated_data = "ASSOCIATED_DATA";
210 options.public_metadata = "PUBLIC_METADATA";
211 options.verification_key_id = "VERIFICATION_KEY_ID";
212 options.decryption_key_id = "DECRYPTION_KEY_ID";
213 options.encryption_type = "ENCRYPTION_TYPE";
214 options.signature_type = "SIGNATURE_TYPE";
215
216 client.CreateSecureMessage( 206 client.CreateSecureMessage(
217 "PAYLOAD", 207 "PAYLOAD",
218 options, 208 "KEY",
209 "ASSOCIATED_DATA",
210 "PUBLIC_METADATA",
211 "VERIFICATION_KEY_ID",
212 "DECRYPTION_KEY_ID",
213 "ENCRYPTION_TYPE",
214 "SIGNATURE_TYPE",
219 base::Bind(&RecordData, &message)); 215 base::Bind(&RecordData, &message));
220 216
221 const std::string expected_message( 217 const std::string expected_message(
222 "{\"securemessage\": {" 218 "{\"securemessage\": {"
223 "\"payload\": \"PAYLOAD\"," 219 "\"payload\": \"PAYLOAD\","
224 "\"key\": \"KEY\"," 220 "\"key\": \"KEY\","
225 "\"associated_data\": \"ASSOCIATED_DATA\"," 221 "\"associated_data\": \"ASSOCIATED_DATA\","
226 "\"public_metadata\": \"PUBLIC_METADATA\"," 222 "\"public_metadata\": \"PUBLIC_METADATA\","
227 "\"verification_key_id\": \"VERIFICATION_KEY_ID\"," 223 "\"verification_key_id\": \"VERIFICATION_KEY_ID\","
228 "\"decryption_key_id\": \"DECRYPTION_KEY_ID\"," 224 "\"decryption_key_id\": \"DECRYPTION_KEY_ID\","
229 "\"encryption_type\": \"ENCRYPTION_TYPE\"," 225 "\"encryption_type\": \"ENCRYPTION_TYPE\","
230 "\"signature_type\": \"SIGNATURE_TYPE\"}" 226 "\"signature_type\": \"SIGNATURE_TYPE\"}"
231 "}"); 227 "}");
232 ASSERT_EQ(expected_message, message); 228 ASSERT_EQ(expected_message, message);
233 } 229 }
234 230
235 TEST(FakeEasyUnlockClientTest, UnwrapSecureMessage) { 231 TEST(FakeEasyUnlockClientTest, UnwrapSecureMessage) {
236 chromeos::FakeEasyUnlockClient client; 232 chromeos::FakeEasyUnlockClient client;
237 233
238 std::string message; 234 std::string message;
239
240 chromeos::EasyUnlockClient::UnwrapSecureMessageOptions options;
241 options.key = "KEY";
242 options.associated_data = "ASSOCIATED_DATA";
243 options.encryption_type = "ENCRYPTION_TYPE";
244 options.signature_type = "SIGNATURE_TYPE";
245
246 client.UnwrapSecureMessage( 235 client.UnwrapSecureMessage(
247 "MESSAGE", 236 "MESSAGE",
248 options, 237 "KEY",
238 "ASSOCIATED_DATA",
239 "ENCRYPTION_TYPE",
240 "SIGNATURE_TYPE",
249 base::Bind(&RecordData, &message)); 241 base::Bind(&RecordData, &message));
250 242
251 const std::string expected_message( 243 const std::string expected_message(
252 "{\"unwrapped_securemessage\": {" 244 "{\"unwrapped_securemessage\": {"
253 "\"message\": \"MESSAGE\"," 245 "\"message\": \"MESSAGE\","
254 "\"key\": \"KEY\"," 246 "\"key\": \"KEY\","
255 "\"associated_data\": \"ASSOCIATED_DATA\"," 247 "\"associated_data\": \"ASSOCIATED_DATA\","
256 "\"encryption_type\": \"ENCRYPTION_TYPE\"," 248 "\"encryption_type\": \"ENCRYPTION_TYPE\","
257 "\"signature_type\": \"SIGNATURE_TYPE\"}" 249 "\"signature_type\": \"SIGNATURE_TYPE\"}"
258 "}"); 250 "}");
259 ASSERT_EQ(expected_message, message); 251 ASSERT_EQ(expected_message, message);
260 } 252 }
261 253
262 } // namespace 254 } // namespace
263 255
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_easy_unlock_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698