|
90 | 90 | $ENV{PG_TEST_EXTRA} && $ENV{PG_TEST_EXTRA} =~ /\bkerberos\b/; |
91 | 91 | my $ssl_supported = $ENV{with_ssl} eq 'openssl'; |
92 | 92 |
|
| 93 | +my $injection_points_supported = $ENV{enable_injection_points} eq 'yes'; |
| 94 | + |
93 | 95 | ### |
94 | 96 | ### Prepare test server for GSSAPI and SSL authentication, with a few |
95 | 97 | ### different test users and helper functions. We don't actually |
|
155 | 157 | $node->safe_psql('postgres', 'CREATE USER nossluser;'); |
156 | 158 | $node->safe_psql('postgres', 'CREATE USER gssuser;'); |
157 | 159 | $node->safe_psql('postgres', 'CREATE USER nogssuser;'); |
| 160 | +if ($injection_points_supported != 0) |
| 161 | +{ |
| 162 | + $node->safe_psql('postgres', 'CREATE EXTENSION injection_points;'); |
| 163 | +} |
158 | 164 |
|
159 | 165 | my $unixdir = $node->safe_psql('postgres', 'SHOW unix_socket_directories;'); |
160 | 166 | chomp($unixdir); |
@@ -312,6 +318,29 @@ BEGIN |
312 | 318 | ['disable'], \@all_sslmodes, \@all_sslnegotiations, |
313 | 319 | parse_table($test_table)); |
314 | 320 |
|
| 321 | + if ($injection_points_supported != 0) |
| 322 | + { |
| 323 | + $node->safe_psql( |
| 324 | + 'postgres', |
| 325 | + "SELECT injection_points_attach('backend-initialize', 'error');", |
| 326 | + connstr => "user=localuser host=$unixdir"); |
| 327 | + connect_test( |
| 328 | + $node, |
| 329 | + "user=testuser sslmode=prefer", |
| 330 | + 'connect, backenderror -> fail'); |
| 331 | + $node->restart; |
| 332 | + |
| 333 | + $node->safe_psql( |
| 334 | + 'postgres', |
| 335 | + "SELECT injection_points_attach('backend-initialize-v2-error', 'error');", |
| 336 | + connstr => "user=localuser host=$unixdir"); |
| 337 | + connect_test( |
| 338 | + $node, |
| 339 | + "user=testuser sslmode=prefer", |
| 340 | + 'connect, v2error -> fail'); |
| 341 | + $node->restart; |
| 342 | + } |
| 343 | + |
315 | 344 | # Disable SSL again |
316 | 345 | $node->adjust_conf('postgresql.conf', 'ssl', 'off'); |
317 | 346 | $node->reload; |
@@ -393,6 +422,29 @@ BEGIN |
393 | 422 | test_matrix($node, [ 'testuser', 'gssuser', 'nogssuser' ], |
394 | 423 | \@all_gssencmodes, $sslmodes, $sslnegotiations, |
395 | 424 | parse_table($test_table)); |
| 425 | + |
| 426 | + if ($injection_points_supported != 0) |
| 427 | + { |
| 428 | + $node->safe_psql( |
| 429 | + 'postgres', |
| 430 | + "SELECT injection_points_attach('backend-initialize', 'error');", |
| 431 | + connstr => "user=localuser host=$unixdir"); |
| 432 | + connect_test( |
| 433 | + $node, |
| 434 | + "user=testuser gssencmode=prefer sslmode=disable", |
| 435 | + 'connect, backenderror, reconnect, backenderror -> fail'); |
| 436 | + $node->restart; |
| 437 | + |
| 438 | + $node->safe_psql( |
| 439 | + 'postgres', |
| 440 | + "SELECT injection_points_attach('backend-initialize-v2-error', 'error');", |
| 441 | + connstr => "user=localuser host=$unixdir"); |
| 442 | + connect_test( |
| 443 | + $node, |
| 444 | + "user=testuser gssencmode=prefer sslmode=disable", |
| 445 | + 'connect, v2error -> fail'); |
| 446 | + $node->restart; |
| 447 | + } |
396 | 448 | } |
397 | 449 |
|
398 | 450 | ### |
@@ -738,6 +790,10 @@ sub parse_log_events |
738 | 790 | push @events, "gssreject" if $line =~ /GSSENCRequest rejected/; |
739 | 791 | push @events, "authfail" if $line =~ /no pg_hba.conf entry/; |
740 | 792 | push @events, "authok" if $line =~ /connection authenticated/; |
| 793 | + push @events, "backenderror" |
| 794 | + if $line =~ /error triggered for injection point backend-/; |
| 795 | + push @events, "v2error" |
| 796 | + if $line =~ /protocol version 2 error triggered/; |
741 | 797 | } |
742 | 798 |
|
743 | 799 | # No events at all is represented by "-" |
|
0 commit comments