(t *testing.T)
| 599 | } |
| 600 | |
| 601 | func TestMultipleRecorders(t *testing.T) { |
| 602 | if runtime.GOOS != "linux" && runtime.GOOS != "darwin" { |
| 603 | t.Skipf("skipping on %q; only runs on linux and darwin", runtime.GOOS) |
| 604 | } |
| 605 | done := make(chan struct{}) |
| 606 | recordingServer := mockRecordingServer(t, func(w http.ResponseWriter, r *http.Request) { |
| 607 | defer close(done) |
| 608 | w.WriteHeader(http.StatusOK) |
| 609 | w.(http.Flusher).Flush() |
| 610 | io.ReadAll(r.Body) |
| 611 | }) |
| 612 | badRecorder, err := net.Listen("tcp", ":0") |
| 613 | if err != nil { |
| 614 | t.Fatal(err) |
| 615 | } |
| 616 | badRecorderAddr := badRecorder.Addr().String() |
| 617 | badRecorder.Close() |
| 618 | |
| 619 | badRecordingServer500 := mockRecordingServer(t, func(w http.ResponseWriter, r *http.Request) { |
| 620 | w.WriteHeader(http.StatusInternalServerError) |
| 621 | }) |
| 622 | |
| 623 | s := &server{ |
| 624 | logf: tstest.WhileTestRunningLogger(t), |
| 625 | lb: &localState{ |
| 626 | sshEnabled: true, |
| 627 | varRoot: t.TempDir(), |
| 628 | matchingRule: newSSHRule( |
| 629 | &tailcfg.SSHAction{ |
| 630 | Accept: true, |
| 631 | Recorders: []netip.AddrPort{ |
| 632 | netip.MustParseAddrPort(badRecorderAddr), |
| 633 | netip.MustParseAddrPort(badRecordingServer500.Listener.Addr().String()), |
| 634 | netip.MustParseAddrPort(recordingServer.Listener.Addr().String()), |
| 635 | }, |
| 636 | OnRecordingFailure: &tailcfg.SSHRecorderFailureAction{ |
| 637 | RejectSessionWithMessage: "session rejected", |
| 638 | TerminateSessionWithMessage: "session terminated", |
| 639 | }, |
| 640 | }, |
| 641 | ), |
| 642 | }, |
| 643 | } |
| 644 | defer s.Shutdown() |
| 645 | |
| 646 | src, dst := must.Get(netip.ParseAddrPort("100.100.100.101:2231")), must.Get(netip.ParseAddrPort("100.100.100.102:22")) |
| 647 | sc, dc := memnet.NewTCPConn(src, dst, 1024) |
| 648 | |
| 649 | const sshUser = "alice" |
| 650 | cfg := &testssh.ClientConfig{ |
| 651 | User: sshUser, |
| 652 | HostKeyCallback: testssh.InsecureIgnoreHostKey(), |
| 653 | } |
| 654 | |
| 655 | var wg sync.WaitGroup |
| 656 | wg.Go(func() { |
| 657 | c, chans, reqs, err := testssh.NewClientConn(sc, sc.RemoteAddr().String(), cfg) |
| 658 | if err != nil { |
nothing calls this directly
no test coverage detected
searching dependent graphs…