assertions

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DateLayout = "2006-01-02"

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTAssertion

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

JWTAssertion is used to build a chain of assertions for the JWT node.

func (*JWTAssertion) Assert

func (a *JWTAssertion) Assert(assertFunc func(tb testing.TB, token *jwt.Token)) *JWTAssertion

Assert asserts that the JWT is satisfied by the user function assertFunc.

func (*JWTAssertion) Value

func (a *JWTAssertion) Value() *jwt.Token

Value returns decoded jwt.Token. If parsing fails it will return empty struct.

func (*JWTAssertion) WithAlgorithm

func (a *JWTAssertion) WithAlgorithm(alg string, msgAndArgs ...interface{}) *JWTAssertion

WithAlgorithm asserts that the JWT is signed with expected algorithm ("alg" header).

func (*JWTAssertion) WithAudience

func (a *JWTAssertion) WithAudience(expected []string, msgAndArgs ...interface{}) *JWTAssertion

WithAudience asserts that the JWT has audience field ("aud" field in payload) with the expected values.

func (*JWTAssertion) WithExpiresAt

func (a *JWTAssertion) WithExpiresAt() *TimeAssertion

WithExpiresAt asserts that the JWT has expired at field ("exp" field in payload). It runs TimeAssertion on its value.

func (*JWTAssertion) WithHeader

func (a *JWTAssertion) WithHeader(jsonAssert assertjson.JSONAssertFunc) *JWTAssertion

WithHeader executes JSON assertion on JWT header.

func (*JWTAssertion) WithID

func (a *JWTAssertion) WithID(expected string, msgAndArgs ...interface{}) *JWTAssertion

WithID asserts that the JWT has id field ("jti" field in payload) with the expected value.

func (*JWTAssertion) WithIssuedAt

func (a *JWTAssertion) WithIssuedAt() *TimeAssertion

WithIssuedAt asserts that the JWT has issued at field ("iat" field in payload). It runs TimeAssertion on its value.

func (*JWTAssertion) WithIssuer

func (a *JWTAssertion) WithIssuer(expected string, msgAndArgs ...interface{}) *JWTAssertion

WithIssuer asserts that the JWT has issuer field ("iss" field in payload) with the expected value.

func (*JWTAssertion) WithNotBefore

func (a *JWTAssertion) WithNotBefore() *TimeAssertion

WithNotBefore asserts that the JWT has not before field ("nbf" field in payload). It runs TimeAssertion on its value.

func (*JWTAssertion) WithPayload

func (a *JWTAssertion) WithPayload(jsonAssert assertjson.JSONAssertFunc) *JWTAssertion

WithPayload executes JSON assertion on JWT payload.

func (*JWTAssertion) WithSubject

func (a *JWTAssertion) WithSubject(expected string, msgAndArgs ...interface{}) *JWTAssertion

WithSubject asserts that the JWT has subject field ("sub" field in payload) with the expected value.

type StringAssertion

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

StringAssertion is used to build a chain of assertions for the string node.

func NewStringAssertion

func NewStringAssertion(t TestingT, messagePrefix string, value string) *StringAssertion

func (*StringAssertion) Contains

func (a *StringAssertion) Contains(value string, msgAndArgs ...interface{}) *StringAssertion

Contains asserts that string value that contains a string.

func (*StringAssertion) EqualTo

func (a *StringAssertion) EqualTo(expectedValue string, msgAndArgs ...interface{}) *StringAssertion

EqualTo asserts that string value equals to the given value.

func (*StringAssertion) EqualToOneOf

func (a *StringAssertion) EqualToOneOf(expectedValues ...string) *StringAssertion

EqualToOneOf asserts that string value equals to one of the given values.

func (*StringAssertion) IsEmpty

func (a *StringAssertion) IsEmpty(msgAndArgs ...interface{}) *StringAssertion

IsEmpty asserts that string value equals to empty string.

func (*StringAssertion) IsNotEmpty

func (a *StringAssertion) IsNotEmpty(msgAndArgs ...interface{}) *StringAssertion

IsNotEmpty asserts that string value not equals to empty string.

func (*StringAssertion) Matches

func (a *StringAssertion) Matches(regexp interface{}, msgAndArgs ...interface{}) *StringAssertion

Matches asserts that string value that matches the regular expression.

func (*StringAssertion) NotContains

func (a *StringAssertion) NotContains(value string, msgAndArgs ...interface{}) *StringAssertion

NotContains asserts that string value that does not contain a string.

func (*StringAssertion) NotEqualTo

func (a *StringAssertion) NotEqualTo(expectedValue string, msgAndArgs ...interface{}) *StringAssertion

NotEqualTo asserts that string value not equals to the given value.

func (*StringAssertion) NotMatches

func (a *StringAssertion) NotMatches(regexp interface{}, msgAndArgs ...interface{}) *StringAssertion

NotMatches asserts that string value that does not match the regular expression.

func (*StringAssertion) WithDate

func (a *StringAssertion) WithDate(msgAndArgs ...interface{}) *TimeAssertion

WithDate asserts that the JSON node has a string value with date in "YYYY-MM-DD" format.

func (*StringAssertion) WithJWT

func (a *StringAssertion) WithJWT(keyFunc jwt.Keyfunc, msgAndArgs ...interface{}) *JWTAssertion

WithJWT asserts that the JSON node has a string value with JWT.

func (*StringAssertion) WithLength

func (a *StringAssertion) WithLength(length int, msgAndArgs ...interface{}) *StringAssertion

WithLength asserts that string value with length equal to the given value.

func (*StringAssertion) WithLengthGreaterThan

func (a *StringAssertion) WithLengthGreaterThan(expected int, msgAndArgs ...interface{}) *StringAssertion

WithLengthGreaterThan asserts that string value with length greater than the value.

func (*StringAssertion) WithLengthGreaterThanOrEqual

func (a *StringAssertion) WithLengthGreaterThanOrEqual(expected int, msgAndArgs ...interface{}) *StringAssertion

WithLengthGreaterThanOrEqual asserts that string value with length greater than or equal to the value.

func (*StringAssertion) WithLengthLessThan

func (a *StringAssertion) WithLengthLessThan(expected int, msgAndArgs ...interface{}) *StringAssertion

WithLengthLessThan asserts that string value with length less than the value.

func (*StringAssertion) WithLengthLessThanOrEqual

func (a *StringAssertion) WithLengthLessThanOrEqual(expected int, msgAndArgs ...interface{}) *StringAssertion

WithLengthLessThanOrEqual asserts that string value with length less than or equal to the value.

func (*StringAssertion) WithTime

func (a *StringAssertion) WithTime(msgAndArgs ...interface{}) *TimeAssertion

WithTime asserts that the JSON node has a string value with time in RFC3339 format.

func (*StringAssertion) WithTimeWithLayout

func (a *StringAssertion) WithTimeWithLayout(layout string, msgAndArgs ...interface{}) *TimeAssertion

WithTimeWithLayout asserts that the JSON node has a string value with time with the given layout.

type TestingT

type TestingT interface {
	Helper()
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Log(args ...interface{})
}

TestingT is an interface wrapper around *testing.T.

type TimeAssertion

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

TimeAssertion is used to build a chain of assertions for the time node.

func NewTimeAssertion

func NewTimeAssertion(t TestingT, message string, value time.Time, layout string) *TimeAssertion

func (*TimeAssertion) After

func (a *TimeAssertion) After(expected time.Time, msgAndArgs ...interface{}) *TimeAssertion

After asserts that the time after the given time.

func (*TimeAssertion) AfterDate

func (a *TimeAssertion) AfterDate(year int, month time.Month, day int, msgAndArgs ...interface{}) *TimeAssertion

AfterDate asserts that the time after the given date.

func (*TimeAssertion) AfterOrEqualTo

func (a *TimeAssertion) AfterOrEqualTo(expected time.Time, msgAndArgs ...interface{}) *TimeAssertion

AfterOrEqualTo asserts that the time after or equal to the given time.

func (*TimeAssertion) AfterOrEqualToDate

func (a *TimeAssertion) AfterOrEqualToDate(year int, month time.Month, day int, msgAndArgs ...interface{}) *TimeAssertion

AfterOrEqualToDate asserts that the time after or equal to the given date.

func (*TimeAssertion) AtDate

func (a *TimeAssertion) AtDate(year int, month time.Month, day int, msgAndArgs ...interface{}) *TimeAssertion

AtDate asserts that the time between the beginning and the end of the given date.

func (*TimeAssertion) Before

func (a *TimeAssertion) Before(expected time.Time, msgAndArgs ...interface{}) *TimeAssertion

Before asserts that the time before the given time.

func (*TimeAssertion) BeforeDate

func (a *TimeAssertion) BeforeDate(year int, month time.Month, day int, msgAndArgs ...interface{}) *TimeAssertion

BeforeDate asserts that the time before the given date.

func (*TimeAssertion) BeforeOrEqualTo

func (a *TimeAssertion) BeforeOrEqualTo(expected time.Time, msgAndArgs ...interface{}) *TimeAssertion

BeforeOrEqualTo asserts that the time before or equal to the given time.

func (*TimeAssertion) BeforeOrEqualToDate

func (a *TimeAssertion) BeforeOrEqualToDate(year int, month time.Month, day int, msgAndArgs ...interface{}) *TimeAssertion

BeforeOrEqualToDate asserts that the time before or equal to the given date.

func (*TimeAssertion) EqualTo

func (a *TimeAssertion) EqualTo(expected time.Time, msgAndArgs ...interface{}) *TimeAssertion

EqualTo asserts that the time equals to the given value.

func (*TimeAssertion) EqualToDate

func (a *TimeAssertion) EqualToDate(year int, month time.Month, day int, msgAndArgs ...interface{}) *TimeAssertion

EqualToDate asserts that the time equals to the given date.

func (*TimeAssertion) NotEqualTo

func (a *TimeAssertion) NotEqualTo(expected time.Time, msgAndArgs ...interface{}) *TimeAssertion

NotEqualTo asserts that the time not equals to the given value.

func (*TimeAssertion) NotEqualToDate

func (a *TimeAssertion) NotEqualToDate(year int, month time.Month, day int, msgAndArgs ...interface{}) *TimeAssertion

NotEqualToDate asserts that the time not equals to the given date.

Jump to

Keyboard shortcuts

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