fix(brain_edit): snapshot, rollback and lock file go through the brain root (#192) #194

Open
mathias wants to merge 3 commits from fix/edit-path-io-192 into main
Showing only changes of commit cdcff126ef - Show all commits
@@ -111,6 +111,12 @@ func TestBrainEditRollbackDoesNotWriteThroughASymlinkSwappedInForTheNote(t *test
})() })()
resp := authCall(t, srv, jwtAuthz, "brain_edit", map[string]any{"path": path, "old_str": "static body", "new_str": "injected"}) resp := authCall(t, srv, jwtAuthz, "brain_edit", map[string]any{"path": path, "old_str": "static body", "new_str": "injected"})
require.NotNil(t, resp["error"]) require.NotNil(t, resp["error"])
// The swap happened and the rollback refused it: the error says so,
// and the note path is still the planted symlink.
assert.Contains(t, resp["error"].(map[string]any)["message"], "could NOT be rolled back")
fi, err := os.Lstat(note)
require.NoError(t, err)
assert.NotZero(t, fi.Mode()&os.ModeSymlink, "the note path is still the swapped-in symlink")
got, _ := os.ReadFile(victim) got, _ := os.ReadFile(victim)
assert.Equal(t, "untouched", string(got), "the rollback wrote through the swapped-in symlink") assert.Equal(t, "untouched", string(got), "the rollback wrote through the swapped-in symlink")
}) })