func TestSSHKey(t *testing.T) { Convey("It should discover remote IP for tunneled connection", t, func() { srv := discovertest.Server{ "ssh": {{ Addr: "apple.rafal.grape.koding.me:2222", Local: false, }}, } l, err := srv.Start() So(err, ShouldBeNil) defer l.Close() k := &fakeKlient{ RemoteUsername: "******", Remotes: list.KiteInfos{{ ListMachineInfo: restypes.ListMachineInfo{ Hostname: "root", VMName: "remote", IP: l.Addr().String(), }, }}, } s := ssh.SSHKey{ Klient: k, } userhost, port, err := s.GetSSHAddr("remote") So(err, ShouldBeNil) So(userhost, ShouldEqual, "*****@*****.**") So(port, ShouldEqual, "2222") }) Convey("It should discover local IP for tunneled connection", t, func() { srv := discovertest.Server{ "ssh": {{ Addr: "127.0.0.1:2222", Local: true, }}, } l, err := srv.Start() So(err, ShouldBeNil) defer l.Close() k := &fakeKlient{ RemoteUsername: "******", Remotes: list.KiteInfos{{ ListMachineInfo: restypes.ListMachineInfo{ Hostname: "root", VMName: "local", IP: l.Addr().String(), }, }}, } s := ssh.SSHKey{ Klient: k, } userhost, port, err := s.GetSSHAddr("local") So(err, ShouldBeNil) So(userhost, ShouldEqual, "[email protected]") So(port, ShouldEqual, "2222") }) }