Skip to content

Commit 4ae5fb9

Browse files
committed
unit tests now build again
1 parent 17cc582 commit 4ae5fb9

File tree

2 files changed

+10
-53
lines changed

2 files changed

+10
-53
lines changed

test/unit/test/sansio/handshake/handshake_csha2p_hash_password.cpp

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <boost/mysql/impl/internal/sansio/caching_sha2_password.hpp>
1111

1212
#include "test_common/assert_buffer_equals.hpp"
13-
#include "test_common/printing.hpp"
1413

1514
using namespace boost::mysql;
1615
using namespace boost::mysql::test;
@@ -21,46 +20,25 @@ namespace {
2120
BOOST_AUTO_TEST_SUITE(test_handshake_csha2p_hash_password)
2221

2322
// Values snooped using the MySQL Python connector
24-
constexpr std::uint8_t challenge[20] = {
23+
// TODO: this doesn't make a lot of sense as a separate test now
24+
constexpr std::uint8_t scramble[20] = {
2525
0x3e, 0x3b, 0x4, 0x55, 0x4, 0x70, 0x16, 0x3a, 0x4c, 0x15,
2626
0x35, 0x3, 0x15, 0x76, 0x73, 0x22, 0x46, 0x8, 0x18, 0x1,
2727
};
2828

29-
constexpr std::uint8_t expected[32] = {
29+
constexpr std::uint8_t hash[32] = {
3030
0xa1, 0xc1, 0xe1, 0xe9, 0x1b, 0xb6, 0x54, 0x4b, 0xa7, 0x37, 0x4b, 0x9c, 0x56, 0x6d, 0x69, 0x3e,
3131
0x6, 0xca, 0x7, 0x2, 0x98, 0xac, 0xd1, 0x6, 0x18, 0xc6, 0x90, 0x38, 0x9d, 0x88, 0xe1, 0x20,
3232
};
3333

3434
BOOST_AUTO_TEST_CASE(nonempty_password)
3535
{
36-
auto res = csha2p_hash_password("hola", challenge);
37-
BOOST_MYSQL_ASSERT_BUFFER_EQUALS(res.value(), expected);
36+
BOOST_MYSQL_ASSERT_BUFFER_EQUALS(csha2p_hash_password("hola", scramble), hash);
3837
}
3938

4039
BOOST_AUTO_TEST_CASE(empty_password)
4140
{
42-
auto res = csha2p_hash_password("", challenge);
43-
BOOST_MYSQL_ASSERT_BUFFER_EQUALS(res.value(), std::vector<std::uint8_t>());
44-
}
45-
46-
BOOST_AUTO_TEST_CASE(bad_challenge_length_nonempty_password)
47-
{
48-
constexpr std::uint8_t bad_challenge[] = {0x00, 0x01, 0x02};
49-
auto res = csha2p_hash_password("hola", bad_challenge);
50-
BOOST_TEST(res.error() == client_errc::protocol_value_error);
51-
}
52-
53-
BOOST_AUTO_TEST_CASE(bad_challenge_length_nempty_password)
54-
{
55-
constexpr std::uint8_t bad_challenge[] = {0x00, 0x01, 0x02};
56-
auto res = csha2p_hash_password("", bad_challenge);
57-
BOOST_TEST(res.error() == client_errc::protocol_value_error);
58-
}
59-
60-
BOOST_AUTO_TEST_CASE(empty_challenge)
61-
{
62-
auto res = csha2p_hash_password("", {});
63-
BOOST_TEST(res.error() == client_errc::protocol_value_error);
41+
BOOST_MYSQL_ASSERT_BUFFER_EQUALS(csha2p_hash_password("", scramble), std::vector<std::uint8_t>());
6442
}
6543

6644
BOOST_AUTO_TEST_SUITE_END()

test/unit/test/sansio/handshake/handshake_mnp_hash_password.cpp

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,25 @@ namespace {
2020

2121
BOOST_AUTO_TEST_SUITE(test_handshake_mnp_hash_password)
2222

23+
// TODO: this doesn't make a lot of sense as a separate test now
2324
// Values snooped using Wireshark
24-
constexpr std::uint8_t challenge[20] = {
25+
constexpr std::uint8_t scramble[20] = {
2526
0x79, 0x64, 0x3d, 0x12, 0x1d, 0x71, 0x74, 0x47, 0x5f, 0x48,
2627
0x3e, 0x3e, 0x0b, 0x62, 0x0a, 0x03, 0x3d, 0x27, 0x3a, 0x4c,
2728
};
28-
constexpr std::uint8_t expected[20] = {
29+
constexpr std::uint8_t hash[20] = {
2930
0xf1, 0xb2, 0xfb, 0x1c, 0x8d, 0xe7, 0x5d, 0xb8, 0xeb, 0xa8,
3031
0x12, 0x6a, 0xd1, 0x0f, 0xe9, 0xb1, 0x10, 0x50, 0xd4, 0x28,
3132
};
3233

3334
BOOST_AUTO_TEST_CASE(nonempty_password)
3435
{
35-
auto res = mnp_hash_password("root", challenge);
36-
BOOST_MYSQL_ASSERT_BUFFER_EQUALS(res.value(), expected);
36+
BOOST_MYSQL_ASSERT_BUFFER_EQUALS(mnp_hash_password("root", scramble), hash);
3737
}
3838

3939
BOOST_AUTO_TEST_CASE(empty_password)
4040
{
41-
auto res = mnp_hash_password("", challenge);
42-
BOOST_MYSQL_ASSERT_BUFFER_EQUALS(res.value(), std::vector<std::uint8_t>());
43-
}
44-
45-
BOOST_AUTO_TEST_CASE(bad_challenge_length_nonempty_password)
46-
{
47-
constexpr std::uint8_t bad_challenge[] = {0x01, 0x02, 0x03};
48-
auto res = mnp_hash_password("root", bad_challenge);
49-
BOOST_TEST(res.error() == client_errc::protocol_value_error);
50-
}
51-
52-
BOOST_AUTO_TEST_CASE(bad_challenge_length_empty_password)
53-
{
54-
constexpr std::uint8_t bad_challenge[] = {0x01, 0x02, 0x03};
55-
auto res = mnp_hash_password("", bad_challenge);
56-
BOOST_TEST(res.error() == client_errc::protocol_value_error);
57-
}
58-
59-
BOOST_AUTO_TEST_CASE(empty_challenge)
60-
{
61-
auto res = mnp_hash_password("root", {});
62-
BOOST_TEST(res.error() == client_errc::protocol_value_error);
41+
BOOST_MYSQL_ASSERT_BUFFER_EQUALS(mnp_hash_password("", scramble), std::vector<std::uint8_t>());
6342
}
6443

6544
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)