testutils

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSimpleTestKMS

func NewSimpleTestKMS() config.KeyManagementService

NewSimpleTestKMS creates a new simple test KMS with a default key

func NewTestCrypto

func NewTestCrypto(t interface{}) (*encx.Crypto, error)

NewTestCrypto creates a simple Crypto instance for testing and examples If t is nil, creates a basic test crypto for examples/demos

Types

type SimpleTestKMS

type SimpleTestKMS struct {
	// contains filtered or unexported fields
}

SimpleTestKMS implements a basic in-memory KMS for testing and examples

func (*SimpleTestKMS) CreateKey

func (s *SimpleTestKMS) CreateKey(ctx context.Context, description string) (string, error)

CreateKey creates a new test key and returns its ID

func (*SimpleTestKMS) DecryptDEK

func (s *SimpleTestKMS) DecryptDEK(ctx context.Context, keyID string, ciphertext []byte) ([]byte, error)

DecryptDEK decrypts the DEK using AES-GCM

func (*SimpleTestKMS) EncryptDEK

func (s *SimpleTestKMS) EncryptDEK(ctx context.Context, keyID string, plaintext []byte) ([]byte, error)

EncryptDEK encrypts the DEK using AES-GCM

func (*SimpleTestKMS) GetKeyID

func (s *SimpleTestKMS) GetKeyID(ctx context.Context, alias string) (string, error)

GetKeyID returns a test key ID for the given alias

type UUIDUser added in v0.8.0

type UUIDUser struct {
	// Basic types - should always be encrypted (no condition check)
	ID       uuid.UUID `json:"id"`
	Email    string    `json:"email" encx:"encrypt"`
	Name     string    `json:"name"`
	Age      int       `json:"age" encx:"encrypt"`
	IsActive bool      `json:"is_active" encx:"encrypt"`

	// Struct types with semantic zero values - should check for zero
	CreatedAt time.Time `json:"created_at" encx:"encrypt"`
	UserID    uuid.UUID `json:"user_id" encx:"encrypt"`

	// Pointer types - should check for nil
	NickName  *string    `json:"nickname" encx:"encrypt"`
	UpdatedAt *time.Time `json:"updated_at" encx:"encrypt"`
	TenantID  *uuid.UUID `json:"tenant_id" encx:"encrypt"`
}

UUIDUser represents a user with various field types to test zero-value checking

type User

type User struct {
	ID    int    `json:"id"`
	Email string `json:"email" encx:"encrypt,hash_basic"`
	Phone string `json:"phone" encx:"encrypt"`
	SSN   string `json:"ssn" encx:"hash_secure"`
	// Added a comment to change the file hash
	Name string `json:"name"`

	// Companion fields for encryption/hashing
	EmailEncrypted []byte `json:"email_encrypted" db:"email_encrypted"`
	EmailHash      string `json:"email_hash" db:"email_hash"`
	PhoneEncrypted []byte `json:"phone_encrypted" db:"phone_encrypted"`
	SSNHashSecure  string `json:"ssn_hash_secure" db:"ssn_hash_secure"`
}

User represents a user with encrypted fields

Jump to

Keyboard shortcuts

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