@@ -66,22 +66,22 @@ func TestSSLMode(t *testing.T) {
6666 // sslmode=verify-ca: verify that the certificate was signed by a trusted CA
6767 {"host=postgres sslmode=verify-ca user=pqgossl" , "invalid-cert" },
6868 {"host=postgres sslmode=verify-ca user=pqgossl sslrootcert=''" , "invalid-cert" },
69- {"sslrootcert=testdata/init /root.crt sslmode=verify-ca user=pqgossl host=127.0.0.1" , "" },
70- {"sslrootcert=testdata/init /root.crt sslmode=verify-ca user=pqgossl host=postgres-invalid" , "" },
71- {"sslrootcert=testdata/init /root.crt sslmode=verify-ca user=pqgossl host=postgres" , "" },
69+ {"sslrootcert=testdata/ssl /root.crt sslmode=verify-ca user=pqgossl host=127.0.0.1" , "" },
70+ {"sslrootcert=testdata/ssl /root.crt sslmode=verify-ca user=pqgossl host=postgres-invalid" , "" },
71+ {"sslrootcert=testdata/ssl /root.crt sslmode=verify-ca user=pqgossl host=postgres" , "" },
7272
7373 // sslmode=verify-full: verify that the certification was signed by a trusted CA and the host matches
7474 {"sslmode=verify-full user=pqgossl host=postgres" , "invalid-cert" },
75- {"sslrootcert=testdata/init /root.crt sslmode=verify-full user=pqgossl host=127.0.0.1" , "invalid-cert" },
76- {"sslrootcert=testdata/init /root.crt sslmode=verify-full user=pqgossl host=postgres-invalid" , "invalid-cert" },
77- {"sslrootcert=testdata/init /root.crt sslmode=verify-full user=pqgossl host=postgres" , "" },
75+ {"sslrootcert=testdata/ssl /root.crt sslmode=verify-full user=pqgossl host=127.0.0.1" , "invalid-cert" },
76+ {"sslrootcert=testdata/ssl /root.crt sslmode=verify-full user=pqgossl host=postgres-invalid" , "invalid-cert" },
77+ {"sslrootcert=testdata/ssl /root.crt sslmode=verify-full user=pqgossl host=postgres" , "" },
7878
7979 // With root cert
80- {"sslrootcert=testdata/init /bogus_root.crt host=postgres sslmode=require user=pqgossl" , "invalid-cert" },
81- {"sslrootcert=testdata/init /non_existent.crt host=127.0.0.1 sslmode=require user=pqgossl" , "" },
82- {"sslrootcert=testdata/init /root.crt host=127.0.0.1 sslmode=require user=pqgossl" , "" },
83- {"sslrootcert=testdata/init /root.crt host=postgres sslmode=require user=pqgossl" , "" },
84- {"sslrootcert=testdata/init /root.crt host=postgres-invalid sslmode=require user=pqgossl" , "" },
80+ {"sslrootcert=testdata/ssl /bogus_root.crt host=postgres sslmode=require user=pqgossl" , "invalid-cert" },
81+ {"sslrootcert=testdata/ssl /non_existent.crt host=127.0.0.1 sslmode=require user=pqgossl" , "" },
82+ {"sslrootcert=testdata/ssl /root.crt host=127.0.0.1 sslmode=require user=pqgossl" , "" },
83+ {"sslrootcert=testdata/ssl /root.crt host=postgres sslmode=require user=pqgossl" , "" },
84+ {"sslrootcert=testdata/ssl /root.crt host=postgres-invalid sslmode=require user=pqgossl" , "" },
8585
8686 // sslmode=prefer
8787 {"sslmode=prefer user=pqgossl" , "" },
@@ -138,7 +138,7 @@ func TestSSLClientCertificates(t *testing.T) {
138138 pqtest .SkipPgbouncer (t ) // TODO: can't get it to work.
139139 t .Parallel ()
140140 startSSLTest (t , "pqgosslcert" )
141- pqtest .Chmod (t , 0o600 , "testdata/init /postgresql.key" )
141+ pqtest .Chmod (t , 0o600 , "testdata/ssl /postgresql.key" )
142142
143143 tests := []struct {
144144 connect string
@@ -147,16 +147,16 @@ func TestSSLClientCertificates(t *testing.T) {
147147 {"sslmode=require user=pqgosslcert" , "requires a valid client certificate (28000)" },
148148 {"sslmode=require user=pqgosslcert sslcert=''" , "requires a valid client certificate (28000)" },
149149 {"sslmode=require user=pqgosslcert sslcert=/tmp/filedoesnotexist" , "requires a valid client certificate (28000)" },
150- {"sslmode=require user=pqgosslcert sslcert=testdata/init /postgresql.crt" , "directory" },
151- {"sslmode=require user=pqgosslcert sslcert=testdata/init /postgresql.crt sslkey=''" , "directory" },
152- {"sslmode=require user=pqgosslcert sslcert=testdata/init /postgresql.crt sslkey=/tmp/filedoesnotexist" , "no such file or directory" },
153- {"sslmode=require user=pqgosslcert sslcert=testdata/init /postgresql.crt sslkey=testdata/init /postgresql.crt" , "has world access" },
150+ {"sslmode=require user=pqgosslcert sslcert=testdata/ssl /postgresql.crt" , "directory" },
151+ {"sslmode=require user=pqgosslcert sslcert=testdata/ssl /postgresql.crt sslkey=''" , "directory" },
152+ {"sslmode=require user=pqgosslcert sslcert=testdata/ssl /postgresql.crt sslkey=/tmp/filedoesnotexist" , "no such file or directory" },
153+ {"sslmode=require user=pqgosslcert sslcert=testdata/ssl /postgresql.crt sslkey=testdata/ssl /postgresql.crt" , "has world access" },
154154
155- {"sslmode=require user=pqgosslcert sslcert=testdata/init /postgresql.crt sslkey=testdata/init /postgresql.key" , "" },
155+ {"sslmode=require user=pqgosslcert sslcert=testdata/ssl /postgresql.crt sslkey=testdata/ssl /postgresql.key" , "" },
156156
157157 {fmt .Sprintf ("sslmode=require user=pqgosslcert sslinline=true sslcert='%s' sslkey='%s'" ,
158- pqtest .Read (t , "testdata/init /postgresql.crt" ),
159- pqtest .Read (t , "testdata/init /postgresql.key" )),
158+ pqtest .Read (t , "testdata/ssl /postgresql.crt" ),
159+ pqtest .Read (t , "testdata/ssl /postgresql.key" )),
160160 "" },
161161 }
162162
@@ -187,7 +187,7 @@ func TestSSLClientCertificateIntermediate(t *testing.T) {
187187 pqtest .SkipPgbouncer (t ) // TODO: can't get it to work.
188188 t .Parallel ()
189189 startSSLTest (t , "pqgosslcert" )
190- pqtest .Chmod (t , 0o600 , "testdata/init /client_intermediate.key" )
190+ pqtest .Chmod (t , 0o600 , "testdata/ssl /client_intermediate.key" )
191191
192192 tests := []struct {
193193 name string
@@ -200,27 +200,27 @@ func TestSSLClientCertificateIntermediate(t *testing.T) {
200200 // so sslAppendIntermediates must send the intermediate in the TLS chain.
201201 name : "file certs" ,
202202 connect : "sslmode=require user=pqgosslcert " +
203- "sslrootcert=testdata/init /root+intermediate.crt " +
204- "sslcert=testdata/init /client_intermediate.crt " +
205- "sslkey=testdata/init /client_intermediate.key" ,
203+ "sslrootcert=testdata/ssl /root+intermediate.crt " +
204+ "sslcert=testdata/ssl /client_intermediate.crt " +
205+ "sslkey=testdata/ssl /client_intermediate.key" ,
206206 },
207207 {
208208 name : "inline certs" ,
209209 connect : fmt .Sprintf (
210210 "sslmode=require user=pqgosslcert sslinline=true sslrootcert='%s' sslcert='%s' sslkey='%s'" ,
211- pqtest .Read (t , "testdata/init /root+intermediate.crt" ),
212- pqtest .Read (t , "testdata/init /client_intermediate.crt" ),
213- pqtest .Read (t , "testdata/init /client_intermediate.key" ),
211+ pqtest .Read (t , "testdata/ssl /root+intermediate.crt" ),
212+ pqtest .Read (t , "testdata/ssl /client_intermediate.crt" ),
213+ pqtest .Read (t , "testdata/ssl /client_intermediate.key" ),
214214 ),
215215 },
216216 {
217217 // Without the intermediate in sslrootcert, sslAppendIntermediates has
218218 // nothing to append, so the server can't verify the client cert chain.
219219 name : "fails without intermediate in sslrootcert" ,
220220 connect : "sslmode=require user=pqgosslcert " +
221- "sslrootcert=testdata/init /root.crt " +
222- "sslcert=testdata/init /client_intermediate.crt " +
223- "sslkey=testdata/init /client_intermediate.key" ,
221+ "sslrootcert=testdata/ssl /root.crt " +
222+ "sslcert=testdata/ssl /client_intermediate.crt " +
223+ "sslkey=testdata/ssl /client_intermediate.key" ,
224224 wantErr : "unknown certificate authority" ,
225225 },
226226 }
@@ -376,11 +376,11 @@ func TestSSLDefaults(t *testing.T) {
376376
377377 pqtest .Write (t , []byte ("invalid data" ), pqutil .Home (true ), tt .file )
378378 if tt .file == "postgresql.crt" {
379- pqtest .Write (t , pqtest .Read (t , "testdata/init /postgresql.key" ), pqutil .Home (true ), "postgresql.key" )
379+ pqtest .Write (t , pqtest .Read (t , "testdata/ssl /postgresql.key" ), pqutil .Home (true ), "postgresql.key" )
380380 pqtest .Chmod (t , 0o600 , pqutil .Home (true ), "postgresql.key" )
381381 }
382382 if tt .file == "postgresql.key" {
383- pqtest .Write (t , pqtest .Read (t , "testdata/init /postgresql.crt" ), pqutil .Home (true ), "postgresql.crt" )
383+ pqtest .Write (t , pqtest .Read (t , "testdata/ssl /postgresql.crt" ), pqutil .Home (true ), "postgresql.crt" )
384384 pqtest .Chmod (t , 0o600 , pqutil .Home (true ), "postgresql.key" )
385385 }
386386
@@ -393,9 +393,9 @@ func TestSSLDefaults(t *testing.T) {
393393
394394 t .Run ("work with default paths" , func (t * testing.T ) {
395395 pqtest .Home (t )
396- pqtest .Write (t , pqtest .Read (t , "testdata/init /root.crt" ), pqutil .Home (true ), "root.crt" )
397- pqtest .Write (t , pqtest .Read (t , "testdata/init /postgresql.crt" ), pqutil .Home (true ), "postgresql.crt" )
398- pqtest .Write (t , pqtest .Read (t , "testdata/init /postgresql.key" ), pqutil .Home (true ), "postgresql.key" )
396+ pqtest .Write (t , pqtest .Read (t , "testdata/ssl /root.crt" ), pqutil .Home (true ), "root.crt" )
397+ pqtest .Write (t , pqtest .Read (t , "testdata/ssl /postgresql.crt" ), pqutil .Home (true ), "postgresql.crt" )
398+ pqtest .Write (t , pqtest .Read (t , "testdata/ssl /postgresql.key" ), pqutil .Home (true ), "postgresql.key" )
399399 pqtest .Chmod (t , 0o600 , pqutil .Home (true ), "postgresql.key" )
400400 _ = pqtest .MustDB (t , "host=postgres user=pqgosslcert sslmode=verify-ca" )
401401 })
@@ -411,7 +411,7 @@ func TestSSLRootCA(t *testing.T) {
411411 testSystemRoots = nil
412412 })
413413 testSystemRoots = x509 .NewCertPool ()
414- if ! testSystemRoots .AppendCertsFromPEM (pqtest .Read (t , "testdata/init /root.crt" )) {
414+ if ! testSystemRoots .AppendCertsFromPEM (pqtest .Read (t , "testdata/ssl /root.crt" )) {
415415 t .Fatal ()
416416 }
417417
0 commit comments