Documentation ¶
Overview ¶
Package utils contains the internal test utils
Package utils contains the internal test utils
Index ¶
- Variables
- func TestBinaryDataDecoder(ptr pam.BinaryPointer) ([]byte, error)
- func TestBinaryDataEncoder(bytes []byte) []byte
- func WithWorkDir() withWorkDir
- type Action
- type BaseModule
- func (h *BaseModule) AcctMgmt(pam.ModuleTransaction, pam.Flags, []string) error
- func (h *BaseModule) Authenticate(pam.ModuleTransaction, pam.Flags, []string) error
- func (h *BaseModule) ChangeAuthTok(pam.ModuleTransaction, pam.Flags, []string) error
- func (h *BaseModule) CloseSession(pam.ModuleTransaction, pam.Flags, []string) error
- func (h *BaseModule) OpenSession(pam.ModuleTransaction, pam.Flags, []string) error
- func (h *BaseModule) SetCred(pam.ModuleTransaction, pam.Flags, []string) error
- type BinaryTransaction
- type Control
- type Credentials
- type FallBackModule
- type SerializableError
- type ServiceLine
- type TestSetup
- func (ts *TestSetup) CreateService(serviceName string, services []ServiceLine) string
- func (ts *TestSetup) CreateTemporaryDir(basename string) string
- func (ts *TestSetup) GenerateModule(testModulePath string, moduleName string) string
- func (ts *TestSetup) GenerateModuleDefault(testModulePath string) string
- func (ts TestSetup) GetCurrentFile() string
- func (ts TestSetup) GetCurrentFileDir() string
- func (ts TestSetup) WorkDir() string
Constants ¶
This section is empty.
Variables ¶
var Actions = map[string]Action{ Account.String(): Account, Auth.String(): Auth, Password.String(): Password, Session.String(): Session, }
Actions is a map with all the available Actions by their name.
Functions ¶
func TestBinaryDataDecoder ¶
TestBinaryDataDecoder decodes a test binary data.
func TestBinaryDataEncoder ¶
TestBinaryDataEncoder encodes a test binary data.
func WithWorkDir ¶
func WithWorkDir() withWorkDir
Types ¶
type BaseModule ¶
type BaseModule struct{}
BaseModule is the type for a base PAM module.
func (*BaseModule) AcctMgmt ¶
func (h *BaseModule) AcctMgmt(pam.ModuleTransaction, pam.Flags, []string) error
AcctMgmt is the handler function for PAM AcctMgmt.
func (*BaseModule) Authenticate ¶
func (h *BaseModule) Authenticate(pam.ModuleTransaction, pam.Flags, []string) error
Authenticate is the handler function for PAM Authenticate.
func (*BaseModule) ChangeAuthTok ¶
func (h *BaseModule) ChangeAuthTok(pam.ModuleTransaction, pam.Flags, []string) error
ChangeAuthTok is the handler function for PAM ChangeAuthTok.
func (*BaseModule) CloseSession ¶
func (h *BaseModule) CloseSession(pam.ModuleTransaction, pam.Flags, []string) error
CloseSession is the handler function for PAM CloseSession.
func (*BaseModule) OpenSession ¶
func (h *BaseModule) OpenSession(pam.ModuleTransaction, pam.Flags, []string) error
OpenSession is the handler function for PAM OpenSession.
func (*BaseModule) SetCred ¶
func (h *BaseModule) SetCred(pam.ModuleTransaction, pam.Flags, []string) error
SetCred is the handler function for PAM SetCred.
type BinaryTransaction ¶
type BinaryTransaction struct { ExpectedNull bool ReturnedData []byte // contains filtered or unexported fields }
BinaryTransaction represents a binary PAM transaction handler struct.
func NewBinaryTransactionWithData ¶
func NewBinaryTransactionWithData(data []byte, retData []byte) BinaryTransaction
NewBinaryTransactionWithData creates a new [pam.BinaryTransaction] from bytes.
func NewBinaryTransactionWithRandomData ¶
func NewBinaryTransactionWithRandomData(size uint8, retData []byte) BinaryTransaction
NewBinaryTransactionWithRandomData creates a new [pam.BinaryTransaction] with random data.
func (BinaryTransaction) Data ¶
func (b BinaryTransaction) Data() []byte
Data returns the bytes of the transaction.
func (BinaryTransaction) RespondPAM ¶
func (b BinaryTransaction) RespondPAM(s pam.Style, msg string) (string, error)
RespondPAM (not) handles the PAM string conversations.
func (BinaryTransaction) RespondPAMBinary ¶
func (b BinaryTransaction) RespondPAMBinary(ptr pam.BinaryPointer) ([]byte, error)
RespondPAMBinary handles the PAM binary conversations.
type Control ¶
type Control int
Control represents how a PAM module should controlled in PAM service file.
type Credentials ¶
type Credentials struct { User string Password string EchoOn string EchoOff string TextInfo string ErrorMsg string ExpectedMessage string CheckEmptyMessage bool ExpectedStyle pam.Style CheckZeroStyle bool Context interface{} }
Credentials is a test [pam.ConversationHandler] implementation.
func (Credentials) RespondPAM ¶
func (c Credentials) RespondPAM(s pam.Style, msg string) (string, error)
RespondPAM handles PAM string conversations.
type FallBackModule ¶
type FallBackModule int
FallBackModule is a type to represent the module that should be used as fallback.
const ( // NoFallback add no fallback module. NoFallback FallBackModule = iota + 1 // Permit uses a module that always permits. Permit // Deny uses a module that always denys. Deny )
func (FallBackModule) String ¶
func (a FallBackModule) String() string
type SerializableError ¶
type SerializableError struct {
Msg string
}
SerializableError is a representation of an error in a way can be serialized.
func (*SerializableError) Error ¶
func (e *SerializableError) Error() string
type ServiceLine ¶
ServiceLine is the representation of a PAM module service file line.
type TestSetup ¶
type TestSetup struct {
// contains filtered or unexported fields
}
TestSetup is an utility type for having a playground for test PAM modules.
func NewTestSetup ¶
NewTestSetup creates a new TestSetup.
func (*TestSetup) CreateService ¶
func (ts *TestSetup) CreateService(serviceName string, services []ServiceLine) string
CreateService creates a service file.
func (*TestSetup) CreateTemporaryDir ¶
CreateTemporaryDir creates a temporary directory with provided basename.
func (*TestSetup) GenerateModule ¶
GenerateModule generates a PAM module for the provided path and name.
func (*TestSetup) GenerateModuleDefault ¶
GenerateModuleDefault generates a default module.
func (TestSetup) GetCurrentFile ¶
GetCurrentFile returns the current file path.
func (TestSetup) GetCurrentFileDir ¶
GetCurrentFileDir returns the current file directory.