test

package
v2.21.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OwnerClaim    = testOAuthUri.OwnerClaimKey
	DeviceIDClaim = testOAuthUri.DeviceIDClaimKey
)

Variables

View Source
var JWTPrivateKeyOAuthClient = service.Client{
	ID:                  "JWTPrivateKeyClient",
	SecretFile:          "data:,JWTPrivateKeyClientSecret",
	AccessTokenLifetime: 0,
	AllowedGrantTypes:   []service.GrantType{service.GrantTypeClientCredentials},
	AllowedAudiences:    nil,
	AllowedScopes:       nil,
	JWTPrivateKey: service.PrivateKeyJWTConfig{
		Enabled:       true,
		Authorization: config.MakeValidatorConfig(),
	},
}
View Source
var ServiceOAuthClient = service.Client{
	ID:                  "serviceClient",
	SecretFile:          "data:,serviceClientSecret",
	AccessTokenLifetime: 0,
	AllowedGrantTypes:   []service.GrantType{service.GrantTypeClientCredentials},
	AllowedAudiences:    nil,
	AllowedScopes:       nil,
	InsertTokenClaims:   map[string]interface{}{"hardcodedClaim": true},
}

Functions

func GetAccessToken

func GetAccessToken(t *testing.T, expectedCode int, opts ...func(opts *AccessTokenOptions)) map[string]string

func GetDefaultAccessToken

func GetDefaultAccessToken(t *testing.T, opts ...func(opts *AccessTokenOptions)) string

func GetJWTValidator

func GetJWTValidator(jwkURL string) *jwt.Validator

func GetSecret

func GetSecret(t require.TestingT, clientID string) string

func MakeConfig

func MakeConfig(t require.TestingT) service.Config

func New

func New(t require.TestingT, cfg service.Config) func()

func SetUp

func SetUp(t require.TestingT) (tearDown func())

func WithAccessTokenAudience

func WithAccessTokenAudience(audience string) func(opts *AccessTokenOptions)

func WithAccessTokenClientID

func WithAccessTokenClientID(clientID string) func(opts *AccessTokenOptions)

func WithAccessTokenClientSecret

func WithAccessTokenClientSecret(clientSecret string) func(opts *AccessTokenOptions)

func WithAccessTokenGrantType

func WithAccessTokenGrantType(grantType string) func(opts *AccessTokenOptions)

func WithAccessTokenHost

func WithAccessTokenHost(host string) func(opts *AccessTokenOptions)

func WithAccessTokenJWT

func WithAccessTokenJWT(jwt string) func(opts *AccessTokenOptions)

func WithAccessTokenOptions

func WithAccessTokenOptions(options AccessTokenOptions) func(opts *AccessTokenOptions)

func WithContext

func WithContext(ctx context.Context) func(opts *AccessTokenOptions)

func WithPostFrom

func WithPostFrom(enabled bool) func(opts *AccessTokenOptions)

Types

type AccessTokenOptions

type AccessTokenOptions struct {
	Host         string
	ClientID     string
	ClientSecret string
	GrantType    string
	Audience     string
	JWT          string
	PostForm     bool
	Ctx          context.Context
}

Jump to

Keyboard shortcuts

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