MCPcopy Index your code
hub / github.com/ContainerSSH/ContainerSSH / SSH

Function SSH

internal/test/ssh.go:33–63  ·  view source on GitHub ↗

SSH creates a fully functional SSH service which you can SSH into for testing purposes.

(t *testing.T)

Source from the content-addressed store, hash-verified

31
32// SSH creates a fully functional SSH service which you can SSH into for testing purposes.
33func SSH(t *testing.T) SSHHelper {
34 t.Helper()
35
36 username := "ubuntu"
37 password := "ubuntu"
38 files := dockerBuildRootFiles(sshBuildRoot, "ssh")
39 cnt := containerFromBuild(
40 t, "ssh", files, nil, []string{
41 fmt.Sprintf("SSH_USERNAME=%s", username),
42 fmt.Sprintf("SSH_PASSWORD=%s", password),
43 },
44 map[string]string{
45 "22/tcp": "",
46 },
47 )
48
49 hostKey := cnt.extractFile("/etc/ssh/ssh_host_rsa_key")
50 signer, err := ssh.ParsePrivateKey(hostKey)
51 if err != nil {
52 t.Fatalf("failed to parse SSH host key (%v)", err)
53 }
54
55 return &sshHelper{
56 username: username,
57 password: password,
58 hostKey: hostKey,
59 signer: signer,
60 fingerprint: ssh.FingerprintSHA256(signer.PublicKey()),
61 cnt: cnt,
62 }
63}
64
65type sshHelper struct {
66 username string

Callers 3

ConfigureBackendMethod · 0.92
TestSSHFunction · 0.92
TestConformanceFunction · 0.92

Calls 5

dockerBuildRootFilesFunction · 0.85
containerFromBuildFunction · 0.85
FatalfMethod · 0.80
extractFileMethod · 0.65
FingerprintSHA256Method · 0.65

Tested by 3

ConfigureBackendMethod · 0.74
TestSSHFunction · 0.74
TestConformanceFunction · 0.74