Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5392363d20 |
@@ -7,7 +7,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
@@ -182,32 +181,13 @@ 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)
|
||||||
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.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, os.ErrPermission.Error())
|
require.Contains(t, got.ErrorMessage, errStatDenied.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
|
||||||
@@ -237,10 +217,8 @@ 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, err := storer.List(ctx, "blobs/")
|
keys := storedBlobKeys(t, storeDir)
|
||||||
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