From 9a2e8eab5f2d338414652438cce1c759af451c11 Mon Sep 17 00:00:00 2001
From: Jacob Champion <pchampion@vmware.com>
Date: Mon, 5 Apr 2021 09:35:11 -0700
Subject: [PATCH v21 1/2] test/kerberos: fix up test_query

c50624cdd accidentally disabled test_query; add its functionality back
here. expected_stderr has been added to PostgresNode::connect_ok().

Also fix some TODO tests in test/ssl.
---
 src/test/kerberos/t/001_auth.pl | 12 +++++++-----
 src/test/perl/PostgresNode.pm   | 12 ++++++++++--
 src/test/ssl/t/001_ssltests.pl  |  8 ++++----
 3 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/test/kerberos/t/001_auth.pl b/src/test/kerberos/t/001_auth.pl
index de52a66785..8b8c7c4814 100644
--- a/src/test/kerberos/t/001_auth.pl
+++ b/src/test/kerberos/t/001_auth.pl
@@ -20,7 +20,7 @@ use Time::HiRes qw(usleep);
 
 if ($ENV{with_gssapi} eq 'yes')
 {
-	plan tests => 30;
+	plan tests => 34;
 }
 else
 {
@@ -196,7 +196,7 @@ sub test_access
 		$node->connect_ok(
 			$connstr, $test_name,
 			sql             => $query,
-			expected_stdout => qr/t/);
+			expected_stdout => qr/^t$/);
 	}
 	else
 	{
@@ -227,9 +227,11 @@ sub test_query
 	my $connstr = $node->connstr('postgres')
 	  . " user=$role host=$host hostaddr=$hostaddr $gssencmode";
 
-	my ($stdoutres, $stderrres);
-
-	$node->connect_ok($connstr, $test_name, $query, $expected);
+	$node->connect_ok(
+		$connstr, $test_name,
+		sql             => $query,
+		expected_stdout => $expected,
+		expected_stderr => qr/^$/);
 	return;
 }
 
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index bbde34c929..34279e71a8 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -1876,6 +1876,10 @@ instead of the default.
 
 If this regular expression is set, matches it with the output generated.
 
+=item expected_stderr => B<value>
+
+If this regular expression is set, matches it with the stderr generated.
+
 =back
 
 =cut
@@ -1908,7 +1912,11 @@ sub connect_ok
 
 	if (defined($params{expected_stdout}))
 	{
-		like($stdout, $params{expected_stdout}, "$test_name: matches");
+		like($stdout, $params{expected_stdout}, "$test_name: stdout matches");
+	}
+	if (defined($params{expected_stderr}))
+	{
+	    like($stderr, $params{expected_stderr}, "$test_name: stderr matches");
 	}
 }
 
@@ -1946,7 +1954,7 @@ sub connect_fails
 
 	if (defined($params{expected_stderr}))
 	{
-		like($stderr, $params{expected_stderr}, "$test_name: matches");
+		like($stderr, $params{expected_stderr}, "$test_name: stderr matches");
 	}
 }
 
diff --git a/src/test/ssl/t/001_ssltests.pl b/src/test/ssl/t/001_ssltests.pl
index 21865ac30f..0decbe7177 100644
--- a/src/test/ssl/t/001_ssltests.pl
+++ b/src/test/ssl/t/001_ssltests.pl
@@ -459,17 +459,17 @@ TODO:
 	# correct client cert in encrypted PEM with empty password
 	$node->connect_fails(
 		"$common_connstr user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client-encrypted-pem_tmp.key sslpassword=''",
+		"certificate authorization fails with correct client cert and empty password in encrypted PEM format",
 		expected_stderr =>
-		  qr!\Qprivate key file "ssl/client-encrypted-pem_tmp.key": processing error\E!,
-		"certificate authorization fails with correct client cert and empty password in encrypted PEM format"
+		  qr!\Qprivate key file "ssl/client-encrypted-pem_tmp.key": processing error\E!
 	);
 
 	# correct client cert in encrypted PEM with no password
 	$node->connect_fails(
 		"$common_connstr user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client-encrypted-pem_tmp.key",
+		"certificate authorization fails with correct client cert and no password in encrypted PEM format",
 		expected_stderr =>
-		  qr!\Qprivate key file "ssl/client-encrypted-pem_tmp.key": processing error\E!,
-		"certificate authorization fails with correct client cert and no password in encrypted PEM format"
+		  qr!\Qprivate key file "ssl/client-encrypted-pem_tmp.key": processing error\E!
 	);
 
 }
-- 
2.25.1

