diff --git a/auth/iam.go b/auth/iam.go index 14da18c..4a25d8c 100644 --- a/auth/iam.go +++ b/auth/iam.go @@ -25,6 +25,8 @@ type Account struct { } // IAMService is the interface for all IAM service implementations +// +//go:generate moq -out ../s3api/controllers/iam_moq_test.go -pkg controllers . IAMService type IAMService interface { CreateAccount(access string, account Account) error GetUserAccount(access string) (Account, error) diff --git a/backend/backend.go b/backend/backend.go index 11edb4a..c8f4e3c 100644 --- a/backend/backend.go +++ b/backend/backend.go @@ -24,7 +24,6 @@ import ( "github.com/versity/versitygw/s3response" ) -//go:generate moq -out backend_moq_test.go . Backend //go:generate moq -out ../s3api/controllers/backend_moq_test.go -pkg controllers . Backend type Backend interface { fmt.Stringer diff --git a/backend/backend_moq_test.go b/backend/backend_moq_test.go deleted file mode 100644 index d8cc9a4..0000000 --- a/backend/backend_moq_test.go +++ /dev/null @@ -1,1647 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package backend - -import ( - "github.com/aws/aws-sdk-go-v2/service/s3" - "github.com/aws/aws-sdk-go-v2/service/s3/types" - "github.com/versity/versitygw/s3response" - "io" - "sync" -) - -// Ensure, that BackendMock does implement Backend. -// If this is not the case, regenerate this file with moq. -var _ Backend = &BackendMock{} - -// BackendMock is a mock implementation of Backend. -// -// func TestSomethingThatUsesBackend(t *testing.T) { -// -// // make and configure a mocked Backend -// mockedBackend := &BackendMock{ -// AbortMultipartUploadFunc: func(abortMultipartUploadInput *s3.AbortMultipartUploadInput) error { -// panic("mock out the AbortMultipartUpload method") -// }, -// CompleteMultipartUploadFunc: func(bucket string, object string, uploadID string, parts []types.Part) (*s3.CompleteMultipartUploadOutput, error) { -// panic("mock out the CompleteMultipartUpload method") -// }, -// CopyObjectFunc: func(srcBucket string, srcObject string, DstBucket string, dstObject string) (*s3.CopyObjectOutput, error) { -// panic("mock out the CopyObject method") -// }, -// CopyPartFunc: func(srcBucket string, srcObject string, DstBucket string, uploadID string, rangeHeader string, part int) (*types.CopyPartResult, error) { -// panic("mock out the CopyPart method") -// }, -// CreateMultipartUploadFunc: func(createMultipartUploadInput *s3.CreateMultipartUploadInput) (*s3.CreateMultipartUploadOutput, error) { -// panic("mock out the CreateMultipartUpload method") -// }, -// DeleteBucketFunc: func(bucket string) error { -// panic("mock out the DeleteBucket method") -// }, -// DeleteObjectFunc: func(bucket string, object string) error { -// panic("mock out the DeleteObject method") -// }, -// DeleteObjectsFunc: func(bucket string, objects *s3.DeleteObjectsInput) error { -// panic("mock out the DeleteObjects method") -// }, -// GetBucketAclFunc: func(bucket string) ([]byte, error) { -// panic("mock out the GetBucketAcl method") -// }, -// GetObjectFunc: func(bucket string, object string, acceptRange string, writer io.Writer) (*s3.GetObjectOutput, error) { -// panic("mock out the GetObject method") -// }, -// GetObjectAclFunc: func(bucket string, object string) (*s3.GetObjectAclOutput, error) { -// panic("mock out the GetObjectAcl method") -// }, -// GetObjectAttributesFunc: func(bucket string, object string, attributes []string) (*s3.GetObjectAttributesOutput, error) { -// panic("mock out the GetObjectAttributes method") -// }, -// GetTagsFunc: func(bucket string, object string) (map[string]string, error) { -// panic("mock out the GetTags method") -// }, -// HeadBucketFunc: func(bucket string) (*s3.HeadBucketOutput, error) { -// panic("mock out the HeadBucket method") -// }, -// HeadObjectFunc: func(bucket string, object string) (*s3.HeadObjectOutput, error) { -// panic("mock out the HeadObject method") -// }, -// ListBucketsFunc: func() (s3response.ListAllMyBucketsResult, error) { -// panic("mock out the ListBuckets method") -// }, -// ListMultipartUploadsFunc: func(output *s3.ListMultipartUploadsInput) (s3response.ListMultipartUploadsResponse, error) { -// panic("mock out the ListMultipartUploads method") -// }, -// ListObjectPartsFunc: func(bucket string, object string, uploadID string, partNumberMarker int, maxParts int) (s3response.ListPartsResponse, error) { -// panic("mock out the ListObjectParts method") -// }, -// ListObjectsFunc: func(bucket string, prefix string, marker string, delim string, maxkeys int) (*s3.ListObjectsOutput, error) { -// panic("mock out the ListObjects method") -// }, -// ListObjectsV2Func: func(bucket string, prefix string, marker string, delim string, maxkeys int) (*s3.ListObjectsV2Output, error) { -// panic("mock out the ListObjectsV2 method") -// }, -// PutBucketFunc: func(bucket string, owner string) error { -// panic("mock out the PutBucket method") -// }, -// PutBucketAclFunc: func(bucket string, data []byte) error { -// panic("mock out the PutBucketAcl method") -// }, -// PutObjectFunc: func(putObjectInput *s3.PutObjectInput) (string, error) { -// panic("mock out the PutObject method") -// }, -// PutObjectAclFunc: func(putObjectAclInput *s3.PutObjectAclInput) error { -// panic("mock out the PutObjectAcl method") -// }, -// PutObjectPartFunc: func(bucket string, object string, uploadID string, part int, length int64, r io.Reader) (string, error) { -// panic("mock out the PutObjectPart method") -// }, -// RemoveTagsFunc: func(bucket string, object string) error { -// panic("mock out the RemoveTags method") -// }, -// RestoreObjectFunc: func(bucket string, object string, restoreRequest *s3.RestoreObjectInput) error { -// panic("mock out the RestoreObject method") -// }, -// SetTagsFunc: func(bucket string, object string, tags map[string]string) error { -// panic("mock out the SetTags method") -// }, -// ShutdownFunc: func() { -// panic("mock out the Shutdown method") -// }, -// StringFunc: func() string { -// panic("mock out the String method") -// }, -// UploadPartCopyFunc: func(uploadPartCopyInput *s3.UploadPartCopyInput) (*s3.UploadPartCopyOutput, error) { -// panic("mock out the UploadPartCopy method") -// }, -// } -// -// // use mockedBackend in code that requires Backend -// // and then make assertions. -// -// } -type BackendMock struct { - // AbortMultipartUploadFunc mocks the AbortMultipartUpload method. - AbortMultipartUploadFunc func(abortMultipartUploadInput *s3.AbortMultipartUploadInput) error - - // CompleteMultipartUploadFunc mocks the CompleteMultipartUpload method. - CompleteMultipartUploadFunc func(bucket string, object string, uploadID string, parts []types.Part) (*s3.CompleteMultipartUploadOutput, error) - - // CopyObjectFunc mocks the CopyObject method. - CopyObjectFunc func(srcBucket string, srcObject string, DstBucket string, dstObject string) (*s3.CopyObjectOutput, error) - - // CopyPartFunc mocks the CopyPart method. - CopyPartFunc func(srcBucket string, srcObject string, DstBucket string, uploadID string, rangeHeader string, part int) (*types.CopyPartResult, error) - - // CreateMultipartUploadFunc mocks the CreateMultipartUpload method. - CreateMultipartUploadFunc func(createMultipartUploadInput *s3.CreateMultipartUploadInput) (*s3.CreateMultipartUploadOutput, error) - - // DeleteBucketFunc mocks the DeleteBucket method. - DeleteBucketFunc func(bucket string) error - - // DeleteObjectFunc mocks the DeleteObject method. - DeleteObjectFunc func(bucket string, object string) error - - // DeleteObjectsFunc mocks the DeleteObjects method. - DeleteObjectsFunc func(bucket string, objects *s3.DeleteObjectsInput) error - - // GetBucketAclFunc mocks the GetBucketAcl method. - GetBucketAclFunc func(bucket string) ([]byte, error) - - // GetObjectFunc mocks the GetObject method. - GetObjectFunc func(bucket string, object string, acceptRange string, writer io.Writer) (*s3.GetObjectOutput, error) - - // GetObjectAclFunc mocks the GetObjectAcl method. - GetObjectAclFunc func(bucket string, object string) (*s3.GetObjectAclOutput, error) - - // GetObjectAttributesFunc mocks the GetObjectAttributes method. - GetObjectAttributesFunc func(bucket string, object string, attributes []string) (*s3.GetObjectAttributesOutput, error) - - // GetTagsFunc mocks the GetTags method. - GetTagsFunc func(bucket string, object string) (map[string]string, error) - - // HeadBucketFunc mocks the HeadBucket method. - HeadBucketFunc func(bucket string) (*s3.HeadBucketOutput, error) - - // HeadObjectFunc mocks the HeadObject method. - HeadObjectFunc func(bucket string, object string) (*s3.HeadObjectOutput, error) - - // ListBucketsFunc mocks the ListBuckets method. - ListBucketsFunc func() (s3response.ListAllMyBucketsResult, error) - - // ListMultipartUploadsFunc mocks the ListMultipartUploads method. - ListMultipartUploadsFunc func(output *s3.ListMultipartUploadsInput) (s3response.ListMultipartUploadsResponse, error) - - // ListObjectPartsFunc mocks the ListObjectParts method. - ListObjectPartsFunc func(bucket string, object string, uploadID string, partNumberMarker int, maxParts int) (s3response.ListPartsResponse, error) - - // ListObjectsFunc mocks the ListObjects method. - ListObjectsFunc func(bucket string, prefix string, marker string, delim string, maxkeys int) (*s3.ListObjectsOutput, error) - - // ListObjectsV2Func mocks the ListObjectsV2 method. - ListObjectsV2Func func(bucket string, prefix string, marker string, delim string, maxkeys int) (*s3.ListObjectsV2Output, error) - - // PutBucketFunc mocks the PutBucket method. - PutBucketFunc func(bucket string, owner string) error - - // PutBucketAclFunc mocks the PutBucketAcl method. - PutBucketAclFunc func(bucket string, data []byte) error - - // PutObjectFunc mocks the PutObject method. - PutObjectFunc func(putObjectInput *s3.PutObjectInput) (string, error) - - // PutObjectAclFunc mocks the PutObjectAcl method. - PutObjectAclFunc func(putObjectAclInput *s3.PutObjectAclInput) error - - // PutObjectPartFunc mocks the PutObjectPart method. - PutObjectPartFunc func(bucket string, object string, uploadID string, part int, length int64, r io.Reader) (string, error) - - // RemoveTagsFunc mocks the RemoveTags method. - RemoveTagsFunc func(bucket string, object string) error - - // RestoreObjectFunc mocks the RestoreObject method. - RestoreObjectFunc func(bucket string, object string, restoreRequest *s3.RestoreObjectInput) error - - // SetTagsFunc mocks the SetTags method. - SetTagsFunc func(bucket string, object string, tags map[string]string) error - - // ShutdownFunc mocks the Shutdown method. - ShutdownFunc func() - - // StringFunc mocks the String method. - StringFunc func() string - - // UploadPartCopyFunc mocks the UploadPartCopy method. - UploadPartCopyFunc func(uploadPartCopyInput *s3.UploadPartCopyInput) (*s3.UploadPartCopyOutput, error) - - // calls tracks calls to the methods. - calls struct { - // AbortMultipartUpload holds details about calls to the AbortMultipartUpload method. - AbortMultipartUpload []struct { - // AbortMultipartUploadInput is the abortMultipartUploadInput argument value. - AbortMultipartUploadInput *s3.AbortMultipartUploadInput - } - // CompleteMultipartUpload holds details about calls to the CompleteMultipartUpload method. - CompleteMultipartUpload []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - // UploadID is the uploadID argument value. - UploadID string - // Parts is the parts argument value. - Parts []types.Part - } - // CopyObject holds details about calls to the CopyObject method. - CopyObject []struct { - // SrcBucket is the srcBucket argument value. - SrcBucket string - // SrcObject is the srcObject argument value. - SrcObject string - // DstBucket is the DstBucket argument value. - DstBucket string - // DstObject is the dstObject argument value. - DstObject string - } - // CopyPart holds details about calls to the CopyPart method. - CopyPart []struct { - // SrcBucket is the srcBucket argument value. - SrcBucket string - // SrcObject is the srcObject argument value. - SrcObject string - // DstBucket is the DstBucket argument value. - DstBucket string - // UploadID is the uploadID argument value. - UploadID string - // RangeHeader is the rangeHeader argument value. - RangeHeader string - // Part is the part argument value. - Part int - } - // CreateMultipartUpload holds details about calls to the CreateMultipartUpload method. - CreateMultipartUpload []struct { - // CreateMultipartUploadInput is the createMultipartUploadInput argument value. - CreateMultipartUploadInput *s3.CreateMultipartUploadInput - } - // DeleteBucket holds details about calls to the DeleteBucket method. - DeleteBucket []struct { - // Bucket is the bucket argument value. - Bucket string - } - // DeleteObject holds details about calls to the DeleteObject method. - DeleteObject []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - } - // DeleteObjects holds details about calls to the DeleteObjects method. - DeleteObjects []struct { - // Bucket is the bucket argument value. - Bucket string - // Objects is the objects argument value. - Objects *s3.DeleteObjectsInput - } - // GetBucketAcl holds details about calls to the GetBucketAcl method. - GetBucketAcl []struct { - // Bucket is the bucket argument value. - Bucket string - } - // GetObject holds details about calls to the GetObject method. - GetObject []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - // AcceptRange is the acceptRange argument value. - AcceptRange string - // Writer is the writer argument value. - Writer io.Writer - } - // GetObjectAcl holds details about calls to the GetObjectAcl method. - GetObjectAcl []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - } - // GetObjectAttributes holds details about calls to the GetObjectAttributes method. - GetObjectAttributes []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - // Attributes is the attributes argument value. - Attributes []string - } - // GetTags holds details about calls to the GetTags method. - GetTags []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - } - // HeadBucket holds details about calls to the HeadBucket method. - HeadBucket []struct { - // Bucket is the bucket argument value. - Bucket string - } - // HeadObject holds details about calls to the HeadObject method. - HeadObject []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - } - // ListBuckets holds details about calls to the ListBuckets method. - ListBuckets []struct { - } - // ListMultipartUploads holds details about calls to the ListMultipartUploads method. - ListMultipartUploads []struct { - // Output is the output argument value. - Output *s3.ListMultipartUploadsInput - } - // ListObjectParts holds details about calls to the ListObjectParts method. - ListObjectParts []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - // UploadID is the uploadID argument value. - UploadID string - // PartNumberMarker is the partNumberMarker argument value. - PartNumberMarker int - // MaxParts is the maxParts argument value. - MaxParts int - } - // ListObjects holds details about calls to the ListObjects method. - ListObjects []struct { - // Bucket is the bucket argument value. - Bucket string - // Prefix is the prefix argument value. - Prefix string - // Marker is the marker argument value. - Marker string - // Delim is the delim argument value. - Delim string - // Maxkeys is the maxkeys argument value. - Maxkeys int - } - // ListObjectsV2 holds details about calls to the ListObjectsV2 method. - ListObjectsV2 []struct { - // Bucket is the bucket argument value. - Bucket string - // Prefix is the prefix argument value. - Prefix string - // Marker is the marker argument value. - Marker string - // Delim is the delim argument value. - Delim string - // Maxkeys is the maxkeys argument value. - Maxkeys int - } - // PutBucket holds details about calls to the PutBucket method. - PutBucket []struct { - // Bucket is the bucket argument value. - Bucket string - // Owner is the owner argument value. - Owner string - } - // PutBucketAcl holds details about calls to the PutBucketAcl method. - PutBucketAcl []struct { - // Bucket is the bucket argument value. - Bucket string - // Data is the data argument value. - Data []byte - } - // PutObject holds details about calls to the PutObject method. - PutObject []struct { - // PutObjectInput is the putObjectInput argument value. - PutObjectInput *s3.PutObjectInput - } - // PutObjectAcl holds details about calls to the PutObjectAcl method. - PutObjectAcl []struct { - // PutObjectAclInput is the putObjectAclInput argument value. - PutObjectAclInput *s3.PutObjectAclInput - } - // PutObjectPart holds details about calls to the PutObjectPart method. - PutObjectPart []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - // UploadID is the uploadID argument value. - UploadID string - // Part is the part argument value. - Part int - // Length is the length argument value. - Length int64 - // R is the r argument value. - R io.Reader - } - // RemoveTags holds details about calls to the RemoveTags method. - RemoveTags []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - } - // RestoreObject holds details about calls to the RestoreObject method. - RestoreObject []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - // RestoreRequest is the restoreRequest argument value. - RestoreRequest *s3.RestoreObjectInput - } - // SetTags holds details about calls to the SetTags method. - SetTags []struct { - // Bucket is the bucket argument value. - Bucket string - // Object is the object argument value. - Object string - // Tags is the tags argument value. - Tags map[string]string - } - // Shutdown holds details about calls to the Shutdown method. - Shutdown []struct { - } - // String holds details about calls to the String method. - String []struct { - } - // UploadPartCopy holds details about calls to the UploadPartCopy method. - UploadPartCopy []struct { - // UploadPartCopyInput is the uploadPartCopyInput argument value. - UploadPartCopyInput *s3.UploadPartCopyInput - } - } - lockAbortMultipartUpload sync.RWMutex - lockCompleteMultipartUpload sync.RWMutex - lockCopyObject sync.RWMutex - lockCopyPart sync.RWMutex - lockCreateMultipartUpload sync.RWMutex - lockDeleteBucket sync.RWMutex - lockDeleteObject sync.RWMutex - lockDeleteObjects sync.RWMutex - lockGetBucketAcl sync.RWMutex - lockGetObject sync.RWMutex - lockGetObjectAcl sync.RWMutex - lockGetObjectAttributes sync.RWMutex - lockGetTags sync.RWMutex - lockHeadBucket sync.RWMutex - lockHeadObject sync.RWMutex - lockListBuckets sync.RWMutex - lockListMultipartUploads sync.RWMutex - lockListObjectParts sync.RWMutex - lockListObjects sync.RWMutex - lockListObjectsV2 sync.RWMutex - lockPutBucket sync.RWMutex - lockPutBucketAcl sync.RWMutex - lockPutObject sync.RWMutex - lockPutObjectAcl sync.RWMutex - lockPutObjectPart sync.RWMutex - lockRemoveTags sync.RWMutex - lockRestoreObject sync.RWMutex - lockSetTags sync.RWMutex - lockShutdown sync.RWMutex - lockString sync.RWMutex - lockUploadPartCopy sync.RWMutex -} - -// AbortMultipartUpload calls AbortMultipartUploadFunc. -func (mock *BackendMock) AbortMultipartUpload(abortMultipartUploadInput *s3.AbortMultipartUploadInput) error { - if mock.AbortMultipartUploadFunc == nil { - panic("BackendMock.AbortMultipartUploadFunc: method is nil but Backend.AbortMultipartUpload was just called") - } - callInfo := struct { - AbortMultipartUploadInput *s3.AbortMultipartUploadInput - }{ - AbortMultipartUploadInput: abortMultipartUploadInput, - } - mock.lockAbortMultipartUpload.Lock() - mock.calls.AbortMultipartUpload = append(mock.calls.AbortMultipartUpload, callInfo) - mock.lockAbortMultipartUpload.Unlock() - return mock.AbortMultipartUploadFunc(abortMultipartUploadInput) -} - -// AbortMultipartUploadCalls gets all the calls that were made to AbortMultipartUpload. -// Check the length with: -// -// len(mockedBackend.AbortMultipartUploadCalls()) -func (mock *BackendMock) AbortMultipartUploadCalls() []struct { - AbortMultipartUploadInput *s3.AbortMultipartUploadInput -} { - var calls []struct { - AbortMultipartUploadInput *s3.AbortMultipartUploadInput - } - mock.lockAbortMultipartUpload.RLock() - calls = mock.calls.AbortMultipartUpload - mock.lockAbortMultipartUpload.RUnlock() - return calls -} - -// CompleteMultipartUpload calls CompleteMultipartUploadFunc. -func (mock *BackendMock) CompleteMultipartUpload(bucket string, object string, uploadID string, parts []types.Part) (*s3.CompleteMultipartUploadOutput, error) { - if mock.CompleteMultipartUploadFunc == nil { - panic("BackendMock.CompleteMultipartUploadFunc: method is nil but Backend.CompleteMultipartUpload was just called") - } - callInfo := struct { - Bucket string - Object string - UploadID string - Parts []types.Part - }{ - Bucket: bucket, - Object: object, - UploadID: uploadID, - Parts: parts, - } - mock.lockCompleteMultipartUpload.Lock() - mock.calls.CompleteMultipartUpload = append(mock.calls.CompleteMultipartUpload, callInfo) - mock.lockCompleteMultipartUpload.Unlock() - return mock.CompleteMultipartUploadFunc(bucket, object, uploadID, parts) -} - -// CompleteMultipartUploadCalls gets all the calls that were made to CompleteMultipartUpload. -// Check the length with: -// -// len(mockedBackend.CompleteMultipartUploadCalls()) -func (mock *BackendMock) CompleteMultipartUploadCalls() []struct { - Bucket string - Object string - UploadID string - Parts []types.Part -} { - var calls []struct { - Bucket string - Object string - UploadID string - Parts []types.Part - } - mock.lockCompleteMultipartUpload.RLock() - calls = mock.calls.CompleteMultipartUpload - mock.lockCompleteMultipartUpload.RUnlock() - return calls -} - -// CopyObject calls CopyObjectFunc. -func (mock *BackendMock) CopyObject(srcBucket string, srcObject string, DstBucket string, dstObject string) (*s3.CopyObjectOutput, error) { - if mock.CopyObjectFunc == nil { - panic("BackendMock.CopyObjectFunc: method is nil but Backend.CopyObject was just called") - } - callInfo := struct { - SrcBucket string - SrcObject string - DstBucket string - DstObject string - }{ - SrcBucket: srcBucket, - SrcObject: srcObject, - DstBucket: DstBucket, - DstObject: dstObject, - } - mock.lockCopyObject.Lock() - mock.calls.CopyObject = append(mock.calls.CopyObject, callInfo) - mock.lockCopyObject.Unlock() - return mock.CopyObjectFunc(srcBucket, srcObject, DstBucket, dstObject) -} - -// CopyObjectCalls gets all the calls that were made to CopyObject. -// Check the length with: -// -// len(mockedBackend.CopyObjectCalls()) -func (mock *BackendMock) CopyObjectCalls() []struct { - SrcBucket string - SrcObject string - DstBucket string - DstObject string -} { - var calls []struct { - SrcBucket string - SrcObject string - DstBucket string - DstObject string - } - mock.lockCopyObject.RLock() - calls = mock.calls.CopyObject - mock.lockCopyObject.RUnlock() - return calls -} - -// CopyPart calls CopyPartFunc. -func (mock *BackendMock) CopyPart(srcBucket string, srcObject string, DstBucket string, uploadID string, rangeHeader string, part int) (*types.CopyPartResult, error) { - if mock.CopyPartFunc == nil { - panic("BackendMock.CopyPartFunc: method is nil but Backend.CopyPart was just called") - } - callInfo := struct { - SrcBucket string - SrcObject string - DstBucket string - UploadID string - RangeHeader string - Part int - }{ - SrcBucket: srcBucket, - SrcObject: srcObject, - DstBucket: DstBucket, - UploadID: uploadID, - RangeHeader: rangeHeader, - Part: part, - } - mock.lockCopyPart.Lock() - mock.calls.CopyPart = append(mock.calls.CopyPart, callInfo) - mock.lockCopyPart.Unlock() - return mock.CopyPartFunc(srcBucket, srcObject, DstBucket, uploadID, rangeHeader, part) -} - -// CopyPartCalls gets all the calls that were made to CopyPart. -// Check the length with: -// -// len(mockedBackend.CopyPartCalls()) -func (mock *BackendMock) CopyPartCalls() []struct { - SrcBucket string - SrcObject string - DstBucket string - UploadID string - RangeHeader string - Part int -} { - var calls []struct { - SrcBucket string - SrcObject string - DstBucket string - UploadID string - RangeHeader string - Part int - } - mock.lockCopyPart.RLock() - calls = mock.calls.CopyPart - mock.lockCopyPart.RUnlock() - return calls -} - -// CreateMultipartUpload calls CreateMultipartUploadFunc. -func (mock *BackendMock) CreateMultipartUpload(createMultipartUploadInput *s3.CreateMultipartUploadInput) (*s3.CreateMultipartUploadOutput, error) { - if mock.CreateMultipartUploadFunc == nil { - panic("BackendMock.CreateMultipartUploadFunc: method is nil but Backend.CreateMultipartUpload was just called") - } - callInfo := struct { - CreateMultipartUploadInput *s3.CreateMultipartUploadInput - }{ - CreateMultipartUploadInput: createMultipartUploadInput, - } - mock.lockCreateMultipartUpload.Lock() - mock.calls.CreateMultipartUpload = append(mock.calls.CreateMultipartUpload, callInfo) - mock.lockCreateMultipartUpload.Unlock() - return mock.CreateMultipartUploadFunc(createMultipartUploadInput) -} - -// CreateMultipartUploadCalls gets all the calls that were made to CreateMultipartUpload. -// Check the length with: -// -// len(mockedBackend.CreateMultipartUploadCalls()) -func (mock *BackendMock) CreateMultipartUploadCalls() []struct { - CreateMultipartUploadInput *s3.CreateMultipartUploadInput -} { - var calls []struct { - CreateMultipartUploadInput *s3.CreateMultipartUploadInput - } - mock.lockCreateMultipartUpload.RLock() - calls = mock.calls.CreateMultipartUpload - mock.lockCreateMultipartUpload.RUnlock() - return calls -} - -// DeleteBucket calls DeleteBucketFunc. -func (mock *BackendMock) DeleteBucket(bucket string) error { - if mock.DeleteBucketFunc == nil { - panic("BackendMock.DeleteBucketFunc: method is nil but Backend.DeleteBucket was just called") - } - callInfo := struct { - Bucket string - }{ - Bucket: bucket, - } - mock.lockDeleteBucket.Lock() - mock.calls.DeleteBucket = append(mock.calls.DeleteBucket, callInfo) - mock.lockDeleteBucket.Unlock() - return mock.DeleteBucketFunc(bucket) -} - -// DeleteBucketCalls gets all the calls that were made to DeleteBucket. -// Check the length with: -// -// len(mockedBackend.DeleteBucketCalls()) -func (mock *BackendMock) DeleteBucketCalls() []struct { - Bucket string -} { - var calls []struct { - Bucket string - } - mock.lockDeleteBucket.RLock() - calls = mock.calls.DeleteBucket - mock.lockDeleteBucket.RUnlock() - return calls -} - -// DeleteObject calls DeleteObjectFunc. -func (mock *BackendMock) DeleteObject(bucket string, object string) error { - if mock.DeleteObjectFunc == nil { - panic("BackendMock.DeleteObjectFunc: method is nil but Backend.DeleteObject was just called") - } - callInfo := struct { - Bucket string - Object string - }{ - Bucket: bucket, - Object: object, - } - mock.lockDeleteObject.Lock() - mock.calls.DeleteObject = append(mock.calls.DeleteObject, callInfo) - mock.lockDeleteObject.Unlock() - return mock.DeleteObjectFunc(bucket, object) -} - -// DeleteObjectCalls gets all the calls that were made to DeleteObject. -// Check the length with: -// -// len(mockedBackend.DeleteObjectCalls()) -func (mock *BackendMock) DeleteObjectCalls() []struct { - Bucket string - Object string -} { - var calls []struct { - Bucket string - Object string - } - mock.lockDeleteObject.RLock() - calls = mock.calls.DeleteObject - mock.lockDeleteObject.RUnlock() - return calls -} - -// DeleteObjects calls DeleteObjectsFunc. -func (mock *BackendMock) DeleteObjects(bucket string, objects *s3.DeleteObjectsInput) error { - if mock.DeleteObjectsFunc == nil { - panic("BackendMock.DeleteObjectsFunc: method is nil but Backend.DeleteObjects was just called") - } - callInfo := struct { - Bucket string - Objects *s3.DeleteObjectsInput - }{ - Bucket: bucket, - Objects: objects, - } - mock.lockDeleteObjects.Lock() - mock.calls.DeleteObjects = append(mock.calls.DeleteObjects, callInfo) - mock.lockDeleteObjects.Unlock() - return mock.DeleteObjectsFunc(bucket, objects) -} - -// DeleteObjectsCalls gets all the calls that were made to DeleteObjects. -// Check the length with: -// -// len(mockedBackend.DeleteObjectsCalls()) -func (mock *BackendMock) DeleteObjectsCalls() []struct { - Bucket string - Objects *s3.DeleteObjectsInput -} { - var calls []struct { - Bucket string - Objects *s3.DeleteObjectsInput - } - mock.lockDeleteObjects.RLock() - calls = mock.calls.DeleteObjects - mock.lockDeleteObjects.RUnlock() - return calls -} - -// GetBucketAcl calls GetBucketAclFunc. -func (mock *BackendMock) GetBucketAcl(bucket string) ([]byte, error) { - if mock.GetBucketAclFunc == nil { - panic("BackendMock.GetBucketAclFunc: method is nil but Backend.GetBucketAcl was just called") - } - callInfo := struct { - Bucket string - }{ - Bucket: bucket, - } - mock.lockGetBucketAcl.Lock() - mock.calls.GetBucketAcl = append(mock.calls.GetBucketAcl, callInfo) - mock.lockGetBucketAcl.Unlock() - return mock.GetBucketAclFunc(bucket) -} - -// GetBucketAclCalls gets all the calls that were made to GetBucketAcl. -// Check the length with: -// -// len(mockedBackend.GetBucketAclCalls()) -func (mock *BackendMock) GetBucketAclCalls() []struct { - Bucket string -} { - var calls []struct { - Bucket string - } - mock.lockGetBucketAcl.RLock() - calls = mock.calls.GetBucketAcl - mock.lockGetBucketAcl.RUnlock() - return calls -} - -// GetObject calls GetObjectFunc. -func (mock *BackendMock) GetObject(bucket string, object string, acceptRange string, writer io.Writer) (*s3.GetObjectOutput, error) { - if mock.GetObjectFunc == nil { - panic("BackendMock.GetObjectFunc: method is nil but Backend.GetObject was just called") - } - callInfo := struct { - Bucket string - Object string - AcceptRange string - Writer io.Writer - }{ - Bucket: bucket, - Object: object, - AcceptRange: acceptRange, - Writer: writer, - } - mock.lockGetObject.Lock() - mock.calls.GetObject = append(mock.calls.GetObject, callInfo) - mock.lockGetObject.Unlock() - return mock.GetObjectFunc(bucket, object, acceptRange, writer) -} - -// GetObjectCalls gets all the calls that were made to GetObject. -// Check the length with: -// -// len(mockedBackend.GetObjectCalls()) -func (mock *BackendMock) GetObjectCalls() []struct { - Bucket string - Object string - AcceptRange string - Writer io.Writer -} { - var calls []struct { - Bucket string - Object string - AcceptRange string - Writer io.Writer - } - mock.lockGetObject.RLock() - calls = mock.calls.GetObject - mock.lockGetObject.RUnlock() - return calls -} - -// GetObjectAcl calls GetObjectAclFunc. -func (mock *BackendMock) GetObjectAcl(bucket string, object string) (*s3.GetObjectAclOutput, error) { - if mock.GetObjectAclFunc == nil { - panic("BackendMock.GetObjectAclFunc: method is nil but Backend.GetObjectAcl was just called") - } - callInfo := struct { - Bucket string - Object string - }{ - Bucket: bucket, - Object: object, - } - mock.lockGetObjectAcl.Lock() - mock.calls.GetObjectAcl = append(mock.calls.GetObjectAcl, callInfo) - mock.lockGetObjectAcl.Unlock() - return mock.GetObjectAclFunc(bucket, object) -} - -// GetObjectAclCalls gets all the calls that were made to GetObjectAcl. -// Check the length with: -// -// len(mockedBackend.GetObjectAclCalls()) -func (mock *BackendMock) GetObjectAclCalls() []struct { - Bucket string - Object string -} { - var calls []struct { - Bucket string - Object string - } - mock.lockGetObjectAcl.RLock() - calls = mock.calls.GetObjectAcl - mock.lockGetObjectAcl.RUnlock() - return calls -} - -// GetObjectAttributes calls GetObjectAttributesFunc. -func (mock *BackendMock) GetObjectAttributes(bucket string, object string, attributes []string) (*s3.GetObjectAttributesOutput, error) { - if mock.GetObjectAttributesFunc == nil { - panic("BackendMock.GetObjectAttributesFunc: method is nil but Backend.GetObjectAttributes was just called") - } - callInfo := struct { - Bucket string - Object string - Attributes []string - }{ - Bucket: bucket, - Object: object, - Attributes: attributes, - } - mock.lockGetObjectAttributes.Lock() - mock.calls.GetObjectAttributes = append(mock.calls.GetObjectAttributes, callInfo) - mock.lockGetObjectAttributes.Unlock() - return mock.GetObjectAttributesFunc(bucket, object, attributes) -} - -// GetObjectAttributesCalls gets all the calls that were made to GetObjectAttributes. -// Check the length with: -// -// len(mockedBackend.GetObjectAttributesCalls()) -func (mock *BackendMock) GetObjectAttributesCalls() []struct { - Bucket string - Object string - Attributes []string -} { - var calls []struct { - Bucket string - Object string - Attributes []string - } - mock.lockGetObjectAttributes.RLock() - calls = mock.calls.GetObjectAttributes - mock.lockGetObjectAttributes.RUnlock() - return calls -} - -// GetTags calls GetTagsFunc. -func (mock *BackendMock) GetTags(bucket string, object string) (map[string]string, error) { - if mock.GetTagsFunc == nil { - panic("BackendMock.GetTagsFunc: method is nil but Backend.GetTags was just called") - } - callInfo := struct { - Bucket string - Object string - }{ - Bucket: bucket, - Object: object, - } - mock.lockGetTags.Lock() - mock.calls.GetTags = append(mock.calls.GetTags, callInfo) - mock.lockGetTags.Unlock() - return mock.GetTagsFunc(bucket, object) -} - -// GetTagsCalls gets all the calls that were made to GetTags. -// Check the length with: -// -// len(mockedBackend.GetTagsCalls()) -func (mock *BackendMock) GetTagsCalls() []struct { - Bucket string - Object string -} { - var calls []struct { - Bucket string - Object string - } - mock.lockGetTags.RLock() - calls = mock.calls.GetTags - mock.lockGetTags.RUnlock() - return calls -} - -// HeadBucket calls HeadBucketFunc. -func (mock *BackendMock) HeadBucket(bucket string) (*s3.HeadBucketOutput, error) { - if mock.HeadBucketFunc == nil { - panic("BackendMock.HeadBucketFunc: method is nil but Backend.HeadBucket was just called") - } - callInfo := struct { - Bucket string - }{ - Bucket: bucket, - } - mock.lockHeadBucket.Lock() - mock.calls.HeadBucket = append(mock.calls.HeadBucket, callInfo) - mock.lockHeadBucket.Unlock() - return mock.HeadBucketFunc(bucket) -} - -// HeadBucketCalls gets all the calls that were made to HeadBucket. -// Check the length with: -// -// len(mockedBackend.HeadBucketCalls()) -func (mock *BackendMock) HeadBucketCalls() []struct { - Bucket string -} { - var calls []struct { - Bucket string - } - mock.lockHeadBucket.RLock() - calls = mock.calls.HeadBucket - mock.lockHeadBucket.RUnlock() - return calls -} - -// HeadObject calls HeadObjectFunc. -func (mock *BackendMock) HeadObject(bucket string, object string) (*s3.HeadObjectOutput, error) { - if mock.HeadObjectFunc == nil { - panic("BackendMock.HeadObjectFunc: method is nil but Backend.HeadObject was just called") - } - callInfo := struct { - Bucket string - Object string - }{ - Bucket: bucket, - Object: object, - } - mock.lockHeadObject.Lock() - mock.calls.HeadObject = append(mock.calls.HeadObject, callInfo) - mock.lockHeadObject.Unlock() - return mock.HeadObjectFunc(bucket, object) -} - -// HeadObjectCalls gets all the calls that were made to HeadObject. -// Check the length with: -// -// len(mockedBackend.HeadObjectCalls()) -func (mock *BackendMock) HeadObjectCalls() []struct { - Bucket string - Object string -} { - var calls []struct { - Bucket string - Object string - } - mock.lockHeadObject.RLock() - calls = mock.calls.HeadObject - mock.lockHeadObject.RUnlock() - return calls -} - -// ListBuckets calls ListBucketsFunc. -func (mock *BackendMock) ListBuckets() (s3response.ListAllMyBucketsResult, error) { - if mock.ListBucketsFunc == nil { - panic("BackendMock.ListBucketsFunc: method is nil but Backend.ListBuckets was just called") - } - callInfo := struct { - }{} - mock.lockListBuckets.Lock() - mock.calls.ListBuckets = append(mock.calls.ListBuckets, callInfo) - mock.lockListBuckets.Unlock() - return mock.ListBucketsFunc() -} - -// ListBucketsCalls gets all the calls that were made to ListBuckets. -// Check the length with: -// -// len(mockedBackend.ListBucketsCalls()) -func (mock *BackendMock) ListBucketsCalls() []struct { -} { - var calls []struct { - } - mock.lockListBuckets.RLock() - calls = mock.calls.ListBuckets - mock.lockListBuckets.RUnlock() - return calls -} - -// ListMultipartUploads calls ListMultipartUploadsFunc. -func (mock *BackendMock) ListMultipartUploads(output *s3.ListMultipartUploadsInput) (s3response.ListMultipartUploadsResponse, error) { - if mock.ListMultipartUploadsFunc == nil { - panic("BackendMock.ListMultipartUploadsFunc: method is nil but Backend.ListMultipartUploads was just called") - } - callInfo := struct { - Output *s3.ListMultipartUploadsInput - }{ - Output: output, - } - mock.lockListMultipartUploads.Lock() - mock.calls.ListMultipartUploads = append(mock.calls.ListMultipartUploads, callInfo) - mock.lockListMultipartUploads.Unlock() - return mock.ListMultipartUploadsFunc(output) -} - -// ListMultipartUploadsCalls gets all the calls that were made to ListMultipartUploads. -// Check the length with: -// -// len(mockedBackend.ListMultipartUploadsCalls()) -func (mock *BackendMock) ListMultipartUploadsCalls() []struct { - Output *s3.ListMultipartUploadsInput -} { - var calls []struct { - Output *s3.ListMultipartUploadsInput - } - mock.lockListMultipartUploads.RLock() - calls = mock.calls.ListMultipartUploads - mock.lockListMultipartUploads.RUnlock() - return calls -} - -// ListObjectParts calls ListObjectPartsFunc. -func (mock *BackendMock) ListObjectParts(bucket string, object string, uploadID string, partNumberMarker int, maxParts int) (s3response.ListPartsResponse, error) { - if mock.ListObjectPartsFunc == nil { - panic("BackendMock.ListObjectPartsFunc: method is nil but Backend.ListObjectParts was just called") - } - callInfo := struct { - Bucket string - Object string - UploadID string - PartNumberMarker int - MaxParts int - }{ - Bucket: bucket, - Object: object, - UploadID: uploadID, - PartNumberMarker: partNumberMarker, - MaxParts: maxParts, - } - mock.lockListObjectParts.Lock() - mock.calls.ListObjectParts = append(mock.calls.ListObjectParts, callInfo) - mock.lockListObjectParts.Unlock() - return mock.ListObjectPartsFunc(bucket, object, uploadID, partNumberMarker, maxParts) -} - -// ListObjectPartsCalls gets all the calls that were made to ListObjectParts. -// Check the length with: -// -// len(mockedBackend.ListObjectPartsCalls()) -func (mock *BackendMock) ListObjectPartsCalls() []struct { - Bucket string - Object string - UploadID string - PartNumberMarker int - MaxParts int -} { - var calls []struct { - Bucket string - Object string - UploadID string - PartNumberMarker int - MaxParts int - } - mock.lockListObjectParts.RLock() - calls = mock.calls.ListObjectParts - mock.lockListObjectParts.RUnlock() - return calls -} - -// ListObjects calls ListObjectsFunc. -func (mock *BackendMock) ListObjects(bucket string, prefix string, marker string, delim string, maxkeys int) (*s3.ListObjectsOutput, error) { - if mock.ListObjectsFunc == nil { - panic("BackendMock.ListObjectsFunc: method is nil but Backend.ListObjects was just called") - } - callInfo := struct { - Bucket string - Prefix string - Marker string - Delim string - Maxkeys int - }{ - Bucket: bucket, - Prefix: prefix, - Marker: marker, - Delim: delim, - Maxkeys: maxkeys, - } - mock.lockListObjects.Lock() - mock.calls.ListObjects = append(mock.calls.ListObjects, callInfo) - mock.lockListObjects.Unlock() - return mock.ListObjectsFunc(bucket, prefix, marker, delim, maxkeys) -} - -// ListObjectsCalls gets all the calls that were made to ListObjects. -// Check the length with: -// -// len(mockedBackend.ListObjectsCalls()) -func (mock *BackendMock) ListObjectsCalls() []struct { - Bucket string - Prefix string - Marker string - Delim string - Maxkeys int -} { - var calls []struct { - Bucket string - Prefix string - Marker string - Delim string - Maxkeys int - } - mock.lockListObjects.RLock() - calls = mock.calls.ListObjects - mock.lockListObjects.RUnlock() - return calls -} - -// ListObjectsV2 calls ListObjectsV2Func. -func (mock *BackendMock) ListObjectsV2(bucket string, prefix string, marker string, delim string, maxkeys int) (*s3.ListObjectsV2Output, error) { - if mock.ListObjectsV2Func == nil { - panic("BackendMock.ListObjectsV2Func: method is nil but Backend.ListObjectsV2 was just called") - } - callInfo := struct { - Bucket string - Prefix string - Marker string - Delim string - Maxkeys int - }{ - Bucket: bucket, - Prefix: prefix, - Marker: marker, - Delim: delim, - Maxkeys: maxkeys, - } - mock.lockListObjectsV2.Lock() - mock.calls.ListObjectsV2 = append(mock.calls.ListObjectsV2, callInfo) - mock.lockListObjectsV2.Unlock() - return mock.ListObjectsV2Func(bucket, prefix, marker, delim, maxkeys) -} - -// ListObjectsV2Calls gets all the calls that were made to ListObjectsV2. -// Check the length with: -// -// len(mockedBackend.ListObjectsV2Calls()) -func (mock *BackendMock) ListObjectsV2Calls() []struct { - Bucket string - Prefix string - Marker string - Delim string - Maxkeys int -} { - var calls []struct { - Bucket string - Prefix string - Marker string - Delim string - Maxkeys int - } - mock.lockListObjectsV2.RLock() - calls = mock.calls.ListObjectsV2 - mock.lockListObjectsV2.RUnlock() - return calls -} - -// PutBucket calls PutBucketFunc. -func (mock *BackendMock) PutBucket(bucket string, owner string) error { - if mock.PutBucketFunc == nil { - panic("BackendMock.PutBucketFunc: method is nil but Backend.PutBucket was just called") - } - callInfo := struct { - Bucket string - Owner string - }{ - Bucket: bucket, - Owner: owner, - } - mock.lockPutBucket.Lock() - mock.calls.PutBucket = append(mock.calls.PutBucket, callInfo) - mock.lockPutBucket.Unlock() - return mock.PutBucketFunc(bucket, owner) -} - -// PutBucketCalls gets all the calls that were made to PutBucket. -// Check the length with: -// -// len(mockedBackend.PutBucketCalls()) -func (mock *BackendMock) PutBucketCalls() []struct { - Bucket string - Owner string -} { - var calls []struct { - Bucket string - Owner string - } - mock.lockPutBucket.RLock() - calls = mock.calls.PutBucket - mock.lockPutBucket.RUnlock() - return calls -} - -// PutBucketAcl calls PutBucketAclFunc. -func (mock *BackendMock) PutBucketAcl(bucket string, data []byte) error { - if mock.PutBucketAclFunc == nil { - panic("BackendMock.PutBucketAclFunc: method is nil but Backend.PutBucketAcl was just called") - } - callInfo := struct { - Bucket string - Data []byte - }{ - Bucket: bucket, - Data: data, - } - mock.lockPutBucketAcl.Lock() - mock.calls.PutBucketAcl = append(mock.calls.PutBucketAcl, callInfo) - mock.lockPutBucketAcl.Unlock() - return mock.PutBucketAclFunc(bucket, data) -} - -// PutBucketAclCalls gets all the calls that were made to PutBucketAcl. -// Check the length with: -// -// len(mockedBackend.PutBucketAclCalls()) -func (mock *BackendMock) PutBucketAclCalls() []struct { - Bucket string - Data []byte -} { - var calls []struct { - Bucket string - Data []byte - } - mock.lockPutBucketAcl.RLock() - calls = mock.calls.PutBucketAcl - mock.lockPutBucketAcl.RUnlock() - return calls -} - -// PutObject calls PutObjectFunc. -func (mock *BackendMock) PutObject(putObjectInput *s3.PutObjectInput) (string, error) { - if mock.PutObjectFunc == nil { - panic("BackendMock.PutObjectFunc: method is nil but Backend.PutObject was just called") - } - callInfo := struct { - PutObjectInput *s3.PutObjectInput - }{ - PutObjectInput: putObjectInput, - } - mock.lockPutObject.Lock() - mock.calls.PutObject = append(mock.calls.PutObject, callInfo) - mock.lockPutObject.Unlock() - return mock.PutObjectFunc(putObjectInput) -} - -// PutObjectCalls gets all the calls that were made to PutObject. -// Check the length with: -// -// len(mockedBackend.PutObjectCalls()) -func (mock *BackendMock) PutObjectCalls() []struct { - PutObjectInput *s3.PutObjectInput -} { - var calls []struct { - PutObjectInput *s3.PutObjectInput - } - mock.lockPutObject.RLock() - calls = mock.calls.PutObject - mock.lockPutObject.RUnlock() - return calls -} - -// PutObjectAcl calls PutObjectAclFunc. -func (mock *BackendMock) PutObjectAcl(putObjectAclInput *s3.PutObjectAclInput) error { - if mock.PutObjectAclFunc == nil { - panic("BackendMock.PutObjectAclFunc: method is nil but Backend.PutObjectAcl was just called") - } - callInfo := struct { - PutObjectAclInput *s3.PutObjectAclInput - }{ - PutObjectAclInput: putObjectAclInput, - } - mock.lockPutObjectAcl.Lock() - mock.calls.PutObjectAcl = append(mock.calls.PutObjectAcl, callInfo) - mock.lockPutObjectAcl.Unlock() - return mock.PutObjectAclFunc(putObjectAclInput) -} - -// PutObjectAclCalls gets all the calls that were made to PutObjectAcl. -// Check the length with: -// -// len(mockedBackend.PutObjectAclCalls()) -func (mock *BackendMock) PutObjectAclCalls() []struct { - PutObjectAclInput *s3.PutObjectAclInput -} { - var calls []struct { - PutObjectAclInput *s3.PutObjectAclInput - } - mock.lockPutObjectAcl.RLock() - calls = mock.calls.PutObjectAcl - mock.lockPutObjectAcl.RUnlock() - return calls -} - -// PutObjectPart calls PutObjectPartFunc. -func (mock *BackendMock) PutObjectPart(bucket string, object string, uploadID string, part int, length int64, r io.Reader) (string, error) { - if mock.PutObjectPartFunc == nil { - panic("BackendMock.PutObjectPartFunc: method is nil but Backend.PutObjectPart was just called") - } - callInfo := struct { - Bucket string - Object string - UploadID string - Part int - Length int64 - R io.Reader - }{ - Bucket: bucket, - Object: object, - UploadID: uploadID, - Part: part, - Length: length, - R: r, - } - mock.lockPutObjectPart.Lock() - mock.calls.PutObjectPart = append(mock.calls.PutObjectPart, callInfo) - mock.lockPutObjectPart.Unlock() - return mock.PutObjectPartFunc(bucket, object, uploadID, part, length, r) -} - -// PutObjectPartCalls gets all the calls that were made to PutObjectPart. -// Check the length with: -// -// len(mockedBackend.PutObjectPartCalls()) -func (mock *BackendMock) PutObjectPartCalls() []struct { - Bucket string - Object string - UploadID string - Part int - Length int64 - R io.Reader -} { - var calls []struct { - Bucket string - Object string - UploadID string - Part int - Length int64 - R io.Reader - } - mock.lockPutObjectPart.RLock() - calls = mock.calls.PutObjectPart - mock.lockPutObjectPart.RUnlock() - return calls -} - -// RemoveTags calls RemoveTagsFunc. -func (mock *BackendMock) RemoveTags(bucket string, object string) error { - if mock.RemoveTagsFunc == nil { - panic("BackendMock.RemoveTagsFunc: method is nil but Backend.RemoveTags was just called") - } - callInfo := struct { - Bucket string - Object string - }{ - Bucket: bucket, - Object: object, - } - mock.lockRemoveTags.Lock() - mock.calls.RemoveTags = append(mock.calls.RemoveTags, callInfo) - mock.lockRemoveTags.Unlock() - return mock.RemoveTagsFunc(bucket, object) -} - -// RemoveTagsCalls gets all the calls that were made to RemoveTags. -// Check the length with: -// -// len(mockedBackend.RemoveTagsCalls()) -func (mock *BackendMock) RemoveTagsCalls() []struct { - Bucket string - Object string -} { - var calls []struct { - Bucket string - Object string - } - mock.lockRemoveTags.RLock() - calls = mock.calls.RemoveTags - mock.lockRemoveTags.RUnlock() - return calls -} - -// RestoreObject calls RestoreObjectFunc. -func (mock *BackendMock) RestoreObject(bucket string, object string, restoreRequest *s3.RestoreObjectInput) error { - if mock.RestoreObjectFunc == nil { - panic("BackendMock.RestoreObjectFunc: method is nil but Backend.RestoreObject was just called") - } - callInfo := struct { - Bucket string - Object string - RestoreRequest *s3.RestoreObjectInput - }{ - Bucket: bucket, - Object: object, - RestoreRequest: restoreRequest, - } - mock.lockRestoreObject.Lock() - mock.calls.RestoreObject = append(mock.calls.RestoreObject, callInfo) - mock.lockRestoreObject.Unlock() - return mock.RestoreObjectFunc(bucket, object, restoreRequest) -} - -// RestoreObjectCalls gets all the calls that were made to RestoreObject. -// Check the length with: -// -// len(mockedBackend.RestoreObjectCalls()) -func (mock *BackendMock) RestoreObjectCalls() []struct { - Bucket string - Object string - RestoreRequest *s3.RestoreObjectInput -} { - var calls []struct { - Bucket string - Object string - RestoreRequest *s3.RestoreObjectInput - } - mock.lockRestoreObject.RLock() - calls = mock.calls.RestoreObject - mock.lockRestoreObject.RUnlock() - return calls -} - -// SetTags calls SetTagsFunc. -func (mock *BackendMock) SetTags(bucket string, object string, tags map[string]string) error { - if mock.SetTagsFunc == nil { - panic("BackendMock.SetTagsFunc: method is nil but Backend.SetTags was just called") - } - callInfo := struct { - Bucket string - Object string - Tags map[string]string - }{ - Bucket: bucket, - Object: object, - Tags: tags, - } - mock.lockSetTags.Lock() - mock.calls.SetTags = append(mock.calls.SetTags, callInfo) - mock.lockSetTags.Unlock() - return mock.SetTagsFunc(bucket, object, tags) -} - -// SetTagsCalls gets all the calls that were made to SetTags. -// Check the length with: -// -// len(mockedBackend.SetTagsCalls()) -func (mock *BackendMock) SetTagsCalls() []struct { - Bucket string - Object string - Tags map[string]string -} { - var calls []struct { - Bucket string - Object string - Tags map[string]string - } - mock.lockSetTags.RLock() - calls = mock.calls.SetTags - mock.lockSetTags.RUnlock() - return calls -} - -// Shutdown calls ShutdownFunc. -func (mock *BackendMock) Shutdown() { - if mock.ShutdownFunc == nil { - panic("BackendMock.ShutdownFunc: method is nil but Backend.Shutdown was just called") - } - callInfo := struct { - }{} - mock.lockShutdown.Lock() - mock.calls.Shutdown = append(mock.calls.Shutdown, callInfo) - mock.lockShutdown.Unlock() - mock.ShutdownFunc() -} - -// ShutdownCalls gets all the calls that were made to Shutdown. -// Check the length with: -// -// len(mockedBackend.ShutdownCalls()) -func (mock *BackendMock) ShutdownCalls() []struct { -} { - var calls []struct { - } - mock.lockShutdown.RLock() - calls = mock.calls.Shutdown - mock.lockShutdown.RUnlock() - return calls -} - -// String calls StringFunc. -func (mock *BackendMock) String() string { - if mock.StringFunc == nil { - panic("BackendMock.StringFunc: method is nil but Backend.String was just called") - } - callInfo := struct { - }{} - mock.lockString.Lock() - mock.calls.String = append(mock.calls.String, callInfo) - mock.lockString.Unlock() - return mock.StringFunc() -} - -// StringCalls gets all the calls that were made to String. -// Check the length with: -// -// len(mockedBackend.StringCalls()) -func (mock *BackendMock) StringCalls() []struct { -} { - var calls []struct { - } - mock.lockString.RLock() - calls = mock.calls.String - mock.lockString.RUnlock() - return calls -} - -// UploadPartCopy calls UploadPartCopyFunc. -func (mock *BackendMock) UploadPartCopy(uploadPartCopyInput *s3.UploadPartCopyInput) (*s3.UploadPartCopyOutput, error) { - if mock.UploadPartCopyFunc == nil { - panic("BackendMock.UploadPartCopyFunc: method is nil but Backend.UploadPartCopy was just called") - } - callInfo := struct { - UploadPartCopyInput *s3.UploadPartCopyInput - }{ - UploadPartCopyInput: uploadPartCopyInput, - } - mock.lockUploadPartCopy.Lock() - mock.calls.UploadPartCopy = append(mock.calls.UploadPartCopy, callInfo) - mock.lockUploadPartCopy.Unlock() - return mock.UploadPartCopyFunc(uploadPartCopyInput) -} - -// UploadPartCopyCalls gets all the calls that were made to UploadPartCopy. -// Check the length with: -// -// len(mockedBackend.UploadPartCopyCalls()) -func (mock *BackendMock) UploadPartCopyCalls() []struct { - UploadPartCopyInput *s3.UploadPartCopyInput -} { - var calls []struct { - UploadPartCopyInput *s3.UploadPartCopyInput - } - mock.lockUploadPartCopy.RLock() - calls = mock.calls.UploadPartCopy - mock.lockUploadPartCopy.RUnlock() - return calls -} diff --git a/backend/backend_test.go b/backend/backend_test.go deleted file mode 100644 index f696b74..0000000 --- a/backend/backend_test.go +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright 2023 Versity Software -// This file is licensed under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package backend - -import ( - "context" - "testing" - - "github.com/aws/aws-sdk-go-v2/service/s3" - "github.com/versity/versitygw/s3err" - "github.com/versity/versitygw/s3response" -) - -func TestBackend_ListBuckets(t *testing.T) { - type args struct { - ctx context.Context - } - type test struct { - name string - c Backend - args args - wantErr bool - } - var tests []test - tests = append(tests, test{ - name: "list-Bucket", - c: &BackendMock{ - ListBucketsFunc: func() (s3response.ListAllMyBucketsResult, error) { - return s3response.ListAllMyBucketsResult{ - Buckets: s3response.ListAllMyBucketsList{ - Bucket: []s3response.ListAllMyBucketsEntry{ - { - Name: "t1", - }, - }, - }, - }, s3err.GetAPIError(0) - }, - }, - args: args{ - ctx: context.Background(), - }, - wantErr: false, - }, test{ - name: "list-Bucket-error", - c: &BackendMock{ - ListBucketsFunc: func() (s3response.ListAllMyBucketsResult, error) { - return s3response.ListAllMyBucketsResult{}, s3err.GetAPIError(s3err.ErrNotImplemented) - }, - }, - args: args{ - ctx: context.Background(), - }, - wantErr: true, - }) - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if _, err := tt.c.ListBuckets(); (err.(s3err.APIError).Code != "") != tt.wantErr { - t.Errorf("Backend.ListBuckets() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} -func TestBackend_HeadBucket(t *testing.T) { - type args struct { - ctx context.Context - BucketName string - } - type test struct { - name string - c Backend - args args - wantErr bool - } - var tests []test - tests = append(tests, test{ - name: "head-buckets-error", - c: &BackendMock{ - HeadBucketFunc: func(bucket string) (*s3.HeadBucketOutput, error) { - return nil, s3err.GetAPIError(s3err.ErrNotImplemented) - }, - }, - args: args{ - ctx: context.Background(), - BucketName: "b1", - }, - wantErr: true, - }) - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if _, err := tt.c.HeadBucket(tt.args.BucketName); (err.(s3err.APIError).Code != "") != tt.wantErr { - t.Errorf("Backend.HeadBucket() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} -func TestBackend_GetBucketAcl(t *testing.T) { - type args struct { - ctx context.Context - bucketName string - } - type test struct { - name string - c Backend - args args - wantErr bool - } - var tests []test - tests = append(tests, test{ - name: "get bucket acl error", - c: &BackendMock{ - GetBucketAclFunc: func(bucket string) ([]byte, error) { - return nil, s3err.GetAPIError(s3err.ErrNotImplemented) - }, - }, - args: args{ - ctx: context.Background(), - bucketName: "b1", - }, - wantErr: true, - }) - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if _, err := tt.c.GetBucketAcl(tt.args.bucketName); (err.(s3err.APIError).Code != "") != tt.wantErr { - t.Errorf("Backend.GetBucketAcl() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} -func TestBackend_PutBucket(t *testing.T) { - type args struct { - ctx context.Context - bucketName string - bucketOwner string - } - type test struct { - name string - c Backend - args args - wantErr bool - } - var tests []test - tests = append(tests, test{ - name: "put bucket ", - c: &BackendMock{ - PutBucketFunc: func(bucket, owner string) error { - return s3err.GetAPIError(0) - }, - }, - args: args{ - ctx: context.Background(), - bucketName: "b1", - bucketOwner: "owner", - }, - wantErr: false, - }, test{ - name: "put bucket error", - c: &BackendMock{ - PutBucketFunc: func(bucket, owner string) error { - return s3err.GetAPIError(s3err.ErrNotImplemented) - }, - }, - args: args{ - ctx: context.Background(), - bucketName: "b2", - bucketOwner: "owner", - }, - wantErr: true, - }) - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if err := tt.c.PutBucket(tt.args.bucketName, tt.args.bucketOwner); (err.(s3err.APIError).Code != "") != tt.wantErr { - t.Errorf("Backend.PutBucket() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} -func TestBackend_DeleteBucket(t *testing.T) { - type args struct { - ctx context.Context - bucketName string - } - type test struct { - name string - c Backend - args args - wantErr bool - } - var tests []test - tests = append(tests, test{ - name: "Delete Bucket Error", - c: &BackendMock{ - DeleteBucketFunc: func(bucket string) error { - return s3err.GetAPIError(s3err.ErrNotImplemented) - }, - }, - args: args{ - ctx: context.Background(), - bucketName: "b1", - }, - wantErr: true, - }) - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if err := tt.c.DeleteBucket(tt.args.bucketName); (err.(s3err.APIError).Code != "") != tt.wantErr { - t.Errorf("Backend.DeleteBucket() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} diff --git a/s3api/controllers/admin.go b/s3api/controllers/admin.go index 2015ab4..d887f88 100644 --- a/s3api/controllers/admin.go +++ b/s3api/controllers/admin.go @@ -32,6 +32,9 @@ func (c AdminController) CreateUser(ctx *fiber.Ctx) error { if requesterRole != "admin" { return fmt.Errorf("access denied: only admin users have access to this resource") } + if role != "user" && role != "admin" { + return fmt.Errorf("invalid parameters: user role have to be one of the following: 'user', 'admin'") + } user := auth.Account{Secret: secret, Role: role} @@ -40,8 +43,7 @@ func (c AdminController) CreateUser(ctx *fiber.Ctx) error { return fmt.Errorf("failed to create a user: %w", err) } - ctx.SendString("The user has been created successfully") - return nil + return ctx.SendString("The user has been created successfully") } func (c AdminController) DeleteUser(ctx *fiber.Ctx) error { @@ -56,6 +58,5 @@ func (c AdminController) DeleteUser(ctx *fiber.Ctx) error { return err } - ctx.SendString("The user has been created successfully") - return nil + return ctx.SendString("The user has been created successfully") } diff --git a/s3api/controllers/admin_test.go b/s3api/controllers/admin_test.go new file mode 100644 index 0000000..8150e82 --- /dev/null +++ b/s3api/controllers/admin_test.go @@ -0,0 +1,173 @@ +// Copyright 2023 Versity Software +// This file is licensed under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package controllers + +import ( + "net/http" + "net/http/httptest" + "testing" + + "github.com/gofiber/fiber/v2" + "github.com/versity/versitygw/auth" +) + +func TestAdminController_CreateUser(t *testing.T) { + type args struct { + req *http.Request + } + + adminController := AdminController{ + IAMService: &IAMServiceMock{ + CreateAccountFunc: func(access string, account auth.Account) error { + return nil + }, + }, + } + + app := fiber.New() + + app.Use(func(ctx *fiber.Ctx) error { + ctx.Locals("role", "admin") + return ctx.Next() + }) + + app.Post("/create-user", adminController.CreateUser) + + appErr := fiber.New() + + appErr.Use(func(ctx *fiber.Ctx) error { + ctx.Locals("role", "user") + return ctx.Next() + }) + + appErr.Post("/create-user", adminController.CreateUser) + + tests := []struct { + name string + app *fiber.App + args args + wantErr bool + statusCode int + }{ + { + name: "Admin-create-user-success", + app: app, + args: args{ + req: httptest.NewRequest(http.MethodPost, "/create-user?access=test&secret=test&role=user", nil), + }, + wantErr: false, + statusCode: 200, + }, + { + name: "Admin-create-user-invalid-user-role", + app: app, + args: args{ + req: httptest.NewRequest(http.MethodPost, "/create-user?access=test&secret=test&role=invalid", nil), + }, + wantErr: false, + statusCode: 500, + }, + { + name: "Admin-create-user-invalid-requester-role", + app: appErr, + args: args{ + req: httptest.NewRequest(http.MethodPost, "/create-user?access=test&secret=test&role=admin", nil), + }, + wantErr: false, + statusCode: 500, + }, + } + for _, tt := range tests { + resp, err := tt.app.Test(tt.args.req) + + if (err != nil) != tt.wantErr { + t.Errorf("AdminController.CreateUser() error = %v, wantErr %v", err, tt.wantErr) + } + + if resp.StatusCode != tt.statusCode { + t.Errorf("AdminController.CreateUser() statusCode = %v, wantStatusCode = %v", resp.StatusCode, tt.statusCode) + } + } +} + +func TestAdminController_DeleteUser(t *testing.T) { + type args struct { + req *http.Request + } + + adminController := AdminController{ + IAMService: &IAMServiceMock{ + DeleteUserAccountFunc: func(access string) error { + return nil + }, + }, + } + + app := fiber.New() + + app.Use(func(ctx *fiber.Ctx) error { + ctx.Locals("role", "admin") + return ctx.Next() + }) + + app.Delete("/delete-user", adminController.DeleteUser) + + appErr := fiber.New() + + appErr.Use(func(ctx *fiber.Ctx) error { + ctx.Locals("role", "user") + return ctx.Next() + }) + + appErr.Delete("/delete-user", adminController.DeleteUser) + + tests := []struct { + name string + app *fiber.App + args args + wantErr bool + statusCode int + }{ + { + name: "Admin-delete-user-success", + app: app, + args: args{ + req: httptest.NewRequest(http.MethodDelete, "/delete-user?access=test", nil), + }, + wantErr: false, + statusCode: 200, + }, + { + name: "Admin-delete-user-invalid-requester-role", + app: appErr, + args: args{ + req: httptest.NewRequest(http.MethodDelete, "/delete-user?access=test", nil), + }, + wantErr: false, + statusCode: 500, + }, + } + for _, tt := range tests { + resp, err := tt.app.Test(tt.args.req) + + if (err != nil) != tt.wantErr { + t.Errorf("AdminController.DeleteUser() error = %v, wantErr %v", err, tt.wantErr) + } + + if resp.StatusCode != tt.statusCode { + t.Errorf("AdminController.DeleteUser() statusCode = %v, wantStatusCode = %v", resp.StatusCode, tt.statusCode) + } + } +} diff --git a/s3api/controllers/base.go b/s3api/controllers/base.go index ecc0431..8f6e5ab 100644 --- a/s3api/controllers/base.go +++ b/s3api/controllers/base.go @@ -550,7 +550,7 @@ func (c S3ApiController) DeleteObjects(ctx *fiber.Ctx) error { var dObj types.Delete if err := xml.Unmarshal(ctx.Body(), &dObj); err != nil { - return errors.New("wrong api call") + return SendResponse(ctx, s3err.GetAPIError(s3err.ErrInvalidRequest)) } data, err := c.be.GetBucketAcl(bucket) diff --git a/s3api/controllers/base_test.go b/s3api/controllers/base_test.go index 6bcb33c..0a28d75 100644 --- a/s3api/controllers/base_test.go +++ b/s3api/controllers/base_test.go @@ -16,6 +16,7 @@ package controllers import ( "encoding/json" + "fmt" "io" "net/http" "net/http/httptest" @@ -962,7 +963,7 @@ func TestS3ApiController_DeleteObjects(t *testing.T) { req: httptest.NewRequest(http.MethodPost, "/my-bucket", nil), }, wantErr: false, - statusCode: 500, + statusCode: 400, }, } for _, tt := range tests { @@ -995,6 +996,9 @@ func TestS3ApiController_DeleteActions(t *testing.T) { AbortMultipartUploadFunc: func(*s3.AbortMultipartUploadInput) error { return nil }, + RemoveTagsFunc: func(bucket, object string) error { + return nil + }, }, } @@ -1006,7 +1010,7 @@ func TestS3ApiController_DeleteActions(t *testing.T) { }) app.Delete("/:bucket/:key/*", s3ApiController.DeleteActions) - //Error case + // Error case appErr := fiber.New() s3ApiControllerErr := S3ApiController{be: &BackendMock{ @@ -1024,7 +1028,7 @@ func TestS3ApiController_DeleteActions(t *testing.T) { ctx.Locals("isDebug", false) return ctx.Next() }) - appErr.Delete("/:bucket", s3ApiControllerErr.DeleteBucket) + appErr.Delete("/:bucket/:key/*", s3ApiControllerErr.DeleteActions) tests := []struct { name string @@ -1042,6 +1046,15 @@ func TestS3ApiController_DeleteActions(t *testing.T) { wantErr: false, statusCode: 200, }, + { + name: "Remove-object-tagging-success", + app: app, + args: args{ + req: httptest.NewRequest(http.MethodDelete, "/my-bucket/my-key/key2?tagging", nil), + }, + wantErr: false, + statusCode: 200, + }, { name: "Delete-object-success", app: app, @@ -1469,6 +1482,16 @@ func Test_response(t *testing.T) { wantErr: false, statusCode: 500, }, + { + name: "Internal-server-error-not-api", + args: args{ + ctx: &ctx, + resp: nil, + err: fmt.Errorf("custom error"), + }, + wantErr: false, + statusCode: 500, + }, { name: "Error-not-implemented", args: args{ diff --git a/s3api/controllers/iam_moq_test.go b/s3api/controllers/iam_moq_test.go new file mode 100644 index 0000000..8a858b1 --- /dev/null +++ b/s3api/controllers/iam_moq_test.go @@ -0,0 +1,169 @@ +// Code generated by moq; DO NOT EDIT. +// github.com/matryer/moq + +package controllers + +import ( + "github.com/versity/versitygw/auth" + "sync" +) + +// Ensure, that IAMServiceMock does implement auth.IAMService. +// If this is not the case, regenerate this file with moq. +var _ auth.IAMService = &IAMServiceMock{} + +// IAMServiceMock is a mock implementation of auth.IAMService. +// +// func TestSomethingThatUsesIAMService(t *testing.T) { +// +// // make and configure a mocked auth.IAMService +// mockedIAMService := &IAMServiceMock{ +// CreateAccountFunc: func(access string, account auth.Account) error { +// panic("mock out the CreateAccount method") +// }, +// DeleteUserAccountFunc: func(access string) error { +// panic("mock out the DeleteUserAccount method") +// }, +// GetUserAccountFunc: func(access string) (auth.Account, error) { +// panic("mock out the GetUserAccount method") +// }, +// } +// +// // use mockedIAMService in code that requires auth.IAMService +// // and then make assertions. +// +// } +type IAMServiceMock struct { + // CreateAccountFunc mocks the CreateAccount method. + CreateAccountFunc func(access string, account auth.Account) error + + // DeleteUserAccountFunc mocks the DeleteUserAccount method. + DeleteUserAccountFunc func(access string) error + + // GetUserAccountFunc mocks the GetUserAccount method. + GetUserAccountFunc func(access string) (auth.Account, error) + + // calls tracks calls to the methods. + calls struct { + // CreateAccount holds details about calls to the CreateAccount method. + CreateAccount []struct { + // Access is the access argument value. + Access string + // Account is the account argument value. + Account auth.Account + } + // DeleteUserAccount holds details about calls to the DeleteUserAccount method. + DeleteUserAccount []struct { + // Access is the access argument value. + Access string + } + // GetUserAccount holds details about calls to the GetUserAccount method. + GetUserAccount []struct { + // Access is the access argument value. + Access string + } + } + lockCreateAccount sync.RWMutex + lockDeleteUserAccount sync.RWMutex + lockGetUserAccount sync.RWMutex +} + +// CreateAccount calls CreateAccountFunc. +func (mock *IAMServiceMock) CreateAccount(access string, account auth.Account) error { + if mock.CreateAccountFunc == nil { + panic("IAMServiceMock.CreateAccountFunc: method is nil but IAMService.CreateAccount was just called") + } + callInfo := struct { + Access string + Account auth.Account + }{ + Access: access, + Account: account, + } + mock.lockCreateAccount.Lock() + mock.calls.CreateAccount = append(mock.calls.CreateAccount, callInfo) + mock.lockCreateAccount.Unlock() + return mock.CreateAccountFunc(access, account) +} + +// CreateAccountCalls gets all the calls that were made to CreateAccount. +// Check the length with: +// +// len(mockedIAMService.CreateAccountCalls()) +func (mock *IAMServiceMock) CreateAccountCalls() []struct { + Access string + Account auth.Account +} { + var calls []struct { + Access string + Account auth.Account + } + mock.lockCreateAccount.RLock() + calls = mock.calls.CreateAccount + mock.lockCreateAccount.RUnlock() + return calls +} + +// DeleteUserAccount calls DeleteUserAccountFunc. +func (mock *IAMServiceMock) DeleteUserAccount(access string) error { + if mock.DeleteUserAccountFunc == nil { + panic("IAMServiceMock.DeleteUserAccountFunc: method is nil but IAMService.DeleteUserAccount was just called") + } + callInfo := struct { + Access string + }{ + Access: access, + } + mock.lockDeleteUserAccount.Lock() + mock.calls.DeleteUserAccount = append(mock.calls.DeleteUserAccount, callInfo) + mock.lockDeleteUserAccount.Unlock() + return mock.DeleteUserAccountFunc(access) +} + +// DeleteUserAccountCalls gets all the calls that were made to DeleteUserAccount. +// Check the length with: +// +// len(mockedIAMService.DeleteUserAccountCalls()) +func (mock *IAMServiceMock) DeleteUserAccountCalls() []struct { + Access string +} { + var calls []struct { + Access string + } + mock.lockDeleteUserAccount.RLock() + calls = mock.calls.DeleteUserAccount + mock.lockDeleteUserAccount.RUnlock() + return calls +} + +// GetUserAccount calls GetUserAccountFunc. +func (mock *IAMServiceMock) GetUserAccount(access string) (auth.Account, error) { + if mock.GetUserAccountFunc == nil { + panic("IAMServiceMock.GetUserAccountFunc: method is nil but IAMService.GetUserAccount was just called") + } + callInfo := struct { + Access string + }{ + Access: access, + } + mock.lockGetUserAccount.Lock() + mock.calls.GetUserAccount = append(mock.calls.GetUserAccount, callInfo) + mock.lockGetUserAccount.Unlock() + return mock.GetUserAccountFunc(access) +} + +// GetUserAccountCalls gets all the calls that were made to GetUserAccount. +// Check the length with: +// +// len(mockedIAMService.GetUserAccountCalls()) +func (mock *IAMServiceMock) GetUserAccountCalls() []struct { + Access string +} { + var calls []struct { + Access string + } + mock.lockGetUserAccount.RLock() + calls = mock.calls.GetUserAccount + mock.lockGetUserAccount.RUnlock() + return calls +}