Documentation
¶
Overview ¶
Package thunks contains various thunk utilities
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CompareHashAndPassword = bcrypt.CompareHashAndPassword
CompareHashAndPassword is a thunk for bcrypt.CompareHashAndPassword
var GenerateFromPassword = bcrypt.GenerateFromPassword
GenerateFromPassword is a thunk for bcrypt.GenerateFromPassword
var RandReader = rand.Reader
RandReader is rand.Reader by default, but may be replaced in tests
Functions ¶
func AddSetTimeHook ¶
AddSetTimeHook registers a hook function to be called each time the test clock is changed.
func AdvanceNow ¶
AdvanceNow moves the test clock forward by the specified amount
Types ¶
type Clock ¶
type Clock struct {
}
Clock implements the clockwork.Clock interface
type TestReader ¶
TestReader returns bytes from Next whenever asked, unless the number of bytes requested is 1, in which case it always returns 0x00.
This is because in go >= 1.11 the crypto libraries non-deterministically read a single byte from the PRNG in order to prevent people doing what we do and relying on the internal details of cryptographic operations.
For our purposes, having deterministic crypto in tests is super handy, and we have mechanisms for updating our expectations. So, while it might be better if we didn't rely on the crypto/* internals, on balance, the convenience of fixed test data outweighs the uglyness of this hack.
You might ask why we don't use a zero-reader as suggested by the commit message. The reason is that rsa key generation seems to spin forever when given a random source that always returns 0.
[1] https://github.com/golang/go/commit/6269dcdc24d74379d8a609ce886149811020b2cc