simbaTest

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ApiKeyAuthAuthenticationHandler = simba.APIKeyAuth[User](
	ApiKeyAuthFunc,
	simba.APIKeyAuthConfig{
		Name:        "User",
		FieldName:   "sessionid",
		In:          openapi.InCookie,
		Description: "Session cookie",
	})
View Source
var BasicAuthAuthenticationHandler = simba.BasicAuth[User](
	BasicAuthFunc,
	simba.BasicAuthConfig{
		Name:        "admin",
		Description: "admin access only",
	})
View Source
var BearerAuthAuthenticationHandler = simba.BearerAuth[User](
	BearerAuthFunc,
	simba.BearerAuthConfig{
		Name:        "admin",
		Format:      "jwt",
		Description: "Bearer token",
	})

Functions

func ApiKeyAuthHandler added in v0.15.0

ApiKeyAuthHandler A dummy function to test the OpenAPI generation with api key auth. @ID apiKeyAuthHandler @Summary api key handler @Description this is a multiline

description for the handler

@Error 409 Resource already exists

func BasicAuthHandler added in v0.15.0

BasicAuthHandler A dummy function to test the OpenAPI generation with basic auth. @ID basicAuthHandler @Summary basic auth handler @Description this is a multiline

description for the handler

@Error 409 Resource already exists

func BearerTokenAuthHandler added in v0.15.0

BearerTokenAuthHandler A dummy function to test the OpenAPI generation with bearer token auth. @ID bearerTokenAuthHandler @Summary bearer token handler @Description this is a multiline

description for the handler

@Error 409 Resource already exists

func DeprecatedHandler added in v0.16.0

DeprecatedHandler A dummy function to test the OpenAPI generation with deprecated tag. @Deprecated

func NoTagsHandler added in v0.15.0

NoTagsHandler A dummy function to test the OpenAPI generation without any tags in the comment.

func TagsHandler added in v0.15.0

TagsHandler A dummy function to test the OpenAPI generation with tags in the comment. @ID testHandler @Tag Test @Tag User @Summary test handler @Description this is a multiline @StatusCode 201

description for the handler @Error 409 Resource already exists

Types

type AuthRequestBody added in v0.15.0

type AuthRequestBody struct {
	Token string `json:"token" validate:"required"`
}

AuthRequestBody is a test struct for authenticated request body

type Params added in v0.15.0

type Params struct {
	ID        uuid.UUID `path:"id" description:"ID of the user" example:"1"`
	Gender    string    `query:"gender" description:"Gender of the user" example:"male"`
	RequestID string    `header:"X-Request-ID" description:"Request ID" example:"1234"`
	Active    bool      `query:"active" description:"Active status of the user" example:"true"`
	Page      int       `query:"page" description:"Page number" example:"1" default:"1"`
	Size      int64     `query:"size" description:"Page size" example:"10" default:"10"`
	Score     float64   `query:"score" description:"User score" example:"9.5" default:"10.0"`
}

type Receiver added in v0.15.0

type Receiver struct{}

Receiver A dummy struct to test the OpenAPI generation with receiver functions.

func (*Receiver) DeprecatedHandler added in v0.16.0

DeprecatedHandler A dummy function to test the OpenAPI generation with deprecated tag. @Deprecated

func (*Receiver) NoTagsHandler added in v0.15.0

NoTagsHandler A dummy function to test the OpenAPI generation without any tags in the comment.

func (*Receiver) TagsHandler added in v0.15.0

TagsHandler A dummy function to test the OpenAPI generation with tags in the comment with receiver functions. @ID testHandler @Deprecated @Tag Test @Tag User @Summary test handler @Description this is a multiline

description for the handler @Error 409 Resource already exists

type RequestBody added in v0.15.0

type RequestBody struct {
	Name        string `json:"name" description:"Name of the user" example:"John Doe" validate:"required"`
	Age         int    `json:"age" description:"Age of the user" example:"30"`
	Description string `json:"description" description:"description of the user" example:"A test user"`
}

type ResponseBody added in v0.15.0

type ResponseBody struct {
	ID          uuid.UUID `json:"id" description:"ID of the user" example:"1"`
	Name        string    `json:"name" description:"Name of the user" example:"John Doe"`
	Age         int       `json:"age" description:"Age of the user" example:"30"`
	Description string    `json:"description" description:"description of the user" example:"A test user"`
}

type TestApplication

type TestApplication struct {
	*simba.Application
	Server *httptest.Server
}

TestApplication represents a test application with additional testing utilities

func Default added in v0.10.0

func Default(opts ...settings.Option) *TestApplication

Default creates a new test application with default settings

func New

func New(opts ...settings.Option) *TestApplication

New creates a new test application with the given settings

func (*TestApplication) Client

func (a *TestApplication) Client() *http.Client

Client returns an HTTP client configured to work with the test server

func (*TestApplication) RunTest

func (a *TestApplication) RunTest(fn func())

RunTest runs a test function with a started test server and handles cleanup

func (*TestApplication) Start

func (a *TestApplication) Start()

Start starts the test server

func (*TestApplication) Stop

func (a *TestApplication) Stop()

Stop stops the test server

func (*TestApplication) URL

func (a *TestApplication) URL() string

URL returns the base URL of the test server

type User added in v0.15.0

type User struct {
	ID   int    `json:"id" description:"ID of the user" example:"1"`
	Name string `json:"name" description:"Name of the user" example:"John Doe"`
	Role string `json:"role" description:"Role of the user" example:"admin"`
}

func ApiKeyAuthFunc added in v0.15.0

func ApiKeyAuthFunc(ctx context.Context, apiKey string) (*User, error)

ApiKeyAuthFunc A dummy function to test the OpenAPI generation with api key auth. @APIKeyAuth "User" "sessionid" "cookie" "Session cookie"

func BasicAuthFunc added in v0.15.0

func BasicAuthFunc(ctx context.Context, username, password string) (*User, error)

func BearerAuthFunc added in v0.15.0

func BearerAuthFunc(ctx context.Context, token string) (*User, error)

BearerAuthFunc A dummy function to test the OpenAPI generation with bearer token auth. @BearerAuth "admin" "jwt" "Bearer token"

Jump to

Keyboard shortcuts

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