[#604] Add support of MFADelete argument and x-amz-mfa header

Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
Pavel Pogodaev 2025-01-21 15:08:34 +03:00
parent 13fce51021
commit 7fbc69f4f5
28 changed files with 906 additions and 118 deletions

View file

@ -16,6 +16,7 @@ import (
"testing"
"time"
"git.frostfs.info/TrueCloudLab/frostfs-mfa/mfa"
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/cache"
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data"
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/layer"
@ -288,6 +289,7 @@ func prepareHandlerContextBase(config *handlerConfig, log *zap.Logger) (*handler
cfg: cfg,
ape: newAPEMock(),
frostfsid: newFrostfsIDMock(),
mfa: newMFAMock(),
}
accessBox, err := newTestAccessBox(key)
@ -481,6 +483,72 @@ func newFrostfsIDMock() *frostfsidMock {
return &frostfsidMock{data: map[string]*keys.PublicKey{}}
}
func newMFAMock() *mfa.Manager {
cfg := mfa.Config{
Storage: newStorageMock(),
Unlocker: nil,
Container: cid.ID{},
Logger: nil,
}
manager, _ := mfa.NewManager(cfg)
return man
}
type man mfa.Manager
func (m man) GetMFADevice(ctx context.Context, ns, mfaName string) (*mfa.SecretDevice, error) {
// TODO implement me
panic("implement me")
}
type mfaOperations interface {
GetMFADevice(ctx context.Context, ns, mfaName string) (*mfa.SecretDevice, error)
}
type storage struct {
}
func newStorageMock() *storage {
return &storage{}
}
func (s *storage) CreateObject(_ context.Context, _ mfa.PrmObjectCreate) (oid.ID, error) {
// TODO implement me
panic("implement me")
}
func (s *storage) GetObject(_ context.Context, _ oid.Address) ([]byte, error) {
// TODO implement me
panic("implement me")
}
func (s *storage) DeleteObject(_ context.Context, _ oid.Address) error {
// TODO implement me
panic("implement me")
}
func (s *storage) SetTreeNode(_ context.Context, _ cid.ID, _ string, _ map[string]string) (*mfa.TreeMultiNode, error) {
// TODO implement me
panic("implement me")
}
func (s *storage) GetTreeNode(_ context.Context, _ cid.ID, _ string) (*mfa.TreeMultiNode, error) {
// TODO implement me
panic("implement me")
}
func (s *storage) DeleteTreeNode(_ context.Context, _ cid.ID, _ string) ([]*mfa.TreeNode, error) {
// TODO implement me
panic("implement me")
}
func (s *storage) GetTreeNodes(_ context.Context, _ cid.ID, _ string) ([]*mfa.TreeNode, error) {
// TODO implement me
panic("implement me")
}
func (f *frostfsidMock) GetUserAddress(account, user string) (string, error) {
res, ok := f.data[account+user]
if !ok {
@ -530,7 +598,10 @@ func createTestBucketWithLock(hc *handlerContext, bktName string, conf *data.Obj
sp := &layer.PutSettingsParams{
BktInfo: bktInfo,
Settings: &data.BucketSettings{
Versioning: data.VersioningEnabled,
Versioning: data.Versioning{
VersioningStatus: data.VersioningEnabled,
MFADeleteStatus: data.MFADeleteDisabled,
},
LockConfiguration: conf,
OwnerKey: key.PublicKey(),
},