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

Side by Side Diff: chrome/browser/sync/test/engine/mock_gaia_authenticator.h

Issue 9594039: [Sync] Remove unused mock_gaia_authenticator* files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/sync/test/engine/mock_gaia_authenticator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // Use MockGaiaAuthenticator to test your application by faking a login session.
6 // This mock object should be initialized with the response you expect it to
7 // return for multiple users, and then can be used in exactly the same way
8 // as the real GaiaAuthenticator.
9 //
10 // Sample usage:
11 // MockGaiaAuthenticator mock_gaia_auth("User-Agent", SYNC_SERVICE_NAME,
12 // "any random string");
13 // mock_gaia_auth.AddMockUser("email", "password", "authtoken", "lsid", "sid",
14 // AuthenticationError);
15 // mock_gaia_auth.AddMockUser("email2", "password2", "authtoken2", "lsid2",
16 // "sid2", AuthenticationError, error_url,
17 // "captcha_token", "captcha_url");
18 // if (gaia_auth.Authenticate("email", "passwd")) {
19 // // Do something with: gaia_auth.auth_token(), or gaia_auth.sid(),
20 // // or gaia_auth.lsid()
21 // }
22
23 #ifndef CHROME_BROWSER_SYNC_TEST_ENGINE_MOCK_GAIA_AUTHENTICATOR_H_
24 #define CHROME_BROWSER_SYNC_TEST_ENGINE_MOCK_GAIA_AUTHENTICATOR_H_
25 #pragma once
26
27 #include <map>
28 #include <string>
29
30 #include "base/port.h"
31
32 #include "base/basictypes.h"
33 #include "chrome/common/net/gaia/gaia_authenticator.h"
34
35 namespace browser_sync {
36
37 // A struct used internally for storing a user's credentials. You can either
38 // create one yourself, or use the convenience methods to have the
39 // MockGaiaAuthenticator create one for you.
40 typedef struct {
41 std::string email;
42 std::string passwd;
43 std::string auth_token;
44 std::string sid;
45 std::string lsid;
46 gaia::AuthenticationError auth_error;
47 std::string captcha_token;
48 std::string captcha_url;
49 std::string error_url;
50 } MockUser;
51
52 // MockGaiaAuthenticator can be used to fake Gaia authentication without
53 // actually making a network connection. For details about the methods shared
54 // with GaiaAuthenticator, see GaiaAuthenticator in gaia_auth.h. Only methods
55 // that are unique to MockGaiaAuthenticator are documented in this file.
56 class MockGaiaAuthenticator {
57 public:
58 MockGaiaAuthenticator(const char* user_agent, const char* service_id,
59 const char* gaia_url);
60 ~MockGaiaAuthenticator();
61
62 // Add a mock user; takes a struct. You can populate any or all fields when
63 // adding a user. The email field is required, all others optional.
64 void AddMockUser(MockUser mock_user);
65
66 // A convenience method that makes it easy to create new mock users in a
67 // single method call. Includes all parameters.
68 void AddMockUser(std::string email, std::string passwd,
69 std::string auth_token,
70 std::string lsid, std::string sid,
71 gaia::AuthenticationError auth_error,
72 std::string error_url, std::string captcha_token,
73 std::string captcha_url);
74
75 // A convenience method that makes it easy to create new mock users in a
76 // single method call. Includes only the most common parameters. See overload
77 // if you want to pass all parameters.
78 void AddMockUser(std::string email, std::string passwd,
79 std::string auth_token,
80 std::string lsid, std::string sid,
81 enum gaia::AuthenticationError auth_error);
82
83 // Removes a mock user from the current list of added users.
84 void RemoveMockUser(const char* email);
85
86 // Removes all mock users from the current list of added users.
87 void RemoveAllMockUsers();
88
89 // See GaiaAuthenticator::Authenticate()
90 bool Authenticate();
91
92 // See GaiaAuthenticator::Authenticate(...)
93 bool Authenticate(const char* user_name, const char* password,
94 bool should_save_credentials = false);
95
96 // See GaiaAuthenticator::Authenticate(...)
97 void ResetCredentials();
98
99 // Accessors follow.
100 std::string email();
101 std::string auth_token();
102 std::string sid();
103 std::string lsid();
104 gaia::AuthenticationError auth_error();
105 std::string auth_error_url();
106 std::string captcha_token();
107 std::string captcha_url();
108
109 private:
110 bool should_save_credentials_;
111 std::map<std::string, MockUser> mock_credentials_;
112 std::string current_user_;
113 };
114
115 } // namespace browser_sync
116
117 #endif // CHROME_BROWSER_SYNC_TEST_ENGINE_MOCK_GAIA_AUTHENTICATOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/test/engine/mock_gaia_authenticator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698