Documentation ¶
Overview ¶
Package testbase provides a unit test infrastructure and a mock AccountProvider.
Index ¶
- Variables
- func RunCases(t *testing.T, cases []TestCase)
- type FailureCase
- type MockProvider
- func (m *MockProvider) AuthorizedKeys(username string) ([]string, error)
- func (m *MockProvider) GroupByGID(gid uint32) (*accounts.Group, error)
- func (m *MockProvider) GroupByName(name string) (*accounts.Group, error)
- func (m *MockProvider) Groups() ([]*accounts.Group, error)
- func (m *MockProvider) IsName(name string) (bool, error)
- func (m *MockProvider) Names() ([]string, error)
- func (m *MockProvider) UserByName(name string) (*accounts.User, error)
- func (m *MockProvider) UserByUID(uid uint32) (*accounts.User, error)
- func (m *MockProvider) Users() ([]*accounts.User, error)
- type SuccessCase
- type TestCase
Constants ¶
This section is empty.
Variables ¶
View Source
var ExpGroups = []*accounts.Group{ &accounts.Group{ Name: "group1", GID: 1000, Members: []string(nil), }, &accounts.Group{ Name: "group2", GID: 1001, Members: []string{"user2", "user1"}, }, }
ExpGoups is sample group data.
View Source
var ExpKeys = map[string][]string{ "user1": []string{ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCbfMeFT1HFEF4NUfGY1N5xV59DcUSD0wrQ+PLshX3zNseddAq0mPRs1+rLwzH53GFzJu7p9gO2tODz1HanSSVhPXN5GuMVBA/9fZCmSkcsU18v machine1", "ssh-rsa AAAAB3NzaC1yc2EAAAADvUTKEXOxhMCs2MGQyRe1hWfS1wqTuhskuFlw7+iyyvgw2KQDKfJod4DiyXQpNF5361PrfduTF/T5I+tanSSVhPXN5GuMVBA/9fZCmSkcsU18v machine2", }, "user3": []string{ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCbfMeFT1HFEF4NUfGY1N5xV59DcUSD0wrQ+p9gO2tODz1HanSSVhPXN5GuMVBA/9fZCmSkcsU18v machine3", "ssh-rsa AAAAB3NzaC1yc2EAAAADvUTKEXOxhMCs2MGQyRe1hWfS1wqTuhskuFlw7+iyyvgwuTF/T5I+tanSSVhPXN5GuMVBA/9fZCmSkcsU18v machine4", }, }
ExpKeys is sample key data.
View Source
var ExpNames = []string{"group1", "group2", "user1", "user2"}
ExpNames is sample name data.
View Source
var ExpUsers = []*accounts.User{ &accounts.User{ Name: "user1", UID: 1001, GID: 1000, Gecos: "John Doe", HomeDirectory: "/home/user1", Shell: "/bin/bash", }, &accounts.User{ Name: "user2", UID: 1002, GID: 1000, Gecos: "Jane Doe", HomeDirectory: "/home/user2", Shell: "/bin/zsh", }, }
ExpUsers is sample user data.
Functions ¶
Types ¶
type FailureCase ¶
A FailureCase is a test case which is expected to return an error.
type MockProvider ¶
type MockProvider struct { Err error Usrs []*accounts.User Grps []*accounts.Group Nams []string Keys map[string][]string }
A MockProvider is an AccountProvider used for testing.
func (*MockProvider) AuthorizedKeys ¶
func (m *MockProvider) AuthorizedKeys(username string) ([]string, error)
AuthorizedKeys satisfies AccountProvider.
func (*MockProvider) GroupByGID ¶
func (m *MockProvider) GroupByGID(gid uint32) (*accounts.Group, error)
GroupByGID satisfies AccountProvider.
func (*MockProvider) GroupByName ¶
func (m *MockProvider) GroupByName(name string) (*accounts.Group, error)
GroupByName satisfies AccountProvider.
func (*MockProvider) Groups ¶
func (m *MockProvider) Groups() ([]*accounts.Group, error)
Groups satisfies AccountProvider.
func (*MockProvider) IsName ¶
func (m *MockProvider) IsName(name string) (bool, error)
IsName satisfies AccountProvider.
func (*MockProvider) Names ¶
func (m *MockProvider) Names() ([]string, error)
Names satisfies AccountProvider.
func (*MockProvider) UserByName ¶
func (m *MockProvider) UserByName(name string) (*accounts.User, error)
UserByName satisfies AccountProvider.
type SuccessCase ¶
A SuccessCase is a test case which is expected to return successfully.
Click to show internal directories.
Click to hide internal directories.