10
10
#include < boost/mysql/impl/internal/sansio/caching_sha2_password.hpp>
11
11
12
12
#include " test_common/assert_buffer_equals.hpp"
13
- #include " test_common/printing.hpp"
14
13
15
14
using namespace boost ::mysql;
16
15
using namespace boost ::mysql::test;
@@ -21,46 +20,25 @@ namespace {
21
20
BOOST_AUTO_TEST_SUITE (test_handshake_csha2p_hash_password)
22
21
23
22
// 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 ] = {
25
25
0x3e , 0x3b , 0x4 , 0x55 , 0x4 , 0x70 , 0x16 , 0x3a , 0x4c , 0x15 ,
26
26
0x35 , 0x3 , 0x15 , 0x76 , 0x73 , 0x22 , 0x46 , 0x8 , 0x18 , 0x1 ,
27
27
};
28
28
29
- constexpr std::uint8_t expected [32 ] = {
29
+ constexpr std::uint8_t hash [32 ] = {
30
30
0xa1 , 0xc1 , 0xe1 , 0xe9 , 0x1b , 0xb6 , 0x54 , 0x4b , 0xa7 , 0x37 , 0x4b , 0x9c , 0x56 , 0x6d , 0x69 , 0x3e ,
31
31
0x6 , 0xca , 0x7 , 0x2 , 0x98 , 0xac , 0xd1 , 0x6 , 0x18 , 0xc6 , 0x90 , 0x38 , 0x9d , 0x88 , 0xe1 , 0x20 ,
32
32
};
33
33
34
34
BOOST_AUTO_TEST_CASE (nonempty_password)
35
35
{
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);
38
37
}
39
38
40
39
BOOST_AUTO_TEST_CASE (empty_password)
41
40
{
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 >());
64
42
}
65
43
66
44
BOOST_AUTO_TEST_SUITE_END ()
0 commit comments