testutils

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const TestAuthKey = "__the_key__"

TestAuthKey is used by HeaderAuthorizer

Variables

This section is empty.

Functions

func SetupFileServer

func SetupFileServer(paths map[string]string, auth Authorizer) *httptest.Server

SetupFileServer serves files from './test_data' directory in package paths map can be used to servre files based on URL path prefixes and query params (for example, check usgs) if paths is nil, url path will be used to find files in dir

Types

type Authorizer

type Authorizer interface {
	Authorize(req *http.Request) bool
}

Authorizer is used in test server to simulate auth process

type HeaderAuthorizer

type HeaderAuthorizer struct {
	// Key is the name of authorization header
	Key string
}

HeaderAuthorizer checks that value of "Key" header equal TestAuthKey

func (*HeaderAuthorizer) Authorize

func (a *HeaderAuthorizer) Authorize(req *http.Request) bool

Authorize implements Authorizer interface

Jump to

Keyboard shortcuts

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