Skip to content

Commit e35e855

Browse files
author
Aaron Schlesinger
committed
fix(pkg/sshd/server_test.go): pass circuit to the server
1 parent e35609a commit e35e855

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

pkg/sshd/server_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@ func TestServer(t *testing.T) {
2929
}
3030
cfg.AddHostKey(key)
3131

32-
cxt := runServer(&cfg, t)
32+
c := NewCircuit()
33+
cxt := runServer(&cfg, c, t)
3334

3435
// Give server time to initialize.
3536
time.Sleep(200 * time.Millisecond)
3637

38+
if c.State() != ClosedState {
39+
t.Fatalf("circuit was not in closed state")
40+
}
41+
3742
// Connect to the server and issue env var set. This should return true.
3843
client, err := ssh.Dial("tcp", testingServerAddr, &ssh.ClientConfig{})
3944
if err != nil {
@@ -77,7 +82,11 @@ func sshTestingHostKey() (ssh.Signer, error) {
7782
return ssh.ParsePrivateKey([]byte(testingHostKey))
7883
}
7984

80-
func runServer(config *ssh.ServerConfig, t *testing.T) cookoo.Context {
85+
func sshTestingClientKey() (ssh.Signer, error) {
86+
return ssh.ParsePrivateKey([]byte(testingClientKey))
87+
}
88+
89+
func runServer(config *ssh.ServerConfig, c *Circuit, t *testing.T) cookoo.Context {
8190
reg, router, cxt := cookoo.Cookoo()
8291
cxt.Put(ServerConfig, config)
8392
cxt.Put(Address, testingServerAddr)
@@ -99,7 +108,7 @@ func runServer(config *ssh.ServerConfig, t *testing.T) cookoo.Context {
99108
})
100109

101110
go func() {
102-
if err := Serve(reg, router, cxt); err != nil {
111+
if err := Serve(reg, router, c, cxt); err != nil {
103112
t.Fatalf("Failed serving with %s", err)
104113
}
105114
}()

0 commit comments

Comments
 (0)