security: hardening по результатам аудита безопасности
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.tswf.io/infra/go-synapse-backupper/pkg/adapters/config"
|
||||
"git.tswf.io/infra/go-synapse-backupper/pkg/adapters/crypto/keymanager"
|
||||
@@ -127,3 +128,21 @@ func TestRunOnce_ValidKeys_PgDumpMissing(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestArtifactKey(t *testing.T) {
|
||||
ts := time.Date(2025, 1, 2, 15, 4, 5, 0, time.UTC)
|
||||
key := ArtifactKey(ts)
|
||||
|
||||
wantPrefix := "synapse-20250102-150405-"
|
||||
if !strings.HasPrefix(key, wantPrefix) {
|
||||
t.Errorf("key = %q, want prefix %q", key, wantPrefix)
|
||||
}
|
||||
if !strings.HasSuffix(key, ".dump.pqenc") {
|
||||
t.Errorf("key = %q, want suffix .dump.pqenc", key)
|
||||
}
|
||||
|
||||
secondKey := ArtifactKey(ts)
|
||||
if key == secondKey {
|
||||
t.Errorf("two keys for the same timestamp collide: %q", key)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user