Skip to content

Commit 850f45f

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents a6ea31a + 5962af6 commit 850f45f

8 files changed

Lines changed: 64 additions & 80 deletions

File tree

go.mod

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ module github.com/codeGROOVE-dev/sprinkler
33
go 1.25.4
44

55
require (
6-
github.com/codeGROOVE-dev/retry v1.3.1
7-
golang.org/x/crypto v0.46.0
8-
golang.org/x/net v0.48.0
6+
github.com/codeGROOVE-dev/retry v1.3.0
7+
golang.org/x/crypto v0.44.0
8+
golang.org/x/net v0.47.0
99
)
1010

11-
require (
12-
github.com/codeGROOVE-dev/fido v1.10.0 // indirect
13-
github.com/puzpuzpuz/xsync/v4 v4.2.0 // indirect
14-
golang.org/x/text v0.32.0 // indirect
15-
)
11+
require golang.org/x/text v0.31.0 // indirect

go.sum

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
github.com/codeGROOVE-dev/fido v1.10.0 h1:i4Wb6LDd5nD/4Fnp47KAVUVhG1O1mN5jSRbCYPpBYjw=
2-
github.com/codeGROOVE-dev/fido v1.10.0/go.mod h1:/mqfMeKCTYTGt/Y0cWm6gh8gYBKG1w8xBsTDmu+A/pU=
3-
github.com/codeGROOVE-dev/retry v1.2.0 h1:xYpYPX2PQZmdHwuiQAGGzsBm392xIMl4nfMEFApQnu8=
4-
github.com/codeGROOVE-dev/retry v1.2.0/go.mod h1:8OgefgV1XP7lzX2PdKlCXILsYKuz6b4ZpHa/20iLi8E=
5-
github.com/codeGROOVE-dev/retry v1.3.1 h1:BAkfDzs6FssxLCGWGgM97bb+6/8GTa40Cs147vXkJOg=
6-
github.com/codeGROOVE-dev/retry v1.3.1/go.mod h1:+b3huqYGY1+ZJyuCmR8nBVLjd3WJ7qAFss+sI4s6FSc=
7-
github.com/puzpuzpuz/xsync/v4 v4.2.0 h1:dlxm77dZj2c3rxq0/XNvvUKISAmovoXF4a4qM6Wvkr0=
8-
github.com/puzpuzpuz/xsync/v4 v4.2.0/go.mod h1:VJDmTCJMBt8igNxnkQd86r+8KUeN1quSfNKu5bLYFQo=
9-
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
10-
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
11-
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
12-
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
13-
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
14-
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
15-
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
16-
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
17-
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
18-
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
19-
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
20-
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
1+
github.com/codeGROOVE-dev/retry v1.3.0 h1:/+ipAWRJLL6y1R1vprYo0FSjSBvH6fE5j9LKXjpD54g=
2+
github.com/codeGROOVE-dev/retry v1.3.0/go.mod h1:8OgefgV1XP7lzX2PdKlCXILsYKuz6b4ZpHa/20iLi8E=
3+
golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU=
4+
golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc=
5+
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
6+
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
7+
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
8+
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=

pkg/client/client_test.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,7 +2474,7 @@ func TestWritePumpContextCancellation(t *testing.T) {
24742474
// Should exit with context error
24752475
select {
24762476
case err := <-errCh:
2477-
if err != context.Canceled {
2477+
if !errors.Is(err, context.Canceled) {
24782478
t.Errorf("Expected context.Canceled, got: %v", err)
24792479
}
24802480
case <-time.After(1 * time.Second):
@@ -2523,11 +2523,9 @@ func TestReadEventsContextCancellation(t *testing.T) {
25232523
ticker := time.NewTicker(100 * time.Millisecond)
25242524
defer ticker.Stop()
25252525
for range 30 { // Try for 3 seconds max
2526-
select {
2527-
case <-ticker.C:
2528-
msg := map[string]string{"type": "ping"}
2529-
_ = websocket.JSON.Send(ws, msg)
2530-
}
2526+
<-ticker.C
2527+
msg := map[string]string{"type": "ping"}
2528+
_ = websocket.JSON.Send(ws, msg)
25312529
}
25322530
}))
25332531
defer srv.Close()
@@ -2560,7 +2558,7 @@ func TestReadEventsContextCancellation(t *testing.T) {
25602558
// Should exit when context times out
25612559
select {
25622560
case err := <-errCh:
2563-
if err != nil && err != context.DeadlineExceeded {
2561+
if err != nil && !errors.Is(err, context.DeadlineExceeded) {
25642562
t.Logf("readEvents exited with: %v (acceptable)", err)
25652563
}
25662564
case <-time.After(1 * time.Second):
@@ -2699,7 +2697,6 @@ func TestConnectWithWSSOrigin(t *testing.T) {
26992697
_ = client.Start(ctx)
27002698
}
27012699

2702-
27032700
// TestConnectEventTypesWildcard tests connecting with wildcard event type.
27042701
func TestConnectEventTypesWildcard(t *testing.T) {
27052702
srv := newMockServer(t, true)
@@ -2769,7 +2766,7 @@ func TestWriteChannelBackpressure(t *testing.T) {
27692766
"message": "Connected",
27702767
})
27712768

2772-
for i := 0; i < 200; i++ {
2769+
for i := range 200 {
27732770
event := map[string]any{
27742771
"type": "event",
27752772
"event_type": "push",
@@ -2883,7 +2880,7 @@ func TestWriteChannelClosedDuringOperation(t *testing.T) {
28832880
"message": "Connected",
28842881
})
28852882

2886-
for i := 0; i < 100; i++ {
2883+
for i := range 100 {
28872884
event := map[string]any{
28882885
"type": "event",
28892886
"event_type": "push",
@@ -2962,7 +2959,7 @@ func TestReadTimeoutDuringGracefulShutdown(t *testing.T) {
29622959
func TestConcurrentWebSocketClose(t *testing.T) {
29632960
t.Parallel()
29642961

2965-
for i := 0; i < 10; i++ {
2962+
for range 10 {
29662963
srv := httptest.NewServer(websocket.Handler(func(ws *websocket.Conn) {
29672964
var sub map[string]any
29682965
_ = websocket.JSON.Receive(ws, &sub)

pkg/github/client_test.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io"
87
"net/http"
98
"net/http/httptest"
109
"strings"
@@ -107,8 +106,8 @@ func TestAuthenticatedUser_RateLimit(t *testing.T) {
107106
attempts := 0
108107
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
109108
attempts++
110-
w.Header().Set("X-RateLimit-Remaining", "0")
111-
w.Header().Set("X-RateLimit-Reset", "1234567890")
109+
w.Header().Set("X-RateLimit-Remaining", "0") //nolint:canonicalheader // GitHub API header
110+
w.Header().Set("X-RateLimit-Reset", "1234567890") //nolint:canonicalheader // GitHub API header
112111
w.WriteHeader(http.StatusForbidden)
113112
_, _ = w.Write([]byte(`{"message":"API rate limit exceeded"}`))
114113
}))
@@ -841,16 +840,6 @@ func TestLargeResponseBody(t *testing.T) {
841840
}
842841

843842
// TestBrokenPipeError simulates a broken pipe during response read.
844-
type brokenReader struct{}
845-
846-
func (b *brokenReader) Read(p []byte) (n int, err error) {
847-
return 0, io.ErrUnexpectedEOF
848-
}
849-
850-
func (b *brokenReader) Close() error {
851-
return nil
852-
}
853-
854843
// TestUnexpectedStatusCodes tests handling of various unexpected status codes.
855844
func TestUnexpectedStatusCodes(t *testing.T) {
856845
t.Parallel()
@@ -869,6 +858,7 @@ func TestUnexpectedStatusCodes(t *testing.T) {
869858

870859
for _, tc := range testCases {
871860
t.Run(tc.name, func(t *testing.T) {
861+
t.Parallel()
872862
attempts := 0
873863
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
874864
attempts++
@@ -903,6 +893,7 @@ func TestMockClient(t *testing.T) {
903893
t.Parallel()
904894

905895
t.Run("UserAndOrgs success", func(t *testing.T) {
896+
t.Parallel()
906897
mock := &MockClient{
907898
Username: "testuser",
908899
Orgs: []string{"org1", "org2"},
@@ -926,6 +917,7 @@ func TestMockClient(t *testing.T) {
926917
})
927918

928919
t.Run("UserAndOrgs error", func(t *testing.T) {
920+
t.Parallel()
929921
mockErr := fmt.Errorf("mock error")
930922
mock := &MockClient{
931923
Err: mockErr,
@@ -943,6 +935,7 @@ func TestMockClient(t *testing.T) {
943935
})
944936

945937
t.Run("ValidateOrgMembership success", func(t *testing.T) {
938+
t.Parallel()
946939
mock := &MockClient{
947940
Username: "testuser",
948941
Orgs: []string{"org1", "org2"},
@@ -969,6 +962,7 @@ func TestMockClient(t *testing.T) {
969962
})
970963

971964
t.Run("ValidateOrgMembership not member", func(t *testing.T) {
965+
t.Parallel()
972966
mock := &MockClient{
973967
Username: "testuser",
974968
Orgs: []string{"org1", "org2"},
@@ -993,6 +987,7 @@ func TestMockClient(t *testing.T) {
993987
})
994988

995989
t.Run("ValidateOrgMembership error", func(t *testing.T) {
990+
t.Parallel()
996991
mockErr := fmt.Errorf("mock validation error")
997992
mock := &MockClient{
998993
Err: mockErr,
@@ -1010,6 +1005,7 @@ func TestMockClient(t *testing.T) {
10101005
})
10111006

10121007
t.Run("multiple calls tracking", func(t *testing.T) {
1008+
t.Parallel()
10131009
mock := &MockClient{
10141010
Username: "testuser",
10151011
Orgs: []string{"org1"},
@@ -1462,13 +1458,15 @@ func TestUserAndOrgs_TokenTypeDetection(t *testing.T) {
14621458

14631459
for _, tt := range tests {
14641460
t.Run(tt.name, func(t *testing.T) {
1461+
t.Parallel()
14651462
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1466-
if r.URL.Path == "/installation/repositories" {
1463+
switch r.URL.Path {
1464+
case "/installation/repositories":
14671465
w.WriteHeader(http.StatusNotFound)
1468-
} else if r.URL.Path == "/user" {
1466+
case "/user":
14691467
w.WriteHeader(http.StatusOK)
14701468
_ = json.NewEncoder(w).Encode(User{Login: "testuser"})
1471-
} else if r.URL.Path == "/user/orgs" {
1469+
case "/user/orgs":
14721470
w.WriteHeader(http.StatusOK)
14731471
_ = json.NewEncoder(w).Encode([]Organization{})
14741472
}

pkg/logger/logger_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,28 +369,28 @@ func TestAllFunctionsWithNilContext(t *testing.T) {
369369
SetLogger(logger)
370370

371371
// Test Info with nil context
372-
Info(nil, "info with nil context", Fields{"key": "value"})
372+
Info(context.TODO(), "info with nil context", Fields{"key": "value"})
373373
if !strings.Contains(buf.String(), "info with nil context") {
374374
t.Error("Info did not handle nil context")
375375
}
376376

377377
// Test Warn with nil context
378378
buf.Reset()
379-
Warn(nil, "warn with nil context", Fields{"key": "value"})
379+
Warn(context.TODO(), "warn with nil context", Fields{"key": "value"})
380380
if !strings.Contains(buf.String(), "warn with nil context") {
381381
t.Error("Warn did not handle nil context")
382382
}
383383

384384
// Test Error with nil context
385385
buf.Reset()
386386
err := errors.New("test error")
387-
Error(nil, "error with nil context", err, Fields{"key": "value"})
387+
Error(context.TODO(), "error with nil context", err, Fields{"key": "value"})
388388
if !strings.Contains(buf.String(), "error with nil context") {
389389
t.Error("Error did not handle nil context")
390390
}
391391

392392
// Test Debug with nil context
393393
buf.Reset()
394-
Debug(nil, "debug with nil context", Fields{"key": "value"})
394+
Debug(context.TODO(), "debug with nil context", Fields{"key": "value"})
395395
// Debug is filtered by default, just ensure no panic
396396
}

pkg/security/security_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func TestConnectionLimiterReservationMaxIPEntries(t *testing.T) {
361361

362362
// Fill up to near-max entries to trigger eviction logic
363363
// maxIPEntries is 10000, so we create many inactive entries
364-
for i := 0; i < 10005; i++ {
364+
for i := range 10005 {
365365
ip := fmt.Sprintf("192.168.%d.%d", i/256, i%256)
366366
// Create reservation then cancel to make it inactive
367367
token := limiter.Reserve(ip)
@@ -404,7 +404,7 @@ func TestConnectionLimiterEvictWithAllActive(t *testing.T) {
404404
defer limiter.Stop()
405405

406406
// Create many active connections (no inactive to evict)
407-
for i := 0; i < 10005; i++ {
407+
for i := range 10005 {
408408
ip := fmt.Sprintf("192.168.%d.%d", i/256, i%256)
409409
token := limiter.Reserve(ip)
410410
if token != "" {

pkg/srv/websocket_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,6 +2548,7 @@ func TestWebSocketCloseErrors(t *testing.T) {
25482548
t.Parallel()
25492549

25502550
t.Run("close already closed connection", func(t *testing.T) {
2551+
t.Parallel()
25512552
server := httptest.NewServer(websocket.Handler(func(ws *websocket.Conn) {
25522553
time.Sleep(50 * time.Millisecond)
25532554
}))
@@ -2567,6 +2568,7 @@ func TestWebSocketCloseErrors(t *testing.T) {
25672568
})
25682569

25692570
t.Run("close with broken pipe", func(t *testing.T) {
2571+
t.Parallel()
25702572
// Simulate broken pipe by forcefully closing underlying connection
25712573
server := httptest.NewServer(websocket.Handler(func(ws *websocket.Conn) {
25722574
time.Sleep(20 * time.Millisecond)
@@ -2675,7 +2677,7 @@ func TestConcurrentClientCloseOperations(t *testing.T) {
26752677
go hub.Run(ctx)
26762678
defer hub.Stop()
26772679

2678-
for i := 0; i < 50; i++ {
2680+
for i := range 50 {
26792681
client := &Client{
26802682
ID: fmt.Sprintf("test-client-%d", i),
26812683
send: make(chan Event, 10),
@@ -2685,7 +2687,7 @@ func TestConcurrentClientCloseOperations(t *testing.T) {
26852687

26862688
// Trigger multiple concurrent closes
26872689
var wg sync.WaitGroup
2688-
for j := 0; j < 5; j++ {
2690+
for range 5 {
26892691
wg.Add(1)
26902692
go func() {
26912693
defer wg.Done()
@@ -2758,9 +2760,9 @@ func TestValidateAuthConcurrentAccess(t *testing.T) {
27582760

27592761
// Create many concurrent WebSocket connections
27602762
var wg sync.WaitGroup
2761-
for i := 0; i < 20; i++ {
2763+
for range 20 {
27622764
wg.Add(1)
2763-
go func(id int) {
2765+
go func() {
27642766
defer wg.Done()
27652767

27662768
server := httptest.NewServer(websocket.Handler(func(ws *websocket.Conn) {
@@ -2780,7 +2782,7 @@ func TestValidateAuthConcurrentAccess(t *testing.T) {
27802782
}
27812783

27822784
_, _ = handler.validateAuth(ctx, ws, sub, "test-token", "127.0.0.1")
2783-
}(i)
2785+
}()
27842786
}
27852787
wg.Wait()
27862788
}
@@ -2799,7 +2801,7 @@ func TestHandleRapidDisconnectReconnect(t *testing.T) {
27992801

28002802
handler := NewWebSocketHandlerForTest(hub, connLimiter, nil)
28012803

2802-
for i := 0; i < 30; i++ {
2804+
for range 30 {
28032805
server := httptest.NewServer(websocket.Handler(handler.Handle))
28042806

28052807
wsURL := "ws" + strings.TrimPrefix(server.URL, "http")

0 commit comments

Comments
 (0)