]> granicus.if.org Git - postgresql/commitdiff
Add tests for pg_stat_ssl system view
authorPeter Eisentraut <peter@eisentraut.org>
Mon, 28 Jan 2019 13:34:15 +0000 (14:34 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 29 Jan 2019 12:05:54 +0000 (13:05 +0100)
Reviewed-by: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Discussion: https://www.postgresql.org/message-id/flat/398754d8-6bb5-c5cf-e7b8-22e5f0983caf@2ndquadrant.com/

src/test/ssl/t/001_ssltests.pl

index 2b875a3c956a97cdc8288ae1777dcaef3644bd4e..74a5da578a24c8132a4ab615b55ecdab4bff95f7 100644 (file)
@@ -8,7 +8,7 @@ use File::Copy;
 
 if ($ENV{with_openssl} eq 'yes')
 {
-       plan tests => 65;
+       plan tests => 71;
 }
 else
 {
@@ -309,6 +309,16 @@ test_connect_fails(
        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 sslrootcert=invalid",
+       '-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 @@ test_connect_ok(
        "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,