| index ed0a87d9a..d4c389278 100644 |
| --- a/internal/provision/reconcile_test.go |
| +++ b/internal/provision/reconcile_test.go |
| @@ -582,12 +582,26 @@ func TestReconcileConvergesGate(t *testing.T) { |
| t.Fatalf("minted Gate = %q, want open", before.Gate) |
| } |
| |
| + // From here on the log is captured: the converge line names the STATE, |
| + // never the secret. A bcrypt hash is not a password, but it is the |
| + // material an offline cracker works on, and an operations log is copied, |
| + // shipped and pasted far more freely than the registry row is. |
| + var logged bytes.Buffer |
| + log.SetOutput(&logged) |
| + t.Cleanup(func() { log.SetOutput(os.Stderr) }) |
| + |
| const hash = "$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy" |
| rec.Gate = hash |
| putReplace(t, s, RecordKey(sqid, "tito", rec.Host), mustJSON(t, rec)) |
| if err := Reconcile(ctx, s, reg, cfg); err != nil { |
| t.Fatal(err) |
| } |
| + if !strings.Contains(logged.String(), "converged acme.go.tito.io gate open -> set") { |
| + t.Errorf("no open -> set line logged; log was:\n%s", logged.String()) |
| + } |
| + if strings.Contains(logged.String(), hash) { |
| + t.Errorf("the hash reached the log:\n%s", logged.String()) |
| + } |
| after := *mustGet(t, reg, "acme.go.tito.io") |
| if after.Gate != hash { |
| t.Errorf("gate = %q, want the hash", after.Gate) |
| @@ -602,12 +616,19 @@ func TestReconcileConvergesGate(t *testing.T) { |
| // row through SetGate. |
| rec.Gate = "" |
| putReplace(t, s, RecordKey(sqid, "tito", rec.Host), mustJSON(t, rec)) |
| + logged.Reset() |
| if err := Reconcile(ctx, s, reg, cfg); err != nil { |
| t.Fatal(err) |
| } |
| if got := mustGet(t, reg, "acme.go.tito.io").Gate; got != "" { |
| t.Errorf("gate = %q, want it cleared", got) |
| } |
| + if !strings.Contains(logged.String(), "converged acme.go.tito.io gate set -> open") { |
| + t.Errorf("no set -> open line logged; log was:\n%s", logged.String()) |
| + } |
| + if strings.Contains(logged.String(), hash) { |
| + t.Errorf("the hash reached the log:\n%s", logged.String()) |
| + } |
| } |
| |
| // An explicit Hibernate converges; an absent one never does. Absent means |