Close out the repository audit

This commit is contained in:
2026-08-13 13:52:16 +00:00
parent 13b06039b1
commit fc8ddada9a
29 changed files with 421 additions and 263 deletions

View File

@@ -11,6 +11,8 @@ import (
"runtime"
"strings"
"testing"
"gitea.maximumdirect.net/eric/weatherreporter/internal/testutil"
)
func TestPlanDestination(t *testing.T) {
@@ -51,11 +53,11 @@ func TestPlanDestination(t *testing.T) {
t.Run("symbolic links", func(t *testing.T) {
link := filepath.Join(workingDirectory, "link")
requireSymlink(t, empty, link)
testutil.RequireSymlink(t, empty, link)
assertDestinationErrorKind(t, workingDirectory, link, false, DestinationSymlink)
dangling := filepath.Join(workingDirectory, "dangling")
requireSymlink(t, filepath.Join(workingDirectory, "missing"), dangling)
testutil.RequireSymlink(t, filepath.Join(workingDirectory, "missing"), dangling)
assertDestinationErrorKind(t, workingDirectory, dangling, false, DestinationSymlink)
assertDestinationErrorKind(t, workingDirectory, filepath.Join(dangling, "child"), false, DestinationInspection)
})
@@ -116,7 +118,7 @@ func TestRecognizeBundleRejectsUnsafeAndMalformedContents(t *testing.T) {
if err := os.Remove(path); err != nil {
t.Fatal(err)
}
requireSymlink(t, filepath.Join(directory, DataPackageFilename), path)
testutil.RequireSymlink(t, filepath.Join(directory, DataPackageFilename), path)
}},
{name: "digest mismatch", mutate: func(t *testing.T, directory string) {
t.Helper()
@@ -365,7 +367,7 @@ func TestPublishReauthorizesMovedDestination(t *testing.T) {
},
mutate: func(t *testing.T, target string) {
t.Helper()
requireSymlink(t, "unrelated-target", target)
testutil.RequireSymlink(t, "unrelated-target", target)
},
verify: func(t *testing.T, target string) {
t.Helper()
@@ -430,13 +432,6 @@ func TestPublishReauthorizesMovedDestination(t *testing.T) {
}
}
func requireSymlink(t *testing.T, target string, link string) {
t.Helper()
if err := os.Symlink(target, link); err != nil {
t.Skipf("symlink support is unavailable: %v", err)
}
}
func TestPublishRetainsUnauthorizedMovedDestinationWhenRestoreFails(t *testing.T) {
workingDirectory := t.TempDir()
target := filepath.Join(workingDirectory, "comparison-daily")