forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_access_token_fetcher.cc
42 lines (35 loc) · 1.33 KB
/
fake_access_token_fetcher.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2015 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 "remoting/test/fake_access_token_fetcher.h"
namespace remoting {
namespace test {
FakeAccessTokenFetcher::FakeAccessTokenFetcher()
: fail_access_token_from_auth_code_(false),
fail_access_token_from_refresh_token_(false) {
}
FakeAccessTokenFetcher::~FakeAccessTokenFetcher() = default;
void FakeAccessTokenFetcher::GetAccessTokenFromAuthCode(
const std::string& auth_code,
const AccessTokenCallback& callback) {
if (fail_access_token_from_auth_code_) {
// Empty strings are returned in failure cases.
callback.Run(std::string(), std::string());
} else {
callback.Run(kFakeAccessTokenFetcherAccessTokenValue,
kFakeAccessTokenFetcherRefreshTokenValue);
}
}
void FakeAccessTokenFetcher::GetAccessTokenFromRefreshToken(
const std::string& refresh_token,
const AccessTokenCallback& callback) {
if (fail_access_token_from_refresh_token_) {
// Empty strings are returned in failure cases.
callback.Run(std::string(), std::string());
} else {
callback.Run(kFakeAccessTokenFetcherAccessTokenValue,
kFakeAccessTokenFetcherRefreshTokenValue);
}
}
} // namespace test
} // namespace remoting