Skip to content

Commit f2d22aa

Browse files
committed
Merge remote-tracking branch 'origin/development' into android-clang-3
2 parents de4879b + f19c099 commit f2d22aa

File tree

4 files changed

+76
-30
lines changed

4 files changed

+76
-30
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/***
22
* ==++==
33
*
4-
* Copyright (c) Microsoft Corporation. All rights reserved.
4+
* Copyright (c) Microsoft Corporation. All rights reserved.
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
77
* You may obtain a copy of the License at
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,7 +37,7 @@
3737
#endif
3838
#endif
3939

40-
using namespace web;
40+
using namespace web;
4141
using namespace utility;
4242
using namespace concurrency;
4343
using namespace web::http;
@@ -76,7 +76,7 @@ TEST_FIXTURE(uri_address, auth_no_data, "Ignore:Linux", "89", "Ignore:Apple", "8
7676
headers[U("WWW-Authenticate")] = U("Basic realm = \"WallyWorld\"");
7777

7878
// unauthorized
79-
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers);
79+
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers);
8080

8181
}).then([&scoped, replyFunc]()
8282
{
@@ -118,7 +118,7 @@ TEST_FIXTURE(uri_address, proxy_auth_known_contentlength, "Ignore:Linux", "88",
118118
headers[U("WWW-Authenticate")] = U("Basic realm = \"WallyWorld\"");
119119

120120
// unauthorized
121-
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers);
121+
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers);
122122

123123
}).then([&scoped, replyFunc]()
124124
{
@@ -153,7 +153,7 @@ TEST_FIXTURE(uri_address, proxy_auth_noseek, "Ignore:Linux", "88", "Ignore:Apple
153153
headers[U("WWW-Authenticate")] = U("Basic realm = \"WallyWorld\"");
154154

155155
// unauthorized
156-
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers);
156+
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers);
157157

158158
});
159159

@@ -194,7 +194,7 @@ TEST_FIXTURE(uri_address, proxy_auth_unknown_contentlength, "Ignore:Linux", "88"
194194
headers[U("WWW-Authenticate")] = U("Basic realm = \"WallyWorld\"");
195195

196196
// unauthorized
197-
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers);
197+
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers);
198198

199199
}).then([&scoped, replyFunc]()
200200
{
@@ -218,7 +218,7 @@ TEST_FIXTURE(uri_address, empty_username_password)
218218
// Auth header
219219
headers[U("WWW-Authenticate")] = U("Basic realm = \"myRealm\"");
220220
// unauthorized
221-
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers, "a" );
221+
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers, "a" );
222222
});
223223

224224
http_response response = client.request(methods::GET).get();
@@ -249,7 +249,7 @@ TEST_FIXTURE(uri_address, error_after_valid_credentials, "Ignore:Linux", "89", "
249249
headers[U("WWW-Authenticate")] = U("Basic realm = \"WallyWorld\"");
250250
headers[U("h1")] = U("data2");
251251
// still unauthorized after the user has resent the request with the credentials
252-
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers, "def" );
252+
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers, "def" );
253253
};
254254

255255
scoped.server()->next_request().then([&](test_request *p_request)
@@ -259,7 +259,7 @@ TEST_FIXTURE(uri_address, error_after_valid_credentials, "Ignore:Linux", "89", "
259259
// Auth header
260260
headers[U("WWW-Authenticate")] = U("Basic realm = \"myRealm\"");
261261
// unauthorized
262-
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers, "abc" );
262+
p_request->reply(status_codes::Unauthorized, U("Authentication Failed"), headers, "abc" );
263263
}).then([&scoped, &replyFunc]()
264264
{
265265
// Client resent the request
@@ -348,7 +348,7 @@ TEST_FIXTURE(server_properties, unsuccessful_auth_with_basic_cred, "Requires", "
348348

349349
http_client_config config;
350350
config.set_credentials(credentials(m_username, m_password));
351-
351+
352352
http_client client(m_uri, config);
353353
http_response response = client.request(methods::GET).get();
354354
VERIFY_ARE_EQUAL(status_codes::Unauthorized, response.status_code());
@@ -423,7 +423,7 @@ TEST_FIXTURE(uri_address, set_user_options_winrt)
423423
test_http_server::scoped_server scoped(m_uri);
424424
scoped.server()->next_request().then([](test_request *p_request)
425425
{
426-
p_request->reply(status_codes::OK);
426+
p_request->reply(status_codes::OK);
427427
});
428428

429429
http_client_config config;
@@ -451,7 +451,7 @@ TEST_FIXTURE(server_properties, set_user_options, "Requires", "Server;UserName;P
451451
DWORD policy = WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW;
452452
if (!WinHttpSetOption(handle,
453453
WINHTTP_OPTION_AUTOLOGON_POLICY,
454-
&policy,
454+
&policy,
455455
sizeof(policy)))
456456
{
457457
throw std::runtime_error("The Test Error");
@@ -595,7 +595,7 @@ TEST_FIXTURE(uri_address, set_user_options_exceptions)
595595
VERIFY_THROWS(client.request(methods::GET).get(), std::runtime_error);
596596
}
597597
#endif // _MS_WINDOWS
598-
#pragma endregion
598+
#pragma endregion
599599

600600
// Fix for 522831 AV after failed authentication attempt
601601
TEST_FIXTURE(uri_address, failed_authentication_attempt, "Ignore:Linux", "89", "Ignore:Apple", "89")

Release/tests/functional/streams/istream_tests.cpp

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/***
22
* ==++==
33
*
4-
* Copyright (c) Microsoft Corporation. All rights reserved.
4+
* Copyright (c) Microsoft Corporation. All rights reserved.
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
77
* You may obtain a copy of the License at
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,8 @@
2323
#include "unittestpp.h"
2424
#include "stdafx.h"
2525

26+
#include <float.h>
27+
2628
#if defined(__cplusplus_winrt)
2729
using namespace Windows::Storage;
2830
#endif
@@ -1280,6 +1282,31 @@ TEST(istream_extract_unsigned_long_long)
12801282
#endif
12811283
}
12821284

1285+
template <typename T>
1286+
void compare_floating(T expected, T actual, T relativeDiff)
1287+
{
1288+
// http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
1289+
if (expected != actual)
1290+
{
1291+
const auto diff = fabs(expected - actual);
1292+
const auto absExpected = fabs(expected);
1293+
const auto absActual = fabs(actual);
1294+
const auto largest = absExpected > absActual ? absExpected : absActual;
1295+
if (diff > largest * relativeDiff)
1296+
{
1297+
VERIFY_IS_TRUE(false);
1298+
}
1299+
}
1300+
}
1301+
void compare_double(double expected, double actual)
1302+
{
1303+
compare_floating(expected, actual, DBL_EPSILON);
1304+
}
1305+
void compare_float(float expected, float actual)
1306+
{
1307+
compare_floating(expected, actual, FLT_EPSILON);
1308+
}
1309+
12831310
TEST(extract_floating_point)
12841311
{
12851312
std::string test_string;
@@ -1310,13 +1337,14 @@ TEST(extract_floating_point)
13101337

13111338
do
13121339
{
1313-
double expected=0, actual;
1340+
double expected = 0;
13141341
std_istream >> expected;
13151342

1316-
VERIFY_ARE_EQUAL(expected, actual = istream_double.extract<double>().get());
1343+
const auto actual = istream_double.extract<double>().get();
1344+
compare_double(expected, actual);
13171345

13181346
if (actual <= std::numeric_limits<float>::max())
1319-
VERIFY_ARE_EQUAL(float(expected), istream_float.extract<float>().get());
1347+
compare_float(float(expected), istream_float.extract<float>().get());
13201348
else
13211349
VERIFY_THROWS(istream_float.extract<float>().get(), std::exception);
13221350

Release/tests/functional/utils/datetime.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ SUITE(datetime)
3535
// This is by no means a comprehensive test suite for the datetime functionality.
3636
// It's a response to a particular bug and should be amended over time.
3737

38+
// CodePlex 311
39+
#if !defined(_MS_WINDOWS) || (defined(_MSC_VER) && _MSC_VER < 1900)
3840
TEST(parsing_dateandtime_basic)
3941
{
4042
// ISO 8601
@@ -62,6 +64,7 @@ TEST(parsing_dateandtime_extended)
6264

6365
VERIFY_ARE_EQUAL(dt1.to_interval(), dt2.to_interval());
6466
}
67+
#endif
6568

6669
TEST(parsing_date_basic)
6770
{

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

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/***
22
* ==++==
33
*
4-
* Copyright (c) Microsoft Corporation. All rights reserved.
4+
* Copyright (c) Microsoft Corporation. All rights reserved.
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
77
* You may obtain a copy of the License at
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,7 +44,7 @@ void auth_helper(test_websocket_server& server, const utility::string_t &usernam
4444
server.set_http_handler([username, password](test_http_request request)
4545
{
4646
test_http_response resp;
47-
if (request->username().empty()) // No credentials -> challenge the request
47+
if (request->username().empty()) // No credentials -> challenge the request
4848
{
4949
resp.set_status_code(401); // Unauthorized.
5050
resp.set_realm("My Realm");
@@ -86,6 +86,19 @@ TEST_FIXTURE(uri_address, auth_with_credentials, "Ignore", "245")
8686
}
8787
#endif
8888

89+
// helper function to check if failure is due to timeout.
90+
bool is_timeout(const std::string &msg)
91+
{
92+
if (msg.find("set_fail_handler") != std::string::npos)
93+
{
94+
if (msg.find("TLS handshake timed out") != std::string::npos || msg.find("Timer Expired") != std::string::npos)
95+
{
96+
return true;
97+
}
98+
}
99+
return false;
100+
}
101+
89102
TEST(ssl_test)
90103
{
91104
websocket_client client;
@@ -112,15 +125,11 @@ TEST(ssl_test)
112125
}
113126
catch (const websocket_exception &e)
114127
{
115-
const auto msg = std::string(e.what());
116-
if (msg.find("set_fail_handler") != std::string::npos)
128+
if (is_timeout(e.what()))
117129
{
118-
if (msg.find("TLS handshake timed out") != std::string::npos || msg.find("Timer Expired") != std::string::npos)
119-
{
120-
// Since this test depends on an outside server sometimes it sporadically can fail due to timeouts
121-
// especially on our build machines.
122-
return;
123-
}
130+
// Since this test depends on an outside server sometimes it sporadically can fail due to timeouts
131+
// especially on our build machines.
132+
return;
124133
}
125134
throw;
126135
}
@@ -139,6 +148,12 @@ void handshake_error_test_impl(const ::utility::string_t &host)
139148
}
140149
catch (const websocket_exception &e)
141150
{
151+
if (is_timeout(e.what()))
152+
{
153+
// Since this test depends on an outside server sometimes it sporadically can fail due to timeouts
154+
// especially on our build machines.
155+
return;
156+
}
142157
VERIFY_ARE_EQUAL("TLS handshake failed", e.error_code().message());
143158
}
144159
}

0 commit comments

Comments
 (0)