|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Tarantool Client package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Eugene Leonovich <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Tarantool\Client\Tests; |
|
15
|
|
|
|
|
16
|
|
|
final class GreetingDataProvider |
|
17
|
|
|
{ |
|
18
|
|
|
public static function provideGreetingsWithInvalidServerName() : iterable |
|
19
|
|
|
{ |
|
20
|
|
|
return [ |
|
21
|
|
|
[''], |
|
22
|
|
|
["\n"], |
|
23
|
|
|
['1'], |
|
24
|
|
|
['tarantool'], |
|
25
|
|
|
['Tarantoo'], |
|
26
|
|
|
['Тарантул'], |
|
27
|
|
|
[str_repeat('2', 63)."\n"], |
|
28
|
|
|
[str_repeat('3', 63)."\n3"], |
|
29
|
|
|
[str_repeat('4', 63)."\n\n"], |
|
30
|
|
|
[str_repeat('5', 63)."\n\n\n"], |
|
31
|
|
|
[str_repeat('6', 63)."\n".str_repeat('6', 63)."\n"], |
|
32
|
|
|
]; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public static function provideGreetingsWithInvalidSalt() : iterable |
|
36
|
|
|
{ |
|
37
|
|
|
return [ |
|
38
|
|
|
[str_pad('Tarantool', 63, '1')."\n"], |
|
39
|
|
|
[str_pad('Tarantool', 63, '2')."\n2"], |
|
40
|
|
|
[str_pad('Tarantool', 63, '3')."\n\n"], |
|
41
|
|
|
[str_pad('Tarantool', 63, '4')."\n\n\n"], |
|
42
|
|
|
[str_pad('Tarantool', 63, '5')."\nтутсолинеттутсолинеттутсолинеттутсолинеттутсолинеттутсолинеттут\n"], |
|
43
|
|
|
]; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public static function provideValidGreetings() : iterable |
|
47
|
|
|
{ |
|
48
|
|
|
return [ |
|
49
|
|
|
[self::generateGreeting('12345678901234567890'), '12345678901234567890'], |
|
50
|
|
|
]; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public static function generateGreeting(?string $salt = null) : string |
|
54
|
|
|
{ |
|
55
|
|
|
$salt = null === $salt ? substr(md5(uniqid()), 0, 20) : $salt; |
|
56
|
|
|
|
|
57
|
|
|
$greeting = str_pad('Tarantool 2.2.2 (Binary) 5e612e67-a9d2-4774-9709-31e44b40ffad', 63, ' ')."\n"; |
|
58
|
|
|
$greeting .= str_pad(base64_encode($salt.str_repeat('_', 12)), 63, ' ')."\n"; |
|
59
|
|
|
|
|
60
|
|
|
return $greeting; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|