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/extensions/api/cryptotoken_private/cryptotoken_private_
api.h" | 5 #include "chrome/browser/extensions/api/cryptotoken_private/cryptotoken_private_
api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
| 10 #include <utility> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "chrome/browser/extensions/extension_api_unittest.h" | 13 #include "chrome/browser/extensions/extension_api_unittest.h" |
13 #include "chrome/browser/extensions/extension_function_test_utils.h" | 14 #include "chrome/browser/extensions/extension_function_test_utils.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace extensions { | 17 namespace extensions { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
(...skipping 29 matching lines...) Expand all Loading... |
49 const std::string& appId) { | 50 const std::string& appId) { |
50 scoped_refptr<api::CryptotokenPrivateCanOriginAssertAppIdFunction> function( | 51 scoped_refptr<api::CryptotokenPrivateCanOriginAssertAppIdFunction> function( |
51 new api::CryptotokenPrivateCanOriginAssertAppIdFunction()); | 52 new api::CryptotokenPrivateCanOriginAssertAppIdFunction()); |
52 function->set_has_callback(true); | 53 function->set_has_callback(true); |
53 | 54 |
54 scoped_ptr<base::ListValue> args(new base::ListValue); | 55 scoped_ptr<base::ListValue> args(new base::ListValue); |
55 args->AppendString(origin); | 56 args->AppendString(origin); |
56 args->AppendString(appId); | 57 args->AppendString(appId); |
57 | 58 |
58 extension_function_test_utils::RunFunction( | 59 extension_function_test_utils::RunFunction( |
59 function.get(), | 60 function.get(), std::move(args), browser(), |
60 args.Pass(), | |
61 browser(), | |
62 extension_function_test_utils::NONE); | 61 extension_function_test_utils::NONE); |
63 | 62 |
64 bool result; | 63 bool result; |
65 GetSingleBooleanResult(function.get(), &result); | 64 GetSingleBooleanResult(function.get(), &result); |
66 return result; | 65 return result; |
67 } | 66 } |
68 }; | 67 }; |
69 | 68 |
70 TEST_F(CryptoTokenPrivateApiTest, CanOriginAssertAppId) { | 69 TEST_F(CryptoTokenPrivateApiTest, CanOriginAssertAppId) { |
71 std::string origin1("https://www.example.com"); | 70 std::string origin1("https://www.example.com"); |
(...skipping 15 matching lines...) Expand all Loading... |
87 std::string gstatic_appid("https://www.gstatic.com/securitykey/origins.json"); | 86 std::string gstatic_appid("https://www.gstatic.com/securitykey/origins.json"); |
88 EXPECT_TRUE(GetCanOriginAssertAppIdResult(google_origin, gstatic_appid)); | 87 EXPECT_TRUE(GetCanOriginAssertAppIdResult(google_origin, gstatic_appid)); |
89 // Not all gstatic urls are allowed, just those specifically whitelisted. | 88 // Not all gstatic urls are allowed, just those specifically whitelisted. |
90 std::string gstatic_otherurl("https://www.gstatic.com/foobar"); | 89 std::string gstatic_otherurl("https://www.gstatic.com/foobar"); |
91 EXPECT_FALSE(GetCanOriginAssertAppIdResult(google_origin, gstatic_otherurl)); | 90 EXPECT_FALSE(GetCanOriginAssertAppIdResult(google_origin, gstatic_otherurl)); |
92 } | 91 } |
93 | 92 |
94 } // namespace | 93 } // namespace |
95 | 94 |
96 } // namespace extensions | 95 } // namespace extensions |
OLD | NEW |