testhelpers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 75 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CodeRegex = fmt.Sprintf(`(\d{%d})`, code.CodeLength)

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 AssertFieldMessage added in v0.11.0

func AssertFieldMessage(t *testing.T, body []byte, fieldName string, message string)

func AssertMessage added in v0.11.0

func AssertMessage(t *testing.T, body []byte, message string)

func AssertNoCSRFCookieInResponse added in v1.1.0

func AssertNoCSRFCookieInResponse(t *testing.T, _ *httptest.Server, _ *http.Client, r *http.Response)

func CheckE2EServerOnHTTP

func CheckE2EServerOnHTTP(t *testing.T, publicPort, adminPort int) (publicUrl, adminUrl string)

func CheckE2EServerOnHTTPS

func CheckE2EServerOnHTTPS(t *testing.T, publicPort, adminPort int) (publicUrl, adminUrl string)

func CourierExpectCodeInMessage added in v0.11.0

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

func CourierExpectLinkInMessage

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

func CourierExpectMessage

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

func CreateSession

func CreateSession(t *testing.T, reg driver.Registry) *session.Session

func EasyCookieJar added in v1.1.0

func EasyCookieJar(t *testing.T, o *cookiejar.Options) *cookiejar.Jar

func EasyGet added in v1.1.0

func EasyGet(t *testing.T, c *http.Client, url string) (*http.Response, []byte)

func EasyGetBody added in v1.1.0

func EasyGetBody(t *testing.T, c *http.Client, url string) []byte

func EasyGetJSON added in v1.1.0

func EasyGetJSON(t *testing.T, c *http.Client, url string) (*http.Response, []byte)

func EncodeFormAsJSON

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

func EnsureAAL

func EnsureAAL(t *testing.T, c *http.Client, ts *httptest.Server, aal string, methods ...string)

func ExpectStatusCode

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

func ExpectURL

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

func GenerateTLSCertificateFilesForTests

func GenerateTLSCertificateFilesForTests(t *testing.T) (certPath, keyPath, certBase64, keyBase64 string)

GenerateTLSCertificateFilesForTests writes a new, self-signed TLS certificate+key (in PEM format) to a temporary location on disk and returns the paths to both, as well as the respective contents in base64 encoding. The files are automatically cleaned up when the given *testing.T concludes its tests.

func GetLoginFlow added in v1.1.0

func GetLoginFlow(t *testing.T, client *http.Client, ts *httptest.Server, flowID string) *kratos.LoginFlow

func GetRecoveryFlow

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

func GetRecoveryFlowForType added in v1.1.0

func GetRecoveryFlowForType(t *testing.T, client *http.Client, ts *httptest.Server, ft flow.Type) *kratos.RecoveryFlow

func GetRegistrationFlow added in v1.1.0

func GetRegistrationFlow(t *testing.T, client *http.Client, ts *httptest.Server, flowID string) *kratos.RegistrationFlow

func GetSelfServiceRedirectLocation

func GetSelfServiceRedirectLocation(t *testing.T, url string) string

func GetVerificationFlow

func GetVerificationFlow(t *testing.T, client *http.Client, ts *httptest.Server) *kratos.VerificationFlow

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, opts ...InitFlowWithOption) *kratos.LoginFlow

func InitializeLoginFlowViaBrowser

func InitializeLoginFlowViaBrowser(t *testing.T, client *http.Client, ts *httptest.Server, forced bool, isSPA bool, expectInitError bool, expectGetError bool, opts ...InitFlowWithOption) *kratos.LoginFlow

func InitializeRecoveryFlowViaAPI

func InitializeRecoveryFlowViaAPI(t *testing.T, client *http.Client, ts *httptest.Server) *kratos.RecoveryFlow

func InitializeRecoveryFlowViaBrowser

func InitializeRecoveryFlowViaBrowser(t *testing.T, client *http.Client, isSPA bool, ts *httptest.Server, values url.Values) *kratos.RecoveryFlow

func InitializeRegistrationFlowViaAPI

func InitializeRegistrationFlowViaAPI(t *testing.T, client *http.Client, ts *httptest.Server) *kratos.RegistrationFlow

func InitializeRegistrationFlowViaBrowser

func InitializeRegistrationFlowViaBrowser(t *testing.T, client *http.Client, ts *httptest.Server, isSPA bool, expectInitError bool, expectGetError bool, opts ...InitFlowWithOption) *kratos.RegistrationFlow

func InitializeSettingsFlowViaAPI

func InitializeSettingsFlowViaAPI(t *testing.T, client *http.Client, ts *httptest.Server) *kratos.SettingsFlow

func InitializeSettingsFlowViaBrowser

func InitializeSettingsFlowViaBrowser(t *testing.T, client *http.Client, isSPA bool, ts *httptest.Server) *kratos.SettingsFlow

func InitializeVerificationFlowViaAPI

func InitializeVerificationFlowViaAPI(t *testing.T, client *http.Client, ts *httptest.Server) *kratos.VerificationFlow

func InitializeVerificationFlowViaBrowser

func InitializeVerificationFlowViaBrowser(t *testing.T, client *http.Client, isSPA bool, ts *httptest.Server) *kratos.VerificationFlow

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,
	isSPA bool,
	f *kratos.LoginFlow,
	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) *http.Cookie

func MockMakeAuthenticatedRequest

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

func MockMakeAuthenticatedRequestWithClient

func MockMakeAuthenticatedRequestWithClient(t *testing.T, reg mockDeps, conf *config.Config, router *httprouter.Router, req *http.Request, client *http.Client) ([]byte, *http.Response)

func MockMakeAuthenticatedRequestWithClientAndID

func MockMakeAuthenticatedRequestWithClientAndID(t *testing.T, reg mockDeps, conf *config.Config, router *httprouter.Router, req *http.Request, client *http.Client, id *identity.Identity) ([]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 MockSessionCreateHandlerWithIdentityAndAMR

func MockSessionCreateHandlerWithIdentityAndAMR(t *testing.T, reg mockDeps, i *identity.Identity, methods []identity.CredentialsType) (httprouter.Handle, *session.Session)

func MockSetSession

func MockSetSession(t *testing.T, reg mockDeps, conf *config.Config) httprouter.Handle

func MockSetSessionWithIdentity

func MockSetSessionWithIdentity(t *testing.T, reg mockDeps, conf *config.Config, i *identity.Identity) httprouter.Handle

func NewClientWithCookieJar added in v0.11.0

func NewClientWithCookieJar(t *testing.T, jar *cookiejar.Jar, debugRedirects bool) *http.Client

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
	config.Provider
}) *httptest.Server

func NewFakeCSRFNode

func NewFakeCSRFNode() *kratos.UiNode

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 NewHTTPClientWithIdentitySessionCookieLocalhost added in v1.1.0

func NewHTTPClientWithIdentitySessionCookieLocalhost(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 NewHTTPClientWithSessionCookieLocalhost

func NewHTTPClientWithSessionCookieLocalhost(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 NewHTTPGetAJAXRequest

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

func NewHTTPGetJSONRequest

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

func NewHTTPTestServer

func NewHTTPTestServer(t *testing.T, h http.Handler) *httptest.Server

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 NewKratosServerWithCSRFAndRouters

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

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, c *config.Config) *httptest.Server

func NewMethodSubmit

func NewMethodSubmit(group, value string) *kratos.UiNode

func NewNoRedirectClientWithCookies

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

func NewNoRedirectHTTPClientWithArbitrarySessionCookie

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

func NewNoRedirectHTTPClientWithSessionCookie

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

func NewPasswordNode

func NewPasswordNode() *kratos.UiNode

func NewRecoveryUIFlowEchoServer

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

func NewRedirNoSessionTS

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

func NewRedirSessionEchoTS

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

func NewRedirTS

func NewRedirTS(t *testing.T, body string, conf *config.Config) *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) *kratos.APIClient

func NewSDKClientFromURL

func NewSDKClientFromURL(u string) *kratos.APIClient

func NewSDKCustomClient

func NewSDKCustomClient(ts *httptest.Server, client *http.Client) *kratos.APIClient

func NewSDKEmailNode

func NewSDKEmailNode(group string) *kratos.UiNode

func NewSDKOIDCNode

func NewSDKOIDCNode(name, provider string) *kratos.UiNode

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, publicClient *kratos.APIClient, conf *config.Config) *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, conf *config.Config) *httptest.Server

func NewTestHTTPRequest added in v1.1.0

func NewTestHTTPRequest(t *testing.T, method, url string, body io.Reader) *http.Request

func NewVerificationUIFlowEchoServer

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

func PersistNewRecoveryFlow added in v0.11.0

func PersistNewRecoveryFlow(t *testing.T, strategy recovery.Strategy, conf *config.Config, reg *driver.RegistryDefault) *recovery.Flow

func RandomEmail

func RandomEmail() string

func RecoveryMakeRequest

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

func RegistrationMakeRequest

func RegistrationMakeRequest(
	t *testing.T,
	isAPI bool,
	isSPA bool,
	f *kratos.RegistrationFlow,
	hc *http.Client,
	values string,
) (string, *http.Response)

func SDKFormFieldsToURLValues

func SDKFormFieldsToURLValues(ff []kratos.UiNode) url.Values

func SelfServiceHookConfigReset

func SelfServiceHookConfigReset(t *testing.T, conf *config.Config) func()

func SelfServiceHookCreateFakeIdentity

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

func SelfServiceHookErrorHandler

func SelfServiceHookErrorHandler(t *testing.T, w http.ResponseWriter, _ *http.Request, abortErr error, actualErr error) bool

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(t *testing.T, conf *config.Config, value string)

func SelfServiceHookLoginSetDefaultRedirectToStrategy

func SelfServiceHookLoginSetDefaultRedirectToStrategy(t *testing.T, conf *config.Config, strategy, value string)

func SelfServiceHookLoginViperSetPost

func SelfServiceHookLoginViperSetPost(t *testing.T, conf *config.Config, strategy string, c []config.SelfServiceHook)

func SelfServiceHookRegistrationErrorHandler

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

func SelfServiceHookRegistrationSetDefaultRedirectTo

func SelfServiceHookRegistrationSetDefaultRedirectTo(t *testing.T, conf *config.Config, value string)

func SelfServiceHookRegistrationSetDefaultRedirectToStrategy

func SelfServiceHookRegistrationSetDefaultRedirectToStrategy(t *testing.T, conf *config.Config, strategy, value string)

func SelfServiceHookRegistrationViperSetPost

func SelfServiceHookRegistrationViperSetPost(t *testing.T, conf *config.Config, strategy string, c []config.SelfServiceHook)

func SelfServiceHookSettingsErrorHandler

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

func SelfServiceHookSettingsSetDefaultRedirectTo

func SelfServiceHookSettingsSetDefaultRedirectTo(t *testing.T, conf *config.Config, value string)

func SelfServiceHookSettingsSetDefaultRedirectToStrategy

func SelfServiceHookSettingsSetDefaultRedirectToStrategy(t *testing.T, conf *config.Config, strategy, value string)

func SelfServiceMakeHookRequest

func SelfServiceMakeHookRequest(t *testing.T, ts *httptest.Server, suffix string, asAPI bool, query url.Values) (*http.Response, 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 SelfServiceMakeRecoveryPreHookRequest added in v0.11.0

func SelfServiceMakeRecoveryPreHookRequest(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 SelfServiceMakeSettingsPreHookRequest added in v0.11.0

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

func SelfServiceMakeVerificationPreHookRequest added in v0.11.0

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

func SetDefaultIdentitySchema

func SetDefaultIdentitySchema(conf *config.Config, url string) func()

func SetDefaultIdentitySchemaFromRaw

func SetDefaultIdentitySchemaFromRaw(conf *config.Config, schema []byte)

SetDefaultIdentitySchemaFromRaw allows setting the default identity schema from a raw JSON string.

func SetIdentitySchemas

func SetIdentitySchemas(t *testing.T, conf *config.Config, 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,
	isSPA bool,
	f *kratos.SettingsFlow,
	hc *http.Client,
	values string,
) (string, *http.Response)

func SkipIfNetworkContext

func SkipIfNetworkContext(t testing.TB, ctx context.Context)

func SnapshotTExcept

func SnapshotTExcept(t *testing.T, actual interface{}, except []string)

func StartE2EServer

func StartE2EServer(t *testing.T, configFile string, configOptions ConfigOptions) (publicUrl, adminUrl string)

func StartE2EServerOnly

func StartE2EServerOnly(t *testing.T, configFile string, isTLS bool, configOptions ConfigOptions) (publicPort, adminPort int)

func StrategyEnable

func StrategyEnable(t *testing.T, c *config.Config, strategy string, enable bool)

func SubmitLoginForm

func SubmitLoginForm(
	t *testing.T,
	isAPI bool,
	hc *http.Client,
	publicTS *httptest.Server,
	withValues func(v url.Values),
	isSPA bool,
	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,
	isSPA bool,
	hc *http.Client,
	publicTS *httptest.Server,
	withValues func(v url.Values),
	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),
	isSPA bool,
	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,
	isSPA bool,
	hc *http.Client,
	publicTS *httptest.Server,
	withValues func(v url.Values),
	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,
	isSPA bool,
	hc *http.Client,
	publicTS *httptest.Server,
	withValues func(v url.Values),
	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,
	conf *config.Config,
) func(t *testing.T)

func UseConfigFile

func UseConfigFile(t *testing.T, path string) *pflag.FlagSet

func UseIdentitySchema added in v0.13.0

func UseIdentitySchema(t *testing.T, conf *config.Config, url string) (id string)

UseIdentitySchema registeres an identity schema in the config with a random ID and returns the ID

It also registeres a test cleanup function, to reset the schemas to the original values, after the test finishes

func VerificationMakeRequest

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

Types

type ConfigOptions

type ConfigOptions map[string]interface{}

type InitFlowWithOption

type InitFlowWithOption func(*initFlowOptions)

func InitFlowWithOAuth2LoginChallenge added in v0.11.0

func InitFlowWithOAuth2LoginChallenge(hlc string) InitFlowWithOption

func InitFlowWithRefresh

func InitFlowWithRefresh() InitFlowWithOption

func InitFlowWithReturnTo

func InitFlowWithReturnTo(returnTo string) InitFlowWithOption

func InitFlowWithVia added in v1.1.0

func InitFlowWithVia(via string) InitFlowWithOption

InitFlowWithVia sets the `via` query parameter which is used by the code MFA flows to determine the trait to use to send the code to the user

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(ctx context.Context) time.Duration

type TransportWithHeader added in v1.1.0

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

func NewAuthorizedTransport added in v0.11.0

func NewAuthorizedTransport(t *testing.T, reg *driver.RegistryDefault, sess *session.Session) *TransportWithHeader

func NewTransportWithHeader added in v1.1.0

func NewTransportWithHeader(t *testing.T, h http.Header) *TransportWithHeader

func (*TransportWithHeader) RoundTrip added in v1.1.0

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

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