1package cmd
 2
 3import (
 4	"os"
 5	"testing"
 6
 7	"github.com/charmbracelet/soft-serve/server/config"
 8	"github.com/charmbracelet/wish/testsession"
 9	"github.com/gliderlabs/ssh"
10)
11
12var ()
13
14func TestMiddleware(t *testing.T) {
15	t.Cleanup(func() {
16		os.RemoveAll("testmiddleware")
17	})
18	cfg := &config.Config{
19		Host: "localhost",
20		SSH: config.SSHConfig{
21			Port: 22223,
22		},
23		DataPath: "testmiddleware",
24	}
25	_ = testsession.New(t, &ssh.Server{
26		Handler: Middleware(cfg)(func(s ssh.Session) {
27			t.Run("TestCatConfig", func(t *testing.T) {
28				_, err := s.Write([]byte("cat config/config.json"))
29				if err == nil {
30					t.Errorf("Expected error, got nil")
31				}
32			})
33		}),
34	}, nil)
35}