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

Side by Side Diff: remoting/webapp/browser_test/mock_oauth2_api.js

Issue 840023004: Implement mocks for identity and host-list, add a browser test to test the app in various failure m… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing file. Created 5 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2014 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 /**
6 * @fileoverview
7 * Mock implementation of remoting.OAuth2Api
8 */
9
10 'use strict';
11
12 /** @suppress {duplicate} */
13 var remoting = remoting || {};
14
15 /**
16 * @constructor
17 * @implements {remoting.OAuth2Api}
18 */
19 remoting.MockOAuth2Api = function() {
20 /**
21 * @type {string}
22 * @private
23 */
24 this.email_ = 'fake-email@test-user.com';
25
26 /**
27 * @type {string}
28 * @private
29 */
30 this.fullName_ = 'Fake User, Esq.';
31 };
32
33 /**
34 * @param {function(string, number): void} onDone
35 * @param {function(remoting.Error):void} onError
36 * @param {string} clientId
37 * @param {string} clientSecret
38 * @param {string} refreshToken
39 * @return {void} Nothing.
40 */
41 remoting.MockOAuth2Api.prototype.refreshAccessToken = function(
42 onDone, onError, clientId, clientSecret, refreshToken) {
43 onDone(remoting.MockIdentity.AccessToken.VALID, 60 * 60);
kelvinp 2015/01/08 22:54:40 With the mock, all callbacks are now invoked synch
Jamie 2015/01/08 23:43:08 We're unlikely ever to use this in mocks, since it
44 };
45
46 /**
47 * @param {function(string, string, number): void} onDone
48 * @param {function(remoting.Error):void} onError
49 * @param {string} clientId
50 * @param {string} clientSecret
51 * @param {string} code
52 * @param {string} redirectUri
53 * @return {void} Nothing.
54 */
55 remoting.MockOAuth2Api.prototype.exchangeCodeForTokens = function(
56 onDone, onError, clientId, clientSecret, code, redirectUri) {
57 onDone('', remoting.MockIdentity.AccessToken.VALID, 60 * 60);
58 };
59
60 /**
61 * @param {function(string)} onDone
62 * @param {function(remoting.Error)} onError
63 * @param {string} token
64 */
65 remoting.MockOAuth2Api.prototype.getEmail = function(onDone, onError, token) {
66 remoting.MockIdentity.validateTokenAndCall(
67 token, onDone, onError, [this.email_]);
68 };
69
70 /**
71 * @param {function(string, string)} onDone
72 * @param {function(remoting.Error)} onError
73 * @param {string} token
74 */
75 remoting.MockOAuth2Api.prototype.getUserInfo =
76 function(onDone, onError, token) {
77 remoting.MockIdentity.validateTokenAndCall(
78 token, onDone, onError, [this.email_, this.fullName_]);
79 };
80
81
82 /**
83 * @param {boolean} active
84 */
85 remoting.MockOAuth2Api.setActive = function(active) {
86 remoting.oauth2Api = active ? new remoting.MockOAuth2Api()
87 : new remoting.OAuth2ApiImpl();
88 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698