testutil

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MockAuthCodeURL = "http://localhost/authorize"
	MockTokenURL    = "http://localhost/token"
)

#nosec G101

Variables

View Source
var MockEndpoint = oauth2.Endpoint{
	AuthURL:  MockAuthCodeURL,
	TokenURL: MockTokenURL,
}

Functions

func ErrorMockExchange

func ErrorMockExchange(_ string) (*oauth2.Token, error)

func MockFactory

func MockFactory(opts ...MockOption) provider.FactoryFunc

func RandomMockExchange

func RandomMockExchange(_ string) (*oauth2.Token, error)

Types

type MockClient

type MockClient struct {
	ID     string
	Secret string
}

type MockExchangeFunc

type MockExchangeFunc func(code string) (*oauth2.Token, error)

func AmendTokenMockExchange

func AmendTokenMockExchange(get MockExchangeFunc, amend func(token *oauth2.Token) error) MockExchangeFunc

func ExpiringMockExchange

func ExpiringMockExchange(fn MockExchangeFunc, duration time.Duration) MockExchangeFunc

func IncrementMockExchange

func IncrementMockExchange(prefix string) MockExchangeFunc

func RefreshableMockExchange

func RefreshableMockExchange(fn MockExchangeFunc, step func(i int) (time.Duration, error)) MockExchangeFunc

func RestrictMockExchange

func RestrictMockExchange(m map[string]MockExchangeFunc) MockExchangeFunc

func StaticMockExchange

func StaticMockExchange(token *oauth2.Token) MockExchangeFunc

type MockOption

type MockOption func(m *mock)

func MockWithExchange

func MockWithExchange(client MockClient, fn MockExchangeFunc) MockOption

func MockWithExpectedOptionValue

func MockWithExpectedOptionValue(opt, value string) MockOption

func MockWithVersion

func MockWithVersion(vsn int) MockOption

type MockRoundTripper

type MockRoundTripper struct {
	Handler http.Handler
}

func (*MockRoundTripper) RoundTrip

func (mrt *MockRoundTripper) RoundTrip(r *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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