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

Side by Side Diff: extensions/browser/api/cast_channel/cast_channel_apitest.cc

Issue 627573002: Enable passing cast channel certificate authority keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review changes. Created 6 years, 2 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_function_test_utils.h" 9 #include "chrome/browser/extensions/extension_function_test_utils.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 177
178 extensions::CastChannelSendFunction* CreateSendFunction( 178 extensions::CastChannelSendFunction* CreateSendFunction(
179 scoped_refptr<Extension> extension) { 179 scoped_refptr<Extension> extension) {
180 extensions::CastChannelSendFunction* cast_channel_send_function = 180 extensions::CastChannelSendFunction* cast_channel_send_function =
181 new extensions::CastChannelSendFunction; 181 new extensions::CastChannelSendFunction;
182 cast_channel_send_function->set_extension(extension.get()); 182 cast_channel_send_function->set_extension(extension.get());
183 return cast_channel_send_function; 183 return cast_channel_send_function;
184 } 184 }
185 185
186 extensions::CastChannelSetAuthorityKeysFunction*
187 CreateSetAuthorityKeysFunction(scoped_refptr<Extension> extension) {
188 extensions::CastChannelSetAuthorityKeysFunction*
189 cast_channel_set_authority_keys_function =
190 new extensions::CastChannelSetAuthorityKeysFunction;
191 cast_channel_set_authority_keys_function->set_extension(extension.get());
192 return cast_channel_set_authority_keys_function;
193 }
194
186 MockCastSocket* mock_cast_socket_; 195 MockCastSocket* mock_cast_socket_;
187 net::CapturingNetLog capturing_net_log_; 196 net::CapturingNetLog capturing_net_log_;
188 }; 197 };
189 198
190 // TODO(munjal): Win Dbg has a workaround that makes RunExtensionSubtest 199 // TODO(munjal): Win Dbg has a workaround that makes RunExtensionSubtest
191 // always return true without actually running the test. Remove when fixed. 200 // always return true without actually running the test. Remove when fixed.
192 #if defined(OS_WIN) && !defined(NDEBUG) 201 #if defined(OS_WIN) && !defined(NDEBUG)
193 #define MAYBE_TestOpenSendClose DISABLED_TestOpenSendClose 202 #define MAYBE_TestOpenSendClose DISABLED_TestOpenSendClose
194 #else 203 #else
195 #define MAYBE_TestOpenSendClose TestOpenSendClose 204 #define MAYBE_TestOpenSendClose TestOpenSendClose
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 cast_channel_send_function.get(), 398 cast_channel_send_function.get(),
390 "[{\"channelId\": 1, \"url\": \"cast://127.0.0.1:8009\", " 399 "[{\"channelId\": 1, \"url\": \"cast://127.0.0.1:8009\", "
391 "\"connectInfo\": " 400 "\"connectInfo\": "
392 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, " 401 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, "
393 "\"auth\": \"ssl\"}, \"readyState\": \"open\"}, " 402 "\"auth\": \"ssl\"}, \"readyState\": \"open\"}, "
394 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", " 403 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", "
395 "\"destinationId\": \"\", \"data\": \"data\"}]", 404 "\"destinationId\": \"\", \"data\": \"data\"}]",
396 browser()); 405 browser());
397 EXPECT_EQ(error, "message_info.destination_id is required"); 406 EXPECT_EQ(error, "message_info.destination_id is required");
398 } 407 }
408
409 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSetAuthorityKeysInvalid) {
410 scoped_refptr<Extension> empty_extension(
411 extensions::test_util::CreateEmptyExtension());
412 scoped_refptr<extensions::CastChannelSetAuthorityKeysFunction>
413 cast_channel_set_authority_keys_function;
414 std::string errorResult = "Unable to set authority keys.";
415
416 cast_channel_set_authority_keys_function =
417 CreateSetAuthorityKeysFunction(empty_extension);
418 std::string error = utils::RunFunctionAndReturnError(
419 cast_channel_set_authority_keys_function.get(),
420 "[\"\", \"\"]",
421 browser());
422 EXPECT_EQ(error, errorResult);
423
424 cast_channel_set_authority_keys_function =
425 CreateSetAuthorityKeysFunction(empty_extension);
426 error = utils::RunFunctionAndReturnError(
427 cast_channel_set_authority_keys_function.get(),
428 "[\"keys\", \"signature\"]",
429 browser());
430 EXPECT_EQ(error, errorResult);
431
432 cast_channel_set_authority_keys_function =
433 CreateSetAuthorityKeysFunction(empty_extension);
434 std::string keys =
435 "CrMCCiBSnZzWf+XraY5w3SbX2PEmWfHm5SNIv2pc9xbhP0EOcxKOAjCCAQoCggEBALwigL"
436 "2A9johADuudl41fz3DZFxVlIY0LwWHKM33aYwXs1CnuIL638dDLdZ+q6BvtxNygKRHFcEg"
437 "mVDN7BRiCVukmM3SQbY2Tv/oLjIwSoGoQqNsmzNuyrL1U2bgJ1OGGoUepzk/SneO+1RmZv"
438 "tYVMBeOcf1UAYL4IrUzuFqVR+LFwDmaaMn5gglaTwSnY0FLNYuojHetFJQ1iBJ3nGg+a0g"
439 "QBLx3SXr1ea4NvTWj3/KQ9zXEFvmP1GKhbPz//YDLcsjT5ytGOeTBYysUpr3TOmZer5ufk"
440 "0K48YcqZP6OqWRXRy9ZuvMYNyGdMrP+JIcmH1X+mFHnquAt+RIgCqSxRsCAwEAAQ==";
441 std::string signature =
442 "chCUHZKkykcwU8HzU+hm027fUTBL0dqPMtrzppwExQwK9+"
443 "XlmCjJswfce2sUUfhR1OL1tyW4hWFwu4JnuQCJ+CvmSmAh2bzRpnuSKzBfgvIDjNOAGUs7"
444 "ADaNSSWPLxp+6ko++2Dn4S9HpOt8N1v6gMWqj3Ru5IqFSQPZSvGH2ois6uE50CFayPcjQE"
445 "OVZt41noQdFd15RmKTvocoCC5tHNlaikeQ52yi0IScOlad1B1lMhoplW3rWophQaqxMumr"
446 "OcHIZ+Y+p858x5f8Pny/kuqUClmFh9B/vF07NsUHwoSL9tA5t5jCY3L5iUc/v7o3oFcW/T"
447 "gojKkX2Kg7KQ86QA==";
448 std::string args = "[\"" + keys + "\", \"" + signature + "\"]";
449 error = utils::RunFunctionAndReturnError(
450 cast_channel_set_authority_keys_function.get(), args, browser());
451 EXPECT_EQ(error, errorResult);
452 }
453
454 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSetAuthorityKeysValid) {
455 scoped_refptr<Extension> empty_extension(
456 extensions::test_util::CreateEmptyExtension());
457 scoped_refptr<extensions::CastChannelSetAuthorityKeysFunction>
458 cast_channel_set_authority_keys_function;
459
460 cast_channel_set_authority_keys_function =
461 CreateSetAuthorityKeysFunction(empty_extension);
462 std::string keys =
463 "CrMCCiBSnZzWf+XraY5w3SbX2PEmWfHm5SNIv2pc9xbhP0EOcxKOAjCCAQoCggEBALwigL"
464 "2A9johADuudl41fz3DZFxVlIY0LwWHKM33aYwXs1CnuIL638dDLdZ+q6BvtxNygKRHFcEg"
465 "mVDN7BRiCVukmM3SQbY2Tv/oLjIwSoGoQqNsmzNuyrL1U2bgJ1OGGoUepzk/SneO+1RmZv"
466 "tYVMBeOcf1UAYL4IrUzuFqVR+LFwDmaaMn5gglaTwSnY0FLNYuojHetFJQ1iBJ3nGg+a0g"
467 "QBLx3SXr1ea4NvTWj3/KQ9zXEFvmP1GKhbPz//YDLcsjT5ytGOeTBYysUpr3TOmZer5ufk"
468 "0K48YcqZP6OqWRXRy9ZuvMYNyGdMrP+JIcmH1X+mFHnquAt+RIgCqSxRsCAwEAAQ==";
469 std::string signature =
470 "QEdWF9Oup2lXxFYbwdpe6OJQsUISN0eqd/F0N6BXWH2zKO0nfDu84FdO7OyKRn+24Dd9Ie"
471 "k6ZM8qC7bd0Aivi3gMbkbC7lJELd5LGP0a+8SsDqUGnW/xkOnrSV1m4+ibrZoKGDqKeERi"
472 "YwbORECCyPzz6TI0zkQ+R6yTLNPcwfRCpLPPOcZ4j+IEy1EW2/f8doBnVDZs6a2S/wlBcQ"
473 "X55XrdUw6FV+LL9HbiWktFDFqOUxitW6zGiZ9FP0TcchWcpvR9hLAs/AosfaC+4GszK1cq"
474 "bOLmrE/+sR5i3TQWsPa0boe04O68l6lQRM1nQ9OpvVtEKgSEtpvYVVHkPWDp5g==";
475 std::string args = "[\"" + keys + "\", \"" + signature + "\"]";
476 std::string error = utils::RunFunctionAndReturnError(
477 cast_channel_set_authority_keys_function.get(), args, browser());
478 EXPECT_EQ(error, std::string());
479 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698