testutil

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SomeClientPublicKey = `` /* 181-byte string literal not displayed */

	SomeClientPrivateKey = `` /* 492-byte string literal not displayed */

	ImplicitClientPublicKey = `` /* 181-byte string literal not displayed */

	ImplicitClientPrivateKey = `` /* 492-byte string literal not displayed */

)
View Source
var (
	LDAP = DummyLDAP{
		"macrat": DummyUserInfo{
			Password: "foobar",
			Attributes: map[string][]string{
				"displayName":     {"SHIDA Yuuma"},
				"givenName":       {"yuuma"},
				"sn":              {"shida"},
				"mail":            {"m@crat.jp"},
				"telephoneNumber": {"000-1234-5678"},
			},
		},
		"j.smith": DummyUserInfo{
			Password: "hello",
			Attributes: map[string][]string{
				"displayName": {"Jhon smith"},
				"givenName":   {"jhon"},
				"sn":          {"smith"},
				"mail":        {"jhon@example.com"},
			},
		},
	}
)

Functions

func FindAvailTCPPort

func FindAvailTCPPort() int

func FindInputsByHTML

func FindInputsByHTML(body io.Reader) (map[string]string, error)

func FindRequestObjectByHTML added in v0.5.0

func FindRequestObjectByHTML(body io.Reader) (string, error)

func ImplicitClientRequestObject added in v0.5.0

func ImplicitClientRequestObject(t *testing.T, values map[string]interface{}) string

func MakeConfig

func MakeConfig() *config.Config

func MakeRequestObject added in v0.5.0

func MakeRequestObject(t *testing.T, values map[string]interface{}, key string) string

func MakeTestRouter

func MakeTestRouter() *gin.Engine

func MakeTokenManager

func MakeTokenManager() (token.Manager, error)

func MustParseQuery

func MustParseQuery(q string) url.Values

func MustParseURL

func MustParseURL(u string) *url.URL

func SomeClientRequestObject added in v0.5.0

func SomeClientRequestObject(t *testing.T, values map[string]interface{}) string

Types

type APITestEnvironment

type APITestEnvironment struct {
	App *gin.Engine
	API *api.LauthAPI
}

func NewAPITestEnvironment

func NewAPITestEnvironment(t *testing.T) *APITestEnvironment

func (*APITestEnvironment) Do

func (env *APITestEnvironment) Do(method, path, token string, values url.Values) *httptest.ResponseRecorder

func (*APITestEnvironment) DoRequest

func (*APITestEnvironment) Get

func (env *APITestEnvironment) Get(path, token string, query url.Values) *httptest.ResponseRecorder

func (*APITestEnvironment) JSONTest

func (env *APITestEnvironment) JSONTest(t *testing.T, method, endpoint string, tests []JSONTest)

func (*APITestEnvironment) Post

func (env *APITestEnvironment) Post(path, token string, body url.Values) *httptest.ResponseRecorder

func (*APITestEnvironment) RedirectTest

func (env *APITestEnvironment) RedirectTest(t *testing.T, method, endpoint string, tests []RedirectTest)

func (*APITestEnvironment) Run

func (env *APITestEnvironment) Run(ctx context.Context) error

func (*APITestEnvironment) ServeRequestURI added in v0.7.0

func (env *APITestEnvironment) ServeRequestURI(t *testing.T) *httptest.Server

func (*APITestEnvironment) Start

func (env *APITestEnvironment) Start(t *testing.T) (stop func())

type DummyLDAP

type DummyLDAP map[string]DummyUserInfo

func (DummyLDAP) Close

func (c DummyLDAP) Close() error

func (DummyLDAP) Connect

func (c DummyLDAP) Connect() (ldap.Session, error)

func (DummyLDAP) GetUserAttributes

func (c DummyLDAP) GetUserAttributes(username string, attributes []string) (map[string][]string, error)

func (DummyLDAP) LoginTest

func (c DummyLDAP) LoginTest(username, password string) error

type DummyUserInfo

type DummyUserInfo struct {
	Password   string
	Attributes map[string][]string
}

type JSONTest

type JSONTest struct {
	Name      string
	Request   url.Values
	Code      int
	CheckBody JSONTester
	Body      map[string]interface{}
	Token     string
}

type JSONTester

type JSONTester func(t *testing.T, body RawBody)

type ParamsTester

type ParamsTester func(t *testing.T, query, fragment url.Values)

type RawBody

type RawBody []byte

func (RawBody) Bind

func (body RawBody) Bind(target interface{}) error

type RedirectTest

type RedirectTest struct {
	Name         string
	Request      url.Values
	Code         int
	HasLocation  bool
	CheckParams  ParamsTester
	Query        url.Values
	Fragment     url.Values
	BodyIncludes []string
}

Jump to

Keyboard shortcuts

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