()
| 102 | } |
| 103 | |
| 104 | func (c *testContext) StartContainerSSH() { |
| 105 | t := c.T |
| 106 | t.Helper() |
| 107 | c.lock.Lock() |
| 108 | defer c.lock.Unlock() |
| 109 | |
| 110 | if c.lifecycle != nil { |
| 111 | t.Fatalf("ContainerSSH is already running.") |
| 112 | } |
| 113 | |
| 114 | t.Logf("Starting ContainerSSH...") |
| 115 | |
| 116 | c.authPort = test.GetNextPort(c.T, "auth server") |
| 117 | c.authServer(c.T, c.users, c.authPort) |
| 118 | c.cfg.Auth.PasswordAuth.Method = config.PasswordAuthMethodWebhook |
| 119 | c.cfg.Auth.PasswordAuth.Webhook.URL = fmt.Sprintf("http://127.0.0.1:%d", c.authPort) |
| 120 | c.cfg.Auth.PublicKeyAuth.Method = config.PubKeyAuthMethodWebhook |
| 121 | c.cfg.Auth.PublicKeyAuth.Webhook.URL = fmt.Sprintf("http://127.0.0.1:%d", c.authPort) |
| 122 | |
| 123 | c.sshPort = test.GetNextPort(c.T, "ContainerSSH") |
| 124 | c.cfg.SSH.Listen = fmt.Sprintf("127.0.0.1:%d", c.sshPort) |
| 125 | if err := c.cfg.SSH.GenerateHostKey(); err != nil { |
| 126 | t.Fatalf("Failed to generate host keys (%v)", err) |
| 127 | } |
| 128 | c.cfg.Log.T = c.T |
| 129 | c.cfg.Log.Destination = config.LogDestinationTest |
| 130 | |
| 131 | cssh, lifecycle, err := containerssh.New(c.cfg, log.NewLoggerFactory()) |
| 132 | if err != nil { |
| 133 | t.Fatalf("Failed to start ContainerSSH (%v)", err) |
| 134 | } |
| 135 | c.lifecycle = lifecycle |
| 136 | running := make(chan struct{}) |
| 137 | stopped := make(chan struct{}) |
| 138 | crashed := make(chan struct{}) |
| 139 | lifecycle.OnRunning( |
| 140 | func(s service.Service, l service.Lifecycle) { |
| 141 | close(running) |
| 142 | }, |
| 143 | ) |
| 144 | lifecycle.OnStopping( |
| 145 | func(s service.Service, l service.Lifecycle, shutdownContext context.Context) { |
| 146 | close(stopped) |
| 147 | }, |
| 148 | ) |
| 149 | lifecycle.OnCrashed( |
| 150 | func(s service.Service, l service.Lifecycle, err error) { |
| 151 | close(crashed) |
| 152 | }, |
| 153 | ) |
| 154 | go func() { |
| 155 | _ = cssh.RunWithLifecycle(lifecycle) |
| 156 | }() |
| 157 | c.T.Cleanup(func() { |
| 158 | lifecycle.Stop(context.Background()) |
| 159 | }) |
| 160 | |
| 161 | select { |
nothing calls this directly
no test coverage detected