blob: 1e8e9d0941cf25dc6ca9f880e9730b587e847377 [file] [log] [blame]
Andreea Costinas90b71642020-06-12 10:18:25 +02001// 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
10namespace {
11const 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
21namespace system_proxy {
22
23TEST(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