test

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func CreateTempAnsibleBootstrapDir(t *testing.T) string

CreateTempAnsibleBootstrapDir creates a temp Ansible bootstrap directory.

func CreateTempAnsibleDataDirectory

func CreateTempAnsibleDataDirectory(t *testing.T) string

CreateTempAnsibleDataDirectory creates a temp Ansible data directory.

func CreateTempAnsibleRemoteTmpDir

func CreateTempAnsibleRemoteTmpDir(t *testing.T) string

CreateTempAnsibleRemoteTmpDir creates a temp Ansible remote_tmp directory.

func GetCurrentUser

func GetCurrentUser(t *testing.T) *user.User

GetCurrentUser returns current user.

func GetDefaultSettingsForUser

func GetDefaultSettingsForUser(t *testing.T, user *user.User) *types.Defaults

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

func WriteTempPlaybook(t *testing.T, dirpath string) string

WriteTempPlaybook writes a temp playbook.

func WriteTempVaultIDFile

func WriteTempVaultIDFile(t *testing.T, password string) string

WriteTempVaultIDFile creates and writes a temporrary Vault ID password file.

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

type TestingSSHUser struct {
	Username  string
	PublicKey string
}

TestingSSHUser represents a user who can authenticate againstg the SSH server.

Jump to

Keyboard shortcuts

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