mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
Fix S3 configurable path handling (#7966)
Also remove some incorrect skipping of the S3 test. Fixes #7362
This commit is contained in:
@@ -225,6 +225,11 @@ func (s *S3Backend) Get(ctx context.Context, key string) (*physical.Entry, error
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Strip path prefix
|
||||
if s.path != "" {
|
||||
key = strings.TrimPrefix(key, s.path+"/")
|
||||
}
|
||||
|
||||
ent := &physical.Entry{
|
||||
Key: key,
|
||||
Value: data.Bytes(),
|
||||
@@ -266,8 +271,8 @@ func (s *S3Backend) List(ctx context.Context, prefix string) ([]string, error) {
|
||||
// Setup prefix
|
||||
prefix = path.Join(s.path, prefix)
|
||||
|
||||
// Validate prefix is ending with a "/"
|
||||
if !strings.HasSuffix(prefix, "/") {
|
||||
// Validate prefix (if present) is ending with a "/"
|
||||
if prefix != "" && !strings.HasSuffix(prefix, "/") {
|
||||
prefix += "/"
|
||||
}
|
||||
|
||||
|
||||
@@ -34,12 +34,12 @@ func DoS3BackendTest(t *testing.T, kmsKeyId string) {
|
||||
|
||||
credsChain, err := credsConfig.GenerateCredentialChain()
|
||||
if err != nil {
|
||||
t.SkipNow()
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = credsChain.Get()
|
||||
if err != nil {
|
||||
t.SkipNow()
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// If the variable is empty or doesn't exist, the default
|
||||
|
||||
Reference in New Issue
Block a user