fix: serialize delegations and repair verification
This commit is contained in:
1 parent
99fa5de747
commit
5f17aab6ca
8 files changed
+99
-43
No files matched your search
+9
-18
@@ -10,10 +10,10 @@ import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/netip"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -63,6 +63,7 @@ type fakeWebStore struct {
|
||||
failOn map[string]error
|
||||
onLock func(state *fakeWebState)
|
||||
calls []string
|
||||
zoneLocks []string
|
||||
commits int
|
||||
rollbacks int
|
||||
}
|
||||
@@ -354,6 +355,13 @@ func (f *fakeWebStore) InTx(ctx context.Context, fn func(tx webTx) error) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *fakeWebStore) InZoneTx(ctx context.Context, zone string, log *slog.Logger, fn func(tx webTx) error) error {
|
||||
f.mu.Lock()
|
||||
f.zoneLocks = append(f.zoneLocks, zone)
|
||||
f.mu.Unlock()
|
||||
return f.InTx(ctx, fn)
|
||||
}
|
||||
|
||||
func (f *fakeWebStore) InsertAudit(ctx context.Context, e auditEntry) (int64, error) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
@@ -700,15 +708,6 @@ type webResult struct {
|
||||
audit []fakeAuditInsert
|
||||
}
|
||||
|
||||
func (r webResult) json(t *testing.T) map[string]any {
|
||||
t.Helper()
|
||||
var m map[string]any
|
||||
if err := json.Unmarshal([]byte(r.body), &m); err != nil {
|
||||
t.Fatalf("invalid JSON %q: %v", r.body, err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func (h *webHarness) do(req webRequest) webResult {
|
||||
h.t.Helper()
|
||||
var body io.Reader = strings.NewReader(req.body)
|
||||
@@ -748,14 +747,6 @@ func (h *webHarness) api(method, path, token, body string) webResult {
|
||||
return h.do(webRequest{method: method, path: apiPrefix + path, token: token, body: body})
|
||||
}
|
||||
|
||||
func trustProxies(prefixes ...string) webOption {
|
||||
return func(cfg *Config) {
|
||||
for _, p := range prefixes {
|
||||
cfg.TrustedProxies = append(cfg.TrustedProxies, netip.MustParsePrefix(p))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func expectOneAudit(t *testing.T, res webResult, operation string, status int) auditEntry {
|
||||
t.Helper()
|
||||
if len(res.audit) != 1 {
|
||||
|
||||
Reference in new issue
Block a user