OLD | NEW |
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 Loading... |
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 Loading... |
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 "[\"\", \"signature\"]", |
| 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\", \"\"]", |
| 429 browser()); |
| 430 EXPECT_EQ(error, errorResult); |
| 431 |
| 432 std::string keys = |
| 433 "CrMCCiBSnZzWf+XraY5w3SbX2PEmWfHm5SNIv2pc9xbhP0EOcxKOAjCCAQoCggEBALwigL" |
| 434 "2A9johADuudl41fz3DZFxVlIY0LwWHKM33aYwXs1CnuIL638dDLdZ+q6BvtxNygKRHFcEg" |
| 435 "mVDN7BRiCVukmM3SQbY2Tv/oLjIwSoGoQqNsmzNuyrL1U2bgJ1OGGoUepzk/SneO+1RmZv" |
| 436 "tYVMBeOcf1UAYL4IrUzuFqVR+LFwDmaaMn5gglaTwSnY0FLNYuojHetFJQ1iBJ3nGg+a0g" |
| 437 "QBLx3SXr1ea4NvTWj3/KQ9zXEFvmP1GKhbPz//YDLcsjT5ytGOeTBYysUpr3TOmZer5ufk" |
| 438 "0K48YcqZP6OqWRXRy9ZuvMYNyGdMrP+JIcmH1X+mFHnquAt+RIgCqSxRsCAwEAAQ=="; |
| 439 std::string signature = |
| 440 "chCUHZKkykcwU8HzU+hm027fUTBL0dqPMtrzppwExQwK9+" |
| 441 "XlmCjJswfce2sUUfhR1OL1tyW4hWFwu4JnuQCJ+CvmSmAh2bzRpnuSKzBfgvIDjNOAGUs7" |
| 442 "ADaNSSWPLxp+6ko++2Dn4S9HpOt8N1v6gMWqj3Ru5IqFSQPZSvGH2ois6uE50CFayPcjQE" |
| 443 "OVZt41noQdFd15RmKTvocoCC5tHNlaikeQ52yi0IScOlad1B1lMhoplW3rWophQaqxMumr" |
| 444 "OcHIZ+Y+p858x5f8Pny/kuqUClmFh9B/vF07NsUHwoSL9tA5t5jCY3L5iUc/v7o3oFcW/T" |
| 445 "gojKkX2Kg7KQ86QA=="; |
| 446 |
| 447 cast_channel_set_authority_keys_function = |
| 448 CreateSetAuthorityKeysFunction(empty_extension); |
| 449 error = utils::RunFunctionAndReturnError( |
| 450 cast_channel_set_authority_keys_function.get(), |
| 451 "[\"" + keys + "\", \"signature\"]", |
| 452 browser()); |
| 453 EXPECT_EQ(error, errorResult); |
| 454 |
| 455 cast_channel_set_authority_keys_function = |
| 456 CreateSetAuthorityKeysFunction(empty_extension); |
| 457 error = utils::RunFunctionAndReturnError( |
| 458 cast_channel_set_authority_keys_function.get(), |
| 459 "[\"keys\", \"" + signature + "\"]", |
| 460 browser()); |
| 461 EXPECT_EQ(error, errorResult); |
| 462 |
| 463 cast_channel_set_authority_keys_function = |
| 464 CreateSetAuthorityKeysFunction(empty_extension); |
| 465 error = utils::RunFunctionAndReturnError( |
| 466 cast_channel_set_authority_keys_function.get(), |
| 467 "[\"" + keys + "\", \"" + signature + "\"]", |
| 468 browser()); |
| 469 EXPECT_EQ(error, errorResult); |
| 470 } |
| 471 |
| 472 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSetAuthorityKeysValid) { |
| 473 scoped_refptr<Extension> empty_extension( |
| 474 extensions::test_util::CreateEmptyExtension()); |
| 475 scoped_refptr<extensions::CastChannelSetAuthorityKeysFunction> |
| 476 cast_channel_set_authority_keys_function; |
| 477 |
| 478 cast_channel_set_authority_keys_function = |
| 479 CreateSetAuthorityKeysFunction(empty_extension); |
| 480 std::string keys = |
| 481 "CrMCCiBSnZzWf+XraY5w3SbX2PEmWfHm5SNIv2pc9xbhP0EOcxKOAjCCAQoCggEBALwigL" |
| 482 "2A9johADuudl41fz3DZFxVlIY0LwWHKM33aYwXs1CnuIL638dDLdZ+q6BvtxNygKRHFcEg" |
| 483 "mVDN7BRiCVukmM3SQbY2Tv/oLjIwSoGoQqNsmzNuyrL1U2bgJ1OGGoUepzk/SneO+1RmZv" |
| 484 "tYVMBeOcf1UAYL4IrUzuFqVR+LFwDmaaMn5gglaTwSnY0FLNYuojHetFJQ1iBJ3nGg+a0g" |
| 485 "QBLx3SXr1ea4NvTWj3/KQ9zXEFvmP1GKhbPz//YDLcsjT5ytGOeTBYysUpr3TOmZer5ufk" |
| 486 "0K48YcqZP6OqWRXRy9ZuvMYNyGdMrP+JIcmH1X+mFHnquAt+RIgCqSxRsCAwEAAQqzAgog" |
| 487 "okjC6FTmVqVt6CMfHuF1b9vkB/n+1GUNYMxay2URxyASjgIwggEKAoIBAQCwDl4HOt+kX2" |
| 488 "j3Icdk27Z27+6Lk/j2G4jhk7cX8BUeflJVdzwCjXtKbNO91sGccsizFc8RwfVGxNUgR/sw" |
| 489 "9ORhDGjwXqs3jpvhvIHDcIp41oM0MpwZYuvknO3jZGxBHZzSi0hMI5CVs+dS6gVXzGCzuh" |
| 490 "TkugA55EZVdM5ajnpnI9poCvrEhB60xaGianMfbsguL5qeqLEO/Yemj009SwXVNVp0TbyO" |
| 491 "gkSW9LWVYE6l3yc9QVwHo7Q1WrOe8gUkys0xWg0mTNTT/VDhNOlMgVgwssd63YGJptQ6OI" |
| 492 "QDtzSedz//eAdbmcGyHzVWbjo8DCXhV/aKfknAzIMRNeeRbS5lAgMBAAE="; |
| 493 std::string signature = |
| 494 "o83oku3jP+xjTysNBalqp/ZfJRPLt8R+IUhZMepbARFSRVizLoeFW5XyUwe6lQaC+PFFQH" |
| 495 "SZeGZyeeGRpwCJ/lef0xh6SWJlVMWNTk5+z0U84GQdizJP/CTCeHpIwMobN+kyDajgOyfD" |
| 496 "DLhktc6LHmSlFGG6J7B8W67oziS8ZFEdrcT9WSXFrjLVyURHjvidZD5iFtuImI6k9R9OoX" |
| 497 "LR6SyAwpjdrL+vlHMk3Gol6KQ98YpF0ghHnN3/FFW4ibvIwjmRbp+tUV3h8TRcCOjlXVGp" |
| 498 "bzPtNRRlTqfv7Rxm5YXkZMLmJJMZiTs5+o8FMRMTQZT4hRR3DQ+A/jofViyTGA=="; |
| 499 |
| 500 std::string args = "[\"" + keys + "\", \"" + signature + "\"]"; |
| 501 std::string error = utils::RunFunctionAndReturnError( |
| 502 cast_channel_set_authority_keys_function.get(), args, browser()); |
| 503 EXPECT_EQ(error, std::string()); |
| 504 } |
OLD | NEW |