Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1782571

Browse files
committed
Improve check in LDAP test to find the OpenLDAP installation
If the OpenLDAP installation directory is not found, set $setup to 0so that the LDAP tests are skipped. The macOS checks were alreadydoing that, but the checks on other OS's were not. While we're at it,improve the error message when the tests are skipped, to specifywhether the OS is supported at all, or if we just didn't find theinstallation directory.This was accidentally "working" without this, i.e. we were skippingthe tests if the OpenLDAP installation was not found, because of a bugin the LdapServer test module: the END block clobbered the exit codeso if the script die()s before running the first subtest, the wholetest script was marked as SKIPped. The next commit will fix that bug,but we need to fix the setup code first.These checks should probably go into configure/meson, but this isbetter than nothing and allows fixing the bug in the END block.Backpatch to all supported versions.Discussion:https://www.postgresql.org/message-id/fb898a70-3a88-4629-88e9-f2375020061d@iki.fi
1 parent360d007 commit1782571

File tree

1 file changed

+56
-28
lines changed

1 file changed

+56
-28
lines changed

‎src/test/ldap/t/001_auth.pl

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,73 @@
44
use PostgresNode;
55
use Test::More;
66

7-
if ($ENV{with_ldap}eq'yes')
8-
{
9-
plantests=> 22;
10-
}
11-
else
12-
{
13-
planskip_all=>'LDAP not supported by this build';
14-
}
15-
167
my ($slapd,$ldap_bin_dir,$ldap_schema_dir);
178

189
$ldap_bin_dir =undef;# usually in PATH
1910

20-
if ($^Oeq'darwin' &&-d'/opt/homebrew/opt/openldap')
11+
if ($ENV{with_ldap}ne'yes')
2112
{
22-
# typical paths for Homebrew on ARM
23-
$slapd ='/opt/homebrew/opt/openldap/libexec/slapd';
24-
$ldap_schema_dir ='/opt/homebrew/etc/openldap/schema';
25-
}
26-
elsif ($^Oeq'darwin' &&-d'/usr/local/opt/openldap')
27-
{
28-
# typical paths for Homebrew on Intel
29-
$slapd ='/usr/local/opt/openldap/libexec/slapd';
30-
$ldap_schema_dir ='/usr/local/etc/openldap/schema';
13+
planskip_all=>'LDAP not supported by this build';
3114
}
32-
elsif ($^Oeq'darwin' &&-d'/opt/local/etc/openldap')
15+
# Find the OpenLDAP server binary and directory containing schema
16+
# definition files.
17+
elsif ($^Oeq'darwin')
3318
{
34-
# typical paths for MacPorts
35-
$slapd ='/opt/local/libexec/slapd';
36-
$ldap_schema_dir ='/opt/local/etc/openldap/schema';
19+
if (-d'/opt/homebrew/opt/openldap')
20+
{
21+
# typical paths for Homebrew on ARM
22+
$slapd ='/opt/homebrew/opt/openldap/libexec/slapd';
23+
$ldap_schema_dir ='/opt/homebrew/etc/openldap/schema';
24+
}
25+
elsif (-d'/usr/local/opt/openldap')
26+
{
27+
# typical paths for Homebrew on Intel
28+
$slapd ='/usr/local/opt/openldap/libexec/slapd';
29+
$ldap_schema_dir ='/usr/local/etc/openldap/schema';
30+
}
31+
elsif (-d'/opt/local/etc/openldap')
32+
{
33+
# typical paths for MacPorts
34+
$slapd ='/opt/local/libexec/slapd';
35+
$ldap_schema_dir ='/opt/local/etc/openldap/schema';
36+
}
37+
else
38+
{
39+
planskip_all=>"OpenLDAP server installation not found";
40+
}
3741
}
3842
elsif ($^Oeq'linux')
3943
{
40-
$slapd ='/usr/sbin/slapd';
41-
$ldap_schema_dir ='/etc/ldap/schema'if-d'/etc/ldap/schema';
42-
$ldap_schema_dir ='/etc/openldap/schema'if-d'/etc/openldap/schema';
44+
if (-d'/etc/ldap/schema')
45+
{
46+
$slapd ='/usr/sbin/slapd';
47+
$ldap_schema_dir ='/etc/ldap/schema';
48+
}
49+
elsif (-d'/etc/openldap/schema')
50+
{
51+
$slapd ='/usr/sbin/slapd';
52+
$ldap_schema_dir ='/etc/openldap/schema';
53+
}
54+
else
55+
{
56+
planskip_all=>"OpenLDAP server installation not found";
57+
}
4358
}
4459
elsif ($^Oeq'freebsd')
4560
{
46-
$slapd ='/usr/local/libexec/slapd';
47-
$ldap_schema_dir ='/usr/local/etc/openldap/schema';
61+
if (-d'/usr/local/etc/openldap/schema')
62+
{
63+
$slapd ='/usr/local/libexec/slapd';
64+
$ldap_schema_dir ='/usr/local/etc/openldap/schema';
65+
}
66+
else
67+
{
68+
planskip_all=>"OpenLDAP server installation not found";
69+
}
70+
}
71+
else
72+
{
73+
planskip_all=>"ldap tests not supported on $^O";
4874
}
4975

5076
# make your own edits here
@@ -336,3 +362,5 @@ sub test_access
336362

337363
$ENV{"PGPASSWORD"} ='secret1';
338364
test_access($node,'test1', 2,'bad combination of LDAPS and StartTLS');
365+
366+
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp