testhelpers

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestLifespans = client.Lifespans{
	AuthorizationCodeGrantAccessTokenLifespan:  x.NullDuration{Duration: 31 * time.Hour, Valid: true},
	AuthorizationCodeGrantIDTokenLifespan:      x.NullDuration{Duration: 32 * time.Hour, Valid: true},
	AuthorizationCodeGrantRefreshTokenLifespan: x.NullDuration{Duration: 33 * time.Hour, Valid: true},
	ClientCredentialsGrantAccessTokenLifespan:  x.NullDuration{Duration: 34 * time.Hour, Valid: true},
	ImplicitGrantAccessTokenLifespan:           x.NullDuration{Duration: 35 * time.Hour, Valid: true},
	ImplicitGrantIDTokenLifespan:               x.NullDuration{Duration: 36 * time.Hour, Valid: true},
	JwtBearerGrantAccessTokenLifespan:          x.NullDuration{Duration: 37 * time.Hour, Valid: true},
	PasswordGrantAccessTokenLifespan:           x.NullDuration{Duration: 38 * time.Hour, Valid: true},
	PasswordGrantRefreshTokenLifespan:          x.NullDuration{Duration: 39 * time.Hour, Valid: true},
	RefreshTokenGrantIDTokenLifespan:           x.NullDuration{Duration: 40 * time.Hour, Valid: true},
	RefreshTokenGrantAccessTokenLifespan:       x.NullDuration{Duration: 41 * time.Hour, Valid: true},
	RefreshTokenGrantRefreshTokenLifespan:      x.NullDuration{Duration: 42 * time.Hour, Valid: true},
}

Functions

func CleanAndMigrate added in v2.3.0

func CleanAndMigrate(reg driver.Registry) func(*testing.T)

func ConnectDatabases added in v2.3.0

func ConnectDatabases(t *testing.T, migrate bool, ctxer contextx.Contextualizer) (pg, mysql, crdb driver.Registry, clean func(*testing.T))

func ConnectToCRDB added in v2.3.0

func ConnectToCRDB(t testing.TB) string

func ConnectToMySQL added in v2.3.0

func ConnectToMySQL(t testing.TB) string

func ConnectToPG added in v2.3.0

func ConnectToPG(t testing.TB) string

func DecodeIDToken

func DecodeIDToken(t *testing.T, token *oauth2.Token) gjson.Result

func FlexibleServer

func FlexibleServer(t *testing.T, h *http.HandlerFunc) string

func GenerateTLSCertificateFilesForTests

func GenerateTLSCertificateFilesForTests(t *testing.T) (
	certPath, keyPath string,
	cert *x509.Certificate,
	privateKey interface {
		Public() crypto.PublicKey
		Equal(x crypto.PrivateKey) bool
	},
)

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

func HTTPServerNoExpectedCallHandler

func HTTPServerNoExpectedCallHandler(t testing.TB) http.HandlerFunc

func HTTPServerNotImplementedHandler

func HTTPServerNotImplementedHandler(w http.ResponseWriter, _ *http.Request)

func IntrospectToken

func IntrospectToken(t testing.TB, conf *oauth2.Config, token string, adminTS *httptest.Server) gjson.Result

func JanitorTests

func JanitorTests(
	reg interface {
		ConsentManager() consent.Manager
		OAuth2Storage() x.FositeStorer
		config.Provider
		client.ManagerProvider
		flow.CipherProvider
	},
	network string,
	parallel bool,
) func(t *testing.T)

func MustEnsureRegistryKeys added in v2.3.0

func MustEnsureRegistryKeys(ctx context.Context, r driver.Registry, key string)

func NewCallbackURL

func NewCallbackURL(t testing.TB, prefix string, h http.HandlerFunc) string

func NewConfigurationWithDefaults added in v2.3.0

func NewConfigurationWithDefaults() *config.DefaultProvider

func NewConfigurationWithDefaultsAndHTTPS added in v2.3.0

func NewConfigurationWithDefaultsAndHTTPS() *config.DefaultProvider

func NewEmptyCookieJar

func NewEmptyCookieJar(t testing.TB) *cookiejar.Jar

func NewEmptyJarClient

func NewEmptyJarClient(t testing.TB) *http.Client

func NewIDToken

func NewIDToken(t *testing.T, reg driver.Registry, subject string) string

func NewIDTokenWithClaims

func NewIDTokenWithClaims(t *testing.T, reg driver.Registry, claims jwt.MapClaims) string

func NewIDTokenWithExpiry

func NewIDTokenWithExpiry(t *testing.T, reg driver.Registry, subject string, exp time.Duration) string

func NewLoginConsentUI

func NewLoginConsentUI(t testing.TB, c *config.DefaultProvider, login, consent http.HandlerFunc)

func NewMockedRegistry added in v2.3.0

func NewMockedRegistry(t testing.TB, ctxer contextx.Contextualizer) driver.Registry

func NewOAuth2Server

func NewOAuth2Server(ctx context.Context, t testing.TB, reg driver.Registry) (publicTS, adminTS *httptest.Server)

func NewRegistryMemory added in v2.3.0

func NewRegistryMemory(t testing.TB, c *config.DefaultProvider, ctxer contextx.Contextualizer) driver.Registry

func NewRegistrySQLFromURL added in v2.3.0

func NewRegistrySQLFromURL(t testing.TB, url string, migrate bool, ctxer contextx.Contextualizer) driver.Registry

func RegistryFactory added in v2.3.0

func RegistryFactory(t testing.TB, url string, c *config.DefaultProvider, networkInit, migrate bool, ctxer contextx.Contextualizer) driver.Registry

func RevokeToken added in v2.3.0

func RevokeToken(t testing.TB, conf *oauth2.Config, token string, publicTS *httptest.Server) gjson.Result

func UpdateClientTokenLifespans

func UpdateClientTokenLifespans(t *testing.T, conf *oauth2.Config, clientID string, lifespans client.Lifespans, adminTS *httptest.Server)

func Userinfo

func Userinfo(t *testing.T, token *oauth2.Token, publicTS *httptest.Server) gjson.Result

Types

type JanitorConsentTestHelper

type JanitorConsentTestHelper struct {
	Lifespan time.Duration
	// contains filtered or unexported fields
}

func NewConsentJanitorTestHelper

func NewConsentJanitorTestHelper(uniqueName string) *JanitorConsentTestHelper

func (*JanitorConsentTestHelper) AccessTokenNotAfterSetup

func (j *JanitorConsentTestHelper) AccessTokenNotAfterSetup(ctx context.Context, cl client.Manager, store x.FositeStorer) func(t *testing.T)

func (*JanitorConsentTestHelper) AccessTokenNotAfterValidate

func (j *JanitorConsentTestHelper) AccessTokenNotAfterValidate(ctx context.Context, notAfter time.Time, store x.FositeStorer) func(t *testing.T)

func (*JanitorConsentTestHelper) ConsentRejectionSetup

func (j *JanitorConsentTestHelper) ConsentRejectionSetup(ctx context.Context, reg interface {
	consent.ManagerProvider
	client.ManagerProvider
	flow.CipherProvider
}) func(t *testing.T)

func (*JanitorConsentTestHelper) ConsentRejectionValidate

func (j *JanitorConsentTestHelper) ConsentRejectionValidate(ctx context.Context, cm consent.Manager) func(t *testing.T)

func (*JanitorConsentTestHelper) ConsentTimeoutSetup

func (j *JanitorConsentTestHelper) ConsentTimeoutSetup(ctx context.Context, reg interface {
	consent.ManagerProvider
	client.ManagerProvider
	flow.CipherProvider
}) func(t *testing.T)

func (*JanitorConsentTestHelper) ConsentTimeoutValidate

func (j *JanitorConsentTestHelper) ConsentTimeoutValidate(ctx context.Context, cm consent.Manager) func(t *testing.T)

func (*JanitorConsentTestHelper) GetAccessTokenLifespan

func (j *JanitorConsentTestHelper) GetAccessTokenLifespan(ctx context.Context) time.Duration

func (*JanitorConsentTestHelper) GetConfig

func (*JanitorConsentTestHelper) GetConsentRequestLifespan

func (j *JanitorConsentTestHelper) GetConsentRequestLifespan(ctx context.Context) time.Duration

func (*JanitorConsentTestHelper) GetDSN

func (j *JanitorConsentTestHelper) GetDSN() string

func (*JanitorConsentTestHelper) GetNotAfterTestCycles

func (j *JanitorConsentTestHelper) GetNotAfterTestCycles() map[string]time.Duration

func (*JanitorConsentTestHelper) GetRefreshTokenLifespan

func (j *JanitorConsentTestHelper) GetRefreshTokenLifespan(ctx context.Context) time.Duration

func (*JanitorConsentTestHelper) GetRegistry

func (j *JanitorConsentTestHelper) GetRegistry(ctx context.Context, dbname string) (driver.Registry, error)

func (*JanitorConsentTestHelper) GrantNotAfterSetup

func (j *JanitorConsentTestHelper) GrantNotAfterSetup(ctx context.Context, gr trust.GrantManager) func(t *testing.T)

func (*JanitorConsentTestHelper) GrantNotAfterValidate

func (j *JanitorConsentTestHelper) GrantNotAfterValidate(ctx context.Context, notAfter time.Time, gr trust.GrantManager) func(t *testing.T)

func (*JanitorConsentTestHelper) LimitSetup

func (*JanitorConsentTestHelper) LimitValidate

func (j *JanitorConsentTestHelper) LimitValidate(ctx context.Context, cm consent.Manager) func(t *testing.T)

func (*JanitorConsentTestHelper) LoginConsentNotAfterSetup

func (j *JanitorConsentTestHelper) LoginConsentNotAfterSetup(ctx context.Context, cm consent.Manager, cl client.Manager) func(t *testing.T)

func (*JanitorConsentTestHelper) LoginConsentNotAfterValidate

func (j *JanitorConsentTestHelper) LoginConsentNotAfterValidate(
	ctx context.Context,
	notAfter time.Time,
	consentRequestLifespan time.Time,
	reg interface {
		consent.ManagerProvider
		flow.CipherProvider
	},
) func(t *testing.T)

func (*JanitorConsentTestHelper) LoginRejectionSetup

func (j *JanitorConsentTestHelper) LoginRejectionSetup(ctx context.Context, reg interface {
	consent.ManagerProvider
	client.ManagerProvider
	flow.CipherProvider
}) func(t *testing.T)

func (*JanitorConsentTestHelper) LoginRejectionValidate

func (j *JanitorConsentTestHelper) LoginRejectionValidate(ctx context.Context, cm consent.Manager) func(t *testing.T)

func (*JanitorConsentTestHelper) LoginTimeoutSetup

func (j *JanitorConsentTestHelper) LoginTimeoutSetup(ctx context.Context, reg interface {
	consent.ManagerProvider
	client.ManagerProvider
	flow.CipherProvider
}) func(t *testing.T)

func (*JanitorConsentTestHelper) LoginTimeoutValidate

func (j *JanitorConsentTestHelper) LoginTimeoutValidate(ctx context.Context, cm consent.Manager) func(t *testing.T)

func (*JanitorConsentTestHelper) RefreshTokenNotAfterSetup

func (j *JanitorConsentTestHelper) RefreshTokenNotAfterSetup(ctx context.Context, cl client.Manager, store x.FositeStorer) func(t *testing.T)

func (*JanitorConsentTestHelper) RefreshTokenNotAfterValidate

func (j *JanitorConsentTestHelper) RefreshTokenNotAfterValidate(ctx context.Context, notAfter time.Time, store x.FositeStorer) func(t *testing.T)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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