From a4b7d9b25eab6d677e388860b4fee0f94c2fb93e Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 21 Aug 2018 21:11:36 +0200 Subject: [PATCH v4 2/4] Add tests for pg_stat_ssl system view --- src/test/ssl/t/001_ssltests.pl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/test/ssl/t/001_ssltests.pl b/src/test/ssl/t/001_ssltests.pl index 2b875a3c95..2bcbb1b42a 100644 --- a/src/test/ssl/t/001_ssltests.pl +++ b/src/test/ssl/t/001_ssltests.pl @@ -8,7 +8,7 @@ if ($ENV{with_openssl} eq 'yes') { - plan tests => 65; + plan tests => 71; } else { @@ -309,6 +309,16 @@ qr/SSL error/, "does not connect with client-side CRL"); +# pg_stat_ssl +command_like([ + 'psql', '-X', '-A', '-F', ',', '-P', 'null=_null_', + '-d', $common_connstr, + '-c', "SELECT * FROM pg_stat_ssl WHERE pid = pg_backend_pid()" + ], + qr{^pid,ssl,version,cipher,bits,compression,clientdn\n + ^\d+,t,TLSv[\d.]+,[\w-]+,\d+,f,$}mx, + 'pg_stat_ssl view without client certificate'); + ### Server-side tests. ### ### Test certificate authorization. @@ -331,6 +341,16 @@ "user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key", "certificate authorization succeeds with correct client cert"); +# pg_stat_ssl +command_like([ + 'psql', '-X', '-A', '-F', ',', '-P', 'null=_null_', + '-d', "$common_connstr user=ssltestuser sslcert=ssl/client.crt sslkey=ssl/client_tmp.key", + '-c', "SELECT * FROM pg_stat_ssl WHERE pid = pg_backend_pid()" + ], + qr{^pid,ssl,version,cipher,bits,compression,clientdn\n + ^\d+,t,TLSv[\d.]+,[\w-]+,\d+,f,/CN=ssltestuser$}mx, + 'pg_stat_ssl with client certificate'); + # client key with wrong permissions test_connect_fails( $common_connstr, -- 2.20.1