|
4 | 4 | use PostgresNode;
|
5 | 5 | use Test::More;
|
6 | 6 |
|
7 |
| -if ($ENV{with_ldap} eq 'yes') |
8 |
| -{ |
9 |
| - plan tests => 22; |
10 |
| -} |
11 |
| -else |
12 |
| -{ |
13 |
| - plan skip_all => 'LDAP not supported by this build'; |
14 |
| -} |
15 |
| - |
16 | 7 | my ($slapd, $ldap_bin_dir, $ldap_schema_dir);
|
17 | 8 |
|
18 | 9 | $ldap_bin_dir = undef; # usually in PATH
|
19 | 10 |
|
20 |
| -if ($^O eq 'darwin' && -d '/opt/homebrew/opt/openldap') |
| 11 | +if ($ENV{with_ldap} ne 'yes') |
21 | 12 | {
|
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 ($^O eq '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 | + plan skip_all => 'LDAP not supported by this build'; |
31 | 14 | }
|
32 |
| -elsif ($^O eq 'darwin' && -d '/opt/local/etc/openldap') |
| 15 | +# Find the OpenLDAP server binary and directory containing schema |
| 16 | +# definition files. |
| 17 | +elsif ($^O eq 'darwin') |
33 | 18 | {
|
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 | + plan skip_all => "OpenLDAP server installation not found"; |
| 40 | + } |
37 | 41 | }
|
38 | 42 | elsif ($^O eq 'linux')
|
39 | 43 | {
|
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 | + plan skip_all => "OpenLDAP server installation not found"; |
| 57 | + } |
43 | 58 | }
|
44 | 59 | elsif ($^O eq 'freebsd')
|
45 | 60 | {
|
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 | + plan skip_all => "OpenLDAP server installation not found"; |
| 69 | + } |
| 70 | +} |
| 71 | +else |
| 72 | +{ |
| 73 | + plan skip_all => "ldap tests not supported on $^O"; |
48 | 74 | }
|
49 | 75 |
|
50 | 76 | # make your own edits here
|
@@ -336,3 +362,5 @@ sub test_access
|
336 | 362 |
|
337 | 363 | $ENV{"PGPASSWORD"} = 'secret1';
|
338 | 364 | test_access($node, 'test1', 2, 'bad combination of LDAPS and StartTLS');
|
| 365 | + |
| 366 | +done_testing(); |
0 commit comments