postgres.git / summary / log / commit / refs

commit    14a737bfdbe4f2328d7f333b207f52f9ed4ee722
Author:   Michael Paquier <michael@paquier.xyz>
Date:     Mon Oct 24 04:48:34 2022 +0000
First released in: 16.0

    Fix and improve TAP tests for pg_hba.conf and regexps
    
    The new tests have been reporting a warning hidden in the logs, as of
    "Odd number of elements in hash assignment" (perlcritic or similar did
    not report an issue, actually).  This comes down to a typo in the test
    "matching regexp for username" for a double-quoted regexp using commas,
    where we passed an extra argument.  The test is intended to pass, but
    this was causing the test to fail.  This also pointed out that the
    newly-added role "md5,role" lacks an entry in the password file used to
    provide the password, so add one.
    
    While on it, make the tests pickier by checking the contents of the logs
    generated on successful authentication.
    
    Oversights in 8fea868.


src/test/authentication/t/001_password.pl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/test/authentication/t/001_password.pl b/src/test/authentication/t/001_password.pl index 6c0c753b56c..42d3d4c79b5 100644 --- a/src/test/authentication/t/001_password.pl +++ b/src/test/authentication/t/001_password.pl @@ -204,14 +204,16 @@ test_conn($node, 'user=md5_role', 'password from pgpass', 2); append_to_file( $pgpassfile, qq! *:*:*:md5_role:p\\ass +*:*:*:md5,role:p\\ass !); test_conn($node, 'user=md5_role', 'password from pgpass', 0); # Testing with regular expression for username. The third regexp matches. reset_pg_hba($node, 'all', '/^.*nomatch.*$, baduser, /^md.*$', 'password'); -test_conn($node, 'user=md5_role', 'password, matching regexp for username', - 0); +test_conn($node, 'user=md5_role', 'password, matching regexp for username', 0, + log_like => + [qr/connection authenticated: identity="md5_role" method=password/]); # The third regex does not match anymore. reset_pg_hba($node, 'all', '/^.*nomatch.*$, baduser, /^m_d.*$', 'password'); @@ -223,15 +225,20 @@ test_conn($node, 'user=md5_role', # double quotes is mandatory so as this is not considered as two elements # of the user name list when parsing pg_hba.conf. reset_pg_hba($node, 'all', '"/^.*5,.*e$"', 'password'); -test_conn($node, 'user=md5,role', 'password', 'matching regexp for username', - 0); +test_conn($node, 'user=md5,role', 'password, matching regexp for username', 0, + log_like => + [qr/connection authenticated: identity="md5,role" method=password/]); # Testing with regular expression for dbname. The third regex matches. reset_pg_hba($node, '/^.*nomatch.*$, baddb, /^regex_t.*b$', 'all', 'password'); test_conn( - $node, 'user=md5_role dbname=regex_testdb', 'password, - matching regexp for dbname', 0); + $node, + 'user=md5_role dbname=regex_testdb', + 'password, matching regexp for dbname', + 0, + log_like => + [qr/connection authenticated: identity="md5_role" method=password/]); # The third regexp does not match anymore. reset_pg_hba($node, '/^.*nomatch.*$, baddb, /^regex_t.*ba$', [parent: 8fea86830e1d]