Skip to content

Commit 9d483a6

Browse files
committed
Making more of our manual test cases automated, particularly around ssl certificate validation.
1 parent d63f7f7 commit 9d483a6

File tree

5 files changed

+72
-64
lines changed

5 files changed

+72
-64
lines changed

Release/tests/Functional/http/client/authentication_tests.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace tests { namespace functional { namespace http { namespace client {
5050
SUITE(authentication_tests)
5151
{
5252

53-
TEST_FIXTURE(uri_address, auth_no_data, "Ignore:Linux", "698420", "Ignore:Apple", "698420")
53+
TEST_FIXTURE(uri_address, auth_no_data, "Ignore:Linux", "89", "Ignore:Apple", "89")
5454
{
5555
test_http_server::scoped_server scoped(m_uri);
5656
http_client_config client_config;
@@ -89,7 +89,7 @@ TEST_FIXTURE(uri_address, auth_no_data, "Ignore:Linux", "698420", "Ignore:Apple"
8989

9090
// TFS 648783
9191
#ifndef __cplusplus_winrt
92-
TEST_FIXTURE(uri_address, proxy_auth_known_contentlength, "Ignore:Linux", "646268", "Ignore:Apple", "646268")
92+
TEST_FIXTURE(uri_address, proxy_auth_known_contentlength, "Ignore:Linux", "88", "Ignore:Apple", "88")
9393
{
9494
test_http_server::scoped_server scoped(m_uri);
9595
http_client_config client_config;
@@ -130,9 +130,7 @@ TEST_FIXTURE(uri_address, proxy_auth_known_contentlength, "Ignore:Linux", "64626
130130
}
131131
#endif
132132

133-
TEST_FIXTURE(uri_address, proxy_auth_noseek,
134-
"Ignore:Linux", "646268",
135-
"Ignore:Apple", "646268")
133+
TEST_FIXTURE(uri_address, proxy_auth_noseek, "Ignore:Linux", "88", "Ignore:Apple", "88")
136134
{
137135
web::http::uri uri(U("http://localhost:34567/"));
138136
test_http_server::scoped_server scoped(uri);
@@ -164,9 +162,7 @@ TEST_FIXTURE(uri_address, proxy_auth_noseek,
164162

165163
// Must specify content length with winrt client, so this test case isn't possible.
166164
#ifndef __cplusplus_winrt
167-
TEST_FIXTURE(uri_address, proxy_auth_unknown_contentlength,
168-
"Ignore:Linux", "646268",
169-
"Ignore:Apple", "646268")
165+
TEST_FIXTURE(uri_address, proxy_auth_unknown_contentlength, "Ignore:Linux", "88", "Ignore:Apple", "88")
170166
{
171167
test_http_server::scoped_server scoped(m_uri);
172168
http_client_config client_config;
@@ -237,7 +233,7 @@ TEST_FIXTURE(uri_address, empty_username_password)
237233
// Fails on WinRT due to TFS 648278
238234
// Accessing a server that supports auth, but returns 401, even after the user has provided valid creds
239235
// We're making sure the error is reported properly, and the response data from the second response is received
240-
TEST_FIXTURE(uri_address, error_after_valid_credentials, "Ignore:Linux", "646268", "Ignore:Apple", "646268")
236+
TEST_FIXTURE(uri_address, error_after_valid_credentials, "Ignore:Linux", "89", "Ignore:Apple", "89")
241237
{
242238
web::http::uri uri(U("http://localhost:34569/"));
243239
test_http_server::scoped_server scoped(uri);
@@ -398,6 +394,7 @@ TEST_FIXTURE(server_properties, successful_auth_with_domain_cred, "Requires", "S
398394
VERIFY_ARE_EQUAL(status_codes::OK, response.status_code());
399395
}
400396

397+
#ifndef __cplusplus_winrt // WinRT implementation doesn't support request buffer caching.
401398
TEST_FIXTURE(server_properties, failed_authentication_resend_request_error, "Requires", "Server;UserName;Password")
402399
{
403400
load_parameters();
@@ -414,14 +411,11 @@ TEST_FIXTURE(server_properties, failed_authentication_resend_request_error, "Req
414411
http_request request;
415412
request.set_method(methods::POST);
416413
request.set_body(data);
417-
auto responseTask = client.request(request);
418-
419-
http_response response;
420-
421-
response = responseTask.get();
414+
http_response response = client.request(request).get();
422415

423416
VERIFY_ARE_EQUAL(200, response.status_code());
424417
}
418+
#endif
425419

426420
#ifdef __cplusplus_winrt
427421
TEST_FIXTURE(uri_address, set_user_options_winrt)
@@ -604,7 +598,7 @@ TEST_FIXTURE(uri_address, set_user_options_exceptions)
604598
#pragma endregion
605599

606600
// Fix for 522831 AV after failed authentication attempt
607-
TEST_FIXTURE(uri_address, failed_authentication_attempt, "Ignore:Linux", "698420", "Ignore:Apple", "698420")
601+
TEST_FIXTURE(uri_address, failed_authentication_attempt, "Ignore:Linux", "89", "Ignore:Apple", "89")
608602
{
609603
http_client_config config;
610604
credentials cred(U("user"),U("schmuser"));

Release/tests/Functional/http/client/connections_and_errors.cpp

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -165,28 +165,6 @@ TEST_FIXTURE(uri_address, handshake_fail)
165165
VERIFY_THROWS(request.get(), http_exception);
166166
}
167167

168-
#if !defined(__cplusplus_winrt)
169-
// Test case needs a server with invalid certificate running.
170-
TEST(server_cert_invalid, "Ignore", "Manual")
171-
{
172-
http_client client(U("https://localhost"));
173-
174-
auto requestTask = client.request(methods::GET);
175-
VERIFY_THROWS(requestTask.get(), http_exception);
176-
}
177-
178-
// Test case needs a server with invalid certificate running.
179-
TEST(ignore_server_cert_invalid, "Ignore", "Manual")
180-
{
181-
http_client_config config;
182-
config.set_validate_certificates(false);
183-
http_client client(U("https://localhost"), config);
184-
185-
auto request = client.request(methods::GET).get();
186-
VERIFY_ARE_EQUAL(status_codes::OK, request.status_code());
187-
}
188-
#endif
189-
190168
#if !defined(__cplusplus_winrt)
191169
// This test still sometimes segfaults on Linux, but I'm re-enabling it [AL]
192170
TEST_FIXTURE(uri_address, content_ready_timeout)
@@ -219,7 +197,7 @@ TEST_FIXTURE(uri_address, content_ready_timeout)
219197
listener.close().wait();
220198
}
221199

222-
TEST_FIXTURE(uri_address, stream_timeout, "Ignore:Apple", "Bug 885080")
200+
TEST_FIXTURE(uri_address, stream_timeout, "Ignore:Apple", "149")
223201
{
224202
web::http::experimental::listener::http_listener listener(m_uri);
225203
listener.open().wait();
@@ -386,18 +364,6 @@ TEST_FIXTURE(uri_address, cancel_while_downloading_data)
386364
}
387365
#endif
388366

389-
TEST_FIXTURE(uri_address, no_transfer_encoding_content_length, "Ignore", "Manual")
390-
{
391-
http_client client(U("http://ws.audioscrobbler.com/2.0/?method=artist.gettoptracks&artist=cher&api_key=6fcd59047568e89b1615975081258990&format=json"));
392-
393-
client.request(methods::GET).then([](http_response response){
394-
VERIFY_IS_FALSE(response.headers().has(header_names::content_length)
395-
&& response.headers().has(header_names::transfer_encoding));
396-
return response.extract_string();
397-
}).then([](string_t result){
398-
VERIFY_ARE_EQUAL(result.size(), 34686); // hardcoded the content size here, need to check the correct number for manual test.
399-
}).wait();
400-
}
401367
#pragma endregion
402368

403369
} // SUITE(connections_and_errors)

Release/tests/Functional/http/client/outside_tests.cpp

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ namespace tests { namespace functional { namespace http { namespace client {
4040
SUITE(outside_tests)
4141
{
4242

43-
TEST_FIXTURE(uri_address, outside_cnn_dot_com,
44-
"Ignore", "Manual")
43+
TEST_FIXTURE(uri_address, outside_cnn_dot_com)
4544
{
4645
http_client client(U("http://www.cnn.com"));
4746

@@ -62,8 +61,7 @@ TEST_FIXTURE(uri_address, outside_cnn_dot_com,
6261
#endif
6362
}
6463

65-
TEST_FIXTURE(uri_address, outside_google_dot_com,
66-
"Ignore", "Manual")
64+
TEST_FIXTURE(uri_address, outside_google_dot_com)
6765
{
6866
http_client client(U("http://www.google.com"));
6967

@@ -84,8 +82,7 @@ TEST_FIXTURE(uri_address, outside_google_dot_com,
8482
#endif
8583
}
8684

87-
TEST_FIXTURE(uri_address, reading_google_stream,
88-
"Ignore", "Manual")
85+
TEST_FIXTURE(uri_address, reading_google_stream)
8986
{
9087
http_client simpleclient(U("http://www.google.com"));
9188
utility::string_t path = m_uri.query();
@@ -100,8 +97,62 @@ TEST_FIXTURE(uri_address, reading_google_stream,
10097
VERIFY_ARE_EQUAL(strcmp((const char *)chars, "<!doctype html><html itemscope=\"\" itemtype=\"http://schema.org/WebPage\""), 0);
10198
}
10299

103-
TEST_FIXTURE(uri_address, outside_ssl_json,
104-
"Ignore", "Manual")
100+
TEST_FIXTURE(uri_address, no_transfer_encoding_content_length)
101+
{
102+
http_client client(U("http://ws.audioscrobbler.com/2.0/?method=artist.gettoptracks&artist=cher&api_key=6fcd59047568e89b1615975081258990&format=json"));
103+
104+
client.request(methods::GET).then([](http_response response){
105+
VERIFY_ARE_EQUAL(response.status_code(), status_codes::OK);
106+
VERIFY_IS_FALSE(response.headers().has(header_names::content_length)
107+
&& response.headers().has(header_names::transfer_encoding));
108+
return response.extract_string();
109+
}).then([](string_t result){
110+
// Verify that the body size isn't empty.
111+
VERIFY_IS_TRUE(result.size() > 0);
112+
}).wait();
113+
}
114+
115+
// Note additional sites for testing can be found at:
116+
// https://www.ssllabs.com/ssltest/
117+
// http://www.internetsociety.org/deploy360/resources/dane-test-sites/
118+
// https://onlinessl.netlock.hu/#
119+
TEST(server_selfsigned_cert, "Ignore:Android", "SSL certs not implemented")
120+
{
121+
http_client client(U("https://www.pcwebshop.co.uk/"));
122+
auto requestTask = client.request(methods::GET);
123+
VERIFY_THROWS(requestTask.get(), http_exception);
124+
}
125+
126+
TEST(server_hostname_mismatch, "Ignore:Android", "SSL certs not implemented")
127+
{
128+
http_client client(U("https://swordsoftruth.com/"));
129+
auto requestTask = client.request(methods::GET);
130+
VERIFY_THROWS(requestTask.get(), http_exception);
131+
}
132+
133+
TEST(server_cert_expired, "Ignore:Android", "SSL certs not implemented")
134+
{
135+
http_client client(U("https://tv.eurosport.com/"));
136+
auto requestTask = client.request(methods::GET);
137+
VERIFY_THROWS(requestTask.get(), http_exception);
138+
}
139+
140+
#if !defined(__cplusplus_winrt)
141+
TEST(ignore_server_cert_invalid,
142+
"Ignore:Android", "229",
143+
"Ignore:Apple", "229",
144+
"Ignore:Linux", "229")
145+
{
146+
http_client_config config;
147+
config.set_validate_certificates(false);
148+
http_client client(U("https://www.pcwebshop.co.uk/"), config);
149+
150+
auto request = client.request(methods::GET).get();
151+
VERIFY_ARE_EQUAL(status_codes::OK, request.status_code());
152+
}
153+
#endif
154+
155+
TEST_FIXTURE(uri_address, outside_ssl_json, "Ignore:Android", "SSL certs not implemented")
105156
{
106157
// Create URI for:
107158
// https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUF1hMUVwlrvlVMjUGOZExgg&key=AIzaSyAviHxf_y0SzNoAq3iKqvWVE4KQ0yylsnk

Release/tests/Functional/http/client/proxy_tests.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,8 @@ TEST_FIXTURE(uri_address, no_proxy_options_on_winrt)
8686

8787
VERIFY_THROWS(client.request(methods::GET, U("/")).get(), http_exception);
8888
}
89-
#endif
9089

91-
// Test is disabled since one time the office site was unavaliable.
92-
// We want 100% reliability in our automated test cases.
93-
TEST_FIXTURE(uri_address, proxy_with_credentials,
94-
"Ignore", "Manual")
90+
TEST_FIXTURE(uri_address, proxy_with_credentials)
9591
{
9692
uri u(U("http://netproxy.redmond.corp.microsoft.com"));
9793

@@ -112,6 +108,7 @@ TEST_FIXTURE(uri_address, proxy_with_credentials,
112108
VERIFY_ARE_EQUAL(status_codes::OK, response.status_code());
113109
response.content_ready().wait();
114110
}
111+
#endif
115112

116113
} // SUITE(proxy_tests)
117114

Release/tests/Functional/websockets/client/authentication_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ TEST_FIXTURE(uri_address, auth_with_credentials, "Ignore:Linux", "NYI", "Ignore:
8484
}
8585

8686
// Send and receive text message over SSL
87-
TEST_FIXTURE(uri_address, ssl_test, "Ignore", "Manual")
87+
TEST_FIXTURE(uri_address, ssl_test)
8888
{
8989
websocket_client client;
9090
client.connect(U("wss://echo.websocket.org/")).wait();

0 commit comments

Comments
 (0)