OLD | NEW |
(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 #include "chrome/browser/sync/engine/net/gaia_authenticator.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "chrome/browser/sync/engine/net/http_return.h" |
| 10 #include "chrome/browser/sync/util/sync_types.h" |
| 11 #include "googleurl/src/gurl.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 |
| 14 using std::string; |
| 15 |
| 16 namespace browser_sync { |
| 17 |
| 18 class GaiaAuthenticatorTest : public testing::Test { }; |
| 19 |
| 20 class GaiaAuthMock : public GaiaAuthenticator { |
| 21 public: |
| 22 GaiaAuthMock() : GaiaAuthenticator("useragent", |
| 23 "serviceid", |
| 24 "http://gaia_url") {} |
| 25 ~GaiaAuthMock() {} |
| 26 protected: |
| 27 bool Post(const GURL& url, const string& post_body, |
| 28 unsigned long* response_code, string* response_body) { |
| 29 *response_code = RC_REQUEST_OK; |
| 30 response_body->assign("body\n"); |
| 31 return true; |
| 32 } |
| 33 }; |
| 34 |
| 35 TEST(GaiaAuthenticatorTest, TestNewlineAtEndOfAuthTokenRemoved) { |
| 36 GaiaAuthMock mock_auth; |
| 37 GaiaAuthenticator::AuthResults results; |
| 38 EXPECT_TRUE(mock_auth.IssueAuthToken(&results, "sid", true)); |
| 39 EXPECT_EQ(0, results.auth_token.compare("body")); |
| 40 } |
| 41 |
| 42 } // namespace browser_sync |
OLD | NEW |