OpenVPN 3 Core Library
Loading...
Searching...
No Matches
test_http_proxy.cpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12
13#include "test_common.hpp"
14
16
17using namespace openvpn;
18
19TEST(HttpProxyClient, Options)
20{
21 OptionList cfg;
23 "http-proxy proxyhost 3128 auto\n"
24 "http-proxy-option VERSION 1.1\n"
25 "http-proxy-option AGENT Mosaic/0.9\n"
26 "http-proxy-option CUSTOM-HEADER X-Greeting \"Hi mom!\"\n"
27 "<http-proxy-user-pass>\n"
28 "uzername\n"
29 "pazzword\n"
30 "</http-proxy-user-pass>\n",
31 nullptr);
32 cfg.update_map();
34 ASSERT_EQ(po->allow_cleartext_auth, true);
35 ASSERT_EQ(po->auth_method, HTTPProxyTransport::AuthMethod::Any);
36 ASSERT_EQ(po->username, "uzername");
37 ASSERT_EQ(po->password, "pazzword");
38 ASSERT_EQ(po->http_version, "1.1");
39 ASSERT_EQ(po->user_agent, "Mosaic/0.9");
40 ASSERT_EQ(po->headers.size(), 1u);
41 ASSERT_EQ(po->headers.at(0)->p1, "X-Greeting");
42 ASSERT_EQ(po->headers.at(0)->p2, "Hi mom!");
43
44 cfg.parse_from_config("http-proxy proxyhost 3128 none\n", nullptr);
45 cfg.update_map();
47 ASSERT_EQ(po->auth_method, HTTPProxyTransport::AuthMethod::None);
48
49 cfg.parse_from_config("http-proxy proxyhost 3128 basic\n", nullptr);
50 cfg.update_map();
52 ASSERT_EQ(po->allow_cleartext_auth, true);
53 ASSERT_EQ(po->auth_method, HTTPProxyTransport::AuthMethod::Basic);
54
55 cfg.parse_from_config("http-proxy proxyhost 3128 digest\n", nullptr);
56 cfg.update_map();
58 ASSERT_EQ(po->allow_cleartext_auth, false);
59 ASSERT_EQ(po->auth_method, HTTPProxyTransport::AuthMethod::Digest);
60
61 cfg.parse_from_config("http-proxy proxyhost 3128 ntlm\n", nullptr);
62 cfg.update_map();
64 ASSERT_EQ(po->allow_cleartext_auth, false);
65 ASSERT_EQ(po->auth_method, HTTPProxyTransport::AuthMethod::Ntlm);
66
67 cfg.parse_from_config("http-proxy proxyhost 3128 auto-nct\n", nullptr);
68 cfg.update_map();
70 ASSERT_EQ(po->allow_cleartext_auth, false);
71 ASSERT_EQ(po->auth_method, HTTPProxyTransport::AuthMethod::Any);
72}
static Ptr parse(const OptionList &opt)
Definition httpcli.hpp:103
void parse_from_config(const std::string &str, Limits *lim)
Definition options.hpp:985
TEST(HttpProxyClient, Options)