testhelpers

package
v0.0.0-...-81cd3a7 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Overview

nolint

nolint

nolint

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAndLoginIdentities

func AddAndLoginIdentities(t *testing.T, reg *driver.RegistryDefault, public *httptest.Server, ids map[string]*identity.Identity) map[string]*http.Client

AddAndLoginIdentities adds the given identities to the store (like a registration flow) and returns http.Clients which contain their sessions.

func CleanSQL

func CleanSQL(t *testing.T, c *pop.Connection)

func CourierExpectLinkInMessage

func CourierExpectLinkInMessage(t *testing.T, message *courier.Message, offset int) string

func CourierExpectMessage

func CourierExpectMessage(t *testing.T, reg interface {
	courier.PersistenceProvider
}, recipient, subject string) *courier.Message

func EncodeFormAsJSON

func EncodeFormAsJSON(t *testing.T, isApi bool, values url.Values) (payload string)

func ExpectStatusCode

func ExpectStatusCode(isAPI bool, api, browser int) int

func ExpectURL

func ExpectURL(isAPI bool, api, browser string) string

func GetLoginFlowMethodConfig

func GetLoginFlowMethodConfig(t *testing.T, rs *models.LoginFlow, id string) *models.LoginFlowMethodConfig

func GetRecoveryFlow

func GetRecoveryFlow(t *testing.T, client *http.Client, ts *httptest.Server) *public.GetSelfServiceRecoveryFlowOK

func GetRecoveryFlowMethodConfig

func GetRecoveryFlowMethodConfig(t *testing.T, rs *models.RecoveryFlow, id string) *models.RecoveryFlowMethodConfig

func GetSettingsFlowMethodConfig

func GetSettingsFlowMethodConfig(t *testing.T, rs *models.SettingsFlow, id string) *models.FlowMethodConfig

func GetSettingsFlowMethodConfigDeprecated

func GetSettingsFlowMethodConfigDeprecated(t *testing.T, primaryUser *http.Client, ts *httptest.Server, id string) *models.FlowMethodConfig

func HTTPPostForm

func HTTPPostForm(t *testing.T, client *http.Client, remote string, in *url.Values) ([]byte, *http.Response)

func HTTPRequestJSON

func HTTPRequestJSON(t *testing.T, client *http.Client, method string, url string, in interface{}) ([]byte, *http.Response)

func InitKratosServers

func InitKratosServers(t *testing.T, reg driver.Registry, public, admin *httptest.Server)

func InitializeLoginFlowViaAPI

func InitializeLoginFlowViaAPI(t *testing.T, client *http.Client, ts *httptest.Server, forced bool) *public.InitializeSelfServiceLoginViaAPIFlowOK

func InitializeLoginFlowViaBrowser

func InitializeLoginFlowViaBrowser(t *testing.T, client *http.Client, ts *httptest.Server, forced bool) *public.GetSelfServiceLoginFlowOK

func InitializeRecoveryFlowViaBrowser

func InitializeRecoveryFlowViaBrowser(t *testing.T, client *http.Client, ts *httptest.Server) *public.GetSelfServiceRecoveryFlowOK

func InitializeRegistrationFlowViaBrowser

func InitializeRegistrationFlowViaBrowser(t *testing.T, client *http.Client, ts *httptest.Server) *public.GetSelfServiceRegistrationFlowOK

func InitializeSettingsFlowViaBrowser

func InitializeSettingsFlowViaBrowser(t *testing.T, client *http.Client, ts *httptest.Server) *public.GetSelfServiceSettingsFlowOK

func InitializeVerificationFlowViaBrowser

func InitializeVerificationFlowViaBrowser(t *testing.T, client *http.Client, ts *httptest.Server) *public.GetSelfServiceVerificationFlowOK

func JSONEq

func JSONEq(t *testing.T, expected, actual interface{}, messageAndArgs ...interface{})

func LogJSON

func LogJSON(t *testing.T, v interface{})

func LoginMakeRequest

func LoginMakeRequest(
	t *testing.T,
	isAPI bool,
	f *models.LoginFlowMethodConfig,
	hc *http.Client,
	values string,
) (string, *http.Response)

func MockGetSession

func MockGetSession(t *testing.T, reg mockDeps) httprouter.Handle

func MockHydrateCookieClient

func MockHydrateCookieClient(t *testing.T, c *http.Client, u string)

func MockMakeAuthenticatedRequest

func MockMakeAuthenticatedRequest(t *testing.T, reg mockDeps, conf configuration.Provider, router *httprouter.Router, req *http.Request) ([]byte, *http.Response)

func MockSessionCreateHandler

func MockSessionCreateHandler(t *testing.T, reg mockDeps) (httprouter.Handle, *session.Session)

func MockSessionCreateHandlerWithIdentity

func MockSessionCreateHandlerWithIdentity(t *testing.T, reg mockDeps, i *identity.Identity) (httprouter.Handle, *session.Session)

func MockSetSession

func MockSetSession(t *testing.T, reg mockDeps, conf configuration.Provider) httprouter.Handle

func NewClientWithCookies

func NewClientWithCookies(t *testing.T) *http.Client

func NewDebugClient

func NewDebugClient(t *testing.T) *http.Client

func NewErrorTestServer

func NewErrorTestServer(t *testing.T, reg interface{ errorx.PersistenceProvider }) *httptest.Server

func NewHTTPClientWithArbitrarySessionCookie

func NewHTTPClientWithArbitrarySessionCookie(t *testing.T, reg *driver.RegistryDefault) *http.Client

func NewHTTPClientWithArbitrarySessionToken

func NewHTTPClientWithArbitrarySessionToken(t *testing.T, reg *driver.RegistryDefault) *http.Client

func NewHTTPClientWithIdentitySessionCookie

func NewHTTPClientWithIdentitySessionCookie(t *testing.T, reg *driver.RegistryDefault, id *identity.Identity) *http.Client

func NewHTTPClientWithIdentitySessionToken

func NewHTTPClientWithIdentitySessionToken(t *testing.T, reg *driver.RegistryDefault, id *identity.Identity) *http.Client

func NewHTTPClientWithSessionCookie

func NewHTTPClientWithSessionCookie(t *testing.T, reg *driver.RegistryDefault, sess *session.Session) *http.Client

func NewHTTPClientWithSessionToken

func NewHTTPClientWithSessionToken(t *testing.T, reg *driver.RegistryDefault, sess *session.Session) *http.Client

func NewHTTPDeleteJSONRequest

func NewHTTPDeleteJSONRequest(t *testing.T, url string, in interface{}) *http.Request

func NewHTTPGetJSONRequest

func NewHTTPGetJSONRequest(t *testing.T, url string) *http.Request

func NewKratosServer

func NewKratosServer(t *testing.T, reg driver.Registry) (public, admin *httptest.Server)

func NewKratosServerWithCSRF

func NewKratosServerWithCSRF(t *testing.T, reg driver.Registry) (public, admin *httptest.Server)

func NewKratosServerWithRouters

func NewKratosServerWithRouters(t *testing.T, reg driver.Registry, rp *x.RouterPublic, ra *x.RouterAdmin) (public, admin *httptest.Server)

func NewKratosServers

func NewKratosServers(t *testing.T) (public, admin *httptest.Server)

func NewLoginUIFlowEchoServer

func NewLoginUIFlowEchoServer(t *testing.T, reg driver.Registry) *httptest.Server

func NewLoginUIWith401Response

func NewLoginUIWith401Response(t *testing.T) *httptest.Server

func NewRecoveryUIFlowEchoServer

func NewRecoveryUIFlowEchoServer(t *testing.T, reg driver.Registry) *httptest.Server

func NewRedirSessionEchoTS

func NewRedirSessionEchoTS(t *testing.T, reg interface {
	x.WriterProvider
	session.ManagementProvider
}) *httptest.Server

func NewRedirTS

func NewRedirTS(t *testing.T, body string) *httptest.Server

func NewRegistrationUIFlowEchoServer

func NewRegistrationUIFlowEchoServer(t *testing.T, reg driver.Registry) *httptest.Server

func NewRequest

func NewRequest(t *testing.T, isAPI bool, method string, url string, payload io.Reader) *http.Request

func NewSDKClient

func NewSDKClient(ts *httptest.Server) *client.OryKratos

func NewSDKClientFromURL

func NewSDKClientFromURL(u string) *client.OryKratos

func NewSessionClient

func NewSessionClient(t *testing.T, u string) *http.Client

func NewSettingsAPIServer

func NewSettingsAPIServer(t *testing.T, reg *driver.RegistryDefault, ids map[string]*identity.Identity) (*httptest.Server, *httptest.Server, map[string]*http.Client)

func NewSettingsLoginAcceptAPIServer

func NewSettingsLoginAcceptAPIServer(t *testing.T, adminClient *client.OryKratos) *httptest.Server

func NewSettingsUIEchoServer

func NewSettingsUIEchoServer(t *testing.T, reg *driver.RegistryDefault) *httptest.Server

func NewSettingsUIFlowEchoServer

func NewSettingsUIFlowEchoServer(t *testing.T, reg driver.Registry) *httptest.Server

func NewSettingsUITestServer

func NewSettingsUITestServer(t *testing.T) *httptest.Server

func NewVerificationUIFlowEchoServer

func NewVerificationUIFlowEchoServer(t *testing.T, reg driver.Registry) *httptest.Server

func RecoveryFlowEnable

func RecoveryFlowEnable(enable bool)

func RecoveryMakeRequest

func RecoveryMakeRequest(
	t *testing.T,
	isAPI bool,
	f *models.RecoveryFlowMethodConfig,
	hc *http.Client,
	values string,
) (string, *http.Response)

func RegistrationMakeRequest

func RegistrationMakeRequest(
	t *testing.T,
	isAPI bool,
	f *models.RegistrationFlowMethodConfig,
	hc *http.Client,
	values string,
) (string, *http.Response)

func SDKFormFieldsToURLValues

func SDKFormFieldsToURLValues(ff models.FormFields) url.Values

func SelfServiceHookConfigReset

func SelfServiceHookConfigReset()

func SelfServiceHookCreateFakeIdentity

func SelfServiceHookCreateFakeIdentity(t *testing.T, reg driver.Registry) *identity.Identity

func SelfServiceHookFakeIdentity

func SelfServiceHookFakeIdentity(t *testing.T) *identity.Identity

func SelfServiceHookLoginErrorHandler

func SelfServiceHookLoginErrorHandler(t *testing.T, w http.ResponseWriter, r *http.Request, err error) bool

func SelfServiceHookLoginSetDefaultRedirectTo

func SelfServiceHookLoginSetDefaultRedirectTo(value string)

func SelfServiceHookLoginSetDefaultRedirectToStrategy

func SelfServiceHookLoginSetDefaultRedirectToStrategy(strategy, value string)

func SelfServiceHookLoginViperSetPost

func SelfServiceHookLoginViperSetPost(strategy string, c []configuration.SelfServiceHook)

func SelfServiceHookRegistrationErrorHandler

func SelfServiceHookRegistrationErrorHandler(t *testing.T, w http.ResponseWriter, r *http.Request, err error) bool

func SelfServiceHookRegistrationSetDefaultRedirectTo

func SelfServiceHookRegistrationSetDefaultRedirectTo(value string)

func SelfServiceHookRegistrationSetDefaultRedirectToStrategy

func SelfServiceHookRegistrationSetDefaultRedirectToStrategy(strategy, value string)

func SelfServiceHookRegistrationViperSetPost

func SelfServiceHookRegistrationViperSetPost(strategy string, c []configuration.SelfServiceHook)

func SelfServiceHookSettingsErrorHandler

func SelfServiceHookSettingsErrorHandler(t *testing.T, w http.ResponseWriter, r *http.Request, err error) bool

func SelfServiceHookSettingsSetDefaultRedirectTo

func SelfServiceHookSettingsSetDefaultRedirectTo(value string)

func SelfServiceHookSettingsSetDefaultRedirectToStrategy

func SelfServiceHookSettingsSetDefaultRedirectToStrategy(strategy, value string)

func SelfServiceMakeLoginPostHookRequest

func SelfServiceMakeLoginPostHookRequest(t *testing.T, ts *httptest.Server, asAPI bool, query url.Values) (*http.Response, string)

func SelfServiceMakeLoginPreHookRequest

func SelfServiceMakeLoginPreHookRequest(t *testing.T, ts *httptest.Server) (*http.Response, string)

func SelfServiceMakeRegistrationPostHookRequest

func SelfServiceMakeRegistrationPostHookRequest(t *testing.T, ts *httptest.Server, asAPI bool, query url.Values) (*http.Response, string)

func SelfServiceMakeRegistrationPreHookRequest

func SelfServiceMakeRegistrationPreHookRequest(t *testing.T, ts *httptest.Server) (*http.Response, string)

func SelfServiceMakeSettingsPostHookRequest

func SelfServiceMakeSettingsPostHookRequest(t *testing.T, ts *httptest.Server, asAPI bool, query url.Values) (*http.Response, string)

func SetDefaultIdentitySchema

func SetDefaultIdentitySchema(location string)

SetDefaultIdentitySchema sets the identity schemas in viper config:

testhelpers.SetDefaultIdentitySchema("file://customer.json")

func SetIdentitySchemas

func SetIdentitySchemas(schemas map[string]string)

SetIdentitySchemas sets the identity schemas in viper config:

testhelpers.SetIdentitySchemas(map[string]string{"customer": "file://customer.json"})

func SettingsMakeRequest

func SettingsMakeRequest(
	t *testing.T,
	isAPI bool,
	f *models.FlowMethodConfig,
	hc *http.Client,
	values string,
) (string, *http.Response)

func StrategyEnable

func StrategyEnable(strategy string, enable bool)

func SubmitLoginForm

func SubmitLoginForm(
	t *testing.T,
	isAPI bool,
	hc *http.Client,
	publicTS *httptest.Server,
	withValues func(v url.Values),
	method identity.CredentialsType,
	forced bool,
	expectedStatusCode int,
	expectedURL string,
) string

SubmitLoginForm initiates a login flow (for Browser and API!), fills out the form and modifies the form values with `withValues`, and submits the form. Returns the body and checks for expectedStatusCode and expectedURL on completion

func SubmitRecoveryForm

func SubmitRecoveryForm(
	t *testing.T,
	isAPI bool,
	hc *http.Client,
	publicTS *httptest.Server,
	withValues func(v url.Values),
	method identity.CredentialsType,
	expectedStatusCode int,
	expectedURL string,
) string

SubmitRecoveryForm initiates a registration flow (for Browser and API!), fills out the form and modifies the form values with `withValues`, and submits the form. If completed, it will return the flow as JSON.

func SubmitRegistrationForm

func SubmitRegistrationForm(
	t *testing.T,
	isAPI bool,
	hc *http.Client,
	publicTS *httptest.Server,
	withValues func(v url.Values),
	method identity.CredentialsType,
	expectedStatusCode int,
	expectedURL string,
) string

SubmitRegistrationForm (for Browser and API!), fills out the form and modifies // the form values with `withValues`, and submits the form. Returns the body and checks for expectedStatusCode and // expectedURL on completion

func SubmitSettingsForm

func SubmitSettingsForm(
	t *testing.T,
	isAPI bool,
	hc *http.Client,
	publicTS *httptest.Server,
	withValues func(v url.Values),
	method string,
	expectedStatusCode int,
	expectedURL string,
) string

SubmitSettingsForm initiates a settings flow (for Browser and API!), fills out the form and modifies the form values with `withValues`, and submits the form. If completed, it will return the flow as JSON.

func SubmitVerificationForm

func SubmitVerificationForm(
	t *testing.T,
	isAPI bool,
	hc *http.Client,
	publicTS *httptest.Server,
	withValues func(v url.Values),
	method identity.CredentialsType,
	expectedStatusCode int,
	expectedURL string,
) string

SubmitVerificationForm initiates a registration flow (for Browser and API!), fills out the form and modifies the form values with `withValues`, and submits the form. If completed, it will return the flow as JSON.

func TestSelfServicePreHook

func TestSelfServicePreHook(
	configKey string,
	makeRequestPre func(t *testing.T, ts *httptest.Server) (*http.Response, string),
	newServer func(t *testing.T) *httptest.Server,
) func(t *testing.T)

func VerificationFlowEnable

func VerificationFlowEnable(enable bool)

func VerificationMakeRequest

func VerificationMakeRequest(
	t *testing.T,
	isAPI bool,
	f *models.VerificationFlowMethodConfig,
	hc *http.Client,
	values string,
) (string, *http.Response)

Types

type SessionLifespanProvider

type SessionLifespanProvider struct {
	// contains filtered or unexported fields
}

func NewSessionLifespanProvider

func NewSessionLifespanProvider(expiresIn time.Duration) *SessionLifespanProvider

func (*SessionLifespanProvider) SessionLifespan

func (p *SessionLifespanProvider) SessionLifespan() time.Duration

type TransportWithLogger

type TransportWithLogger struct {
	http.RoundTripper
	// contains filtered or unexported fields
}

func NewTransportWithLogger

func NewTransportWithLogger(parent http.RoundTripper, t *testing.T) *TransportWithLogger

func (*TransportWithLogger) RoundTrip

func (ct *TransportWithLogger) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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