Documentation
¶
Overview ¶
Package spec implements reusable integration tests to test against any OAuth2 authentication server.
Index ¶
- func AccessTokenTest(t *testing.T, c *Config, accessToken string)
- func AuthorizationCodeGrantTest(t *testing.T, c *Config)
- func AuthorizationEndpointTest(t *testing.T, c *Config)
- func ClientCredentialsGrantTest(t *testing.T, c *Config)
- func Do(handler http.Handler, req *Request)
- func ImplicitGrantTest(t *testing.T, c *Config)
- func IntrospectionEndpointTest(t *testing.T, c *Config)
- func PasswordGrantTest(t *testing.T, c *Config)
- func ProtectedResourceTest(t *testing.T, c *Config)
- func RefreshTokenGrantTest(t *testing.T, c *Config)
- func RefreshTokenTest(t *testing.T, c *Config, refreshToken string)
- func RevocationEndpointTest(t *testing.T, c *Config)
- func Run(t *testing.T, c *Config)
- func TokenEndpointTest(t *testing.T, c *Config)
- type Config
- type Request
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessTokenTest ¶
AccessTokenTest validates the specified access token by requesting the protected resource.
func AuthorizationCodeGrantTest ¶
AuthorizationCodeGrantTest tests the authorization code grant.
func AuthorizationEndpointTest ¶
AuthorizationEndpointTest executes general authorization endpoint tests.
func ClientCredentialsGrantTest ¶
ClientCredentialsGrantTest tests the client credentials grant.
func ImplicitGrantTest ¶
ImplicitGrantTest tests the implicit grant.
func IntrospectionEndpointTest ¶ added in v1.3.0
IntrospectionEndpointTest executes general token introspection tests.
func PasswordGrantTest ¶
PasswordGrantTest tests the password grant.
func ProtectedResourceTest ¶
ProtectedResourceTest validates authorization of the protected resource.
func RefreshTokenGrantTest ¶
RefreshTokenGrantTest tests the refresh token grant.
func RefreshTokenTest ¶
RefreshTokenTest validates the specified refreshToken by requesting a new access token and validating it as well.
func RevocationEndpointTest ¶ added in v0.3.0
RevocationEndpointTest executes general token revocation tests.
func TokenEndpointTest ¶
TokenEndpointTest executes general token endpoint tests.
Types ¶
type Config ¶
type Config struct {
// The server handler.
Handler http.Handler
// The token endpoint (e.g. /oauth2/token).
TokenEndpoint string
// The authorization endpoint (e.g. /oauth2/authorize).
AuthorizeEndpoint string
// The revocation endpoint (e.g. /oauth2/revoke).
RevocationEndpoint string
// The introspection endpoint (e.g. /oauth2/introspect).
IntrospectionEndpoint string
// The protected resource (e.g. /api/protected).
ProtectedResource string
// The supported grants.
PasswordGrantSupport bool
ClientCredentialsGrantSupport bool
ImplicitGrantSupport bool
AuthorizationCodeGrantSupport bool
RefreshTokenGrantSupport bool
// The details of a confidential client.
ConfidentialClientID string
ConfidentialClientSecret string
// The details of a public client.
PublicClientID string
// The scopes that are considered invalid, valid and exceeding by the
// authentication server.
InvalidScope string
ValidScope string
ExceedingScope string
// The expected "expire_in" value of returned tokens.
ExpectedExpiresIn int
// The tokens for the protected resource tests.
InvalidToken string
UnknownToken string
ValidToken string
ExpiredToken string
InsufficientToken string
// The details of the primary resource owner for the password grant test.
//
// Note: Only needed if the password grant is supported.
ResourceOwnerUsername string
ResourceOwnerPassword string
// The redirect URI that is considered invalid and valid by the
// authentication server.
//
// Note: Only needed if the implicit grant or authorization code grant is
// supported.
InvalidRedirectURI string
PrimaryRedirectURI string
SecondaryRedirectURI string
// The invalid, unknown, valid and expired refresh tokens that is used
// during the refresh token grant tests.
//
// Note: Only needed if the refresh token grant is supported.
InvalidRefreshToken string
UnknownRefreshToken string
ValidRefreshToken string
ExpiredRefreshToken string
// The invalid, unknown and expired authorization code that is used during
// the authorization code grant tests.
//
// Note: Only needed if the authorization code grant is supported.
InvalidAuthorizationCode string
UnknownAuthorizationCode string
ExpiredAuthorizationCode string
// The params and headers needed to authorize the resource owner during the
// implicit grant or authorization code grant test.
//
// Note: Only needed if the implicit grant or authorization code grant
// is supported.
InvalidAuthorizationParams map[string]string
InvalidAuthorizationHeaders map[string]string
ValidAuthorizationParams map[string]string
ValidAuthorizationHeaders map[string]string
// If enabled the implementation is checked for properly revoking tokens
// if a code replay attack is carried out.
CodeReplayMitigation bool
}
A Config declares the needed info for testing an OAuth2 authentication server.