Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
763be0ec37 |
@@ -7,6 +7,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
@@ -181,13 +182,32 @@ func TestDeepVerifyStopsOnBlobThatCannotBeChecked(t *testing.T) {
|
|||||||
storeDir := filepath.Join(t.TempDir(), "remote")
|
storeDir := filepath.Join(t.TempDir(), "remote")
|
||||||
|
|
||||||
cfg, storer, snapshotID, keys := backUpSeveralBlobs(ctx, t, storeDir)
|
cfg, storer, snapshotID, keys := backUpSeveralBlobs(ctx, t, storeDir)
|
||||||
failing := statFailingStorer{Storer: storer, failKeys: []string{keys[0]}}
|
denied := &statDeniedStorer{Storer: storer, deniedKey: keys[0]}
|
||||||
|
|
||||||
got, err := deepVerifyJSON(ctx, t, cfg, failing, snapshotID)
|
got, err := deepVerifyJSON(ctx, t, cfg, denied, snapshotID)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.Equal(t, "failed", got.Status)
|
require.Equal(t, "failed", got.Status)
|
||||||
require.Zero(t, got.Missing)
|
require.Zero(t, got.Missing)
|
||||||
require.Contains(t, got.ErrorMessage, errStatDenied.Error())
|
require.Contains(t, got.ErrorMessage, os.ErrPermission.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// statDeniedStorer passes every call through to the wrapped Storer,
|
||||||
|
// except that Stat of deniedKey fails with a permission error, as it
|
||||||
|
// does for a blob that is present but cannot be read.
|
||||||
|
type statDeniedStorer struct {
|
||||||
|
storage.Storer
|
||||||
|
|
||||||
|
deniedKey string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *statDeniedStorer) Stat(
|
||||||
|
ctx context.Context, key string,
|
||||||
|
) (*storage.ObjectInfo, error) {
|
||||||
|
if key == s.deniedKey {
|
||||||
|
return nil, os.ErrPermission
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.Storer.Stat(ctx, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// backUpSeveralBlobs backs up random data, which does not compress or
|
// backUpSeveralBlobs backs up random data, which does not compress or
|
||||||
@@ -217,8 +237,10 @@ func backUpSeveralBlobs(
|
|||||||
cfg, storer, snapshotID := runFileStorageBackup(
|
cfg, storer, snapshotID := runFileStorageBackup(
|
||||||
ctx, t, fs, dataDir, storeDir, dbPath, chunkSize, maxBlobSize)
|
ctx, t, fs, dataDir, storeDir, dbPath, chunkSize, maxBlobSize)
|
||||||
|
|
||||||
keys := storedBlobKeys(t, storeDir)
|
keys, err := storer.List(ctx, "blobs/")
|
||||||
|
require.NoError(t, err)
|
||||||
require.GreaterOrEqual(t, len(keys), 3)
|
require.GreaterOrEqual(t, len(keys), 3)
|
||||||
|
slices.Sort(keys)
|
||||||
|
|
||||||
return cfg, storer, snapshotID, keys
|
return cfg, storer, snapshotID, keys
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user