| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "google_apis/gaia/oauth_request_signer.h" | 5 #include "google_apis/gaia/oauth_request_signer.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
| 9 | 9 |
| 10 // This value is used to seed the PRNG at the beginning of a sequence of | 10 // This value is used to seed the PRNG at the beginning of a sequence of |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 ASSERT_EQ(OAuthRequestSigner::Encode("!5}&QF~0R-Ecy[?2Cig>6g=;hH!\\Ju4K%UK;"), | 47 ASSERT_EQ(OAuthRequestSigner::Encode("!5}&QF~0R-Ecy[?2Cig>6g=;hH!\\Ju4K%UK;"), |
| 48 "%215%7D%26QF~0R-Ecy%5B%3F2Cig%3E6g%3D%3BhH%21%5CJu4K%25UK%3B"); | 48 "%215%7D%26QF~0R-Ecy%5B%3F2Cig%3E6g%3D%3BhH%21%5CJu4K%25UK%3B"); |
| 49 ASSERT_EQ(OAuthRequestSigner::Encode("1UgHf(r)SkMRS`fRZ/8PsTcXT0:\\<9I=6{|:"), | 49 ASSERT_EQ(OAuthRequestSigner::Encode("1UgHf(r)SkMRS`fRZ/8PsTcXT0:\\<9I=6{|:"), |
| 50 "1UgHf%28r%29SkMRS%60fRZ%2F8PsTcXT0%3A%5C%3C9I%3D6%7B%7C%3A"); | 50 "1UgHf%28r%29SkMRS%60fRZ%2F8PsTcXT0%3A%5C%3C9I%3D6%7B%7C%3A"); |
| 51 ASSERT_EQ(OAuthRequestSigner::Encode("|<XIy1?o`r\"RuGSX#!:MeP&RLZQM@:\\';2X"), | 51 ASSERT_EQ(OAuthRequestSigner::Encode("|<XIy1?o`r\"RuGSX#!:MeP&RLZQM@:\\';2X"), |
| 52 "%7C%3CXIy1%3Fo%60r%22RuGSX%23%21%3AMeP%26RLZQM%40%3A%5C%27%3B2X"); | 52 "%7C%3CXIy1%3Fo%60r%22RuGSX%23%21%3AMeP%26RLZQM%40%3A%5C%27%3B2X"); |
| 53 ASSERT_EQ(OAuthRequestSigner::Encode("#a@A>ZtcQ/yb.~^Q_]daRT?ffK>@A:afWuZL"), | 53 ASSERT_EQ(OAuthRequestSigner::Encode("#a@A>ZtcQ/yb.~^Q_]daRT?ffK>@A:afWuZL"), |
| 54 "%23a%40A%3EZtcQ%2Fyb.~%5EQ_%5DdaRT%3FffK%3E%40A%3AafWuZL"); | 54 "%23a%40A%3EZtcQ%2Fyb.~%5EQ_%5DdaRT%3FffK%3E%40A%3AafWuZL"); |
| 55 } | 55 } |
| 56 | 56 |
| 57 TEST(OAuthRequestSignerTest, DecodeEncoded) { | 57 // http://crbug.com/685352 |
| 58 #if defined(OS_WIN) |
| 59 #define MAYBE_DecodeEncoded DISABLED_DecodeEncoded |
| 60 #else |
| 61 #define MAYBE_DecodeEncoded DecodeEncoded |
| 62 #endif |
| 63 TEST(OAuthRequestSignerTest, MAYBE_DecodeEncoded) { |
| 58 srand(RANDOM_SEED); | 64 srand(RANDOM_SEED); |
| 59 static const int kIterations = 500; | 65 static const int kIterations = 500; |
| 60 static const int kLengthLimit = 500; | 66 static const int kLengthLimit = 500; |
| 61 for (int iteration = 0; iteration < kIterations; ++iteration) { | 67 for (int iteration = 0; iteration < kIterations; ++iteration) { |
| 62 std::string text; | 68 std::string text; |
| 63 int length = rand() % kLengthLimit; | 69 int length = rand() % kLengthLimit; |
| 64 for (int position = 0; position < length; ++position) { | 70 for (int position = 0; position < length; ++position) { |
| 65 text += static_cast<char>(rand() % 256); | 71 text += static_cast<char>(rand() % 256); |
| 66 } | 72 } |
| 67 std::string encoded = OAuthRequestSigner::Encode(text); | 73 std::string encoded = OAuthRequestSigner::Encode(text); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 "oauth_nonce=\"2oiE_aHdk5qRTz0L9C8Lq0g\", " | 320 "oauth_nonce=\"2oiE_aHdk5qRTz0L9C8Lq0g\", " |
| 315 "oauth_signature=\"PFqDTaiyey1UObcvOyI4Ng2HXW0%3D\", " | 321 "oauth_signature=\"PFqDTaiyey1UObcvOyI4Ng2HXW0%3D\", " |
| 316 "oauth_signature_method=\"HMAC-SHA1\", " | 322 "oauth_signature_method=\"HMAC-SHA1\", " |
| 317 "oauth_timestamp=\"1308152953\", " | 323 "oauth_timestamp=\"1308152953\", " |
| 318 "oauth_token=\"4%2FVGY0MsQadcmO8VnCv9gnhoEooq1v\", " | 324 "oauth_token=\"4%2FVGY0MsQadcmO8VnCv9gnhoEooq1v\", " |
| 319 "oauth_version=\"1.0\", " | 325 "oauth_version=\"1.0\", " |
| 320 "scope=\"https%3A%2F%2Faccounts.google.com%2FOAuthLogin\", " | 326 "scope=\"https%3A%2F%2Faccounts.google.com%2FOAuthLogin\", " |
| 321 "xaouth_display_name=\"Chromium\"", | 327 "xaouth_display_name=\"Chromium\"", |
| 322 signed_text); | 328 signed_text); |
| 323 } | 329 } |
| OLD | NEW |