Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5392363d20 |
@@ -7,7 +7,6 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
@@ -182,32 +181,13 @@ func TestDeepVerifyStopsOnBlobThatCannotBeChecked(t *testing.T) {
|
||||
storeDir := filepath.Join(t.TempDir(), "remote")
|
||||
|
||||
cfg, storer, snapshotID, keys := backUpSeveralBlobs(ctx, t, storeDir)
|
||||
denied := &statDeniedStorer{Storer: storer, deniedKey: keys[0]}
|
||||
failing := statFailingStorer{Storer: storer, failKeys: []string{keys[0]}}
|
||||
|
||||
got, err := deepVerifyJSON(ctx, t, cfg, denied, snapshotID)
|
||||
got, err := deepVerifyJSON(ctx, t, cfg, failing, snapshotID)
|
||||
require.Error(t, err)
|
||||
require.Equal(t, "failed", got.Status)
|
||||
require.Zero(t, got.Missing)
|
||||
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)
|
||||
require.Contains(t, got.ErrorMessage, errStatDenied.Error())
|
||||
}
|
||||
|
||||
// backUpSeveralBlobs backs up random data, which does not compress or
|
||||
@@ -237,10 +217,8 @@ func backUpSeveralBlobs(
|
||||
cfg, storer, snapshotID := runFileStorageBackup(
|
||||
ctx, t, fs, dataDir, storeDir, dbPath, chunkSize, maxBlobSize)
|
||||
|
||||
keys, err := storer.List(ctx, "blobs/")
|
||||
require.NoError(t, err)
|
||||
keys := storedBlobKeys(t, storeDir)
|
||||
require.GreaterOrEqual(t, len(keys), 3)
|
||||
slices.Sort(keys)
|
||||
|
||||
return cfg, storer, snapshotID, keys
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user