@@ -21,47 +21,106 @@ using namespace tests::functional::http::utilities;
21
21
22
22
namespace tests { namespace functional { namespace http { namespace client {
23
23
24
+ // In order to run this test, replace this proxy uri with one that you have access to.
25
+ static const auto proxy_uri = U(" http://netproxy.redmond.corp.microsoft.com" );
26
+
24
27
SUITE (proxy_tests)
25
28
{
26
29
30
+ TEST_FIXTURE (uri_address, web_proxy_uri)
31
+ {
32
+ uri u (proxy_uri);
33
+
34
+ web_proxy uri_proxy (u);
35
+ VERIFY_IS_TRUE (uri_proxy.is_specified ());
36
+ VERIFY_IS_FALSE (uri_proxy.is_disabled ());
37
+ VERIFY_IS_FALSE (uri_proxy.is_auto_discovery ());
38
+ VERIFY_IS_FALSE (uri_proxy.is_default ());
39
+ VERIFY_ARE_EQUAL (u, uri_proxy.address ());
40
+ }
41
+
42
+ TEST_FIXTURE (uri_address, web_proxy_disabled)
43
+ {
44
+ web_proxy disabled_proxy (web_proxy::disabled);
45
+ VERIFY_IS_FALSE (disabled_proxy.is_specified ());
46
+ VERIFY_IS_TRUE (disabled_proxy.is_disabled ());
47
+ VERIFY_IS_FALSE (disabled_proxy.is_auto_discovery ());
48
+ VERIFY_IS_FALSE (disabled_proxy.is_default ());
49
+ }
50
+
51
+ TEST_FIXTURE (uri_address, web_proxy_discover)
52
+ {
53
+ web_proxy discover_proxy (web_proxy::use_auto_discovery);
54
+ VERIFY_IS_FALSE (discover_proxy.is_specified ());
55
+ VERIFY_IS_FALSE (discover_proxy.is_disabled ());
56
+ VERIFY_IS_TRUE (discover_proxy.is_auto_discovery ());
57
+ VERIFY_IS_FALSE (discover_proxy.is_default ());
58
+ }
59
+
60
+ TEST_FIXTURE (uri_address, web_proxy_default)
61
+ {
62
+ web_proxy default_proxy (web_proxy::use_default);
63
+ VERIFY_IS_FALSE (default_proxy.is_specified ());
64
+ VERIFY_IS_FALSE (default_proxy.is_disabled ());
65
+ VERIFY_IS_FALSE (default_proxy.is_auto_discovery ());
66
+ VERIFY_IS_TRUE (default_proxy.is_default ());
67
+ }
68
+
69
+ TEST_FIXTURE (uri_address, web_proxy_default_construct)
70
+ {
71
+ web_proxy default_proxy_2;
72
+ VERIFY_IS_FALSE (default_proxy_2.is_specified ());
73
+ VERIFY_IS_FALSE (default_proxy_2.is_disabled ());
74
+ VERIFY_IS_FALSE (default_proxy_2.is_auto_discovery ());
75
+ VERIFY_IS_TRUE (default_proxy_2.is_default ());
76
+ }
77
+
78
+ TEST_FIXTURE (uri_address, http_client_config_set_proxy)
79
+ {
80
+ http_client_config hconfig;
81
+ VERIFY_IS_TRUE (hconfig.proxy ().is_default ());
82
+
83
+ uri u = U (" http://x" );
84
+
85
+ hconfig.set_proxy (web_proxy (u));
86
+ VERIFY_ARE_EQUAL (u, hconfig.proxy ().address ());
87
+ }
88
+
27
89
#ifndef __cplusplus_winrt
28
90
// IXHR2 does not allow the proxy settings to be changed
29
91
TEST_FIXTURE (uri_address, auto_discovery_proxy)
30
92
{
31
93
test_http_server::scoped_server scoped (m_uri);
32
- scoped.server ()->next_request ().then ([&](test_request *p_request)
94
+ auto t = scoped.server ()->next_request ().then ([&](test_request *p_request)
33
95
{
34
96
http_asserts::assert_test_request_equals (p_request, methods::PUT, U (" /" ), U (" text/plain" ), U (" this is a test" ));
35
- p_request->reply (200 );
97
+ p_request->reply (status_codes::OK );
36
98
});
37
99
http_client_config config;
38
-
39
100
config.set_proxy (web_proxy::use_auto_discovery);
40
- VERIFY_IS_FALSE (config.proxy ().is_disabled ());
41
- VERIFY_IS_FALSE (config.proxy ().is_specified ());
42
- http_client client (m_uri, config);
43
101
102
+ http_client client (m_uri, config);
44
103
http_asserts::assert_response_equals (client.request (methods::PUT, U (" /" ), U (" this is a test" )).get (), status_codes::OK);
104
+
105
+ t.get ();
45
106
}
46
107
47
108
TEST_FIXTURE (uri_address, disabled_proxy)
48
109
{
49
110
test_http_server::scoped_server scoped (m_uri);
50
- scoped.server ()->next_request ().then ([&](test_request *p_request)
111
+ auto t = scoped.server ()->next_request ().then ([&](test_request *p_request)
51
112
{
52
113
http_asserts::assert_test_request_equals (p_request, methods::PUT, U (" /" ), U (" text/plain" ), U (" sample data" ));
53
114
p_request->reply (status_codes::OK);
54
115
});
55
116
56
117
http_client_config config;
57
- config.set_proxy (web_proxy (web_proxy::disabled));
58
- VERIFY_IS_TRUE (config.proxy ().is_disabled ());
59
- VERIFY_IS_FALSE (config.proxy ().is_auto_discovery ());
60
- VERIFY_IS_FALSE (config.proxy ().is_specified ());
61
- VERIFY_IS_FALSE (config.proxy ().is_default ());
118
+ config.set_proxy (web_proxy::disabled);
62
119
63
120
http_client client (m_uri, config);
64
121
http_asserts::assert_response_equals (client.request (methods::PUT, U (" /" ), U (" sample data" )).get (), status_codes::OK);
122
+
123
+ t.get ();
65
124
}
66
125
67
126
#endif // __cplusplus_winrt
@@ -79,13 +138,9 @@ TEST_FIXTURE(uri_address, no_proxy_options_on_winrt)
79
138
80
139
#ifndef __cplusplus_winrt
81
140
// Can't specify a proxy with WinRT implementation.
82
- TEST_FIXTURE (uri_address, http_proxy_with_credentials, " Ignore:Linux" , " Github 53" , " Ignore:Apple" , " Github 53" , " Ignore:Android" , " Github 53" , " Ignore:IOS" , " Github 53" )
141
+ TEST_FIXTURE (uri_address, http_proxy_with_credentials, " Ignore:Linux" , " Github 53" , " Ignore:Apple" , " Github 53" , " Ignore:Android" , " Github 53" , " Ignore:IOS" , " Github 53" , " Ignore " , " Manual " )
83
142
{
84
- uri u (U (" http://netproxy.redmond.corp.microsoft.com" ));
85
-
86
- web_proxy proxy (u);
87
- VERIFY_IS_TRUE (proxy.is_specified ());
88
- VERIFY_ARE_EQUAL (u, proxy.address ());
143
+ web_proxy proxy (proxy_uri);
89
144
web::credentials cred (U (" artur" ), U (" fred" )); // relax, this is not my real password
90
145
proxy.set_credentials (cred);
91
146
@@ -116,15 +171,9 @@ TEST_FIXTURE(uri_address, no_proxy_options_on_winrt)
116
171
117
172
TEST_FIXTURE (uri_address, http_proxy, " Ignore" , " Manual" )
118
173
{
119
- // In order to run this test, replace this proxy uri with one that you have access to.
120
- uri u (U (" http://netproxy.redmond.corp.microsoft.com" ));
121
-
122
- web_proxy proxy (u);
123
- VERIFY_IS_TRUE (proxy.is_specified ());
124
- VERIFY_ARE_EQUAL (u, proxy.address ());
125
174
126
175
http_client_config config;
127
- config.set_proxy (proxy );
176
+ config.set_proxy (web_proxy (proxy_uri) );
128
177
129
178
http_client client (U (" http://httpbin.org" ), config);
130
179
@@ -136,15 +185,8 @@ TEST_FIXTURE(uri_address, http_proxy, "Ignore", "Manual")
136
185
137
186
TEST_FIXTURE (uri_address, https_proxy, " Ignore" , " Manual" )
138
187
{
139
- // In order to run this test, replace this proxy uri with one that you have access to.
140
- uri u (U (" http://netproxy.redmond.corp.microsoft.com" ));
141
-
142
- web_proxy proxy (u);
143
- VERIFY_IS_TRUE (proxy.is_specified ());
144
- VERIFY_ARE_EQUAL (u, proxy.address ());
145
-
146
188
http_client_config config;
147
- config.set_proxy (proxy );
189
+ config.set_proxy (web_proxy (proxy_uri) );
148
190
149
191
http_client client (U (" https://httpbin.org" ), config);
150
192
0 commit comments