internal

package
v0.0.0-...-72724d7 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoop is here to be used for testing only
	// Purpose is to be propagated up the stack and retrieved/compared later
	// for error propagation check
	ErrNoop = fmt.Errorf("noop")
)

Functions

func ErrEqual

func ErrEqual(err1, err2 error) bool

ErrEqual compare two errors, it is safe to use with nil values and will compare the string representation

func IntEqual

func IntEqual(int1, int2 *big.Int) bool

IntEqual compare two big.Int, it is safe to use with nil values. Comparison is done against the string representation of the arguments.

func Key

func Key(name string, modified int64, low, high uint) *yubico.Yubikey

Key is an util function to create a yubico.Yubikey with all fields set up

func LogRecordsEqual

func LogRecordsEqual(lr1, lr2 *LogRecords) bool

LogRecordsEqual compare two LogRecord arrays, it is safe to use with nil values. Comparison is done against the level and format (if arguments differs it will still return true).

func RSAEqual

func RSAEqual(key1, key2 *rsa.PrivateKey) bool

RSAEqual compare two RSA private keys, it is safe to use with nil values. Comparison is done against the string representation of the internal big.Int.

func ReadAll

func ReadAll(t *testing.T, r io.Reader) string

ReadAll is a wrapper around ioutil.ReadAll and abort on error

func StrSliceEqual

func StrSliceEqual(slice1, slice2 []string) bool

StrSliceEqual compare two slices of strings, it is safe to use with nil values.

func TempFile

func TempFile(t *testing.T, cb func(*os.File) error) error

TempFile wraps the ioutil.TempFile, handling the lifecycle of the file and removing it when callback has been executed

func TempFileName

func TempFileName(t *testing.T, cb func(string) error) error

TempFileName wraps the ioutil.TempFile, handling the lifecycle of the file and removing it when callback has been executed. It only pass the name and not the file descriptor.

func TestError

func TestError(err error) testError

TestError creates an error for testing purpose out of a regular error interface

func TestRSA

func TestRSA(key *rsa.PrivateKey) testRSA

TestRSA creates a rsa private key for testing purpose out of a rsa.PrivateKey pointer

func TestToken

func TestToken(token *yubico.Token) testToken

TestToken creates a token for testing purpose out of a yubico.Token

func TestYubikey

func TestYubikey(ykey *yubico.Yubikey) testYubikey

TestYubikey creates a yubikey for testing purpose out of a yubico.Yubikey

func Token

func Token(low uint16, high uint8) *yubico.Token

Token is an util function to create a yubico.Token with only low and high markers

func TokenAll

func TokenAll(name string, ctr, use, high, low uint) *yubico.Token

TokenAll is an util function to create a yubico.Token with all fields set up

func TokenEqual

func TokenEqual(token1, token2 *yubico.Token) bool

TokenEqual compare two tokens, it is safe to use with nil values.

func YubikeyEqual

func YubikeyEqual(ykey1, ykey2 *yubico.Yubikey) bool

YubikeyEqual compare two yubikeys, it is safe to use with nil values. It only compares the public name attribute (sufficient for tests)

Types

type DumbYubikeyMapper

type DumbYubikeyMapper struct {
	yubico.YubikeyLoader
	yubico.YubikeyProducer
	yubico.YubikeyUpdater
}

DumbYubikeyMapper is an utility structure for test purpose. It allows to customize internal interface behavior at runtime.

func NewDumbYubikeyMapper

func NewDumbYubikeyMapper() *DumbYubikeyMapper

NewDumbYubikeyMapper creates a DumbYubikeyMapper with sensible defaults implementations

func (DumbYubikeyMapper) YubikeyLoad

func (dym DumbYubikeyMapper) YubikeyLoad(name string) (*yubico.Yubikey, error)

YubikeyLoad implement the load interface and return the internal implementation

func (DumbYubikeyMapper) YubikeyProduce

func (dym DumbYubikeyMapper) YubikeyProduce(
	token *yubico.Token, nonce string,
) (*yubico.Yubikey, error)

YubikeyProduce implement the load interface and return the internal implementation

func (DumbYubikeyMapper) YubikeyUpdate

func (dym DumbYubikeyMapper) YubikeyUpdate(yubikey *yubico.Yubikey) error

YubikeyUpdate implement the update interface and return the internal implementation

type FileCb

type FileCb func(*os.File) error

FileCb is a type representing a callback using a file Most probably the wrapping service is responsible for handling the file descriptor lifecycle, the callback is here for user to manipulate the file.

type LogRecord

type LogRecord struct {
	Level  int
	Format string
	Args   []interface{}
}

LogRecord is storing the log arguments to compare them later

func (LogRecord) String

func (lg LogRecord) String() string

String is a dump of a LogRecord

type LogRecords

type LogRecords []LogRecord

LogRecords is an array of LogRecord

func (*LogRecords) Log

func (lg *LogRecords) Log(level int, format string, a ...interface{})

Log is a wrapper to save logs in a cache for later comparison nolint:goprintffuncname

func (*LogRecords) Reset

func (lg *LogRecords) Reset()

Reset reinitialize the internal cache

func (*LogRecords) String

func (lg *LogRecords) String() string

String is a dump of an array of LogRecord

Jump to

Keyboard shortcuts

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