git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 58597ed)
Add tests for regex replacement with 1円 in pg_ident.conf to 0003_peer.pl
2023年1月13日 01:35:28 +0000 (10:35 +0900)
2023年1月13日 01:35:28 +0000 (10:35 +0900)
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


diff --git a/src/test/authentication/t/003_peer.pl b/src/test/authentication/t/003_peer.pl
index 24cefd14e0ae685893761e33d13794eaae060c57..966b2aa47efaf35105da79876e9130f2541de995 100644 (file)
--- a/src/test/authentication/t/003_peer.pl
+++ b/src/test/authentication/t/003_peer.pl
@@ -141,6 +141,30 @@ test_role(
[qr/connection authenticated: identity="$system_user" method=peer/]);
+# Success as the regular expression matches and 1円 is replaced in the given
+# subexpression.
+reset_pg_ident($node, 'mypeermap', qq{/^$system_user(.*)\$}, 'test1円mapuser');
+test_role(
+ $node,
+ qq{testmapuser},
+ 'peer',
+ 0,
+ 'with regular expression in user name map with 1円 replaced',
+ log_like =>
+ [qr/connection authenticated: identity="$system_user" method=peer/]);
+
+# Failure as the regular expression does not include a subexpression, but
+# the database user contains 1,円 requesting a replacement.
+reset_pg_ident($node, 'mypeermap', qq{/^$system_user\$}, '1円testmapuser');
+test_role(
+ $node,
+ qq{testmapuser},
+ 'peer', 2,
+ 'with regular expression in user name map with 1円 not replaced',
+ log_like => [
+ qr/regular expression "\^$system_user\$" has no subexpressions as requested by backreference in "\1円testmapuser"/
+ ]);
+
# Concatenate system_user to system_user.
$regex_test_string = $system_user . $system_user;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /