Skip to content

Commit

Permalink
miniogw: return 404 for GetObjectLockConfig if no lock found
Browse files Browse the repository at this point in the history
This endpoint should return a 404 for when lock config is not
found, instead of a 400.

Additionally, fix tests to use the object API layer for testing
GetObjectLockConfig. Gateway tests should not be testing the
metaclient endpoints, since that's uplink domain.

Updates storj/edge#498

Change-Id: Ic7cbb3f217acf086884c8ebe935bd9fc976c1680
  • Loading branch information
halkyon authored and Storj Robot committed Sep 10, 2024
1 parent d0242d3 commit 6229533
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions miniogw/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ func (layer *gatewayLayer) GetObjectLockConfig(ctx context.Context, bucketName s

enabled, err := bucket.GetBucketObjectLockConfiguration(ctx, project, bucketName)
if err != nil {
if errors.Is(err, bucket.ErrBucketNoLock) {
return &objectlock.Config{}, minio.BucketObjectLockConfigNotFound{Bucket: bucketName}
}
return &objectlock.Config{}, ConvertError(err, bucketName, "")
}

Expand Down
9 changes: 4 additions & 5 deletions testsuite/miniogw/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"storj.io/storj/private/testplanet"
"storj.io/storj/satellite"
"storj.io/uplink"
"storj.io/uplink/private/bucket"
)

const (
Expand Down Expand Up @@ -85,18 +84,18 @@ func TestMakeBucketWithObjectLock(t *testing.T) {
err := layer.MakeBucketWithLocation(ctx, testBucket, minio.BucketOptions{})
require.NoError(t, err)

_, err = bucket.GetBucketObjectLockConfiguration(ctx, project, testBucket)
require.ErrorIs(t, err, bucket.ErrBucketNoLock)
_, err = layer.GetObjectLockConfig(ctx, testBucket)
require.ErrorIs(t, err, minio.BucketObjectLockConfigNotFound{Bucket: testBucket})

// Create a bucket with object lock enabled
err = layer.MakeBucketWithLocation(ctx, testBucket+"2", minio.BucketOptions{
LockEnabled: true,
})
require.NoError(t, err)

enabled, err := bucket.GetBucketObjectLockConfiguration(ctx, project, testBucket+"2")
lockConfig, err := layer.GetObjectLockConfig(ctx, testBucket+"2")
require.NoError(t, err)
require.True(t, enabled)
require.Equal(t, "Enabled", lockConfig.ObjectLockEnabled)
})
}

Expand Down

0 comments on commit 6229533

Please sign in to comment.