Andreea Costinas | 90b7164 | 2020-06-12 10:18:25 +0200 | [diff] [blame] | 1 | // Copyright 2020 The Chromium OS 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 "system-proxy/http_util.h" |
| 6 | |
| 7 | #include <gtest/gtest.h> |
| 8 | #include <utility> |
| 9 | |
| 10 | namespace { |
| 11 | const char kUnauthorizedResponse[] = |
| 12 | "HTTP/1.1 407 Unauthorized\r\n" |
| 13 | "Content-Length: 0\r\n" |
| 14 | "Proxy-Authenticate: Digest realm=\"My sample realm with SP\", " |
| 15 | "nonce=\"nonce-value\"\r\n" |
| 16 | "Proxy-Authenticate: Basic\r\n" |
| 17 | "\r\n"; |
| 18 | |
| 19 | } // namespace |
| 20 | |
| 21 | namespace system_proxy { |
| 22 | |
| 23 | TEST(HttpUtilTest, ParseAuthChallenge) { |
| 24 | auto result = ParseAuthChallenge(kUnauthorizedResponse); |
| 25 | |
| 26 | EXPECT_EQ(result.size(), 2); |
| 27 | EXPECT_EQ(result[0].first, "Digest"); |
| 28 | EXPECT_EQ(result[0].second, "\"My sample realm with SP\""); |
| 29 | EXPECT_EQ(result[1].first, "Basic"); |
| 30 | EXPECT_EQ(result[1].second, ""); |
| 31 | } |
| 32 | |
| 33 | } // namespace system_proxy |