mock

package
v0.0.0-...-b621bad Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package mock provides in-memory test doubles for go-steam internals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeChunk

func EncodeChunk(plaintext, depotKey []byte) ([]byte, error)

EncodeChunk AES-ECB-encrypts plaintext with depotKey for use with AddChunk.

func EncodeManifest

func EncodeManifest(protoBytes []byte) []byte

EncodeManifest builds a minimal mock manifest payload with a single length-prefixed section (for use with AddManifest).

Types

type CDNServer

type CDNServer struct {

	// SimulateErrors counts how many requests fail before succeeding.
	SimulateErrors int
	// contains filtered or unexported fields
}

CDNServer is an httptest-based mock CDN that serves pre-registered manifests and chunks. It exercises the full AES+LZMA pipeline.

func NewCDNServer

func NewCDNServer() *CDNServer

NewCDNServer creates and starts a mock CDN HTTP server.

func (*CDNServer) AddChunk

func (c *CDNServer) AddChunk(depotID uint32, chunkHex string, data []byte)

AddChunk registers a pre-encoded (AES-ECB encrypted) chunk response. Use EncodeChunk to prepare the bytes.

func (*CDNServer) AddManifest

func (c *CDNServer) AddManifest(depotID uint32, manifestGID uint64, data []byte)

AddManifest registers a pre-encoded manifest response.

func (*CDNServer) AddToken

func (c *CDNServer) AddToken(token string)

AddToken registers an auth token as valid.

func (*CDNServer) Close

func (c *CDNServer) Close()

Close shuts down the mock server.

func (*CDNServer) Host

func (c *CDNServer) Host() string

Host returns the mock server host (without scheme).

func (*CDNServer) URL

func (c *CDNServer) URL() string

URL returns the full mock server base URL.

type Store

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

Store is an in-memory implementation of the cache interfaces — no disk I/O.

func NewStore

func NewStore() *Store

NewStore returns a fresh in-memory store.

func (*Store) ClearSession

func (s *Store) ClearSession() error

ClearSession removes any stored session.

func (*Store) LoadDepotKey

func (s *Store) LoadDepotKey(depotID uint32) (*store.CachedDepotKey, error)

LoadDepotKey returns the cached key for depotID, or nil.

func (*Store) LoadSession

func (s *Store) LoadSession() (*store.CachedSession, error)

LoadSession returns the stored session if one exists and isn't expired.

func (*Store) LoadToken

func (s *Store) LoadToken(host string, depotID uint32) (*store.CachedToken, error)

LoadToken returns a cached CDN token if it's not expired.

func (*Store) SaveDepotKey

func (s *Store) SaveDepotKey(k store.CachedDepotKey) error

SaveDepotKey stores a depot key.

func (*Store) SaveSession

func (s *Store) SaveSession(sess *store.CachedSession) error

SaveSession stores a session.

func (*Store) SaveToken

func (s *Store) SaveToken(t store.CachedToken) error

SaveToken stores a CDN auth token.

func (*Store) SetDepotKey

func (s *Store) SetDepotKey(depotID uint32, key []byte)

SetDepotKey is a test helper for pre-seeding a depot key.

func (*Store) SetToken

func (s *Store) SetToken(host string, depotID uint32, token string)

SetToken is a test helper for pre-seeding a CDN token.

Jump to

Keyboard shortcuts

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