test

package
v0.0.0-...-edf464d Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 29

Documentation

Index

Constants

View Source
const (
	// JwtPubKey1 is the response to 1st call for JWT public key returned by mock server.
	JwtPubKey1 = `` /* 175-byte string literal not displayed */

	// JwtPubKey1Reordered is the response to 1st call for JWT public key returned by mock server, but in a modified order of json elements.
	JwtPubKey1Reordered = `` /* 175-byte string literal not displayed */

	// JwtPubKey2 is the response to later calls for JWT public key returned by mock server.
	JwtPubKey2 = `` /* 176-byte string literal not displayed */

	JwtPubKeyNoKid = `` /* 133-byte string literal not displayed */

	JwtPubKeyNoKid2 = `` /* 133-byte string literal not displayed */

	JwtPubKeyNoKeys = `` /* 174-byte string literal not displayed */

	JwtPubKeyNoKeys2 = `` /* 174-byte string literal not displayed */

	JwtPubKeyExtraElements = `` /* 205-byte string literal not displayed */

)

Variables

This section is empty.

Functions

This section is empty.

Types

type MockOpenIDDiscoveryServer

type MockOpenIDDiscoveryServer struct {
	Port int
	URL  string

	// How many times openIDCfg is called, use this number to verify cache takes effect.
	OpenIDHitNum uint64

	// How many times jwtPubKey is called, use this number to verify cache takes effect.
	PubKeyHitNum uint64

	// The mock server will return an error for the first number of hits for public key, this is used
	// to simulate network errors and test the retry logic in jwks resolver for public key fetch.
	ReturnErrorForFirstNumHits uint64

	// The mock server will start to return an error after the first number of hits for public key,
	// this is used to simulate network errors and test the refresh logic in jwks resolver.
	ReturnErrorAfterFirstNumHits uint64

	// The mock server will start to return a successful response after the first number of hits for public key,
	// this is used to simulate network errors and test the refresh logic in jwks resolver. Note the idea is to
	// use this in combination with ReturnErrorAfterFirstNumHits to simulate something like this:
	// { success, success, error, error, success, success }
	ReturnSuccessAfterFirstNumHits uint64

	// The mock server will start to return an error after the first number of hits for public key,
	// this is used to simulate network errors and test the refresh logic in jwks resolver.
	ReturnReorderedKeyAfterFirstNumHits uint64

	// If both TLSKeyFile and TLSCertFile are set, Start() will attempt to start a HTTPS server.
	TLSKeyFile  string
	TLSCertFile string
	// contains filtered or unexported fields
}

MockOpenIDDiscoveryServer is the in-memory openID discovery server.

func StartNewServer

func StartNewServer() (*MockOpenIDDiscoveryServer, error)

StartNewServer creates a mock openID discovery server and starts it

func StartNewServerWithHandlerDelay

func StartNewServerWithHandlerDelay(timeout time.Duration) (*MockOpenIDDiscoveryServer, error)

StartNewServer creates a mock openID discovery server with an artificious timeout on handling requests and starts it

func StartNewTLSServer

func StartNewTLSServer(tlsCert, tlsKey string) (*MockOpenIDDiscoveryServer, error)

StartNewTLSServer creates a mock openID discovery server that serves HTTPS and starts it

func (*MockOpenIDDiscoveryServer) Start

func (ms *MockOpenIDDiscoveryServer) Start() error

Start starts the mock server.

func (*MockOpenIDDiscoveryServer) Stop

func (ms *MockOpenIDDiscoveryServer) Stop() error

Stop stops he mock server.

Jump to

Keyboard shortcuts

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