| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/extensions/api/identity/identity_api.h" | 8 #include "chrome/browser/extensions/api/identity/identity_api.h" |
| 9 #include "chrome/browser/extensions/component_loader.h" | 9 #include "chrome/browser/extensions/component_loader.h" |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_TOKEN, | 920 EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_TOKEN, |
| 921 id_api()->GetCachedToken(extension->id(), | 921 id_api()->GetCachedToken(extension->id(), |
| 922 oauth2_info.scopes).status()); | 922 oauth2_info.scopes).status()); |
| 923 } | 923 } |
| 924 | 924 |
| 925 class RemoveCachedAuthTokenFunctionTest : public ExtensionBrowserTest { | 925 class RemoveCachedAuthTokenFunctionTest : public ExtensionBrowserTest { |
| 926 protected: | 926 protected: |
| 927 bool InvalidateDefaultToken() { | 927 bool InvalidateDefaultToken() { |
| 928 scoped_refptr<IdentityRemoveCachedAuthTokenFunction> func( | 928 scoped_refptr<IdentityRemoveCachedAuthTokenFunction> func( |
| 929 new IdentityRemoveCachedAuthTokenFunction); | 929 new IdentityRemoveCachedAuthTokenFunction); |
| 930 func->set_extension(utils::CreateEmptyExtension(kExtensionId)); | 930 func->set_extension(utils::CreateEmptyExtension(kExtensionId).get()); |
| 931 return utils::RunFunction( | 931 return utils::RunFunction( |
| 932 func.get(), | 932 func.get(), |
| 933 std::string("[{\"token\": \"") + kAccessToken + "\"}]", | 933 std::string("[{\"token\": \"") + kAccessToken + "\"}]", |
| 934 browser(), | 934 browser(), |
| 935 extension_function_test_utils::NONE); | 935 extension_function_test_utils::NONE); |
| 936 } | 936 } |
| 937 | 937 |
| 938 IdentityAPI* id_api() { | 938 IdentityAPI* id_api() { |
| 939 return IdentityAPI::GetFactoryInstance()->GetForProfile( | 939 return IdentityAPI::GetFactoryInstance()->GetForProfile( |
| 940 browser()->profile()); | 940 browser()->profile()); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 GURL auth_url(https_server.GetURL("files/five_hundred.html")); | 1054 GURL auth_url(https_server.GetURL("files/five_hundred.html")); |
| 1055 | 1055 |
| 1056 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1056 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
| 1057 new IdentityLaunchWebAuthFlowFunction()); | 1057 new IdentityLaunchWebAuthFlowFunction()); |
| 1058 scoped_refptr<Extension> empty_extension( | 1058 scoped_refptr<Extension> empty_extension( |
| 1059 utils::CreateEmptyExtension()); | 1059 utils::CreateEmptyExtension()); |
| 1060 function->set_extension(empty_extension.get()); | 1060 function->set_extension(empty_extension.get()); |
| 1061 | 1061 |
| 1062 std::string args = "[{\"interactive\": true, \"url\": \"" + | 1062 std::string args = "[{\"interactive\": true, \"url\": \"" + |
| 1063 auth_url.spec() + "\"}]"; | 1063 auth_url.spec() + "\"}]"; |
| 1064 std::string error = utils::RunFunctionAndReturnError(function, args, | 1064 std::string error = |
| 1065 browser()); | 1065 utils::RunFunctionAndReturnError(function.get(), args, browser()); |
| 1066 | 1066 |
| 1067 EXPECT_EQ(std::string(errors::kPageLoadFailure), error); | 1067 EXPECT_EQ(std::string(errors::kPageLoadFailure), error); |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, NonInteractiveSuccess) { | 1070 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, NonInteractiveSuccess) { |
| 1071 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1071 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
| 1072 new IdentityLaunchWebAuthFlowFunction()); | 1072 new IdentityLaunchWebAuthFlowFunction()); |
| 1073 scoped_refptr<Extension> empty_extension( | 1073 scoped_refptr<Extension> empty_extension( |
| 1074 utils::CreateEmptyExtension()); | 1074 utils::CreateEmptyExtension()); |
| 1075 function->set_extension(empty_extension.get()); | 1075 function->set_extension(empty_extension.get()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 scoped_ptr<base::Value> value( | 1130 scoped_ptr<base::Value> value( |
| 1131 utils::RunFunctionAndReturnSingleResult(function.get(), args, browser())); | 1131 utils::RunFunctionAndReturnSingleResult(function.get(), args, browser())); |
| 1132 | 1132 |
| 1133 std::string url; | 1133 std::string url; |
| 1134 EXPECT_TRUE(value->GetAsString(&url)); | 1134 EXPECT_TRUE(value->GetAsString(&url)); |
| 1135 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1135 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
| 1136 url); | 1136 url); |
| 1137 } | 1137 } |
| 1138 | 1138 |
| 1139 } // namespace extensions | 1139 } // namespace extensions |
| OLD | NEW |