helpers

package
v0.0.0-...-d0b8644 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyApiRule

func ApplyApiRule(toExecute RetryableApiRule, onRetry RetryableApiRule, k8sClient dynamic.Interface, retryOpts []retry.Option, resources []unstructured.Unstructured) error

APIRuleWithRetries tries toExecute function and retries with onRetry if APIRule status is "ERROR"

func GenerateRandomString

func GenerateRandomString(length int) string

func GenerateRandomTestId

func GenerateRandomTestId() string

func GetLoadBalancerIp

func GetLoadBalancerIp(loadBalancerIngress map[string]interface{}) (net.IP, error)

GetLoadBalancerIp returns the IP of the load balancer from the load balancer ingress object

Types

type BodyContainsPredicate

type BodyContainsPredicate struct {
	Expected []string
}

BodyContainsPredicate is a struct representing desired HTTP response body containing expected strings

func (*BodyContainsPredicate) Assert

func (s *BodyContainsPredicate) Assert(response http.Response) (bool, string)

Assert asserts that the response body contains the expected string

type HttpResponseAsserter

type HttpResponseAsserter interface {
	// Assert asserts that the response is valid and returns true if it is. It also returns a message with details about the failure.
	Assert(response http.Response) (bool, string)
}

type OIDCConfiguration

type OIDCConfiguration struct {
	Issuer                                string   `json:"issuer"`
	AuthorizationEndpoint                 string   `json:"authorization_endpoint"`
	TokenEndpoint                         string   `json:"token_endpoint"`
	UserinfoEndpoint                      string   `json:"userinfo_endpoint"`
	EndSessionEndpoint                    string   `json:"end_session_endpoint"`
	JwksUri                               string   `json:"jwks_uri"`
	IntrospectionEndpoint                 string   `json:"introspection_endpoint"`
	RevocationEndpoint                    string   `json:"revocation_endpoint"`
	ResponseTypesSupported                []string `json:"response_types_supported"`
	GrantTypesSupported                   []string `json:"grant_types_supported"`
	SubjectTypesSupported                 []string `json:"subject_types_supported"`
	IdTokenSigningAlgValuesSupported      []string `json:"id_token_signing_alg_values_supported"`
	ScopesSupported                       []string `json:"scopes_supported"`
	TokenEndpointAuthMethodsSupported     []string `json:"token_endpoint_auth_methods_supported"`
	ClaimsSupported                       []string `json:"claims_supported"`
	CodeChallengeMethodsSupported         []string `json:"code_challenge_methods_supported"`
	TlsClientCertificateBoundAccessTokens bool     `json:"tls_client_certificate_bound_access_tokens"`
	FrontchannelLogoutSupported           bool     `json:"frontchannel_logout_supported"`
	FrontchannelLogoutSessionSupported    bool     `json:"frontchannel_logout_session_supported"`
}

func GetOIDCConfiguration

func GetOIDCConfiguration(oidcConfigurationEndpoint string) (oidcConfiguration OIDCConfiguration, err error)

type RequestOptions

type RequestOptions struct {
	Audiences []string
	Scopes    []string
}

type RetryableApiRule

type RetryableApiRule func(k8sClient dynamic.Interface, resources ...unstructured.Unstructured) (*unstructured.Unstructured, error)

RetryableApiRule wraps any function that modifies or creates an APIRule

type RetryableHttpClient

type RetryableHttpClient struct {
	// contains filtered or unexported fields
}

func NewClientWithRetry

func NewClientWithRetry(c *http.Client, opts []retry.Option) *RetryableHttpClient

func (*RetryableHttpClient) CallEndpointWithHeadersAndMethod

func (h *RetryableHttpClient) CallEndpointWithHeadersAndMethod(requestHeaders map[string]string, url string, method string, validator HttpResponseAsserter) error

CallEndpointWithHeadersAndMethod calls given url with given method and headers. Returns error if the status code is not in between bounds of status predicate after retrying deadline is reached

func (*RetryableHttpClient) CallEndpointWithHeadersWithRetries

func (h *RetryableHttpClient) CallEndpointWithHeadersWithRetries(requestHeaders map[string]string, url string, validator HttpResponseAsserter) error

CallEndpointWithHeadersWithRetries calls given url with headers and GET method. Returns error if the status code is not in between bounds of status predicate after retrying deadline is reached

func (*RetryableHttpClient) CallEndpointWithRequest

func (h *RetryableHttpClient) CallEndpointWithRequest(req *http.Request, url string, validator HttpResponseAsserter) error

func (*RetryableHttpClient) CallEndpointWithRetries

func (h *RetryableHttpClient) CallEndpointWithRetries(url string, validator HttpResponseAsserter) error

CallEndpointWithRetries returns error if the status code is not in between bounds of status predicate after retrying deadline is reached

func (*RetryableHttpClient) CallEndpointWithRetriesAndGetResponse

func (h *RetryableHttpClient) CallEndpointWithRetriesAndGetResponse(headers map[string]string, body io.Reader, method, url string) (*http.Response, error)

type StatusPredicate

type StatusPredicate struct {
	LowerStatusBound int
	UpperStatusBound int
}

StatusPredicate is a struct representing desired endpoint call response status code, that is between LowerStatusBound and UpperStatusBound

func (*StatusPredicate) Assert

func (s *StatusPredicate) Assert(response http.Response) (bool, string)

Jump to

Keyboard shortcuts

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