testing

package
v0.0.0-...-a17a3e0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2017 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShortWait    = 20 * time.Millisecond
	LongWait     = 300 * time.Millisecond
	CleanupWait  = 10 * time.Millisecond
	VeryLongWait = 3 * time.Second
)

Timeout constants.

Variables

View Source
var FailHeader = http.Header{
	"Content-Type":           {"text/plain; charset=utf-8"},
	"X-Content-Type-Options": {"nosniff"},
}
View Source
var OKHeader = http.Header{
	"Content-Type": []string{"text/plain; charset=utf-8"},
}

Functions

func Admin

func Admin(token auth.Token) http.Header

Admin returns the appropriate Authorization Header for the given Admin token.

func Bearer

func Bearer(token auth.Token) http.Header

Bearer returns the appropriate Authorization Header for the given Bearer token.

func CleanupDB

func CleanupDB(db *bolt.DB) error

func ExpectResponse

func ExpectResponse(
	h http.Handler,
	url, method string,
	bodySend, into, bodyExpect interface{},
	code int,
	header http.Header,
	expectHeaders ...http.Header,
) error

ExpectResponse makes an HTTP Request on the given Handler, using the given URL and REST Method (i.e. PUT, POST, GET, etc.)

Multiple expected headers may be added. Each will be added into one map of expected headers using http.Header.Add; if the same header key is passed twice, the last one given will be used.

If no expected headers are passed, defaults will be selected based on expected HTTP status code: if 200,

func FindAll

func FindAll(tx *bolt.Tx, bucket []byte) ([][]byte, [][]byte, error)

FindAll returns a copy of all keys and values in the given bucket.

func FindForKeys

func FindForKeys(tx *bolt.Tx, bucket []byte, keys ...[]byte) ([][]byte, error)

func FindSession

func FindSession(db *bolt.DB, expiration time.Time) (*auth.Session, error)

func GetSession

func GetSession(userID string, sesh *auth.Session, db *bolt.DB) error

GetSession creates a new Session in the DB for the given User, if the user has a valid login.

func GetWSClient

func GetWSClient(token, urlStr string) (*ws.Conn, error)

GetWSClient opens and returns a websocket.Conn to the given URL using the given auth token.

func MakeLogin

func MakeLogin(name, pw string, db *bolt.DB) (*auth.Login, error)

MakeLogin creates a new auth.Login in the DB using the given name and SHA256-hashed password.

func Options

func Options(methods ...string) http.Header

Options returns the appropriate Allow header for the given Options.

func Sha256

func Sha256(str string) []byte

Sha256 gets the SHA256 of the given string and slices the array.

func TempDB

func TempDB(name string) (*bolt.DB, string, error)

TempDB returns a temporary DB and its temporary directory.

func WSAuthProtocols

func WSAuthProtocols(token auth.Token) []string

WSAuthProtocols returns the websocket Auth Protocol to be passed for the given Bearer Token.

Types

type Timer

type Timer time.Time

Timer implements util.Timer using a given Time. Now() will always return that Time value.

func (Timer) Now

func (t Timer) Now() time.Time

Now implements Timer.Now on Timer.

Jump to

Keyboard shortcuts

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