]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
libpq: Add TAP test for nested service file
authorMichael Paquier <michael@paquier.xyz>
Wed, 9 Jul 2025 06:46:31 +0000 (15:46 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 9 Jul 2025 06:46:31 +0000 (15:46 +0900)
This test corresponds to the case of a "service" defined in a service
file, that libpq is not able to support in parseServiceFile().

This has come up during the review of a patch to add more features in
this area, useful on its own.  Piece extracted from a larger patch by
the same author.

Author: Ryo Kanbayashi <kanbayashi.dev@gmail.com>
Discussion: https://postgr.es/m/Zz2AE7NKKLIZTtEh@paquier.xyz

src/interfaces/libpq/t/006_service.pl

index 4fe5adc5c2acd69a151cf3aceb4de6cc780b43f3..d896558a6cc248f65e13647ebf94af153b2c4566 100644 (file)
@@ -47,6 +47,12 @@ my $srvfile_default = "$td/pg_service.conf";
 # Missing service file.
 my $srvfile_missing = "$td/pg_service_missing.conf";
 
+# Service file with nested "service" defined.
+my $srvfile_nested = "$td/pg_service_nested.conf";
+copy($srvfile_valid, $srvfile_nested)
+  or die "Could not copy $srvfile_valid to $srvfile_nested: $!";
+append_to_file($srvfile_nested, 'service=invalid_srv' . $newline);
+
 # Set the fallback directory lookup of the service file to the temporary
 # directory of this test.  PGSYSCONFDIR is used if the service file
 # defined in PGSERVICEFILE cannot be found, or when a service file is
@@ -146,6 +152,17 @@ local $ENV{PGSERVICEFILE} = "$srvfile_empty";
        unlink($srvfile_default);
 }
 
+# Checks nested service file contents.
+{
+       local $ENV{PGSERVICEFILE} = $srvfile_nested;
+
+       $dummy_node->connect_fails(
+               'service=my_srv',
+               'connection with nested service file',
+               expected_stderr =>
+                 qr/nested service specifications not supported in service file/);
+}
+
 $node->teardown_node;
 
 done_testing();