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
3 // found in the LICENSE file.
5 #include "google_apis/gaia/gaia_authenticator.h"
9 #include "googleurl/src/gurl.h"
10 #include "net/http/http_status_code.h"
11 #include "testing/gtest/include/gtest/gtest.h"
17 class GaiaAuthenticatorTest
: public testing::Test
{ };
19 class GaiaAuthMockForGaiaAuthenticator
: public GaiaAuthenticator
{
21 GaiaAuthMockForGaiaAuthenticator()
22 : GaiaAuthenticator("useragent", "serviceid", "http://gaia_url") {}
23 ~GaiaAuthMockForGaiaAuthenticator() {}
25 bool Post(const GURL
& url
, const string
& post_body
,
26 unsigned long* response_code
, string
* response_body
) {
27 *response_code
= net::HTTP_OK
;
28 response_body
->assign("body\n");
32 int GetBackoffDelaySeconds(
33 int current_backoff_delay
) {
39 TEST(GaiaAuthenticatorTest
, TestNewlineAtEndOfAuthTokenRemoved
) {
40 GaiaAuthMockForGaiaAuthenticator mock_auth
;
41 MessageLoop message_loop
;
42 mock_auth
.set_message_loop(&message_loop
);
43 GaiaAuthenticator::AuthResults results
;
44 EXPECT_TRUE(mock_auth
.IssueAuthToken(&results
, "sid"));
45 EXPECT_EQ(0, results
.auth_token
.compare("body"));