testhelpers

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

func NewAgent

func NewAgent(config *Config) (*Agent, error)

func (*Agent) GetToken

func (a *Agent) GetToken() string

GetToken returns the current token

func (*Agent) SendRequest

func (a *Agent) SendRequest(ctx context.Context, data string) (*Response, error)

SendRequest sends an authenticated request to the server

func (*Agent) Start

func (a *Agent) Start(ctx context.Context) error

Start initializes the agent and starts background tasks

func (*Agent) Stop

func (a *Agent) Stop()

Stop gracefully stops the agent

type Config

type Config struct {
	// Agent identification
	AgentID string

	// TLS configuration
	CertFile string
	KeyFile  string
	CAFile   string

	// Server connection
	ServerURL string
	Timeout   time.Duration

	// Retry configuration
	MaxRetries    int
	RetryInterval time.Duration
	BackoffFactor float64
	MaxBackoff    time.Duration

	// Keep-alive configuration
	KeepAlive         bool
	KeepAliveInterval time.Duration
}

func DefaultAgentConfig

func DefaultAgentConfig() *Config

DefaultConfig returns a default agent configuration

func (*Config) LoadTLSConfig

func (c *Config) LoadTLSConfig() (*tls.Config, error)

LoadTLSConfig creates a TLS configuration from the agent config

func (*Config) Validate

func (c *Config) Validate() error

type Request

type Request struct {
	AgentID string `json:"agent_id"`
	Data    string `json:"data,omitempty"`
}

Request represents a request to the server

type Response

type Response struct {
	Token   string `json:"token,omitempty"`
	Message string `json:"message"`
}

Response represents a response from the server

type Server

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

Server represents the authentication server

func NewServer

func NewServer(config *serverLib.Config) (*Server, error)

New creates a new Server instance with the provided configuration

func (*Server) Start

func (s *Server) Start() error

Start starts the server

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully stops the server

Jump to

Keyboard shortcuts

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