Initial commit: archer, a Go-native MySQL/MariaDB table archiver
Renamed from arcdb: module path, cmd/archer, internal/archererr, docs, build scripts and ARCHER_* environment variables. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
bc4a6b504f
99 files changed
+12752
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"archer/internal/checkpoint"
|
||||
"archer/internal/cli"
|
||||
)
|
||||
|
||||
func TestStateConfigStoresRedactedDSN(t *testing.T) {
|
||||
const source = "u:s3cr3t@tcp(h:3306)/db?charset=utf8mb4"
|
||||
cfg, err := cli.Parse([]string{"--source", source, "--table", "t", "--where", "id > 0", "--file", "out"}, &bytes.Buffer{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hash, fields, err := cfg.Fingerprint()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
dir := t.TempDir()
|
||||
if err := checkpoint.Save(dir, &checkpoint.State{ConfigHash: hash, Config: fields}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
st, err := checkpoint.Load(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
want := redactDSN(source)
|
||||
if st.Config["source"] != want {
|
||||
t.Fatalf("config.source = %q, want %q", st.Config["source"], want)
|
||||
}
|
||||
raw, err := os.ReadFile(checkpoint.Path(dir))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if bytes.Contains(raw, []byte("s3cr3t")) {
|
||||
t.Fatal("state.json must not contain the password")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user