Skip to content

Commit c6ab308

Browse files
ptomuliknikic
authored andcommitted
fix some ext/ldap/tests
1 parent 2235286 commit c6ab308

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

ext/ldap/tests/connect.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ $host = getenv("LDAP_TEST_HOST") ?: "localhost";
99
$port = getenv("LDAP_TEST_PORT") ?: 389;
1010
$base = getenv("LDAP_TEST_BASE") ?: "dc=my-domain,dc=com";
1111
$user = getenv("LDAP_TEST_USER") ?: "cn=Manager,$base";
12-
$sasl_user = getenv("LDAP_TEST_SASL_USER") ?: "Manager";
1312
$passwd = getenv("LDAP_TEST_PASSWD") ?: "secret";
13+
$sasl_user = getenv("LDAP_TEST_SASL_USER") ?: "userA";
14+
$sasl_passwd = getenv("LDAP_TEST_SASL_PASSWD") ?: "oops";
1415
$protocol_version = getenv("LDAP_TEST_OPT_PROTOCOL_VERSION") ?: 3;
1516
$skip_on_bind_failure = getenv("LDAP_TEST_SKIP_BIND_FAILURE") ?: true;
1617

ext/ldap/tests/ldap_sasl_bind_basic.phpt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,22 @@ Patrick Allaert <patrickallaert@php.net>
1717
<?php
1818
require "connect.inc";
1919

20+
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
21+
insert_dummy_data($link, $base);
22+
ldap_unbind($link);
23+
2024
$link = ldap_connect($host, $port);
2125
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
22-
var_dump(ldap_sasl_bind($link, null, $passwd, 'DIGEST-MD5', 'realm', $sasl_user));
26+
var_dump(ldap_sasl_bind($link, null, $sasl_passwd, 'DIGEST-MD5', 'realm', $sasl_user));
2327
?>
2428
===DONE===
29+
--CLEAN--
30+
<?php
31+
include "connect.inc";
32+
33+
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
34+
remove_dummy_data($link, $base);
35+
?>
2536
--EXPECT--
2637
bool(true)
2738
===DONE===

ext/ldap/tests/ldap_sasl_bind_error.phpt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,38 @@ Patrick Allaert <patrickallaert@php.net>
1111
<?php
1212
require "connect.inc";
1313

14+
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
15+
insert_dummy_data($link, $base);
16+
ldap_unbind($link);
17+
1418
$link = ldap_connect($host, $port);
1519
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
1620

1721
// Invalid parameter count
1822
var_dump(ldap_sasl_bind());
1923

2024
// Invalid DN
21-
var_dump(ldap_sasl_bind($link, "Invalid DN", $passwd, 'DIGEST-MD5', 'realm', $sasl_user));
25+
var_dump(ldap_sasl_bind($link, "Invalid DN", $sasl_passwd, 'DIGEST-MD5', 'realm', $sasl_user));
2226

2327
// Invalid user
24-
var_dump(ldap_sasl_bind($link, null, "ThisIsNotCorrect$passwd", 'DIGEST-MD5', "realm", "invalid$sasl_user"));
28+
var_dump(ldap_sasl_bind($link, null, "ThisIsNotCorrect$sasl_passwd", 'DIGEST-MD5', "realm", "invalid$sasl_user"));
2529

2630
// Invalid password
27-
var_dump(ldap_sasl_bind($link, null, "ThisIsNotCorrect$passwd", 'DIGEST-MD5', "realm", $sasl_user));
31+
var_dump(ldap_sasl_bind($link, null, "ThisIsNotCorrect$sasl_passwd", 'DIGEST-MD5', "realm", $sasl_user));
2832

29-
var_dump(ldap_sasl_bind($link, null, $passwd, 'DIGEST-MD5', "realm", "Manager", "test"));
33+
var_dump(ldap_sasl_bind($link, null, $sasl_passwd, 'DIGEST-MD5', "realm", "Manager", "test"));
3034

3135
// Invalid DN syntax
32-
var_dump(ldap_sasl_bind($link, "unexistingProperty=weirdValue,$user", $passwd));
36+
var_dump(ldap_sasl_bind($link, "unexistingProperty=weirdValue,$user", $sasl_passwd));
3337
?>
3438
===DONE===
39+
--CLEAN--
40+
<?php
41+
include "connect.inc";
42+
43+
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
44+
remove_dummy_data($link, $base);
45+
?>
3546
--EXPECTF--
3647
Warning: ldap_sasl_bind() expects at least 1 parameter, 0 given in %s on line %d
3748
bool(false)

0 commit comments

Comments
 (0)