update mockimpl version to allow concurrent mock calls (#9989)
this uses the associated new version in our fork https://github.com/fleetdm/mockimpl/commit/ecbb3041eabfc9e046a3f2e414e32c28254b75b2 to allow for concurrent access to mocks
This commit is contained in:
@@ -173,7 +173,7 @@ generate-dev: .prefix
|
||||
NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=development yarn run webpack --progress --colors --watch
|
||||
|
||||
generate-mock: .prefix
|
||||
go install github.com/fleetdm/mockimpl@8d7943aa39d8f5f464d3d3618d9571d385f7bcc5
|
||||
go install github.com/fleetdm/mockimpl@ecbb3041eabfc9e046a3f2e414e32c28254b75b2
|
||||
go generate github.com/fleetdm/fleet/v4/server/mock github.com/fleetdm/fleet/v4/server/mock/mockresult github.com/fleetdm/fleet/v4/server/service/mock
|
||||
|
||||
generate-doc: .prefix
|
||||
|
||||
@@ -5,6 +5,7 @@ package mock
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/fleetdm/fleet/v4/server/fleet"
|
||||
)
|
||||
@@ -26,19 +27,27 @@ type InstallerStore struct {
|
||||
|
||||
ExistsFunc ExistsFunc
|
||||
ExistsFuncInvoked bool
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (s *InstallerStore) Get(ctx context.Context, installer fleet.Installer) (io.ReadCloser, int64, error) {
|
||||
s.mu.Lock()
|
||||
s.GetFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.GetFunc(ctx, installer)
|
||||
}
|
||||
|
||||
func (s *InstallerStore) Put(ctx context.Context, installer fleet.Installer) (string, error) {
|
||||
s.mu.Lock()
|
||||
s.PutFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.PutFunc(ctx, installer)
|
||||
}
|
||||
|
||||
func (s *InstallerStore) Exists(ctx context.Context, installer fleet.Installer) (bool, error) {
|
||||
s.mu.Lock()
|
||||
s.ExistsFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.ExistsFunc(ctx, installer)
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@ package mock
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/fleetdm/fleet/v4/server/fleet"
|
||||
)
|
||||
@@ -25,19 +26,27 @@ type QueryResultStore struct {
|
||||
|
||||
HealthCheckFunc HealthCheckFunc
|
||||
HealthCheckFuncInvoked bool
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (s *QueryResultStore) WriteResult(result fleet.DistributedQueryResult) error {
|
||||
s.mu.Lock()
|
||||
s.WriteResultFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.WriteResultFunc(result)
|
||||
}
|
||||
|
||||
func (s *QueryResultStore) ReadChannel(ctx context.Context, query fleet.DistributedQueryCampaign) (<-chan interface{}, error) {
|
||||
s.mu.Lock()
|
||||
s.ReadChannelFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.ReadChannelFunc(ctx, query)
|
||||
}
|
||||
|
||||
func (s *QueryResultStore) HealthCheck() error {
|
||||
s.mu.Lock()
|
||||
s.HealthCheckFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.HealthCheckFunc()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package mock
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/micromdm/nanodep/client"
|
||||
@@ -62,54 +63,76 @@ type Storage struct {
|
||||
|
||||
StoreAssignerProfileFunc StoreAssignerProfileFunc
|
||||
StoreAssignerProfileFuncInvoked bool
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (s *Storage) RetrieveAuthTokens(ctx context.Context, name string) (*client.OAuth1Tokens, error) {
|
||||
s.mu.Lock()
|
||||
s.RetrieveAuthTokensFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.RetrieveAuthTokensFunc(ctx, name)
|
||||
}
|
||||
|
||||
func (s *Storage) RetrieveConfig(p0 context.Context, p1 string) (*client.Config, error) {
|
||||
s.mu.Lock()
|
||||
s.RetrieveConfigFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.RetrieveConfigFunc(p0, p1)
|
||||
}
|
||||
|
||||
func (s *Storage) RetrieveAssignerProfile(ctx context.Context, name string) (profileUUID string, modTime time.Time, err error) {
|
||||
s.mu.Lock()
|
||||
s.RetrieveAssignerProfileFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.RetrieveAssignerProfileFunc(ctx, name)
|
||||
}
|
||||
|
||||
func (s *Storage) RetrieveCursor(ctx context.Context, name string) (cursor string, modTime time.Time, err error) {
|
||||
s.mu.Lock()
|
||||
s.RetrieveCursorFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.RetrieveCursorFunc(ctx, name)
|
||||
}
|
||||
|
||||
func (s *Storage) StoreCursor(ctx context.Context, name string, cursor string) error {
|
||||
s.mu.Lock()
|
||||
s.StoreCursorFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.StoreCursorFunc(ctx, name, cursor)
|
||||
}
|
||||
|
||||
func (s *Storage) StoreAuthTokens(ctx context.Context, name string, tokens *client.OAuth1Tokens) error {
|
||||
s.mu.Lock()
|
||||
s.StoreAuthTokensFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.StoreAuthTokensFunc(ctx, name, tokens)
|
||||
}
|
||||
|
||||
func (s *Storage) StoreConfig(ctx context.Context, name string, config *client.Config) error {
|
||||
s.mu.Lock()
|
||||
s.StoreConfigFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.StoreConfigFunc(ctx, name, config)
|
||||
}
|
||||
|
||||
func (s *Storage) StoreTokenPKI(ctx context.Context, name string, pemCert []byte, pemKey []byte) error {
|
||||
s.mu.Lock()
|
||||
s.StoreTokenPKIFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.StoreTokenPKIFunc(ctx, name, pemCert, pemKey)
|
||||
}
|
||||
|
||||
func (s *Storage) RetrieveTokenPKI(ctx context.Context, name string) (pemCert []byte, pemKey []byte, err error) {
|
||||
s.mu.Lock()
|
||||
s.RetrieveTokenPKIFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.RetrieveTokenPKIFunc(ctx, name)
|
||||
}
|
||||
|
||||
func (s *Storage) StoreAssignerProfile(ctx context.Context, name string, profileUUID string) error {
|
||||
s.mu.Lock()
|
||||
s.StoreAssignerProfileFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.StoreAssignerProfileFunc(ctx, name, profileUUID)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ package mock
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"sync"
|
||||
|
||||
"github.com/micromdm/nanomdm/mdm"
|
||||
"github.com/micromdm/nanomdm/storage"
|
||||
@@ -112,104 +113,146 @@ type Storage struct {
|
||||
|
||||
RetrieveTokenUpdateTallyFunc RetrieveTokenUpdateTallyFunc
|
||||
RetrieveTokenUpdateTallyFuncInvoked bool
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (s *Storage) StoreAuthenticate(r *mdm.Request, msg *mdm.Authenticate) error {
|
||||
s.mu.Lock()
|
||||
s.StoreAuthenticateFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.StoreAuthenticateFunc(r, msg)
|
||||
}
|
||||
|
||||
func (s *Storage) StoreTokenUpdate(r *mdm.Request, msg *mdm.TokenUpdate) error {
|
||||
s.mu.Lock()
|
||||
s.StoreTokenUpdateFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.StoreTokenUpdateFunc(r, msg)
|
||||
}
|
||||
|
||||
func (s *Storage) StoreUserAuthenticate(r *mdm.Request, msg *mdm.UserAuthenticate) error {
|
||||
s.mu.Lock()
|
||||
s.StoreUserAuthenticateFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.StoreUserAuthenticateFunc(r, msg)
|
||||
}
|
||||
|
||||
func (s *Storage) Disable(r *mdm.Request) error {
|
||||
s.mu.Lock()
|
||||
s.DisableFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.DisableFunc(r)
|
||||
}
|
||||
|
||||
func (s *Storage) StoreCommandReport(r *mdm.Request, report *mdm.CommandResults) error {
|
||||
s.mu.Lock()
|
||||
s.StoreCommandReportFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.StoreCommandReportFunc(r, report)
|
||||
}
|
||||
|
||||
func (s *Storage) RetrieveNextCommand(r *mdm.Request, skipNotNow bool) (*mdm.Command, error) {
|
||||
s.mu.Lock()
|
||||
s.RetrieveNextCommandFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.RetrieveNextCommandFunc(r, skipNotNow)
|
||||
}
|
||||
|
||||
func (s *Storage) ClearQueue(r *mdm.Request) error {
|
||||
s.mu.Lock()
|
||||
s.ClearQueueFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.ClearQueueFunc(r)
|
||||
}
|
||||
|
||||
func (s *Storage) StoreBootstrapToken(r *mdm.Request, msg *mdm.SetBootstrapToken) error {
|
||||
s.mu.Lock()
|
||||
s.StoreBootstrapTokenFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.StoreBootstrapTokenFunc(r, msg)
|
||||
}
|
||||
|
||||
func (s *Storage) RetrieveBootstrapToken(r *mdm.Request, msg *mdm.GetBootstrapToken) (*mdm.BootstrapToken, error) {
|
||||
s.mu.Lock()
|
||||
s.RetrieveBootstrapTokenFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.RetrieveBootstrapTokenFunc(r, msg)
|
||||
}
|
||||
|
||||
func (s *Storage) RetrievePushInfo(p0 context.Context, p1 []string) (map[string]*mdm.Push, error) {
|
||||
s.mu.Lock()
|
||||
s.RetrievePushInfoFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.RetrievePushInfoFunc(p0, p1)
|
||||
}
|
||||
|
||||
func (s *Storage) IsPushCertStale(ctx context.Context, topic string, staleToken string) (bool, error) {
|
||||
s.mu.Lock()
|
||||
s.IsPushCertStaleFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.IsPushCertStaleFunc(ctx, topic, staleToken)
|
||||
}
|
||||
|
||||
func (s *Storage) RetrievePushCert(ctx context.Context, topic string) (cert *tls.Certificate, staleToken string, err error) {
|
||||
s.mu.Lock()
|
||||
s.RetrievePushCertFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.RetrievePushCertFunc(ctx, topic)
|
||||
}
|
||||
|
||||
func (s *Storage) StorePushCert(ctx context.Context, pemCert []byte, pemKey []byte) error {
|
||||
s.mu.Lock()
|
||||
s.StorePushCertFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.StorePushCertFunc(ctx, pemCert, pemKey)
|
||||
}
|
||||
|
||||
func (s *Storage) EnqueueCommand(ctx context.Context, id []string, cmd *mdm.Command) (map[string]error, error) {
|
||||
s.mu.Lock()
|
||||
s.EnqueueCommandFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.EnqueueCommandFunc(ctx, id, cmd)
|
||||
}
|
||||
|
||||
func (s *Storage) HasCertHash(r *mdm.Request, hash string) (bool, error) {
|
||||
s.mu.Lock()
|
||||
s.HasCertHashFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.HasCertHashFunc(r, hash)
|
||||
}
|
||||
|
||||
func (s *Storage) EnrollmentHasCertHash(r *mdm.Request, hash string) (bool, error) {
|
||||
s.mu.Lock()
|
||||
s.EnrollmentHasCertHashFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.EnrollmentHasCertHashFunc(r, hash)
|
||||
}
|
||||
|
||||
func (s *Storage) IsCertHashAssociated(r *mdm.Request, hash string) (bool, error) {
|
||||
s.mu.Lock()
|
||||
s.IsCertHashAssociatedFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.IsCertHashAssociatedFunc(r, hash)
|
||||
}
|
||||
|
||||
func (s *Storage) AssociateCertHash(r *mdm.Request, hash string) error {
|
||||
s.mu.Lock()
|
||||
s.AssociateCertHashFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.AssociateCertHashFunc(r, hash)
|
||||
}
|
||||
|
||||
func (s *Storage) RetrieveMigrationCheckins(p0 context.Context, p1 chan<- interface{}) error {
|
||||
s.mu.Lock()
|
||||
s.RetrieveMigrationCheckinsFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.RetrieveMigrationCheckinsFunc(p0, p1)
|
||||
}
|
||||
|
||||
func (s *Storage) RetrieveTokenUpdateTally(ctx context.Context, id string) (int, error) {
|
||||
s.mu.Lock()
|
||||
s.RetrieveTokenUpdateTallyFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.RetrieveTokenUpdateTallyFunc(ctx, id)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"math/big"
|
||||
"sync"
|
||||
|
||||
"github.com/micromdm/scep/v2/depot"
|
||||
)
|
||||
@@ -32,24 +33,34 @@ type Depot struct {
|
||||
|
||||
HasCNFunc HasCNFunc
|
||||
HasCNFuncInvoked bool
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (d *Depot) CA(pass []byte) ([]*x509.Certificate, *rsa.PrivateKey, error) {
|
||||
d.mu.Lock()
|
||||
d.CAFuncInvoked = true
|
||||
d.mu.Unlock()
|
||||
return d.CAFunc(pass)
|
||||
}
|
||||
|
||||
func (d *Depot) Put(name string, crt *x509.Certificate) error {
|
||||
d.mu.Lock()
|
||||
d.PutFuncInvoked = true
|
||||
d.mu.Unlock()
|
||||
return d.PutFunc(name, crt)
|
||||
}
|
||||
|
||||
func (d *Depot) Serial() (*big.Int, error) {
|
||||
d.mu.Lock()
|
||||
d.SerialFuncInvoked = true
|
||||
d.mu.Unlock()
|
||||
return d.SerialFunc()
|
||||
}
|
||||
|
||||
func (d *Depot) HasCN(cn string, allowTime int, cert *x509.Certificate, revokeOldCertificate bool) (bool, error) {
|
||||
d.mu.Lock()
|
||||
d.HasCNFuncInvoked = true
|
||||
d.mu.Unlock()
|
||||
return d.HasCNFunc(cn, allowTime, cert, revokeOldCertificate)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ package mock
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"sync"
|
||||
|
||||
"github.com/fleetdm/fleet/v4/server/fleet"
|
||||
)
|
||||
@@ -46,39 +47,55 @@ type TLSService struct {
|
||||
|
||||
SubmitResultLogsFunc SubmitResultLogsFunc
|
||||
SubmitResultLogsFuncInvoked bool
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (s *TLSService) EnrollAgent(ctx context.Context, enrollSecret string, hostIdentifier string, hostDetails map[string](map[string]string)) (nodeKey string, err error) {
|
||||
s.mu.Lock()
|
||||
s.EnrollAgentFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.EnrollAgentFunc(ctx, enrollSecret, hostIdentifier, hostDetails)
|
||||
}
|
||||
|
||||
func (s *TLSService) AuthenticateHost(ctx context.Context, nodeKey string) (host *fleet.Host, debug bool, err error) {
|
||||
s.mu.Lock()
|
||||
s.AuthenticateHostFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.AuthenticateHostFunc(ctx, nodeKey)
|
||||
}
|
||||
|
||||
func (s *TLSService) GetClientConfig(ctx context.Context) (config map[string]interface{}, err error) {
|
||||
s.mu.Lock()
|
||||
s.GetClientConfigFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.GetClientConfigFunc(ctx)
|
||||
}
|
||||
|
||||
func (s *TLSService) GetDistributedQueries(ctx context.Context) (queries map[string]string, discovery map[string]string, accelerate uint, err error) {
|
||||
s.mu.Lock()
|
||||
s.GetDistributedQueriesFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.GetDistributedQueriesFunc(ctx)
|
||||
}
|
||||
|
||||
func (s *TLSService) SubmitDistributedQueryResults(ctx context.Context, results fleet.OsqueryDistributedQueryResults, statuses map[string]fleet.OsqueryStatus, messages map[string]string) (err error) {
|
||||
s.mu.Lock()
|
||||
s.SubmitDistributedQueryResultsFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.SubmitDistributedQueryResultsFunc(ctx, results, statuses, messages)
|
||||
}
|
||||
|
||||
func (s *TLSService) SubmitStatusLogs(ctx context.Context, logs []json.RawMessage) (err error) {
|
||||
s.mu.Lock()
|
||||
s.SubmitStatusLogsFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.SubmitStatusLogsFunc(ctx, logs)
|
||||
}
|
||||
|
||||
func (s *TLSService) SubmitResultLogs(ctx context.Context, logs []json.RawMessage) (err error) {
|
||||
s.mu.Lock()
|
||||
s.SubmitResultLogsFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.SubmitResultLogsFunc(ctx, logs)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/micromdm/nanomdm/mdm"
|
||||
"github.com/micromdm/nanomdm/push"
|
||||
)
|
||||
@@ -14,9 +16,13 @@ type PushFunc func(p0 []*mdm.Push) (map[string]*push.Response, error)
|
||||
type APNSPushProvider struct {
|
||||
PushFunc PushFunc
|
||||
PushFuncInvoked bool
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (s *APNSPushProvider) Push(p0 []*mdm.Push) (map[string]*push.Response, error) {
|
||||
s.mu.Lock()
|
||||
s.PushFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.PushFunc(p0)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package mock
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"sync"
|
||||
|
||||
"github.com/micromdm/nanomdm/push"
|
||||
)
|
||||
@@ -15,9 +16,13 @@ type NewPushProviderFunc func(p0 *tls.Certificate) (push.PushProvider, error)
|
||||
type APNSPushProviderFactory struct {
|
||||
NewPushProviderFunc NewPushProviderFunc
|
||||
NewPushProviderFuncInvoked bool
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (s *APNSPushProviderFactory) NewPushProvider(p0 *tls.Certificate) (push.PushProvider, error) {
|
||||
s.mu.Lock()
|
||||
s.NewPushProviderFuncInvoked = true
|
||||
s.mu.Unlock()
|
||||
return s.NewPushProviderFunc(p0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user