Skip to content

Commit 3bc0bdf

Browse files
authored
update workflows (#1124)
1 parent 2a217b9 commit 3bc0bdf

File tree

3 files changed

+36
-19
lines changed

3 files changed

+36
-19
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
steps:
1515
- name: Checkout repo
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1717

1818
- name: Initialize CodeQL
1919
uses: github/codeql-action/init@v1

.github/workflows/test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
postgres:
12+
- '15'
13+
- '14'
1214
- '13'
1315
- '12'
1416
- '11'
1517
- '10'
1618
- '9.6'
1719
go:
20+
- '1.20'
21+
- '1.19'
22+
- '1.18'
1823
- '1.17'
1924
- '1.16'
2025
- '1.15'
@@ -169,10 +174,10 @@ jobs:
169174
docker exec pg createuser -h localhost -U postgres -DRS pqgosslcert
170175
171176
- name: check out code into the Go module directory
172-
uses: actions/checkout@v2
177+
uses: actions/checkout@v3
173178

174179
- name: set up go
175-
uses: actions/setup-go@v2
180+
uses: actions/setup-go@v4
176181
with:
177182
go-version: ${{ matrix.go }}
178183
id: go

ssl_test.go

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"crypto/tls"
99
"crypto/x509"
1010
"database/sql"
11+
"errors"
1112
"fmt"
1213
"io"
1314
"net"
@@ -86,11 +87,13 @@ func TestSSLVerifyFull(t *testing.T) {
8687
if err == nil {
8788
t.Fatal("expected error")
8889
}
89-
_, ok := err.(x509.UnknownAuthorityError)
90-
if !ok {
91-
_, ok := err.(x509.HostnameError)
92-
if !ok {
93-
t.Fatalf("expected x509.UnknownAuthorityError or x509.HostnameError, got %#+v", err)
90+
{
91+
var x509err x509.UnknownAuthorityError
92+
if !errors.As(err, &x509err) {
93+
var x509err x509.HostnameError
94+
if !errors.As(err, &x509err) {
95+
t.Fatalf("expected x509.UnknownAuthorityError or x509.HostnameError, got %#+v", err)
96+
}
9497
}
9598
}
9699

@@ -101,9 +104,11 @@ func TestSSLVerifyFull(t *testing.T) {
101104
if err == nil {
102105
t.Fatal("expected error")
103106
}
104-
_, ok = err.(x509.HostnameError)
105-
if !ok {
106-
t.Fatalf("expected x509.HostnameError, got %#+v", err)
107+
{
108+
var x509err x509.HostnameError
109+
if !errors.As(err, &x509err) {
110+
t.Fatalf("expected x509.HostnameError, got %#+v", err)
111+
}
107112
}
108113
// OK
109114
_, err = openSSLConn(t, rootCert+"host=postgres sslmode=verify-full user=pqgossltest")
@@ -126,9 +131,11 @@ func TestSSLRequireWithRootCert(t *testing.T) {
126131
if err == nil {
127132
t.Fatal("expected error")
128133
}
129-
_, ok := err.(x509.UnknownAuthorityError)
130-
if !ok {
131-
t.Fatalf("expected x509.UnknownAuthorityError, got %s, %#+v", err, err)
134+
{
135+
var x509err x509.UnknownAuthorityError
136+
if !errors.As(err, &x509err) {
137+
t.Fatalf("expected x509.UnknownAuthorityError, got %s, %#+v", err, err)
138+
}
132139
}
133140

134141
nonExistentCertPath := filepath.Join(os.Getenv("PQSSLCERTTEST_PATH"), "non_existent.crt")
@@ -164,15 +171,17 @@ func TestSSLVerifyCA(t *testing.T) {
164171
// Not OK according to the system CA
165172
{
166173
_, err := openSSLConn(t, "host=postgres sslmode=verify-ca user=pqgossltest")
167-
if _, ok := err.(x509.UnknownAuthorityError); !ok {
174+
var x509err x509.UnknownAuthorityError
175+
if !errors.As(err, &x509err) {
168176
t.Fatalf("expected %T, got %#+v", x509.UnknownAuthorityError{}, err)
169177
}
170178
}
171179

172180
// Still not OK according to the system CA; empty sslrootcert is treated as unspecified.
173181
{
174182
_, err := openSSLConn(t, "host=postgres sslmode=verify-ca user=pqgossltest sslrootcert=''")
175-
if _, ok := err.(x509.UnknownAuthorityError); !ok {
183+
var x509err x509.UnknownAuthorityError
184+
if !errors.As(err, &x509err) {
176185
t.Fatalf("expected %T, got %#+v", x509.UnknownAuthorityError{}, err)
177186
}
178187
}
@@ -243,23 +252,26 @@ func TestSSLClientCertificates(t *testing.T) {
243252
// Cert present, key not specified, should fail
244253
{
245254
_, err := openSSLConn(t, baseinfo+" sslcert="+sslcert)
246-
if _, ok := err.(*os.PathError); !ok {
255+
var pathErr *os.PathError
256+
if !errors.As(err, &pathErr) {
247257
t.Fatalf("expected %T, got %#+v", (*os.PathError)(nil), err)
248258
}
249259
}
250260

251261
// Cert present, empty key specified, should fail
252262
{
253263
_, err := openSSLConn(t, baseinfo+" sslcert="+sslcert+" sslkey=''")
254-
if _, ok := err.(*os.PathError); !ok {
264+
var pathErr *os.PathError
265+
if !errors.As(err, &pathErr) {
255266
t.Fatalf("expected %T, got %#+v", (*os.PathError)(nil), err)
256267
}
257268
}
258269

259270
// Cert present, non-existent key, should fail
260271
{
261272
_, err := openSSLConn(t, baseinfo+" sslcert="+sslcert+" sslkey=/tmp/filedoesnotexist")
262-
if _, ok := err.(*os.PathError); !ok {
273+
var pathErr *os.PathError
274+
if !errors.As(err, &pathErr) {
263275
t.Fatalf("expected %T, got %#+v", (*os.PathError)(nil), err)
264276
}
265277
}

0 commit comments

Comments
 (0)