Skip to content

Commit 5fc8f9b

Browse files
rybakitbigbes
authored andcommitted
Allow null as a password for the guest user (#79)
* Allow null as a password for the guest user * Update PHPUnit * Tweak data provider signrature in CreateTest * Update phpunit to the stable release * Fix typos
1 parent cd0f726 commit 5fc8f9b

File tree

3 files changed

+20964
-24451
lines changed

3 files changed

+20964
-24451
lines changed

src/tarantool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ PHP_METHOD(tarantool_class, authenticate) {
888888
char *login; int login_len;
889889
char *passwd = NULL; int passwd_len = 0;
890890

891-
TARANTOOL_PARSE_PARAMS(id, "s|s", &login, &login_len,
891+
TARANTOOL_PARSE_PARAMS(id, "s|s!", &login, &login_len,
892892
&passwd, &passwd_len);
893893
TARANTOOL_FETCH_OBJECT(obj, id);
894894
obj->login = pestrdup(login, 1);

test/CreateTest.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
class CreateTest extends PHPUnit_Framework_TestCase
34
{
45
protected static $port, $tm;
@@ -89,7 +90,7 @@ public function test_05_flush()
8990
* @expectedException Exception
9091
* @expectedExceptionMessage Query error
9192
*/
92-
public function test_06_bad_cridentials()
93+
public function test_06_bad_credentials()
9394
{
9495
$c = new Tarantool('localhost', self::$port);
9596
$c->connect();
@@ -101,7 +102,7 @@ public function test_06_bad_cridentials()
101102
* @expectedException Exception
102103
* @expectedExceptionMessage Query error
103104
*/
104-
public function test_07_bad_guest_cridentials()
105+
public function test_07_bad_guest_credentials()
105106
{
106107
$c = new Tarantool('localhost', self::$port);
107108
$c->connect();
@@ -113,20 +114,36 @@ public function test_07_bad_guest_cridentials()
113114
* @expectedException Exception
114115
* @expectedExceptionMessage Query error
115116
*/
116-
public function test_07_01_bad_guest_cridentials()
117+
public function test_07_01_bad_guest_credentials()
117118
{
118119
$c = new Tarantool('localhost', self::$port);
119120
$c->connect();
120121
$this->assertTrue($c->ping());
121122
$c->authenticate('guest', '');
122123
}
123124

124-
public function test_08_good_cridentials()
125+
/**
126+
* @dataProvider provideGoodCredentials
127+
*/
128+
public function test_08_good_credentials($username, $password = null)
125129
{
126130
$c = new Tarantool('localhost', self::$port);
127131
$c->connect();
128132
$this->assertTrue($c->ping());
129-
$c->authenticate('guest');
133+
134+
(1 === func_num_args())
135+
? $c->authenticate($username)
136+
: $c->authenticate($username, $password);
137+
130138
$this->assertTrue($c->ping());
131139
}
140+
141+
public static function provideGoodCredentials()
142+
{
143+
return [
144+
['guest'],
145+
['guest', null],
146+
];
147+
}
132148
}
149+

0 commit comments

Comments
 (0)