testkeycloak

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	BaseURL      string
	IssuerURL    string
	DiscoveryURL string
	TokenURL     string
	AdminURL     string
	Realm        string
	ClientID     string
	ClientSecret string
	// contains filtered or unexported fields
}

Server exposes a running Keycloak test instance.

func StartKeycloak

func StartKeycloak(tb testing.TB) *Server

StartKeycloak starts a disposable Keycloak container with the memory-service realm imported.

func (*Server) AccessToken

func (s *Server) AccessToken(ctx context.Context, username, password string) (string, error)

AccessToken gets an OIDC access token using password grant for a Keycloak realm user.

func (*Server) AccessTokenWithScopes added in v0.0.3

func (s *Server) AccessTokenWithScopes(ctx context.Context, username, password, scopes string) (string, error)

AccessTokenWithScopes gets an OIDC access token requesting only the given space-separated scopes. When scopes is empty the default Keycloak scopes are used.

func (*Server) EnsureUser

func (s *Server) EnsureUser(ctx context.Context, username, password string, realmRoles []string) error

func (*Server) GetDiscoveryURL added in v0.0.3

func (s *Server) GetDiscoveryURL() string

GetDiscoveryURL returns the discovery URL for OIDC provider configuration.

func (*Server) GetIssuerURL added in v0.0.3

func (s *Server) GetIssuerURL() string

GetIssuerURL returns the issuer URL used for OIDC token validation.

Jump to

Keyboard shortcuts

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