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

Side by Side Diff: chrome/browser/extensions/api/identity/identity_apitest.cc

Issue 10178020: Start implementing an auth flow for platform apps to be able to do auth (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/extensions/api/identity/identity_api.h" 5 #include "chrome/browser/extensions/api/identity/identity_api.h"
6 #include "chrome/browser/extensions/api/identity/web_auth_flow.h"
6 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/common/net/gaia/google_service_auth_error.h" 8 #include "chrome/common/net/gaia/google_service_auth_error.h"
8 #include "chrome/common/net/gaia/oauth2_mint_token_flow.h" 9 #include "chrome/common/net/gaia/oauth2_mint_token_flow.h"
9 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 #include "googleurl/src/gurl.h"
10 12
11 namespace { 13 namespace {
12 14
13 class IdentityInterceptor : public OAuth2MintTokenFlow::InterceptorForTests { 15 class IdentityInterceptor : public OAuth2MintTokenFlow::InterceptorForTests {
14 public: 16 public:
17 IdentityInterceptor() : called_(false) { }
18
15 virtual bool DoIntercept(const OAuth2MintTokenFlow* flow, 19 virtual bool DoIntercept(const OAuth2MintTokenFlow* flow,
16 std::string* access_token, 20 std::string* access_token,
17 GoogleServiceAuthError* error) OVERRIDE { 21 GoogleServiceAuthError* error) OVERRIDE {
18 *access_token = "auth_token"; 22 *access_token = "auth_token";
19 get_auth_token_called_ = true; 23 called_ = true;
20 return true; 24 return true;
21 } 25 }
22 26
23 bool get_auth_token_called() const { return get_auth_token_called_; } 27 bool called() const { return called_; }
24 28
25 private: 29 private:
26 bool get_auth_token_called_; 30 bool called_;
31 };
32
33 class WebAuthFlowInterceptor
34 : public extensions::WebAuthFlow::InterceptorForTests {
35 public:
36 WebAuthFlowInterceptor() : called_(false) { }
37
38 virtual GURL DoIntercept(const GURL& provider_url) OVERRIDE {
39 called_ = true;
40 return GURL("https://abcd.chromiumapp.org/cb#access_token=tok");
41 }
42
43 bool called() const { return called_; }
44
45 private:
46 bool called_;
27 }; 47 };
28 48
29 } // namespace 49 } // namespace
30 50
31 IN_PROC_BROWSER_TEST_F(PlatformAppApiTest, Identity) { 51 IN_PROC_BROWSER_TEST_F(PlatformAppApiTest, Identity) {
32 IdentityInterceptor interceptor; 52 IdentityInterceptor id_interceptor;
33 OAuth2MintTokenFlow::SetInterceptorForTests(&interceptor); 53 OAuth2MintTokenFlow::SetInterceptorForTests(&id_interceptor);
54 WebAuthFlowInterceptor waf_interceptor;
55 extensions::WebAuthFlow::SetInterceptorForTests(&waf_interceptor);
34 ASSERT_TRUE(RunExtensionTest("identity")) << message_; 56 ASSERT_TRUE(RunExtensionTest("identity")) << message_;
35 ASSERT_TRUE(interceptor.get_auth_token_called()); 57 ASSERT_TRUE(id_interceptor.called());
58 ASSERT_TRUE(waf_interceptor.called());
36 }; 59 };
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_api.cc ('k') | chrome/browser/extensions/api/identity/web_auth_flow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698