2022-02-22 18:18:05 +01:00
|
|
|
package mock_server
|
|
|
|
|
|
|
|
import (
|
2024-07-03 11:33:02 +02:00
|
|
|
"context"
|
2024-02-20 09:59:56 +01:00
|
|
|
"net"
|
2024-06-13 13:24:24 +02:00
|
|
|
"net/netip"
|
2023-02-28 15:01:24 +01:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"google.golang.org/grpc/status"
|
|
|
|
|
2022-09-30 13:47:11 +02:00
|
|
|
nbdns "github.com/netbirdio/netbird/dns"
|
2024-06-13 13:24:24 +02:00
|
|
|
"github.com/netbirdio/netbird/management/domain"
|
2022-03-26 12:08:54 +01:00
|
|
|
"github.com/netbirdio/netbird/management/server"
|
2023-01-02 15:11:32 +01:00
|
|
|
"github.com/netbirdio/netbird/management/server/activity"
|
2024-03-27 18:48:48 +01:00
|
|
|
"github.com/netbirdio/netbird/management/server/group"
|
2024-02-28 16:57:35 +01:00
|
|
|
"github.com/netbirdio/netbird/management/server/idp"
|
2022-03-26 12:08:54 +01:00
|
|
|
"github.com/netbirdio/netbird/management/server/jwtclaims"
|
2023-11-29 16:46:35 +01:00
|
|
|
nbpeer "github.com/netbirdio/netbird/management/server/peer"
|
2024-02-20 09:59:56 +01:00
|
|
|
"github.com/netbirdio/netbird/management/server/posture"
|
2022-08-18 18:22:15 +02:00
|
|
|
"github.com/netbirdio/netbird/route"
|
2022-02-22 18:18:05 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type MockAccountManager struct {
|
2024-07-03 11:33:02 +02:00
|
|
|
GetOrCreateAccountByUserFunc func(ctx context.Context, userId, domain string) (*server.Account, error)
|
|
|
|
CreateSetupKeyFunc func(ctx context.Context, accountId string, keyName string, keyType server.SetupKeyType,
|
2023-09-04 11:37:39 +02:00
|
|
|
expiresIn time.Duration, autoGroups []string, usageLimit int, userID string, ephemeral bool) (*server.SetupKey, error)
|
2024-07-03 11:33:02 +02:00
|
|
|
GetSetupKeyFunc func(ctx context.Context, accountID, userID, keyID string) (*server.SetupKey, error)
|
|
|
|
GetAccountByUserOrAccountIdFunc func(ctx context.Context, userId, accountId, domain string) (*server.Account, error)
|
|
|
|
GetUserFunc func(ctx context.Context, claims jwtclaims.AuthorizationClaims) (*server.User, error)
|
|
|
|
ListUsersFunc func(ctx context.Context, accountID string) ([]*server.User, error)
|
|
|
|
GetPeersFunc func(ctx context.Context, accountID, userID string) ([]*nbpeer.Peer, error)
|
|
|
|
MarkPeerConnectedFunc func(ctx context.Context, peerKey string, connected bool, realIP net.IP) error
|
2024-08-01 16:21:43 +02:00
|
|
|
SyncAndMarkPeerFunc func(ctx context.Context, accountID string, peerPubKey string, meta nbpeer.PeerSystemMeta, realIP net.IP) (*nbpeer.Peer, *server.NetworkMap, []*posture.Checks, error)
|
2024-07-03 11:33:02 +02:00
|
|
|
DeletePeerFunc func(ctx context.Context, accountID, peerKey, userID string) error
|
|
|
|
GetNetworkMapFunc func(ctx context.Context, peerKey string) (*server.NetworkMap, error)
|
|
|
|
GetPeerNetworkFunc func(ctx context.Context, peerKey string) (*server.Network, error)
|
|
|
|
AddPeerFunc func(ctx context.Context, setupKey string, userId string, peer *nbpeer.Peer) (*nbpeer.Peer, *server.NetworkMap, []*posture.Checks, error)
|
|
|
|
GetGroupFunc func(ctx context.Context, accountID, groupID, userID string) (*group.Group, error)
|
|
|
|
GetAllGroupsFunc func(ctx context.Context, accountID, userID string) ([]*group.Group, error)
|
|
|
|
GetGroupByNameFunc func(ctx context.Context, accountID, groupName string) (*group.Group, error)
|
|
|
|
SaveGroupFunc func(ctx context.Context, accountID, userID string, group *group.Group) error
|
2024-07-15 16:04:06 +02:00
|
|
|
SaveGroupsFunc func(ctx context.Context, accountID, userID string, groups []*group.Group) error
|
2024-07-03 11:33:02 +02:00
|
|
|
DeleteGroupFunc func(ctx context.Context, accountID, userId, groupID string) error
|
|
|
|
ListGroupsFunc func(ctx context.Context, accountID string) ([]*group.Group, error)
|
|
|
|
GroupAddPeerFunc func(ctx context.Context, accountID, groupID, peerID string) error
|
|
|
|
GroupDeletePeerFunc func(ctx context.Context, accountID, groupID, peerID string) error
|
|
|
|
DeleteRuleFunc func(ctx context.Context, accountID, ruleID, userID string) error
|
|
|
|
GetPolicyFunc func(ctx context.Context, accountID, policyID, userID string) (*server.Policy, error)
|
|
|
|
SavePolicyFunc func(ctx context.Context, accountID, userID string, policy *server.Policy) error
|
|
|
|
DeletePolicyFunc func(ctx context.Context, accountID, policyID, userID string) error
|
|
|
|
ListPoliciesFunc func(ctx context.Context, accountID, userID string) ([]*server.Policy, error)
|
|
|
|
GetUsersFromAccountFunc func(ctx context.Context, accountID, userID string) ([]*server.UserInfo, error)
|
|
|
|
GetAccountFromPATFunc func(ctx context.Context, pat string) (*server.Account, *server.User, *server.PersonalAccessToken, error)
|
|
|
|
MarkPATUsedFunc func(ctx context.Context, pat string) error
|
|
|
|
UpdatePeerMetaFunc func(ctx context.Context, peerID string, meta nbpeer.PeerSystemMeta) error
|
|
|
|
UpdatePeerSSHKeyFunc func(ctx context.Context, peerID string, sshKey string) error
|
|
|
|
UpdatePeerFunc func(ctx context.Context, accountID, userID string, peer *nbpeer.Peer) (*nbpeer.Peer, error)
|
|
|
|
CreateRouteFunc func(ctx context.Context, accountID string, prefix netip.Prefix, networkType route.NetworkType, domains domain.List, peer string, peerGroups []string, description string, netID route.NetID, masquerade bool, metric int, groups []string, enabled bool, userID string, keepRoute bool) (*route.Route, error)
|
|
|
|
GetRouteFunc func(ctx context.Context, accountID string, routeID route.ID, userID string) (*route.Route, error)
|
|
|
|
SaveRouteFunc func(ctx context.Context, accountID string, userID string, route *route.Route) error
|
|
|
|
DeleteRouteFunc func(ctx context.Context, accountID string, routeID route.ID, userID string) error
|
|
|
|
ListRoutesFunc func(ctx context.Context, accountID, userID string) ([]*route.Route, error)
|
|
|
|
SaveSetupKeyFunc func(ctx context.Context, accountID string, key *server.SetupKey, userID string) (*server.SetupKey, error)
|
|
|
|
ListSetupKeysFunc func(ctx context.Context, accountID, userID string) ([]*server.SetupKey, error)
|
|
|
|
SaveUserFunc func(ctx context.Context, accountID, userID string, user *server.User) (*server.UserInfo, error)
|
|
|
|
SaveOrAddUserFunc func(ctx context.Context, accountID, userID string, user *server.User, addIfNotExists bool) (*server.UserInfo, error)
|
2024-07-15 16:04:06 +02:00
|
|
|
SaveOrAddUsersFunc func(ctx context.Context, accountID, initiatorUserID string, update []*server.User, addIfNotExists bool) ([]*server.UserInfo, error)
|
2024-07-03 11:33:02 +02:00
|
|
|
DeleteUserFunc func(ctx context.Context, accountID string, initiatorUserID string, targetUserID string) error
|
|
|
|
CreatePATFunc func(ctx context.Context, accountID string, initiatorUserID string, targetUserId string, tokenName string, expiresIn int) (*server.PersonalAccessTokenGenerated, error)
|
|
|
|
DeletePATFunc func(ctx context.Context, accountID string, initiatorUserID string, targetUserId string, tokenID string) error
|
|
|
|
GetPATFunc func(ctx context.Context, accountID string, initiatorUserID string, targetUserId string, tokenID string) (*server.PersonalAccessToken, error)
|
|
|
|
GetAllPATsFunc func(ctx context.Context, accountID string, initiatorUserID string, targetUserId string) ([]*server.PersonalAccessToken, error)
|
|
|
|
GetNameServerGroupFunc func(ctx context.Context, accountID, userID, nsGroupID string) (*nbdns.NameServerGroup, error)
|
|
|
|
CreateNameServerGroupFunc func(ctx context.Context, accountID string, name, description string, nameServerList []nbdns.NameServer, groups []string, primary bool, domains []string, enabled bool, userID string, searchDomainsEnabled bool) (*nbdns.NameServerGroup, error)
|
|
|
|
SaveNameServerGroupFunc func(ctx context.Context, accountID, userID string, nsGroupToSave *nbdns.NameServerGroup) error
|
|
|
|
DeleteNameServerGroupFunc func(ctx context.Context, accountID, nsGroupID, userID string) error
|
|
|
|
ListNameServerGroupsFunc func(ctx context.Context, accountID string, userID string) ([]*nbdns.NameServerGroup, error)
|
|
|
|
CreateUserFunc func(ctx context.Context, accountID, userID string, key *server.UserInfo) (*server.UserInfo, error)
|
|
|
|
GetAccountFromTokenFunc func(ctx context.Context, claims jwtclaims.AuthorizationClaims) (*server.Account, *server.User, error)
|
|
|
|
CheckUserAccessByJWTGroupsFunc func(ctx context.Context, claims jwtclaims.AuthorizationClaims) error
|
|
|
|
DeleteAccountFunc func(ctx context.Context, accountID, userID string) error
|
2024-05-06 14:47:49 +02:00
|
|
|
GetDNSDomainFunc func() string
|
2024-07-03 11:33:02 +02:00
|
|
|
StoreEventFunc func(ctx context.Context, initiatorID, targetID, accountID string, activityID activity.ActivityDescriber, meta map[string]any)
|
|
|
|
GetEventsFunc func(ctx context.Context, accountID, userID string) ([]*activity.Event, error)
|
|
|
|
GetDNSSettingsFunc func(ctx context.Context, accountID, userID string) (*server.DNSSettings, error)
|
|
|
|
SaveDNSSettingsFunc func(ctx context.Context, accountID, userID string, dnsSettingsToSave *server.DNSSettings) error
|
|
|
|
GetPeerFunc func(ctx context.Context, accountID, peerID, userID string) (*nbpeer.Peer, error)
|
|
|
|
UpdateAccountSettingsFunc func(ctx context.Context, accountID, userID string, newSettings *server.Settings) (*server.Account, error)
|
|
|
|
LoginPeerFunc func(ctx context.Context, login server.PeerLogin) (*nbpeer.Peer, *server.NetworkMap, []*posture.Checks, error)
|
|
|
|
SyncPeerFunc func(ctx context.Context, sync server.PeerSync, account *server.Account) (*nbpeer.Peer, *server.NetworkMap, []*posture.Checks, error)
|
|
|
|
InviteUserFunc func(ctx context.Context, accountID string, initiatorUserID string, targetUserEmail string) error
|
2024-05-06 14:47:49 +02:00
|
|
|
GetAllConnectedPeersFunc func() (map[string]struct{}, error)
|
|
|
|
HasConnectedChannelFunc func(peerID string) bool
|
|
|
|
GetExternalCacheManagerFunc func() server.ExternalCacheManager
|
2024-07-03 11:33:02 +02:00
|
|
|
GetPostureChecksFunc func(ctx context.Context, accountID, postureChecksID, userID string) (*posture.Checks, error)
|
|
|
|
SavePostureChecksFunc func(ctx context.Context, accountID, userID string, postureChecks *posture.Checks) error
|
|
|
|
DeletePostureChecksFunc func(ctx context.Context, accountID, postureChecksID, userID string) error
|
|
|
|
ListPostureChecksFunc func(ctx context.Context, accountID, userID string) ([]*posture.Checks, error)
|
2024-05-06 14:47:49 +02:00
|
|
|
GetIdpManagerFunc func() idp.Manager
|
2024-07-03 11:33:02 +02:00
|
|
|
UpdateIntegratedValidatorGroupsFunc func(ctx context.Context, accountID string, userID string, groups []string) error
|
|
|
|
GroupValidationFunc func(ctx context.Context, accountId string, groups []string) (bool, error)
|
|
|
|
SyncPeerMetaFunc func(ctx context.Context, peerPubKey string, meta nbpeer.PeerSystemMeta) error
|
2024-05-30 15:22:42 +02:00
|
|
|
FindExistingPostureCheckFunc func(accountID string, checks *posture.ChecksDefinition) (*posture.Checks, error)
|
2024-07-03 11:33:02 +02:00
|
|
|
GetAccountIDForPeerKeyFunc func(ctx context.Context, peerKey string) (string, error)
|
2024-03-27 18:48:48 +01:00
|
|
|
}
|
|
|
|
|
2024-08-01 16:21:43 +02:00
|
|
|
func (am *MockAccountManager) SyncAndMarkPeer(ctx context.Context, accountID string, peerPubKey string, meta nbpeer.PeerSystemMeta, realIP net.IP) (*nbpeer.Peer, *server.NetworkMap, []*posture.Checks, error) {
|
2024-05-07 14:30:03 +02:00
|
|
|
if am.SyncAndMarkPeerFunc != nil {
|
2024-08-01 16:21:43 +02:00
|
|
|
return am.SyncAndMarkPeerFunc(ctx, accountID, peerPubKey, meta, realIP)
|
2024-05-07 14:30:03 +02:00
|
|
|
}
|
2024-06-22 16:41:16 +02:00
|
|
|
return nil, nil, nil, status.Errorf(codes.Unimplemented, "method MarkPeerConnected is not implemented")
|
2024-05-07 14:30:03 +02:00
|
|
|
}
|
|
|
|
|
2024-08-01 16:21:43 +02:00
|
|
|
func (am *MockAccountManager) OnPeerDisconnected(_ context.Context, accountID string, peerPubKey string) error {
|
2024-05-07 14:30:03 +02:00
|
|
|
// TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2024-03-27 18:48:48 +01:00
|
|
|
func (am *MockAccountManager) GetValidatedPeers(account *server.Account) (map[string]struct{}, error) {
|
|
|
|
approvedPeers := make(map[string]struct{})
|
|
|
|
for id := range account.Peers {
|
|
|
|
approvedPeers[id] = struct{}{}
|
|
|
|
}
|
|
|
|
return approvedPeers, nil
|
2022-05-05 08:58:34 +02:00
|
|
|
}
|
|
|
|
|
2024-03-27 16:11:45 +01:00
|
|
|
// GetGroup mock implementation of GetGroup from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetGroup(ctx context.Context, accountId, groupID, userID string) (*group.Group, error) {
|
2024-03-27 16:11:45 +01:00
|
|
|
if am.GetGroupFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetGroupFunc(ctx, accountId, groupID, userID)
|
2024-03-27 16:11:45 +01:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetGroup is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetAllGroups mock implementation of GetAllGroups from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetAllGroups(ctx context.Context, accountID, userID string) ([]*group.Group, error) {
|
2024-03-27 16:11:45 +01:00
|
|
|
if am.GetAllGroupsFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetAllGroupsFunc(ctx, accountID, userID)
|
2024-03-27 16:11:45 +01:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetAllGroups is not implemented")
|
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// GetUsersFromAccount mock implementation of GetUsersFromAccount from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetUsersFromAccount(ctx context.Context, accountID string, userID string) ([]*server.UserInfo, error) {
|
2022-05-05 08:58:34 +02:00
|
|
|
if am.GetUsersFromAccountFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetUsersFromAccountFunc(ctx, accountID, userID)
|
2022-05-05 08:58:34 +02:00
|
|
|
}
|
2022-06-23 17:04:53 +02:00
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetUsersFromAccount is not implemented")
|
2022-05-03 16:02:51 +02:00
|
|
|
}
|
|
|
|
|
2022-11-07 12:10:56 +01:00
|
|
|
// DeletePeer mock implementation of DeletePeer from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) DeletePeer(ctx context.Context, accountID, peerID, userID string) error {
|
2022-11-07 12:10:56 +01:00
|
|
|
if am.DeletePeerFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.DeletePeerFunc(ctx, accountID, peerID, userID)
|
2022-11-07 12:10:56 +01:00
|
|
|
}
|
2023-10-01 19:51:39 +02:00
|
|
|
return status.Errorf(codes.Unimplemented, "method DeletePeer is not implemented")
|
2022-11-07 12:10:56 +01:00
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// GetOrCreateAccountByUser mock implementation of GetOrCreateAccountByUser from server.AccountManager interface
|
2022-05-03 16:02:51 +02:00
|
|
|
func (am *MockAccountManager) GetOrCreateAccountByUser(
|
2024-07-03 11:33:02 +02:00
|
|
|
ctx context.Context, userId, domain string,
|
2022-05-03 16:02:51 +02:00
|
|
|
) (*server.Account, error) {
|
2022-02-22 18:18:05 +01:00
|
|
|
if am.GetOrCreateAccountByUserFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetOrCreateAccountByUserFunc(ctx, userId, domain)
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
2022-05-03 16:02:51 +02:00
|
|
|
return nil, status.Errorf(
|
|
|
|
codes.Unimplemented,
|
2022-06-23 17:04:53 +02:00
|
|
|
"method GetOrCreateAccountByUser is not implemented",
|
2022-05-03 16:02:51 +02:00
|
|
|
)
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
|
|
|
|
2022-09-11 23:16:40 +02:00
|
|
|
// CreateSetupKey mock implementation of CreateSetupKey from server.AccountManager interface
|
|
|
|
func (am *MockAccountManager) CreateSetupKey(
|
2024-07-03 11:33:02 +02:00
|
|
|
ctx context.Context,
|
2022-12-05 13:09:59 +01:00
|
|
|
accountID string,
|
2022-05-03 16:02:51 +02:00
|
|
|
keyName string,
|
|
|
|
keyType server.SetupKeyType,
|
2022-06-14 10:32:54 +02:00
|
|
|
expiresIn time.Duration,
|
2022-09-11 23:16:40 +02:00
|
|
|
autoGroups []string,
|
2022-12-05 13:09:59 +01:00
|
|
|
usageLimit int,
|
2023-01-02 15:11:32 +01:00
|
|
|
userID string,
|
2023-09-04 11:37:39 +02:00
|
|
|
ephemeral bool,
|
2022-05-03 16:02:51 +02:00
|
|
|
) (*server.SetupKey, error) {
|
2022-09-11 23:16:40 +02:00
|
|
|
if am.CreateSetupKeyFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.CreateSetupKeyFunc(ctx, accountID, keyName, keyType, expiresIn, autoGroups, usageLimit, userID, ephemeral)
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
2022-09-11 23:16:40 +02:00
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method CreateSetupKey is not implemented")
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
|
|
|
|
2022-11-11 20:36:45 +01:00
|
|
|
// GetAccountByUserOrAccountID mock implementation of GetAccountByUserOrAccountID from server.AccountManager interface
|
2022-11-07 17:52:23 +01:00
|
|
|
func (am *MockAccountManager) GetAccountByUserOrAccountID(
|
2024-07-03 11:33:02 +02:00
|
|
|
ctx context.Context, userId, accountId, domain string,
|
2022-05-03 16:02:51 +02:00
|
|
|
) (*server.Account, error) {
|
2022-02-22 18:18:05 +01:00
|
|
|
if am.GetAccountByUserOrAccountIdFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetAccountByUserOrAccountIdFunc(ctx, userId, accountId, domain)
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
2022-05-03 16:02:51 +02:00
|
|
|
return nil, status.Errorf(
|
|
|
|
codes.Unimplemented,
|
2022-11-07 17:52:23 +01:00
|
|
|
"method GetAccountByUserOrAccountID is not implemented",
|
2022-05-03 16:02:51 +02:00
|
|
|
)
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// MarkPeerConnected mock implementation of MarkPeerConnected from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) MarkPeerConnected(ctx context.Context, peerKey string, connected bool, realIP net.IP, account *server.Account) error {
|
2022-02-22 18:18:05 +01:00
|
|
|
if am.MarkPeerConnectedFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.MarkPeerConnectedFunc(ctx, peerKey, connected, realIP)
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
2022-06-23 17:04:53 +02:00
|
|
|
return status.Errorf(codes.Unimplemented, "method MarkPeerConnected is not implemented")
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
|
|
|
|
2023-03-16 16:44:05 +01:00
|
|
|
// GetAccountFromPAT mock implementation of GetAccountFromPAT from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetAccountFromPAT(ctx context.Context, pat string) (*server.Account, *server.User, *server.PersonalAccessToken, error) {
|
2023-03-16 16:44:05 +01:00
|
|
|
if am.GetAccountFromPATFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetAccountFromPATFunc(ctx, pat)
|
2023-03-16 16:44:05 +01:00
|
|
|
}
|
2023-03-29 15:25:44 +02:00
|
|
|
return nil, nil, nil, status.Errorf(codes.Unimplemented, "method GetAccountFromPAT is not implemented")
|
2023-03-16 16:44:05 +01:00
|
|
|
}
|
|
|
|
|
2023-11-28 14:23:38 +01:00
|
|
|
// DeleteAccount mock implementation of DeleteAccount from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) DeleteAccount(ctx context.Context, accountID, userID string) error {
|
2023-11-28 14:23:38 +01:00
|
|
|
if am.DeleteAccountFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.DeleteAccountFunc(ctx, accountID, userID)
|
2023-11-28 14:23:38 +01:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method DeleteAccount is not implemented")
|
|
|
|
}
|
|
|
|
|
2023-03-30 10:54:09 +02:00
|
|
|
// MarkPATUsed mock implementation of MarkPATUsed from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) MarkPATUsed(ctx context.Context, pat string) error {
|
2023-03-30 10:54:09 +02:00
|
|
|
if am.MarkPATUsedFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.MarkPATUsedFunc(ctx, pat)
|
2023-03-30 10:54:09 +02:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method MarkPATUsed is not implemented")
|
|
|
|
}
|
|
|
|
|
2023-03-30 13:58:44 +02:00
|
|
|
// CreatePAT mock implementation of GetPAT from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) CreatePAT(ctx context.Context, accountID string, initiatorUserID string, targetUserID string, name string, expiresIn int) (*server.PersonalAccessTokenGenerated, error) {
|
2023-03-30 13:58:44 +02:00
|
|
|
if am.CreatePATFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.CreatePATFunc(ctx, accountID, initiatorUserID, targetUserID, name, expiresIn)
|
2023-03-20 16:38:17 +01:00
|
|
|
}
|
2023-03-30 13:58:44 +02:00
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method CreatePAT is not implemented")
|
2023-03-20 16:38:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// DeletePAT mock implementation of DeletePAT from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) DeletePAT(ctx context.Context, accountID string, initiatorUserID string, targetUserID string, tokenID string) error {
|
2023-03-20 16:38:17 +01:00
|
|
|
if am.DeletePATFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.DeletePATFunc(ctx, accountID, initiatorUserID, targetUserID, tokenID)
|
2023-03-20 16:38:17 +01:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method DeletePAT is not implemented")
|
|
|
|
}
|
|
|
|
|
2023-03-30 13:58:44 +02:00
|
|
|
// GetPAT mock implementation of GetPAT from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetPAT(ctx context.Context, accountID string, initiatorUserID string, targetUserID string, tokenID string) (*server.PersonalAccessToken, error) {
|
2023-03-30 13:58:44 +02:00
|
|
|
if am.GetPATFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetPATFunc(ctx, accountID, initiatorUserID, targetUserID, tokenID)
|
2023-03-30 13:58:44 +02:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetPAT is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetAllPATs mock implementation of GetAllPATs from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetAllPATs(ctx context.Context, accountID string, initiatorUserID string, targetUserID string) ([]*server.PersonalAccessToken, error) {
|
2023-03-30 13:58:44 +02:00
|
|
|
if am.GetAllPATsFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetAllPATsFunc(ctx, accountID, initiatorUserID, targetUserID)
|
2023-03-30 13:58:44 +02:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetAllPATs is not implemented")
|
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// GetNetworkMap mock implementation of GetNetworkMap from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetNetworkMap(ctx context.Context, peerKey string) (*server.NetworkMap, error) {
|
2022-02-22 18:18:05 +01:00
|
|
|
if am.GetNetworkMapFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetNetworkMapFunc(ctx, peerKey)
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
2022-06-23 17:04:53 +02:00
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetNetworkMap is not implemented")
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
|
|
|
|
2022-06-24 21:30:51 +02:00
|
|
|
// GetPeerNetwork mock implementation of GetPeerNetwork from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetPeerNetwork(ctx context.Context, peerKey string) (*server.Network, error) {
|
2022-06-24 21:30:51 +02:00
|
|
|
if am.GetPeerNetworkFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetPeerNetworkFunc(ctx, peerKey)
|
2022-06-24 21:30:51 +02:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetPeerNetwork is not implemented")
|
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// AddPeer mock implementation of AddPeer from server.AccountManager interface
|
2022-05-25 18:26:50 +02:00
|
|
|
func (am *MockAccountManager) AddPeer(
|
2024-07-03 11:33:02 +02:00
|
|
|
ctx context.Context,
|
2022-05-25 18:26:50 +02:00
|
|
|
setupKey string,
|
|
|
|
userId string,
|
2023-11-29 16:46:35 +01:00
|
|
|
peer *nbpeer.Peer,
|
2024-06-22 16:41:16 +02:00
|
|
|
) (*nbpeer.Peer, *server.NetworkMap, []*posture.Checks, error) {
|
2022-02-22 18:18:05 +01:00
|
|
|
if am.AddPeerFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.AddPeerFunc(ctx, setupKey, userId, peer)
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
2024-06-22 16:41:16 +02:00
|
|
|
return nil, nil, nil, status.Errorf(codes.Unimplemented, "method AddPeer is not implemented")
|
2022-02-22 18:18:05 +01:00
|
|
|
}
|
2022-05-03 16:02:51 +02:00
|
|
|
|
2024-01-19 15:41:27 +01:00
|
|
|
// GetGroupByName mock implementation of GetGroupByName from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetGroupByName(ctx context.Context, accountID, groupName string) (*group.Group, error) {
|
2024-01-19 15:41:27 +01:00
|
|
|
if am.GetGroupFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetGroupByNameFunc(ctx, accountID, groupName)
|
2024-01-19 15:41:27 +01:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetGroupByName is not implemented")
|
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// SaveGroup mock implementation of SaveGroup from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) SaveGroup(ctx context.Context, accountID, userID string, group *group.Group) error {
|
2022-05-03 16:02:51 +02:00
|
|
|
if am.SaveGroupFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.SaveGroupFunc(ctx, accountID, userID, group)
|
2022-05-03 16:02:51 +02:00
|
|
|
}
|
2022-06-23 17:04:53 +02:00
|
|
|
return status.Errorf(codes.Unimplemented, "method SaveGroup is not implemented")
|
2022-05-03 16:02:51 +02:00
|
|
|
}
|
|
|
|
|
2024-07-15 16:04:06 +02:00
|
|
|
// SaveGroups mock implementation of SaveGroups from server.AccountManager interface
|
|
|
|
func (am *MockAccountManager) SaveGroups(ctx context.Context, accountID, userID string, groups []*group.Group) error {
|
|
|
|
if am.SaveGroupsFunc != nil {
|
|
|
|
return am.SaveGroupsFunc(ctx, accountID, userID, groups)
|
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method SaveGroups is not implemented")
|
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// DeleteGroup mock implementation of DeleteGroup from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) DeleteGroup(ctx context.Context, accountId, userId, groupID string) error {
|
2022-05-03 16:02:51 +02:00
|
|
|
if am.DeleteGroupFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.DeleteGroupFunc(ctx, accountId, userId, groupID)
|
2022-05-03 16:02:51 +02:00
|
|
|
}
|
2022-06-23 17:04:53 +02:00
|
|
|
return status.Errorf(codes.Unimplemented, "method DeleteGroup is not implemented")
|
2022-05-03 16:02:51 +02:00
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// ListGroups mock implementation of ListGroups from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) ListGroups(ctx context.Context, accountID string) ([]*group.Group, error) {
|
2022-05-03 16:02:51 +02:00
|
|
|
if am.ListGroupsFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.ListGroupsFunc(ctx, accountID)
|
2022-05-03 16:02:51 +02:00
|
|
|
}
|
2022-06-23 17:04:53 +02:00
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method ListGroups is not implemented")
|
2022-05-03 16:02:51 +02:00
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// GroupAddPeer mock implementation of GroupAddPeer from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GroupAddPeer(ctx context.Context, accountID, groupID, peerID string) error {
|
2022-05-03 16:02:51 +02:00
|
|
|
if am.GroupAddPeerFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GroupAddPeerFunc(ctx, accountID, groupID, peerID)
|
2022-05-03 16:02:51 +02:00
|
|
|
}
|
2022-06-23 17:04:53 +02:00
|
|
|
return status.Errorf(codes.Unimplemented, "method GroupAddPeer is not implemented")
|
2022-05-03 16:02:51 +02:00
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// GroupDeletePeer mock implementation of GroupDeletePeer from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GroupDeletePeer(ctx context.Context, accountID, groupID, peerID string) error {
|
2022-05-03 16:02:51 +02:00
|
|
|
if am.GroupDeletePeerFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GroupDeletePeerFunc(ctx, accountID, groupID, peerID)
|
2022-05-03 16:02:51 +02:00
|
|
|
}
|
2022-06-23 17:04:53 +02:00
|
|
|
return status.Errorf(codes.Unimplemented, "method GroupDeletePeer is not implemented")
|
2022-05-03 16:02:51 +02:00
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// DeleteRule mock implementation of DeleteRule from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) DeleteRule(ctx context.Context, accountID, ruleID, userID string) error {
|
2022-05-21 15:21:39 +02:00
|
|
|
if am.DeleteRuleFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.DeleteRuleFunc(ctx, accountID, ruleID, userID)
|
2022-05-21 15:21:39 +02:00
|
|
|
}
|
2022-06-23 17:04:53 +02:00
|
|
|
return status.Errorf(codes.Unimplemented, "method DeleteRule is not implemented")
|
2022-05-21 15:21:39 +02:00
|
|
|
}
|
|
|
|
|
2023-03-13 15:14:18 +01:00
|
|
|
// GetPolicy mock implementation of GetPolicy from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetPolicy(ctx context.Context, accountID, policyID, userID string) (*server.Policy, error) {
|
2023-03-13 15:14:18 +01:00
|
|
|
if am.GetPolicyFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetPolicyFunc(ctx, accountID, policyID, userID)
|
2023-03-13 15:14:18 +01:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetPolicy is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SavePolicy mock implementation of SavePolicy from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) SavePolicy(ctx context.Context, accountID, userID string, policy *server.Policy) error {
|
2023-03-13 15:14:18 +01:00
|
|
|
if am.SavePolicyFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.SavePolicyFunc(ctx, accountID, userID, policy)
|
2023-03-13 15:14:18 +01:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method SavePolicy is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeletePolicy mock implementation of DeletePolicy from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) DeletePolicy(ctx context.Context, accountID, policyID, userID string) error {
|
2023-03-13 15:14:18 +01:00
|
|
|
if am.DeletePolicyFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.DeletePolicyFunc(ctx, accountID, policyID, userID)
|
2023-03-13 15:14:18 +01:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method DeletePolicy is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListPolicies mock implementation of ListPolicies from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) ListPolicies(ctx context.Context, accountID, userID string) ([]*server.Policy, error) {
|
2023-03-13 15:14:18 +01:00
|
|
|
if am.ListPoliciesFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.ListPoliciesFunc(ctx, accountID, userID)
|
2023-03-13 15:14:18 +01:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method ListPolicies is not implemented")
|
|
|
|
}
|
|
|
|
|
2022-06-14 10:32:54 +02:00
|
|
|
// UpdatePeerMeta mock implementation of UpdatePeerMeta from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) UpdatePeerMeta(ctx context.Context, peerID string, meta nbpeer.PeerSystemMeta) error {
|
2022-05-23 13:03:57 +02:00
|
|
|
if am.UpdatePeerMetaFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.UpdatePeerMetaFunc(ctx, peerID, meta)
|
2022-05-23 13:03:57 +02:00
|
|
|
}
|
2023-11-13 14:04:18 +01:00
|
|
|
return status.Errorf(codes.Unimplemented, "method UpdatePeerMeta is not implemented")
|
2022-05-23 13:03:57 +02:00
|
|
|
}
|
2022-05-25 18:26:50 +02:00
|
|
|
|
2023-05-11 18:09:36 +02:00
|
|
|
// GetUser mock implementation of GetUser from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetUser(ctx context.Context, claims jwtclaims.AuthorizationClaims) (*server.User, error) {
|
2023-05-11 18:09:36 +02:00
|
|
|
if am.GetUserFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetUserFunc(ctx, claims)
|
2022-05-25 18:26:50 +02:00
|
|
|
}
|
2023-11-13 14:04:18 +01:00
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetUser is not implemented")
|
|
|
|
}
|
|
|
|
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) ListUsers(ctx context.Context, accountID string) ([]*server.User, error) {
|
2023-11-13 14:04:18 +01:00
|
|
|
if am.ListUsersFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.ListUsersFunc(ctx, accountID)
|
2023-11-13 14:04:18 +01:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method ListUsers is not implemented")
|
2022-06-23 17:04:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// UpdatePeerSSHKey mocks UpdatePeerSSHKey function of the account manager
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) UpdatePeerSSHKey(ctx context.Context, peerID string, sshKey string) error {
|
2022-06-23 17:04:53 +02:00
|
|
|
if am.UpdatePeerSSHKeyFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.UpdatePeerSSHKeyFunc(ctx, peerID, sshKey)
|
2022-06-23 17:04:53 +02:00
|
|
|
}
|
2023-11-10 16:33:13 +01:00
|
|
|
return status.Errorf(codes.Unimplemented, "method UpdatePeerSSHKey is not implemented")
|
2022-06-23 17:04:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// UpdatePeer mocks UpdatePeerFunc function of the account manager
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) UpdatePeer(ctx context.Context, accountID, userID string, peer *nbpeer.Peer) (*nbpeer.Peer, error) {
|
2022-06-23 17:04:53 +02:00
|
|
|
if am.UpdatePeerFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.UpdatePeerFunc(ctx, accountID, userID, peer)
|
2022-06-23 17:04:53 +02:00
|
|
|
}
|
2023-11-13 14:04:18 +01:00
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method UpdatePeer is not implemented")
|
2022-05-25 18:26:50 +02:00
|
|
|
}
|
2022-08-18 18:22:15 +02:00
|
|
|
|
|
|
|
// CreateRoute mock implementation of CreateRoute from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) CreateRoute(ctx context.Context, accountID string, prefix netip.Prefix, networkType route.NetworkType, domains domain.List, peerID string, peerGroupIDs []string, description string, netID route.NetID, masquerade bool, metric int, groups []string, enabled bool, userID string, keepRoute bool) (*route.Route, error) {
|
2022-11-05 10:24:50 +01:00
|
|
|
if am.CreateRouteFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.CreateRouteFunc(ctx, accountID, prefix, networkType, domains, peerID, peerGroupIDs, description, netID, masquerade, metric, groups, enabled, userID, keepRoute)
|
2022-08-18 18:22:15 +02:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method CreateRoute is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetRoute mock implementation of GetRoute from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetRoute(ctx context.Context, accountID string, routeID route.ID, userID string) (*route.Route, error) {
|
2022-08-18 18:22:15 +02:00
|
|
|
if am.GetRouteFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetRouteFunc(ctx, accountID, routeID, userID)
|
2022-08-18 18:22:15 +02:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetRoute is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveRoute mock implementation of SaveRoute from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) SaveRoute(ctx context.Context, accountID string, userID string, route *route.Route) error {
|
2022-08-18 18:22:15 +02:00
|
|
|
if am.SaveRouteFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.SaveRouteFunc(ctx, accountID, userID, route)
|
2022-08-18 18:22:15 +02:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method SaveRoute is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteRoute mock implementation of DeleteRoute from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) DeleteRoute(ctx context.Context, accountID string, routeID route.ID, userID string) error {
|
2022-08-18 18:22:15 +02:00
|
|
|
if am.DeleteRouteFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.DeleteRouteFunc(ctx, accountID, routeID, userID)
|
2022-08-18 18:22:15 +02:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method DeleteRoute is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListRoutes mock implementation of ListRoutes from server.AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) ListRoutes(ctx context.Context, accountID, userID string) ([]*route.Route, error) {
|
2022-08-18 18:22:15 +02:00
|
|
|
if am.ListRoutesFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.ListRoutesFunc(ctx, accountID, userID)
|
2022-08-18 18:22:15 +02:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method ListRoutes is not implemented")
|
|
|
|
}
|
2022-09-11 23:16:40 +02:00
|
|
|
|
|
|
|
// SaveSetupKey mocks SaveSetupKey of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) SaveSetupKey(ctx context.Context, accountID string, key *server.SetupKey, userID string) (*server.SetupKey, error) {
|
2022-09-11 23:16:40 +02:00
|
|
|
if am.SaveSetupKeyFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.SaveSetupKeyFunc(ctx, accountID, key, userID)
|
2022-09-11 23:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method SaveSetupKey is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSetupKey mocks GetSetupKey of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetSetupKey(ctx context.Context, accountID, userID, keyID string) (*server.SetupKey, error) {
|
2022-09-11 23:16:40 +02:00
|
|
|
if am.GetSetupKeyFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetSetupKeyFunc(ctx, accountID, userID, keyID)
|
2022-09-11 23:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetSetupKey is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListSetupKeys mocks ListSetupKeys of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) ListSetupKeys(ctx context.Context, accountID, userID string) ([]*server.SetupKey, error) {
|
2022-09-11 23:16:40 +02:00
|
|
|
if am.ListSetupKeysFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.ListSetupKeysFunc(ctx, accountID, userID)
|
2022-09-11 23:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method ListSetupKeys is not implemented")
|
|
|
|
}
|
2022-09-22 09:06:32 +02:00
|
|
|
|
|
|
|
// SaveUser mocks SaveUser of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) SaveUser(ctx context.Context, accountID, userID string, user *server.User) (*server.UserInfo, error) {
|
2022-09-22 09:06:32 +02:00
|
|
|
if am.SaveUserFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.SaveUserFunc(ctx, accountID, userID, user)
|
2022-09-22 09:06:32 +02:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method SaveUser is not implemented")
|
|
|
|
}
|
2022-09-30 13:47:11 +02:00
|
|
|
|
2023-11-13 14:04:18 +01:00
|
|
|
// SaveOrAddUser mocks SaveOrAddUser of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) SaveOrAddUser(ctx context.Context, accountID, userID string, user *server.User, addIfNotExists bool) (*server.UserInfo, error) {
|
2023-12-11 17:32:10 +01:00
|
|
|
if am.SaveOrAddUserFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.SaveOrAddUserFunc(ctx, accountID, userID, user, addIfNotExists)
|
2023-11-13 14:04:18 +01:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method SaveOrAddUser is not implemented")
|
|
|
|
}
|
|
|
|
|
2024-07-15 16:04:06 +02:00
|
|
|
// SaveOrAddUsers mocks SaveOrAddUsers of the AccountManager interface
|
|
|
|
func (am *MockAccountManager) SaveOrAddUsers(ctx context.Context, accountID, userID string, users []*server.User, addIfNotExists bool) ([]*server.UserInfo, error) {
|
|
|
|
if am.SaveOrAddUsersFunc != nil {
|
|
|
|
return am.SaveOrAddUsersFunc(ctx, accountID, userID, users, addIfNotExists)
|
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method SaveOrAddUsers is not implemented")
|
|
|
|
}
|
|
|
|
|
2023-04-22 12:57:51 +02:00
|
|
|
// DeleteUser mocks DeleteUser of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) DeleteUser(ctx context.Context, accountID string, initiatorUserID string, targetUserID string) error {
|
2023-04-22 12:57:51 +02:00
|
|
|
if am.DeleteUserFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.DeleteUserFunc(ctx, accountID, initiatorUserID, targetUserID)
|
2023-04-22 12:57:51 +02:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method DeleteUser is not implemented")
|
|
|
|
}
|
|
|
|
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) InviteUser(ctx context.Context, accountID string, initiatorUserID string, targetUserID string) error {
|
2023-07-03 12:20:19 +02:00
|
|
|
if am.InviteUserFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.InviteUserFunc(ctx, accountID, initiatorUserID, targetUserID)
|
2023-07-03 12:20:19 +02:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method InviteUser is not implemented")
|
|
|
|
}
|
|
|
|
|
2022-09-30 13:47:11 +02:00
|
|
|
// GetNameServerGroup mocks GetNameServerGroup of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetNameServerGroup(ctx context.Context, accountID, userID, nsGroupID string) (*nbdns.NameServerGroup, error) {
|
2022-09-30 13:47:11 +02:00
|
|
|
if am.GetNameServerGroupFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetNameServerGroupFunc(ctx, accountID, userID, nsGroupID)
|
2022-09-30 13:47:11 +02:00
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateNameServerGroup mocks CreateNameServerGroup of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) CreateNameServerGroup(ctx context.Context, accountID string, name, description string, nameServerList []nbdns.NameServer, groups []string, primary bool, domains []string, enabled bool, userID string, searchDomainsEnabled bool) (*nbdns.NameServerGroup, error) {
|
2022-09-30 13:47:11 +02:00
|
|
|
if am.CreateNameServerGroupFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.CreateNameServerGroupFunc(ctx, accountID, name, description, nameServerList, groups, primary, domains, enabled, userID, searchDomainsEnabled)
|
2022-09-30 13:47:11 +02:00
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveNameServerGroup mocks SaveNameServerGroup of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) SaveNameServerGroup(ctx context.Context, accountID, userID string, nsGroupToSave *nbdns.NameServerGroup) error {
|
2022-09-30 13:47:11 +02:00
|
|
|
if am.SaveNameServerGroupFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.SaveNameServerGroupFunc(ctx, accountID, userID, nsGroupToSave)
|
2022-09-30 13:47:11 +02:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteNameServerGroup mocks DeleteNameServerGroup of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) DeleteNameServerGroup(ctx context.Context, accountID, nsGroupID, userID string) error {
|
2022-09-30 13:47:11 +02:00
|
|
|
if am.DeleteNameServerGroupFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.DeleteNameServerGroupFunc(ctx, accountID, nsGroupID, userID)
|
2022-09-30 13:47:11 +02:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListNameServerGroups mocks ListNameServerGroups of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) ListNameServerGroups(ctx context.Context, accountID string, userID string) ([]*nbdns.NameServerGroup, error) {
|
2022-09-30 13:47:11 +02:00
|
|
|
if am.ListNameServerGroupsFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.ListNameServerGroupsFunc(ctx, accountID, userID)
|
2022-09-30 13:47:11 +02:00
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
2022-10-13 18:26:31 +02:00
|
|
|
|
|
|
|
// CreateUser mocks CreateUser of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) CreateUser(ctx context.Context, accountID, userID string, invite *server.UserInfo) (*server.UserInfo, error) {
|
2022-10-13 18:26:31 +02:00
|
|
|
if am.CreateUserFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.CreateUserFunc(ctx, accountID, userID, invite)
|
2022-10-13 18:26:31 +02:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method CreateUser is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetAccountFromToken mocks GetAccountFromToken of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetAccountFromToken(ctx context.Context, claims jwtclaims.AuthorizationClaims) (*server.Account, *server.User,
|
2023-03-13 15:14:18 +01:00
|
|
|
error,
|
|
|
|
) {
|
2022-10-13 18:26:31 +02:00
|
|
|
if am.GetAccountFromTokenFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetAccountFromTokenFunc(ctx, claims)
|
2022-10-13 18:26:31 +02:00
|
|
|
}
|
2022-11-11 20:36:45 +01:00
|
|
|
return nil, nil, status.Errorf(codes.Unimplemented, "method GetAccountFromToken is not implemented")
|
2022-10-13 18:26:31 +02:00
|
|
|
}
|
2022-11-05 10:24:50 +01:00
|
|
|
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) CheckUserAccessByJWTGroups(ctx context.Context, claims jwtclaims.AuthorizationClaims) error {
|
2023-12-13 11:18:35 +01:00
|
|
|
if am.CheckUserAccessByJWTGroupsFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.CheckUserAccessByJWTGroupsFunc(ctx, claims)
|
2023-12-13 11:18:35 +01:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method CheckUserAccessByJWTGroups is not implemented")
|
|
|
|
}
|
|
|
|
|
2022-11-05 10:24:50 +01:00
|
|
|
// GetPeers mocks GetPeers of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetPeers(ctx context.Context, accountID, userID string) ([]*nbpeer.Peer, error) {
|
2023-12-11 17:32:10 +01:00
|
|
|
if am.GetPeersFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetPeersFunc(ctx, accountID, userID)
|
2022-11-05 10:24:50 +01:00
|
|
|
}
|
2023-11-13 14:04:18 +01:00
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetPeers is not implemented")
|
2022-11-05 10:24:50 +01:00
|
|
|
}
|
2022-11-21 11:14:42 +01:00
|
|
|
|
|
|
|
// GetDNSDomain mocks GetDNSDomain of the AccountManager interface
|
|
|
|
func (am *MockAccountManager) GetDNSDomain() string {
|
|
|
|
if am.GetDNSDomainFunc != nil {
|
|
|
|
return am.GetDNSDomainFunc()
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
2023-01-02 15:11:32 +01:00
|
|
|
|
|
|
|
// GetEvents mocks GetEvents of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetEvents(ctx context.Context, accountID, userID string) ([]*activity.Event, error) {
|
2023-01-02 15:11:32 +01:00
|
|
|
if am.GetEventsFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetEventsFunc(ctx, accountID, userID)
|
2023-01-02 15:11:32 +01:00
|
|
|
}
|
2023-11-13 14:04:18 +01:00
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetEvents is not implemented")
|
2023-01-02 15:11:32 +01:00
|
|
|
}
|
2023-01-17 17:34:40 +01:00
|
|
|
|
|
|
|
// GetDNSSettings mocks GetDNSSettings of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetDNSSettings(ctx context.Context, accountID string, userID string) (*server.DNSSettings, error) {
|
2023-01-17 17:34:40 +01:00
|
|
|
if am.GetDNSSettingsFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetDNSSettingsFunc(ctx, accountID, userID)
|
2023-01-17 17:34:40 +01:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetDNSSettings is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveDNSSettings mocks SaveDNSSettings of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) SaveDNSSettings(ctx context.Context, accountID string, userID string, dnsSettingsToSave *server.DNSSettings) error {
|
2023-01-17 17:34:40 +01:00
|
|
|
if am.SaveDNSSettingsFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.SaveDNSSettingsFunc(ctx, accountID, userID, dnsSettingsToSave)
|
2023-01-17 17:34:40 +01:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method SaveDNSSettings is not implemented")
|
|
|
|
}
|
2023-02-07 20:11:08 +01:00
|
|
|
|
|
|
|
// GetPeer mocks GetPeer of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetPeer(ctx context.Context, accountID, peerID, userID string) (*nbpeer.Peer, error) {
|
2023-02-07 20:11:08 +01:00
|
|
|
if am.GetPeerFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetPeerFunc(ctx, accountID, peerID, userID)
|
2023-02-07 20:11:08 +01:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetPeer is not implemented")
|
|
|
|
}
|
2023-02-13 12:21:02 +01:00
|
|
|
|
2023-03-03 18:35:38 +01:00
|
|
|
// UpdateAccountSettings mocks UpdateAccountSettings of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) UpdateAccountSettings(ctx context.Context, accountID, userID string, newSettings *server.Settings) (*server.Account, error) {
|
2023-03-03 18:35:38 +01:00
|
|
|
if am.UpdateAccountSettingsFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.UpdateAccountSettingsFunc(ctx, accountID, userID, newSettings)
|
2023-02-13 12:21:02 +01:00
|
|
|
}
|
2023-03-03 18:35:38 +01:00
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method UpdateAccountSettings is not implemented")
|
2023-02-13 12:21:02 +01:00
|
|
|
}
|
|
|
|
|
2023-03-03 18:35:38 +01:00
|
|
|
// LoginPeer mocks LoginPeer of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) LoginPeer(ctx context.Context, login server.PeerLogin) (*nbpeer.Peer, *server.NetworkMap, []*posture.Checks, error) {
|
2023-03-03 18:35:38 +01:00
|
|
|
if am.LoginPeerFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.LoginPeerFunc(ctx, login)
|
2023-02-13 12:21:02 +01:00
|
|
|
}
|
2024-06-22 16:41:16 +02:00
|
|
|
return nil, nil, nil, status.Errorf(codes.Unimplemented, "method LoginPeer is not implemented")
|
2023-02-13 12:21:02 +01:00
|
|
|
}
|
2023-02-16 12:00:41 +01:00
|
|
|
|
2023-03-03 18:35:38 +01:00
|
|
|
// SyncPeer mocks SyncPeer of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) SyncPeer(ctx context.Context, sync server.PeerSync, account *server.Account) (*nbpeer.Peer, *server.NetworkMap, []*posture.Checks, error) {
|
2023-03-03 18:35:38 +01:00
|
|
|
if am.SyncPeerFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.SyncPeerFunc(ctx, sync, account)
|
2023-02-16 12:00:41 +01:00
|
|
|
}
|
2024-06-22 16:41:16 +02:00
|
|
|
return nil, nil, nil, status.Errorf(codes.Unimplemented, "method SyncPeer is not implemented")
|
2023-02-16 12:00:41 +01:00
|
|
|
}
|
2023-10-11 18:11:45 +02:00
|
|
|
|
|
|
|
// GetAllConnectedPeers mocks GetAllConnectedPeers of the AccountManager interface
|
|
|
|
func (am *MockAccountManager) GetAllConnectedPeers() (map[string]struct{}, error) {
|
|
|
|
if am.GetAllConnectedPeersFunc != nil {
|
|
|
|
return am.GetAllConnectedPeersFunc()
|
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetAllConnectedPeers is not implemented")
|
|
|
|
}
|
2023-11-08 11:35:37 +01:00
|
|
|
|
2024-02-22 12:27:08 +01:00
|
|
|
// HasConnectedChannel mocks HasConnectedChannel of the AccountManager interface
|
2023-12-05 14:17:56 +01:00
|
|
|
func (am *MockAccountManager) HasConnectedChannel(peerID string) bool {
|
|
|
|
if am.HasConnectedChannelFunc != nil {
|
|
|
|
return am.HasConnectedChannelFunc(peerID)
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2023-11-08 11:35:37 +01:00
|
|
|
// StoreEvent mocks StoreEvent of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) StoreEvent(ctx context.Context, initiatorID, targetID, accountID string, activityID activity.ActivityDescriber, meta map[string]any) {
|
2023-11-08 11:35:37 +01:00
|
|
|
if am.StoreEventFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
am.StoreEventFunc(ctx, initiatorID, targetID, accountID, activityID, meta)
|
2023-11-08 11:35:37 +01:00
|
|
|
}
|
|
|
|
}
|
2023-11-13 14:04:18 +01:00
|
|
|
|
|
|
|
// GetExternalCacheManager mocks GetExternalCacheManager of the AccountManager interface
|
|
|
|
func (am *MockAccountManager) GetExternalCacheManager() server.ExternalCacheManager {
|
|
|
|
if am.GetExternalCacheManagerFunc() != nil {
|
|
|
|
return am.GetExternalCacheManagerFunc()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2024-02-20 09:59:56 +01:00
|
|
|
|
|
|
|
// GetPostureChecks mocks GetPostureChecks of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GetPostureChecks(ctx context.Context, accountID, postureChecksID, userID string) (*posture.Checks, error) {
|
2024-02-20 09:59:56 +01:00
|
|
|
if am.GetPostureChecksFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GetPostureChecksFunc(ctx, accountID, postureChecksID, userID)
|
2024-02-20 09:59:56 +01:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetPostureChecks is not implemented")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// SavePostureChecks mocks SavePostureChecks of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) SavePostureChecks(ctx context.Context, accountID, userID string, postureChecks *posture.Checks) error {
|
2024-02-20 09:59:56 +01:00
|
|
|
if am.SavePostureChecksFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.SavePostureChecksFunc(ctx, accountID, userID, postureChecks)
|
2024-02-20 09:59:56 +01:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method SavePostureChecks is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeletePostureChecks mocks DeletePostureChecks of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) DeletePostureChecks(ctx context.Context, accountID, postureChecksID, userID string) error {
|
2024-02-20 09:59:56 +01:00
|
|
|
if am.DeletePostureChecksFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.DeletePostureChecksFunc(ctx, accountID, postureChecksID, userID)
|
2024-02-20 09:59:56 +01:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method DeletePostureChecks is not implemented")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListPostureChecks mocks ListPostureChecks of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) ListPostureChecks(ctx context.Context, accountID, userID string) ([]*posture.Checks, error) {
|
2024-02-20 09:59:56 +01:00
|
|
|
if am.ListPostureChecksFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.ListPostureChecksFunc(ctx, accountID, userID)
|
2024-02-20 09:59:56 +01:00
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method ListPostureChecks is not implemented")
|
|
|
|
}
|
2024-02-22 12:27:08 +01:00
|
|
|
|
2024-02-28 16:57:35 +01:00
|
|
|
// GetIdpManager mocks GetIdpManager of the AccountManager interface
|
|
|
|
func (am *MockAccountManager) GetIdpManager() idp.Manager {
|
|
|
|
if am.GetIdpManagerFunc != nil {
|
|
|
|
return am.GetIdpManagerFunc()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2024-03-27 18:48:48 +01:00
|
|
|
|
2024-04-09 13:18:38 +02:00
|
|
|
// UpdateIntegratedValidatorGroups mocks UpdateIntegratedApprovalGroups of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) UpdateIntegratedValidatorGroups(ctx context.Context, accountID string, userID string, groups []string) error {
|
2024-03-27 18:48:48 +01:00
|
|
|
if am.UpdateIntegratedValidatorGroupsFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.UpdateIntegratedValidatorGroupsFunc(ctx, accountID, userID, groups)
|
2024-03-27 18:48:48 +01:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method UpdateIntegratedValidatorGroups is not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
// GroupValidation mocks GroupValidation of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) GroupValidation(ctx context.Context, accountId string, groups []string) (bool, error) {
|
2024-03-27 18:48:48 +01:00
|
|
|
if am.GroupValidationFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.GroupValidationFunc(ctx, accountId, groups)
|
2024-03-27 18:48:48 +01:00
|
|
|
}
|
|
|
|
return false, status.Errorf(codes.Unimplemented, "method GroupValidation is not implemented")
|
|
|
|
}
|
2024-05-30 15:22:42 +02:00
|
|
|
|
2024-06-13 13:24:24 +02:00
|
|
|
// SyncPeerMeta mocks SyncPeerMeta of the AccountManager interface
|
2024-07-03 11:33:02 +02:00
|
|
|
func (am *MockAccountManager) SyncPeerMeta(ctx context.Context, peerPubKey string, meta nbpeer.PeerSystemMeta) error {
|
2024-06-13 13:24:24 +02:00
|
|
|
if am.SyncPeerMetaFunc != nil {
|
2024-07-03 11:33:02 +02:00
|
|
|
return am.SyncPeerMetaFunc(ctx, peerPubKey, meta)
|
2024-06-13 13:24:24 +02:00
|
|
|
}
|
|
|
|
return status.Errorf(codes.Unimplemented, "method SyncPeerMeta is not implemented")
|
|
|
|
}
|
|
|
|
|
2024-05-30 15:22:42 +02:00
|
|
|
// FindExistingPostureCheck mocks FindExistingPostureCheck of the AccountManager interface
|
|
|
|
func (am *MockAccountManager) FindExistingPostureCheck(accountID string, checks *posture.ChecksDefinition) (*posture.Checks, error) {
|
|
|
|
if am.FindExistingPostureCheckFunc != nil {
|
|
|
|
return am.FindExistingPostureCheckFunc(accountID, checks)
|
|
|
|
}
|
|
|
|
return nil, status.Errorf(codes.Unimplemented, "method FindExistingPostureCheck is not implemented")
|
|
|
|
}
|
2024-07-03 11:33:02 +02:00
|
|
|
|
|
|
|
// GetAccountIDForPeerKey mocks GetAccountIDForPeerKey of the AccountManager interface
|
|
|
|
func (am *MockAccountManager) GetAccountIDForPeerKey(ctx context.Context, peerKey string) (string, error) {
|
|
|
|
if am.GetAccountIDForPeerKeyFunc != nil {
|
|
|
|
return am.GetAccountIDForPeerKeyFunc(ctx, peerKey)
|
|
|
|
}
|
|
|
|
return "", status.Errorf(codes.Unimplemented, "method GetAccountIDForPeerKey is not implemented")
|
|
|
|
}
|