func (s *IntSuite) TestInteractive(c *check.C) {
	t := s.newTeleport(c, nil, true)
	defer t.Stop(true)

	sessionEndC := make(chan interface{}, 0)

	// get a reference to site obj:
	site := t.GetSiteAPI(Site)
	c.Assert(site, check.NotNil)

	personA := NewTerminal(250)
	personB := NewTerminal(250)

	// PersonA: SSH into the server, wait one second, then type some commands on stdin:
	openSession := func() {
		cl, err := t.NewClient(s.me.Username, Site, Host, t.GetPortSSHInt())
		c.Assert(err, check.IsNil)
		cl.Stdout = &personA
		cl.Stdin = &personA
		// Person A types something into the terminal (including "exit")
		personA.Type("\aecho hi\n\r\aexit\n\r\a")
		err = cl.SSH([]string{}, false)
		c.Assert(err, check.IsNil)
		sessionEndC <- true
	}

	// PersonB: wait for a session to become available, then join:
	joinSession := func() {
		var sessionID string
		for {
			time.Sleep(time.Millisecond)
			sessions, _ := site.GetSessions()
			if len(sessions) == 0 {
				continue
			}
			sessionID = string(sessions[0].ID)
			break
		}
		cl, err := t.NewClient(s.me.Username, Site, Host, t.GetPortSSHInt())
		c.Assert(err, check.IsNil)
		cl.Stdout = &personB
		for i := 0; i < 10; i++ {
			err = cl.Join(session.ID(sessionID), &personB)
			if err == nil {
				break
			}
		}
		c.Assert(err, check.IsNil)
	}

	go openSession()
	go joinSession()

	// wait for the session to end
	waitFor(sessionEndC, time.Second*10)

	// make sure the output of B is mirrored in A
	outputOfA := string(personA.Output(100))
	outputOfB := string(personB.Output(100))
	c.Assert(strings.Contains(outputOfA, outputOfB), check.Equals, true)
}
// TestInteractive covers SSH into shell and joining the same session from another client
TestInteractive covers SSH into shell and joining the same session from another client
// TestInteractive covers SSH into shell and joining the same session from another client
func (s *IntSuite) TestInteractive(c *check.C) {
	t := s.newTeleport(c, nil, true)
	defer t.Stop(true)
	sessionEndC := make(chan interface{}, 0)
	site := t.GetSiteAPI(Site)
	c.Assert(site, check.NotNil)
	personA := NewTerminal(250)
	personB := NewTerminal(250)
	openSession := func() {
		cl, err := t.NewClient(s.me.Username, Site, Host, t.GetPortSSHInt())
		c.Assert(err, check.IsNil)
		cl.Stdout = &personA
		cl.Stdin = &personA
		personA.Type("\aecho hi\n\r\aexit\n\r\a")
		err = cl.SSH([]string{}, false)
		c.Assert(err, check.IsNil)
		sessionEndC <- true
	}
	joinSession := func() {
		var sessionID string
		for {
			time.Sleep(time.Millisecond)
			sessions, _ := site.GetSessions()
			if len(sessions) == 0 {
				continue
			}
			sessionID = string(sessions[0].ID)
			break
		}
		cl, err := t.NewClient(s.me.Username, Site, Host, t.GetPortSSHInt())
		c.Assert(err, check.IsNil)
		cl.Stdout = &personB
		for i := 0; i < 10; i++ {
			err = cl.Join(session.ID(sessionID), &personB)
			if err == nil {
				break
			}
		}
		c.Assert(err, check.IsNil)
	}
	go openSession()
	go joinSession()
	waitFor(sessionEndC, time.Second*10)
	outputOfA := string(personA.Output(100))
	outputOfB := string(personB.Output(100))
	c.Assert(strings.Contains(outputOfA, outputOfB), check.Equals, true)
}
func ( s * IntSuite ) TestInteractive ( c * check . C ) { t := s . newTeleport ( c , nil , true ) defer t . Stop ( true ) sessionEndC := make ( chan interface { } , 0 ) site := t . GetSiteAPI ( Site ) c . Assert ( site , check . NotNil ) personA := NewTerminal ( 250 ) personB := NewTerminal ( 250 ) openSession := func ( ) { cl , err := t . NewClient ( s . me . Username , Site , Host , t . GetPortSSHInt ( ) ) c . Assert ( err , check . IsNil ) cl . Stdout = & personA cl . Stdin = & personA personA . Type ( " \a \n \r \a \n \r \a " ) err = cl . SSH ( [ ] string { } , false ) c . Assert ( err , check . IsNil ) sessionEndC <- true } joinSession := func ( ) { var sessionID string for { time . Sleep ( time . Millisecond ) sessions , _ := site . GetSessions ( ) if len ( sessions ) == 0 { continue } sessionID = string ( sessions [ 0 ] . ID ) break } cl , err := t . NewClient ( s . me . Username , Site , Host , t . GetPortSSHInt ( ) ) c . Assert ( err , check . IsNil ) cl . Stdout = & personB for i := 0 ; i < 10 ; i ++ { err = cl . Join ( session . ID ( sessionID ) , & personB ) if err == nil { break } } c . Assert ( err , check . IsNil ) } go openSession ( ) go joinSession ( ) waitFor ( sessionEndC , time . Second * 10 ) outputOfA := string ( personA . Output ( 100 ) ) outputOfB := string ( personB . Output ( 100 ) ) c . Assert ( strings . Contains ( outputOfA , outputOfB ) , check . Equals , true ) }
TestInteractive covers SSH into shell and joining the same session from another client
TestInteractive covers SSH into shell and joining the same session from another client
// get a reference to site obj: // PersonA: SSH into the server, wait one second, then type some commands on stdin: // Person A types something into the terminal (including "exit") // PersonB: wait for a session to become available, then join: // wait for the session to end // make sure the output of B is mirrored in A