Skip to content

Commit e753ae6

Browse files
committed
Add tests for regex replacement with \1 in pg_ident.conf to 0003_peer.pl
Regexp replacement with \1 in pg_ident.conf is tested in one check of the kerberos test suite, still it requires a dependency on --with-gssapi to be triggered. This commit adds to the test suite of peer authentication two tests to check the replacement of \1 in a pg-username, coupled with a system-username regexp: - With a subexpression in system-username, similarly to the kerberos test suite. - Without a subexpression in system-username, checking for a failure. This had no coverage until now, and the error pattern is checked in the server logs. Author: Jelte Fennema Discussion: https://postgr.es/m/CAGECzQRNow4MwkBjgPxywXdJU_K3a9+Pm78JB7De3yQwwkTDew@mail.gmail.com
1 parent 58597ed commit e753ae6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/test/authentication/t/003_peer.pl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,30 @@ sub find_in_log
141141
[qr/connection authenticated: identity="$system_user" method=peer/]);
142142

143143

144+
# Success as the regular expression matches and \1 is replaced in the given
145+
# subexpression.
146+
reset_pg_ident($node, 'mypeermap', qq{/^$system_user(.*)\$}, 'test\1mapuser');
147+
test_role(
148+
$node,
149+
qq{testmapuser},
150+
'peer',
151+
0,
152+
'with regular expression in user name map with \1 replaced',
153+
log_like =>
154+
[qr/connection authenticated: identity="$system_user" method=peer/]);
155+
156+
# Failure as the regular expression does not include a subexpression, but
157+
# the database user contains \1, requesting a replacement.
158+
reset_pg_ident($node, 'mypeermap', qq{/^$system_user\$}, '\1testmapuser');
159+
test_role(
160+
$node,
161+
qq{testmapuser},
162+
'peer', 2,
163+
'with regular expression in user name map with \1 not replaced',
164+
log_like => [
165+
qr/regular expression "\^$system_user\$" has no subexpressions as requested by backreference in "\\1testmapuser"/
166+
]);
167+
144168
# Concatenate system_user to system_user.
145169
$regex_test_string = $system_user . $system_user;
146170

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy