Extract SIGPIPE ignoring code to a common place.
[chromium-blink-merge.git] / google_apis / gaia / gaia_authenticator_unittest.cc
blob8f6319337c57a01c79640422eb3a09bbfebb901c
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"
7 #include <string>
9 #include "googleurl/src/gurl.h"
10 #include "net/http/http_status_code.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 using std::string;
15 namespace gaia {
17 class GaiaAuthenticatorTest : public testing::Test { };
19 class GaiaAuthMockForGaiaAuthenticator : public GaiaAuthenticator {
20 public:
21 GaiaAuthMockForGaiaAuthenticator()
22 : GaiaAuthenticator("useragent", "serviceid", "http://gaia_url") {}
23 ~GaiaAuthMockForGaiaAuthenticator() {}
24 protected:
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");
29 return true;
32 int GetBackoffDelaySeconds(
33 int current_backoff_delay) {
34 // Dummy delay value.
35 return 5;
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"));
48 } // namespace gaia