forked from TrueCloudLab/frostfs-s3-gw
[#535] Support public access block operations
Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
This commit is contained in:
parent
4f0f2ca7bd
commit
a7ce40d745
23 changed files with 940 additions and 87 deletions
|
@ -133,12 +133,12 @@ type frostFSIDMock struct {
|
|||
userGroupsError bool
|
||||
}
|
||||
|
||||
func (f *frostFSIDMock) ValidatePublicKey(*keys.PublicKey) error {
|
||||
func (f *frostFSIDMock) GetUserNamespace(*keys.PublicKey) (string, error) {
|
||||
if f.validateError {
|
||||
return fmt.Errorf("some error")
|
||||
return "", fmt.Errorf("some error")
|
||||
}
|
||||
|
||||
return nil
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (f *frostFSIDMock) GetUserGroupIDsAndClaims(util.Uint160) ([]string, map[string]string, error) {
|
||||
|
@ -176,9 +176,10 @@ func (m *resourceTaggingMock) GetObjectTagging(context.Context, *data.GetObjectT
|
|||
}
|
||||
|
||||
type handlerMock struct {
|
||||
t *testing.T
|
||||
cfg *middlewareSettingsMock
|
||||
buckets map[string]*data.BucketInfo
|
||||
t *testing.T
|
||||
cfg *middlewareSettingsMock
|
||||
buckets map[string]*data.BucketInfo
|
||||
restrict map[string]error
|
||||
}
|
||||
|
||||
type handlerResult struct {
|
||||
|
@ -577,6 +578,37 @@ func (h *handlerMock) PatchObjectHandler(http.ResponseWriter, *http.Request) {
|
|||
panic("implement me")
|
||||
}
|
||||
|
||||
func (h *handlerMock) PutPublicAccessBlockHandler(w http.ResponseWriter, r *http.Request) {
|
||||
cfg := new(data.PublicAccessBlockConfiguration)
|
||||
err := xml.NewDecoder(r.Body).Decode(cfg)
|
||||
require.NoError(h.t, err)
|
||||
|
||||
if cfg.RestrictPublicBuckets {
|
||||
reqInfo := middleware.GetReqInfo(r.Context())
|
||||
h.restrict[reqInfo.Namespace+reqInfo.BucketName] = apierr.GetAPIError(apierr.ErrAccessDenied)
|
||||
}
|
||||
|
||||
res := &handlerResult{
|
||||
Method: "PutPublicAccessBlock",
|
||||
ReqInfo: middleware.GetReqInfo(r.Context()),
|
||||
}
|
||||
|
||||
h.writeResponse(w, res)
|
||||
}
|
||||
|
||||
func (h *handlerMock) GetPublicAccessBlockHandler(http.ResponseWriter, *http.Request) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (h *handlerMock) DeletePublicAccessBlockHandler(http.ResponseWriter, *http.Request) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (h *handlerMock) CheckRestrictPublicBuckets(ctx context.Context) error {
|
||||
reqInfo := middleware.GetReqInfo(ctx)
|
||||
return h.restrict[reqInfo.Namespace+reqInfo.BucketName]
|
||||
}
|
||||
|
||||
func (h *handlerMock) ResolveBucket(ctx context.Context, name string) (*data.BucketInfo, error) {
|
||||
reqInfo := middleware.GetReqInfo(ctx)
|
||||
bktInfo, ok := h.buckets[reqInfo.Namespace+name]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue