Documentation
¶
Overview ¶
Package encryptionmock provides moq-generated mock implementations of the encryption package's interfaces.
Index ¶
- type CipherMock
- func (mock *CipherMock) Open(ctx context.Context, ciphertext []byte, associatedData []byte) ([]byte, error)
- func (mock *CipherMock) OpenCalls() []struct{ ... }
- func (mock *CipherMock) Seal(ctx context.Context, plaintext []byte, associatedData []byte) ([]byte, error)
- func (mock *CipherMock) SealCalls() []struct{ ... }
- type EncryptorDecryptorMock
- func (mock *EncryptorDecryptorMock) Decrypt(ctx context.Context, ciphertext []byte, associatedData []byte) ([]byte, error)
- func (mock *EncryptorDecryptorMock) DecryptCalls() []struct{ ... }
- func (mock *EncryptorDecryptorMock) Encrypt(ctx context.Context, plaintext []byte, associatedData []byte) ([]byte, error)
- func (mock *EncryptorDecryptorMock) EncryptCalls() []struct{ ... }
- type KeyWrapperMock
- func (mock *KeyWrapperMock) Unwrap(ctx context.Context, wrapped []byte, associatedData []byte) ([]byte, error)
- func (mock *KeyWrapperMock) UnwrapCalls() []struct{ ... }
- func (mock *KeyWrapperMock) Wrap(ctx context.Context, key []byte, associatedData []byte) ([]byte, error)
- func (mock *KeyWrapperMock) WrapCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CipherMock ¶
type CipherMock struct {
// OpenFunc mocks the Open method.
OpenFunc func(ctx context.Context, ciphertext []byte, associatedData []byte) ([]byte, error)
// SealFunc mocks the Seal method.
SealFunc func(ctx context.Context, plaintext []byte, associatedData []byte) ([]byte, error)
// contains filtered or unexported fields
}
CipherMock is a mock implementation of encryption.Cipher.
func TestSomethingThatUsesCipher(t *testing.T) {
// make and configure a mocked encryption.Cipher
mockedCipher := &CipherMock{
OpenFunc: func(ctx context.Context, ciphertext []byte, associatedData []byte) ([]byte, error) {
panic("mock out the Open method")
},
SealFunc: func(ctx context.Context, plaintext []byte, associatedData []byte) ([]byte, error) {
panic("mock out the Seal method")
},
}
// use mockedCipher in code that requires encryption.Cipher
// and then make assertions.
}
func (*CipherMock) Open ¶
func (mock *CipherMock) Open(ctx context.Context, ciphertext []byte, associatedData []byte) ([]byte, error)
Open calls OpenFunc.
func (*CipherMock) OpenCalls ¶
func (mock *CipherMock) OpenCalls() []struct { Ctx context.Context Ciphertext []byte AssociatedData []byte }
OpenCalls gets all the calls that were made to Open. Check the length with:
len(mockedCipher.OpenCalls())
type EncryptorDecryptorMock ¶
type EncryptorDecryptorMock struct {
// DecryptFunc mocks the Decrypt method.
DecryptFunc func(ctx context.Context, ciphertext []byte, associatedData []byte) ([]byte, error)
// EncryptFunc mocks the Encrypt method.
EncryptFunc func(ctx context.Context, plaintext []byte, associatedData []byte) ([]byte, error)
// contains filtered or unexported fields
}
EncryptorDecryptorMock is a mock implementation of encryption.EncryptorDecryptor.
func TestSomethingThatUsesEncryptorDecryptor(t *testing.T) {
// make and configure a mocked encryption.EncryptorDecryptor
mockedEncryptorDecryptor := &EncryptorDecryptorMock{
DecryptFunc: func(ctx context.Context, ciphertext []byte, associatedData []byte) ([]byte, error) {
panic("mock out the Decrypt method")
},
EncryptFunc: func(ctx context.Context, plaintext []byte, associatedData []byte) ([]byte, error) {
panic("mock out the Encrypt method")
},
}
// use mockedEncryptorDecryptor in code that requires encryption.EncryptorDecryptor
// and then make assertions.
}
func (*EncryptorDecryptorMock) Decrypt ¶
func (mock *EncryptorDecryptorMock) Decrypt(ctx context.Context, ciphertext []byte, associatedData []byte) ([]byte, error)
Decrypt calls DecryptFunc.
func (*EncryptorDecryptorMock) DecryptCalls ¶
func (mock *EncryptorDecryptorMock) DecryptCalls() []struct { Ctx context.Context Ciphertext []byte AssociatedData []byte }
DecryptCalls gets all the calls that were made to Decrypt. Check the length with:
len(mockedEncryptorDecryptor.DecryptCalls())
func (*EncryptorDecryptorMock) Encrypt ¶
func (mock *EncryptorDecryptorMock) Encrypt(ctx context.Context, plaintext []byte, associatedData []byte) ([]byte, error)
Encrypt calls EncryptFunc.
func (*EncryptorDecryptorMock) EncryptCalls ¶
func (mock *EncryptorDecryptorMock) EncryptCalls() []struct { Ctx context.Context Plaintext []byte AssociatedData []byte }
EncryptCalls gets all the calls that were made to Encrypt. Check the length with:
len(mockedEncryptorDecryptor.EncryptCalls())
type KeyWrapperMock ¶
type KeyWrapperMock struct {
// UnwrapFunc mocks the Unwrap method.
UnwrapFunc func(ctx context.Context, wrapped []byte, associatedData []byte) ([]byte, error)
// WrapFunc mocks the Wrap method.
WrapFunc func(ctx context.Context, key []byte, associatedData []byte) ([]byte, error)
// contains filtered or unexported fields
}
KeyWrapperMock is a mock implementation of encryption.KeyWrapper.
func TestSomethingThatUsesKeyWrapper(t *testing.T) {
// make and configure a mocked encryption.KeyWrapper
mockedKeyWrapper := &KeyWrapperMock{
UnwrapFunc: func(ctx context.Context, wrapped []byte, associatedData []byte) ([]byte, error) {
panic("mock out the Unwrap method")
},
WrapFunc: func(ctx context.Context, key []byte, associatedData []byte) ([]byte, error) {
panic("mock out the Wrap method")
},
}
// use mockedKeyWrapper in code that requires encryption.KeyWrapper
// and then make assertions.
}
func (*KeyWrapperMock) Unwrap ¶
func (mock *KeyWrapperMock) Unwrap(ctx context.Context, wrapped []byte, associatedData []byte) ([]byte, error)
Unwrap calls UnwrapFunc.
func (*KeyWrapperMock) UnwrapCalls ¶
func (mock *KeyWrapperMock) UnwrapCalls() []struct { Ctx context.Context Wrapped []byte AssociatedData []byte }
UnwrapCalls gets all the calls that were made to Unwrap. Check the length with:
len(mockedKeyWrapper.UnwrapCalls())