encryptionmock

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package encryptionmock provides moq-generated mock implementations of the encryption package's interfaces.

Index

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())

func (*CipherMock) Seal

func (mock *CipherMock) Seal(ctx context.Context, plaintext []byte, associatedData []byte) ([]byte, error)

Seal calls SealFunc.

func (*CipherMock) SealCalls

func (mock *CipherMock) SealCalls() []struct {
	Ctx            context.Context
	Plaintext      []byte
	AssociatedData []byte
}

SealCalls gets all the calls that were made to Seal. Check the length with:

len(mockedCipher.SealCalls())

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())

func (*KeyWrapperMock) Wrap

func (mock *KeyWrapperMock) Wrap(ctx context.Context, key []byte, associatedData []byte) ([]byte, error)

Wrap calls WrapFunc.

func (*KeyWrapperMock) WrapCalls

func (mock *KeyWrapperMock) WrapCalls() []struct {
	Ctx            context.Context
	Key            []byte
	AssociatedData []byte
}

WrapCalls gets all the calls that were made to Wrap. Check the length with:

len(mockedKeyWrapper.WrapCalls())

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL