testutil

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package testutil provides test fixtures and utilities for testing.

Index

Constants

View Source
const (
	ValidUUID1   = "01234567-89ab-cdef-0123-456789abcdef"
	ValidUUID2   = "abcdef01-2345-6789-abcd-ef0123456789"
	ValidUUID3   = "12345678-1234-1234-1234-123456789abc"
	InvalidUUID1 = "not-a-uuid"
	InvalidUUID2 = "01234567-89ab-cdef-0123"
	InvalidUUID3 = "01234567-89ab-cdef-0123-456789abcdefg"
)

Sample UUIDs for testing

Variables

This section is empty.

Functions

func ComputePayloadHash

func ComputePayloadHash(payload []byte) string

ComputePayloadHash computes the SHA-256 hash of a payload and returns it as hex.

func CreateExpiredPayloadToken

func CreateExpiredPayloadToken(kp *TestKeyPair, leaseUUID, metaHashHex string) string

CreateExpiredPayloadToken creates an expired payload auth token for testing.

func CreateExpiredToken

func CreateExpiredToken(kp *TestKeyPair, leaseUUID string) string

CreateExpiredToken creates an expired auth token for testing.

func CreateFuturePayloadToken

func CreateFuturePayloadToken(kp *TestKeyPair, leaseUUID, metaHashHex string) string

CreateFuturePayloadToken creates a future-dated payload auth token for testing.

func CreateFutureToken

func CreateFutureToken(kp *TestKeyPair, leaseUUID string) string

CreateFutureToken creates a future-dated auth token for testing.

func CreateTestPayloadToken

func CreateTestPayloadToken(kp *TestKeyPair, leaseUUID, metaHashHex string, timestamp time.Time) string

CreateTestPayloadToken creates a valid payload auth token for testing.

func CreateTestToken

func CreateTestToken(kp *TestKeyPair, leaseUUID string, timestamp time.Time) string

CreateTestToken creates a valid auth token for testing.

Types

type TestAuthToken

type TestAuthToken struct {
	Tenant    string `json:"tenant"`
	LeaseUUID string `json:"lease_uuid"`
	Timestamp int64  `json:"timestamp"`
	PubKey    string `json:"pub_key"`
	Signature string `json:"signature"`
}

TestAuthToken creates a test authentication token.

type TestKeyPair

type TestKeyPair struct {
	PrivKey   *secp256k1.PrivKey
	PubKey    *secp256k1.PubKey
	PubKeyB64 string
	Address   string // Bech32 address with "manifest" prefix
}

TestKeyPair represents a key pair for testing.

func NewTestKeyPair

func NewTestKeyPair(seed string) *TestKeyPair

NewTestKeyPair creates a deterministic test key pair from a seed.

func (*TestKeyPair) Sign

func (kp *TestKeyPair) Sign(message []byte) string

Sign signs a message using ADR-036 format and returns base64-encoded signature.

type TestPayloadAuthToken

type TestPayloadAuthToken struct {
	Tenant    string `json:"tenant"`
	LeaseUUID string `json:"lease_uuid"`
	MetaHash  string `json:"meta_hash"`
	Timestamp int64  `json:"timestamp"`
	PubKey    string `json:"pub_key"`
	Signature string `json:"signature"`
}

TestPayloadAuthToken creates a test payload authentication token.

Jump to

Keyboard shortcuts

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