testing

package
v0.0.0-...-99b6106 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultJWKS

func DefaultJWKS() []byte

DefaultJWKS generates the JSON web key set used for tests.

func JQ

func JQ(filter string, input interface{}) (results []interface{}, err error)

JQ runs the given `jq` filter on the given object and returns the list of results. The returned slice will never be nil; if there are no results it will be empty.

func LocalhostCertificate

func LocalhostCertificate() tls.Certificate

LocalhostCertificate returns a self signed TLS certificate valid for the name `localhost` DNS name, for the `127.0.0.1` IPv4 address and for the `::1` IPv6 address.

A similar certificate can be generated with the following command:

openssl req \
-x509 \
-newkey rsa:4096 \
-nodes \
-keyout tls.key \
-out tls.crt \
-subj '/CN=localhost' \
-addext 'subjectAltName=DNS:localhost,IP:127.0.0.1,IP:::1' \
-days 1

func MakeClaims

func MakeClaims() jwt.MapClaims

MakeClaims generates a default set of claims to be used to issue a token.

func MakeTCPServer

func MakeTCPServer() *ghttp.Server

MakeTCPServer creates a test server that listens in a TCP socket and configured so that it sends log messages to the Ginkgo writer.

func MakeTCPTLSServer

func MakeTCPTLSServer() (server *ghttp.Server, ca string)

MakeTCPTLSServer creates a test server configured so that it sends log messages to the Ginkgo writer. It returns the created server and the name of a temporary file that contains the CA certificate that the client should trust in order to connect to the server. It is the responsibility of the caller to delete this temporary file when it is no longer needed.

func MakeTokenObject

func MakeTokenObject(claims jwt.MapClaims) *jwt.Token

MakeTokenObject generates a token with the claims resulting from merging the default claims and the claims explicitly given.

func MakeTokenString

func MakeTokenString(typ string, life time.Duration) string

MakeTokenString generates a token issued by the default OpenID server and with the given type and with the given life. If the life is zero the token will never expire. If the life is positive the token will be valid, and expire after that time. If the life is negative the token will be already expired that time ago.

func MatchJQ

func MatchJQ(filter string, expected interface{}) types.GomegaMatcher

MatchJQ creates a matcher that checks that the all the results of applying a `jq` filter to the actual value is the given expected value.

func RespondWithContent

func RespondWithContent(status int, contentType, body string) http.HandlerFunc

RespondeWithContent responds with the given status code, content type and body.

func RespondWithJSON

func RespondWithJSON(status int, body string) http.HandlerFunc

RespondWithJSON responds with the given status code and JSON body.

func RespondWithObject

func RespondWithObject(object data.Object) http.HandlerFunc

RespondWithObject returns an HTTP handler that responds with a single object.

Types

This section is empty.

Jump to

Keyboard shortcuts

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