Documentation ¶
Index ¶
- Variables
- func CommandTest(t *testing.T, sshServer *TestingSSHServer, commandPrefix string)
- func CommandTestWithOptional(t *testing.T, sshServer *TestingSSHServer, ...) string
- func CreateTempAnsibleBootstrapDir(t *testing.T) string
- func CreateTempAnsibleDataDirectory(t *testing.T) string
- func CreateTempAnsibleRemoteTmpDir(t *testing.T) string
- func GetCurrentUser(t *testing.T) *user.User
- func GetDefaultSettingsForUser(t *testing.T, user *user.User) *types.Defaults
- func GetNewPlay(t *testing.T, raw map[string]interface{}, defaultSettings *types.Defaults) *types.Play
- func GetNewRemoteSettings(t *testing.T, raw map[string]interface{}) *types.RemoteSettings
- func GetNewSSHInstanceState(t *testing.T, sshUsername string) *terraform.InstanceState
- func GetPlayModuleSchema(t *testing.T, moduleName string) *schema.ResourceData
- func GetPlayPlaybookSchema(t *testing.T, playbookFilePath string) *schema.ResourceData
- func NewTestingSFTPFS(t *testing.T, serverConfig *TestingSSHServerConfig, ...) sftp.Handlers
- func WriteTempPlaybook(t *testing.T, dirpath string) string
- func WriteTempVaultIDFile(t *testing.T, password string) string
- type NotificationCommandExecuted
- type NotificationDirectoryCreated
- type NotificationDirectoryDeleted
- type NotificationFileRenamed
- type NotificationFileWritten
- type NotificationSymlinkCreated
- type TestingSSHServer
- type TestingSSHServerConfig
- type TestingSSHUser
Constants ¶
This section is empty.
Variables ¶
var ( // TestSSHHostKeyPrivate is an integration test host private key. TestSSHHostKeyPrivate = `` /* 3380-byte string literal not displayed */ // TestSSHHostKeyPublic is an integration test host public key. TestSSHHostKeyPublic = `` /* 739-byte string literal not displayed */ // TestSSHUserKeyPrivate is an integration test user private key. TestSSHUserKeyPrivate = `` /* 3380-byte string literal not displayed */ // TestSSHUserKeyPublic is an integration test user public key. TestSSHUserKeyPublic = `` /* 739-byte string literal not displayed */ // CommandWaitTimeoutDuration specifies how long the test awaits for a notification from the SSH server. // External CI (Travis, CircleCI) requires long timeouts, locally these will always be much faster. CommandWaitTimeoutDuration = time.Duration(60) * time.Second // ServerWaitTimeoutDuration specifies how long the test awaits for the SSH server to start. ServerWaitTimeoutDuration = time.Duration(10) * time.Second )
Functions ¶
func CommandTest ¶
func CommandTest(t *testing.T, sshServer *TestingSSHServer, commandPrefix string)
CommandTest tests an SSH server output channel for a command.
func CommandTestWithOptional ¶
func CommandTestWithOptional(t *testing.T, sshServer *TestingSSHServer, commandPrefix1, commandPrefix2 string) string
CommandTestWithOptional tests an SSH server output channel for optional first given command. If first command was not matched, the second must match. If second command was matched, all input is considered matched. This function is used for optionally handling the interpreter discovery command in the local provisioner tests. https://github.com/ansible/ansible/blob/3e9943bc5e7a9cd393757aa8100d7fed80bd316e/lib/ansible/executor/interpreter_discovery.py#L65
func CreateTempAnsibleBootstrapDir ¶
CreateTempAnsibleBootstrapDir creates a temp Ansible bootstrap directory.
func CreateTempAnsibleDataDirectory ¶
CreateTempAnsibleDataDirectory creates a temp Ansible data directory.
func CreateTempAnsibleRemoteTmpDir ¶
CreateTempAnsibleRemoteTmpDir creates a temp Ansible remote_tmp directory.
func GetCurrentUser ¶
GetCurrentUser returns current user.
func GetDefaultSettingsForUser ¶
GetDefaultSettingsForUser returns default settings in the context of a given user.
func GetNewPlay ¶
func GetNewPlay(t *testing.T, raw map[string]interface{}, defaultSettings *types.Defaults) *types.Play
GetNewPlay returns *types.Play from a raw map using th default settings.
func GetNewRemoteSettings ¶
func GetNewRemoteSettings(t *testing.T, raw map[string]interface{}) *types.RemoteSettings
GetNewRemoteSettings returns *types.RemoteSettings from a raw map.
func GetNewSSHInstanceState ¶
func GetNewSSHInstanceState(t *testing.T, sshUsername string) *terraform.InstanceState
GetNewSSHInstanceState returns a new instance of *teraform.InstanceState for a given SSH username.
func GetPlayModuleSchema ¶
func GetPlayModuleSchema(t *testing.T, moduleName string) *schema.ResourceData
GetPlayModuleSchema returns a Terraform *schema.ResourceData for a given module name.
func GetPlayPlaybookSchema ¶
func GetPlayPlaybookSchema(t *testing.T, playbookFilePath string) *schema.ResourceData
GetPlayPlaybookSchema returns a Terraform *schema.ResourceData for a given playbook file path.
func NewTestingSFTPFS ¶
func NewTestingSFTPFS(t *testing.T, serverConfig *TestingSSHServerConfig, chanNotifications chan interface{}) sftp.Handlers
NewTestingSFTPFS returns a Hanlders object with the test handlers.
func WriteTempPlaybook ¶
WriteTempPlaybook writes a temp playbook.
Types ¶
type NotificationCommandExecuted ¶
type NotificationCommandExecuted struct {
Command string
}
NotificationCommandExecuted is a test SSH server command execution notification.
type NotificationDirectoryCreated ¶
type NotificationDirectoryCreated struct {
MemFile *memFile
}
NotificationDirectoryCreated is a test SFTP file system dirctory created notification.
type NotificationDirectoryDeleted ¶
type NotificationDirectoryDeleted struct {
MemFile *memFile
}
NotificationDirectoryDeleted is a test SFTP file system dirctory deleted notification.
type NotificationFileRenamed ¶
type NotificationFileRenamed struct { MemFile *memFile SourcePath string }
NotificationFileRenamed is a test SFTP file system file renamed notification.
type NotificationFileWritten ¶
type NotificationFileWritten struct {
MemFile *memFile
}
NotificationFileWritten is a test SFTP file system file written notification.
type NotificationSymlinkCreated ¶
type NotificationSymlinkCreated struct {
MemFile *memFile
}
NotificationSymlinkCreated is a test SFTP file system symlink created notification.
type TestingSSHServer ¶
type TestingSSHServer struct {
// contains filtered or unexported fields
}
TestingSSHServer represents an instancde of the testing SFTP server.
func GetConfiguredAndRunningSSHServer ¶
func GetConfiguredAndRunningSSHServer(t *testing.T, serverID string, localMode bool, instanceState *terraform.InstanceState, output terraform.UIOutput) *TestingSSHServer
GetConfiguredAndRunningSSHServer returns a running instance of a *TestingSSHServer.
func NewTestingSSHServer ¶
func NewTestingSSHServer(t *testing.T, c *TestingSSHServerConfig) *TestingSSHServer
NewTestingSSHServer creates an instance of the TestingSSHServer.
func (*TestingSSHServer) ListeningHostPort ¶
func (s *TestingSSHServer) ListeningHostPort() (host, port string, err error)
ListeningHostPort returns the host port of an address underlying listener is bound on, or error if server is not started.
func (*TestingSSHServer) Notifications ¶
func (s *TestingSSHServer) Notifications() <-chan interface{}
Notifications returns a channel used for delivering the file SFTP event notifications.
func (*TestingSSHServer) ReadyNotify ¶
func (s *TestingSSHServer) ReadyNotify() <-chan struct{}
ReadyNotify returns a channel that will be closed when the server is ready to serve client requests.
func (*TestingSSHServer) Start ¶
func (s *TestingSSHServer) Start()
Start starts the TestingSSHServer instance.
func (*TestingSSHServer) Stop ¶
func (s *TestingSSHServer) Stop()
Stop stops the TestingSSHServer instance.
type TestingSSHServerConfig ¶
type TestingSSHServerConfig struct { ServerID string HostKey string HostPort string AuthenticatedUsers []*TestingSSHUser Listeners int Output terraform.UIOutput LogPrintln bool LocalMode bool }
TestingSSHServerConfig is an SSH server configuration.
type TestingSSHUser ¶
TestingSSHUser represents a user who can authenticate againstg the SSH server.