[#604] Add MFADelete tests with reworked mfa.Storage implementation
All checks were successful
/ DCO (pull_request) Successful in 36s
/ Builds (pull_request) Successful in 1m38s
/ Vulncheck (pull_request) Successful in 1m37s
/ OCI image (pull_request) Successful in 2m16s
/ Lint (pull_request) Successful in 2m40s
/ Tests (pull_request) Successful in 1m26s
/ Vulncheck (push) Successful in 1m18s
/ Builds (push) Successful in 1m14s
/ OCI image (push) Successful in 2m0s
/ Lint (push) Successful in 2m14s
/ Tests (push) Successful in 1m35s
All checks were successful
/ DCO (pull_request) Successful in 36s
/ Builds (pull_request) Successful in 1m38s
/ Vulncheck (pull_request) Successful in 1m37s
/ OCI image (pull_request) Successful in 2m16s
/ Lint (pull_request) Successful in 2m40s
/ Tests (pull_request) Successful in 1m26s
/ Vulncheck (push) Successful in 1m18s
/ Builds (push) Successful in 1m14s
/ OCI image (push) Successful in 2m0s
/ Lint (push) Successful in 2m14s
/ Tests (push) Successful in 1m35s
Signed-off-by: Alex Vanin <a.vanin@yadro.com> Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
parent
0fc56cbfce
commit
7d6e20fdad
17 changed files with 440 additions and 233 deletions
|
@ -25,6 +25,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/middleware"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/resolver"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/creds/accessbox"
|
||||
intmfa "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/internal/frostfs/mfa"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/pkg/service/tree"
|
||||
bearertest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/bearer/test"
|
||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
|
@ -180,6 +181,7 @@ type handlerConfig struct {
|
|||
cacheCfg *layer.CachesConfig
|
||||
withoutCORS bool
|
||||
withoutLifecycle bool
|
||||
withoutMFA bool
|
||||
}
|
||||
|
||||
func prepareHandlerContext(t *testing.T) *handlerContext {
|
||||
|
@ -198,6 +200,7 @@ func prepareWithoutContainersHandlerContext(t *testing.T, cors, lifecycle bool)
|
|||
cacheCfg: layer.DefaultCachesConfigs(log),
|
||||
withoutCORS: cors,
|
||||
withoutLifecycle: lifecycle,
|
||||
withoutMFA: true,
|
||||
}, log)
|
||||
require.NoError(t, err)
|
||||
return &handlerContext{
|
||||
|
@ -289,7 +292,14 @@ func prepareHandlerContextBase(config *handlerConfig, log *zap.Logger) (*handler
|
|||
cfg: cfg,
|
||||
ape: newAPEMock(),
|
||||
frostfsid: newFrostfsIDMock(),
|
||||
mfa: newMFAMock(),
|
||||
}
|
||||
|
||||
if !config.withoutMFA {
|
||||
// this code creates one more container, so it may affect tests
|
||||
h.mfa, err = newMFAMock(log, layerCfg.GateKey, tp, memCli)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
accessBox, err := newTestAccessBox(key)
|
||||
|
@ -483,70 +493,45 @@ 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,
|
||||
type unlocker struct {
|
||||
k *keys.PrivateKey
|
||||
}
|
||||
|
||||
func (u unlocker) PrivateKey() *keys.PrivateKey {
|
||||
return u.k
|
||||
}
|
||||
|
||||
func (u unlocker) PublicKeys() []*keys.PublicKey {
|
||||
return []*keys.PublicKey{
|
||||
u.k.PublicKey(),
|
||||
}
|
||||
}
|
||||
|
||||
func newMFAMock(log *zap.Logger, key *keys.PrivateKey, p frostfs.FrostFS, t tree.ServiceClient) (*mfa.Manager, error) {
|
||||
bktName := "mfa"
|
||||
res, err := p.CreateContainer(context.Background(), frostfs.PrmContainerCreate{
|
||||
Name: bktName,
|
||||
Policy: getPlacementPolicy(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
manager, _ := mfa.NewManager(cfg)
|
||||
f := intmfa.NewMFAFrostFS(intmfa.FrostFSMFAConfig{
|
||||
ObjStor: p,
|
||||
TreeStor: t,
|
||||
Key: key,
|
||||
Logger: log,
|
||||
})
|
||||
|
||||
return man
|
||||
}
|
||||
cfg := mfa.Config{
|
||||
Storage: f,
|
||||
Unlocker: unlocker{k: key},
|
||||
Container: res.ContainerID,
|
||||
Logger: log,
|
||||
}
|
||||
|
||||
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")
|
||||
return mfa.NewManager(cfg)
|
||||
}
|
||||
|
||||
func (f *frostfsidMock) GetUserAddress(account, user string) (string, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue