summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/identity/identity_apitest.cc
diff options
context:
space:
mode:
authorjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-23 22:14:00 +0000
committerjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-23 22:14:00 +0000
commita79be1ff74b51103636093374277c5a043dbdaac (patch)
tree44130d94294c4beee271bedcd99cc3bc7c4ee375 /chrome/browser/extensions/api/identity/identity_apitest.cc
parentadb11878c09bc7e80a7509cb76b3064120d451b5 (diff)
downloadchromium_src-a79be1ff74b51103636093374277c5a043dbdaac.zip
chromium_src-a79be1ff74b51103636093374277c5a043dbdaac.tar.gz
chromium_src-a79be1ff74b51103636093374277c5a043dbdaac.tar.bz2
Add an experimental identity API for platform apps.
This adds a way for platform apps to access the user's signed into chrome account and generate an OAuth2 token: - chrome.experimental.identity.getAuthToken BUG=none TEST=ExtensionApiTest.Identity Review URL: http://codereview.chromium.org/9474005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128591 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/identity/identity_apitest.cc')
-rw-r--r--chrome/browser/extensions/api/identity/identity_apitest.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/chrome/browser/extensions/api/identity/identity_apitest.cc b/chrome/browser/extensions/api/identity/identity_apitest.cc
new file mode 100644
index 0000000..334c8848
--- /dev/null
+++ b/chrome/browser/extensions/api/identity/identity_apitest.cc
@@ -0,0 +1,45 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/identity/identity_api.h"
+#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/common/net/gaia/google_service_auth_error.h"
+#include "chrome/common/net/gaia/oauth2_mint_token_flow.h"
+#include "chrome/common/chrome_switches.h"
+
+namespace {
+
+class IdentityInterceptor : public OAuth2MintTokenFlow::InterceptorForTests {
+ public:
+ virtual bool DoIntercept(const OAuth2MintTokenFlow* flow,
+ std::string* access_token,
+ GoogleServiceAuthError* error) OVERRIDE {
+ *access_token = "auth_token";
+ get_auth_token_called_ = true;
+ return true;
+ }
+
+ bool get_auth_token_called() const { return get_auth_token_called_; }
+
+ private:
+ bool get_auth_token_called_;
+};
+
+} // namespace
+
+class ExperimentalApiTest : public ExtensionApiTest {
+ public:
+ void SetUpCommandLine(CommandLine* command_line) {
+ ExtensionApiTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(switches::kEnablePlatformApps);
+ command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(ExperimentalApiTest, Identity) {
+ IdentityInterceptor interceptor;
+ OAuth2MintTokenFlow::SetInterceptorForTests(&interceptor);
+ ASSERT_TRUE(RunExtensionTest("identity")) << message_;
+ ASSERT_TRUE(interceptor.get_auth_token_called());
+};