Go 1.27 (#755)
Docker / Build and Push (push) Canceled after 0s
github-pages / deploy (push) Canceled after 0s
Test / make test (push) Canceled after 0s
Docker / release (push) Canceled after 0s

* update to go 1.27

* go fix changes
This commit is contained in:
h44z
2026-09-12 17:52:01 +02:00
committed by GitHub
parent 34ee98a51e
commit 38c372e239
46 changed files with 418 additions and 505 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ type Session interface {
type Validator interface {
// Struct validates the given struct.
Struct(s interface{}) error
Struct(s any) error
}
// endregion handler-interfaces
@@ -5,6 +5,7 @@ import (
"errors"
"net/http"
"net/http/httptest"
"sync"
"testing"
"time"
@@ -18,6 +19,24 @@ import (
// region test-helper
type syncEventBus struct {
bus evbus.MessageBus
onSubscribe func(topic string)
}
func (s *syncEventBus) Subscribe(topic string, fn any) error {
defer func() {
if s.onSubscribe != nil {
s.onSubscribe(topic)
}
}()
return s.bus.Subscribe(topic, fn)
}
func (s *syncEventBus) Unsubscribe(topic string, fn any) error {
return s.bus.Unsubscribe(topic, fn)
}
type websocketTestPeerService struct {
peers map[domain.PeerIdentifier]*domain.Peer
}
@@ -39,8 +58,17 @@ func newTestWebsocketConnection(
) (*websocket.Conn, func()) {
t.Helper()
var wg sync.WaitGroup
wg.Add(2) // TopicPeerStatsUpdated and TopicInterfaceStatsUpdated
wrappedBus := &syncEventBus{
bus: bus,
onSubscribe: func(topic string) {
wg.Done()
},
}
cfg := &config.Config{}
endpoint := NewWebsocketEndpoint(cfg, nil, bus, websocketTestPeerService{peers: peers})
endpoint := NewWebsocketEndpoint(cfg, nil, wrappedBus, websocketTestPeerService{peers: peers})
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r = r.WithContext(domain.SetUserInfo(r.Context(), userInfo))
@@ -55,6 +83,8 @@ func newTestWebsocketConnection(
t.Fatalf("failed to dial websocket: %v", err)
}
wg.Wait() // wait for eventbus to be ready
cleanup := func() {
conn.Close()
server.Close()
@@ -3,6 +3,7 @@ package handlers
import (
"context"
"net/http"
"slices"
"github.com/h44z/wg-portal/internal/app/api/core/request"
"github.com/h44z/wg-portal/internal/app/api/core/respond"
@@ -137,10 +138,8 @@ func UserHasScopes(session SessionData, scopes ...Scope) bool {
}
// Check if admin scope is required
for _, scope := range scopes {
if scope == ScopeAdmin {
return false
}
if slices.Contains(scopes, ScopeAdmin) {
return false
}
// For all other scopes, a logged-in user is sufficient (for now)