Fix S3 configurable path handling (#7966)
Also remove some incorrect skipping of the S3 test. Fixes #7362
This commit is contained in:
parent
f991b92dc3
commit
5d5c1374d2
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue