Skip to content

Commit d2cd73b

Browse files
authored
chore: go toolchain for CI updated to 1.27.3 and golangci updated to 2.15.0 (#163)
1 parent 3d9c253 commit d2cd73b

5 files changed

Lines changed: 111 additions & 38 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
branches: [ main ]
88

99
env:
10-
GO_VERSION: "1.26.9"
11-
GOLANGCI_LINT_VERSION: "v2.9.0"
10+
GO_VERSION: "1.27.3"
11+
GOLANGCI_LINT_VERSION: "v2.15.0"
1212

1313
permissions: {}
1414

‎.github/workflows/security.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "Security Scan"
22

33
env:
4-
GO_VERSION: "1.26.9"
4+
GO_VERSION: "1.27.3"
55

66
on:
77
push:

‎.golangci.yaml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,27 @@ run:
66
linters:
77
default: all
88
disable:
9-
- depguard
109
- dupl
10+
- gomodguard_v2
1111
- exhaustruct
12+
- exhaustruct_v5
1213
- ireturn
1314
- nolintlint
1415
- paralleltest
1516
- testpackage
1617
- tparallel
1718
- wrapcheck
18-
- zerologlint
1919
- goconst
2020
- noinlineerr
2121
# deprecated
2222
- wsl
23+
- depguard
2324
settings:
2425
cyclop:
2526
max-complexity: 11
2627
exhaustive:
2728
default-signifies-exhaustive: true
28-
ignore-enum-members: POT.+
29+
ignore-constants: POT.+
2930
funlen:
3031
lines: 80
3132
mnd:

‎message_digester_test.go‎

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package httpsig
22

33
import (
44
"bufio"
5-
"context"
65
"net/http"
76
"net/http/httptest"
87
"strings"
@@ -24,7 +23,12 @@ func TestContentDigesterVerify(t *testing.T) {
2423
{
2524
uc: "malformed content-digest header",
2625
msg: func() *Message {
27-
req := httptest.NewRequest(http.MethodGet, "http://example.com/foo", strings.NewReader(`{"hello": "world"}`))
26+
req := httptest.NewRequestWithContext(
27+
t.Context(),
28+
http.MethodGet,
29+
"http://example.com/foo",
30+
strings.NewReader(`{"hello": "world"}`),
31+
)
2832
req.Header.Set("content-digest", ",")
2933

3034
return MessageFromRequest(req)
@@ -40,7 +44,12 @@ func TestContentDigesterVerify(t *testing.T) {
4044
{
4145
uc: "invalid digest value format",
4246
msg: func() *Message {
43-
req := httptest.NewRequest(http.MethodGet, "http://example.com/foo", strings.NewReader(`{"hello": "world"}`))
47+
req := httptest.NewRequestWithContext(
48+
t.Context(),
49+
http.MethodGet,
50+
"http://example.com/foo",
51+
strings.NewReader(`{"hello": "world"}`),
52+
)
4453
req.Header.Set("content-digest", "sha-256")
4554

4655
return MessageFromRequest(req)
@@ -56,7 +65,12 @@ func TestContentDigesterVerify(t *testing.T) {
5665
{
5766
uc: "unknown algorithm",
5867
msg: func() *Message {
59-
req := httptest.NewRequest(http.MethodGet, "http://example.com/foo", strings.NewReader(`{"hello": "world"}`))
68+
req := httptest.NewRequestWithContext(
69+
t.Context(),
70+
http.MethodGet,
71+
"http://example.com/foo",
72+
strings.NewReader(`{"hello": "world"}`),
73+
)
6074
req.Header.Set("content-digest", "md5=:eyJoZWxsbyI6ICJ3b3JsZCJ9:")
6175

6276
return MessageFromRequest(req)
@@ -71,7 +85,12 @@ func TestContentDigesterVerify(t *testing.T) {
7185
{
7286
uc: "digest mismatch",
7387
msg: func() *Message {
74-
req := httptest.NewRequest(http.MethodGet, "http://example.com/foo", strings.NewReader(`{"hello": "world"}`))
88+
req := httptest.NewRequestWithContext(
89+
t.Context(),
90+
http.MethodGet,
91+
"http://example.com/foo",
92+
strings.NewReader(`{"hello": "world"}`),
93+
)
7594
req.Header.Set("content-digest", "sha-256=:eyJoZWxsbyI6ICJ3b3JsZCJ9:")
7695

7796
return MessageFromRequest(req)
@@ -86,7 +105,12 @@ func TestContentDigesterVerify(t *testing.T) {
86105
{
87106
uc: "successful request digest verification",
88107
msg: func() *Message {
89-
req := httptest.NewRequest(http.MethodGet, "http://example.com/foo", strings.NewReader(`{"hello": "world"}`))
108+
req := httptest.NewRequestWithContext(
109+
t.Context(),
110+
http.MethodGet,
111+
"http://example.com/foo",
112+
strings.NewReader(`{"hello": "world"}`),
113+
)
90114
req.Header.Set("content-digest", "sha-256=:X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=:")
91115

92116
return MessageFromRequest(req)
@@ -108,8 +132,12 @@ Content-Length: 23
108132
109133
{"message": "good dog"}
110134
`
111-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "http://example.com/foo",
112-
strings.NewReader(`{"hello": "world"}`))
135+
req, err := http.NewRequestWithContext(
136+
t.Context(),
137+
http.MethodGet,
138+
"http://example.com/foo",
139+
strings.NewReader(`{"hello": "world"}`),
140+
)
113141
require.NoError(t, err)
114142

115143
resp, err := http.ReadResponse(bufio.NewReader(strings.NewReader(responseWithBody)), req) //nolint:bodyclose
@@ -134,8 +162,12 @@ Content-Length: 23
134162
135163
{"message": "good dog"}
136164
`
137-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "http://example.com/foo",
138-
strings.NewReader(`{"hello": "world"}`))
165+
req, err := http.NewRequestWithContext(
166+
t.Context(),
167+
http.MethodGet,
168+
"http://example.com/foo",
169+
strings.NewReader(`{"hello": "world"}`),
170+
)
139171
require.NoError(t, err)
140172
req.Header.Set("content-digest", "sha-256=:X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=:")
141173

@@ -175,7 +207,7 @@ func TestContentDigesterUpdate(t *testing.T) {
175207
alg: Sha256,
176208
msg: func() *Message {
177209
req, err := http.NewRequestWithContext(
178-
context.TODO(),
210+
t.Context(),
179211
http.MethodGet,
180212
"http://example.com/foo",
181213
strings.NewReader(`{"hello": "world"}`),
@@ -197,7 +229,7 @@ func TestContentDigesterUpdate(t *testing.T) {
197229
uc: "digest for client-side request without specified algorithm",
198230
msg: func() *Message {
199231
req, err := http.NewRequestWithContext(
200-
context.TODO(),
232+
t.Context(),
201233
http.MethodGet,
202234
"http://example.com/foo",
203235
strings.NewReader(`{"hello": "world"}`),
@@ -222,8 +254,12 @@ func TestContentDigesterUpdate(t *testing.T) {
222254
uc: "digest for server-side response with specifying algorithm",
223255
alg: Sha512,
224256
msg: func() *Message {
225-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "http://example.com/foo",
226-
strings.NewReader(`{"hello": "world"}`))
257+
req, err := http.NewRequestWithContext(
258+
t.Context(),
259+
http.MethodGet,
260+
"http://example.com/foo",
261+
strings.NewReader(`{"hello": "world"}`),
262+
)
227263
require.NoError(t, err)
228264

229265
return MessageForResponse(req, make(http.Header), []byte(`{"message": "good dog"}`), http.StatusOK)
@@ -240,8 +276,12 @@ func TestContentDigesterUpdate(t *testing.T) {
240276
{
241277
uc: "digest for server-side response without specifying algorithm",
242278
msg: func() *Message {
243-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "http://example.com/foo",
244-
strings.NewReader(`{"hello": "world"}`))
279+
req, err := http.NewRequestWithContext(
280+
t.Context(),
281+
http.MethodGet,
282+
"http://example.com/foo",
283+
strings.NewReader(`{"hello": "world"}`),
284+
)
245285
require.NoError(t, err)
246286

247287
return MessageForResponse(req, make(http.Header), []byte(`{"message": "good dog"}`), http.StatusOK)
@@ -263,7 +303,7 @@ func TestContentDigesterUpdate(t *testing.T) {
263303
alg: Sha256,
264304
msg: func() *Message {
265305
req, err := http.NewRequestWithContext(
266-
context.TODO(),
306+
t.Context(),
267307
http.MethodPost,
268308
"http://example.com/foo",
269309
strings.NewReader(`{"hello": "world"}`),
@@ -289,7 +329,7 @@ func TestContentDigesterUpdate(t *testing.T) {
289329
uc: "replaces existing content-digest values without specified algorithm",
290330
msg: func() *Message {
291331
req, err := http.NewRequestWithContext(
292-
context.TODO(),
332+
t.Context(),
293333
http.MethodPost,
294334
"http://example.com/foo",
295335
strings.NewReader(`{"hello": "world"}`),

‎message_test.go‎

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package httpsig
22

33
import (
44
"bufio"
5-
"context"
65
"io"
76
"net/http"
87
"net/http/httptest"
@@ -76,7 +75,12 @@ func TestMessageFromRequest(t *testing.T) {
7675
{
7776
uc: "outbound request without body",
7877
req: func() *http.Request {
79-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "http://example.com?foo=bar", nil)
78+
req, err := http.NewRequestWithContext(
79+
t.Context(),
80+
http.MethodGet,
81+
"http://example.com?foo=bar",
82+
nil,
83+
)
8084
require.NoError(t, err)
8185

8286
req.Header.Set("X-Foo-Bar", "bar")
@@ -117,7 +121,12 @@ func TestMessageFromRequest(t *testing.T) {
117121
{
118122
uc: "inbound request without body",
119123
req: func() *http.Request {
120-
req := httptest.NewRequest(http.MethodPost, "http://example.com?foo=bar", nil)
124+
req := httptest.NewRequestWithContext(
125+
t.Context(),
126+
http.MethodPost,
127+
"http://example.com?foo=bar",
128+
nil,
129+
)
121130
req.Header.Set("X-Foo-Bar", "bar")
122131

123132
return req
@@ -156,8 +165,12 @@ func TestMessageFromRequest(t *testing.T) {
156165
{
157166
uc: "outbound request with body",
158167
req: func() *http.Request {
159-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet,
160-
"http://example.com?foo=bar", strings.NewReader(`{"hello": "world"}`))
168+
req, err := http.NewRequestWithContext(
169+
t.Context(),
170+
http.MethodGet,
171+
"http://example.com?foo=bar",
172+
strings.NewReader(`{"hello": "world"}`),
173+
)
161174
require.NoError(t, err)
162175

163176
req.Header.Set("X-Foo-Bar", "bar")
@@ -198,7 +211,10 @@ func TestMessageFromRequest(t *testing.T) {
198211
{
199212
uc: "inbound request with body",
200213
req: func() *http.Request {
201-
req := httptest.NewRequest(http.MethodPost, "http://example.com?foo=bar", strings.NewReader(`{"hello": "world"}`))
214+
req := httptest.NewRequestWithContext(
215+
t.Context(),
216+
http.MethodPost,
217+
"http://example.com?foo=bar", strings.NewReader(`{"hello": "world"}`))
202218
req.Header.Set("X-Foo-Bar", "bar")
203219

204220
return req
@@ -274,8 +290,12 @@ Content-Length: 23
274290
{
275291
uc: "response without body",
276292
resp: func() *http.Response {
277-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet,
278-
"http://example.com?foo=bar", nil)
293+
req, err := http.NewRequestWithContext(
294+
t.Context(),
295+
http.MethodGet,
296+
"http://example.com?foo=bar",
297+
nil,
298+
)
279299
require.NoError(t, err)
280300
req.Header.Set("X-Foo-Bar", "bar")
281301

@@ -334,8 +354,12 @@ Content-Length: 23
334354
{
335355
uc: "response with body",
336356
resp: func() *http.Response {
337-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodPost,
338-
"http://example.com?foo=bar", strings.NewReader(`{"hello": "world"}`))
357+
req, err := http.NewRequestWithContext(
358+
t.Context(),
359+
http.MethodPost,
360+
"http://example.com?foo=bar",
361+
strings.NewReader(`{"hello": "world"}`),
362+
)
339363
require.NoError(t, err)
340364
req.Header.Set("X-Foo-Bar", "bar")
341365

@@ -416,8 +440,12 @@ func TestMessageForResponse(t *testing.T) {
416440
{
417441
uc: "response without body",
418442
req: func() *http.Request {
419-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet,
420-
"http://example.com?foo=bar", strings.NewReader(`{"hello": "world"}`))
443+
req, err := http.NewRequestWithContext(
444+
t.Context(),
445+
http.MethodGet,
446+
"http://example.com?foo=bar",
447+
strings.NewReader(`{"hello": "world"}`),
448+
)
421449
require.NoError(t, err)
422450
req.Header.Set("X-Foo-Bar", "bar")
423451

@@ -477,8 +505,12 @@ func TestMessageForResponse(t *testing.T) {
477505
{
478506
uc: "response with body",
479507
req: func() *http.Request {
480-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodPost,
481-
"http://example.com?foo=bar", strings.NewReader(`{"hello": "world"}`))
508+
req, err := http.NewRequestWithContext(
509+
t.Context(),
510+
http.MethodPost,
511+
"http://example.com?foo=bar",
512+
strings.NewReader(`{"hello": "world"}`),
513+
)
482514
require.NoError(t, err)
483515
req.Header.Set("X-Foo-Bar", "bar")
484516

0 commit comments

Comments
 (0)