示例#1
0
def test_single_simple():
    config = ssh.Config(fileobj=StringIO("""\
  Host somewhere
  Hostname a.b.c.d
  User paul
  """))
    assert config.hosts == [
        ssh.Host(host='somewhere', hostname='a.b.c.d', user='******')
    ]
示例#2
0
def test_single_more_complex():
    config = ssh.Config(fileobj=StringIO("""\
  Host=somewhere
    Hostname = my.address.com
      Compression= no
    RequestTTY =auto
    ForwardX11 yes
    Ciphers [email protected]
  """))
    assert config.hosts == [
        ssh.Host('somewhere',
                 hostname='my.address.com',
                 compression=False,
                 requesttty='auto',
                 forwardx11=True,
                 ciphers='*****@*****.**')
    ]
    assert not config.chaussettes_hosts
示例#3
0
def test_chaussettes_option():
    config = ssh.Config(fileobj=StringIO("""\
  Host=somewhere
    #Chaussettes yes
    Hostname = my.address.com
      Compression= no
    RequestTTY =auto
    ForwardX11 no
    Ciphers [email protected]
  """))
    assert config.hosts == [
        ssh.Host('somewhere',
                 chaussettes=True,
                 hostname='my.address.com',
                 compression=False,
                 requesttty='auto',
                 forwardx11=False,
                 ciphers='*****@*****.**')
    ]
    assert config.chaussettes_hosts == config.hosts
示例#4
0
def test_multiple_simple():
    config = ssh.Config(fileobj=StringIO("""\

  Host somewhere
  Hostname a.b.c.d
  User paul

  #

  Host somewhere.else
  Hostname e.f
  Host somewhere.else.altogether
  Hostname g.h.i
  User peter
  """))
    assert config.hosts == [
        ssh.Host('somewhere', hostname='a.b.c.d', user='******'),
        ssh.Host('somewhere.else', hostname='e.f'),
        ssh.Host('somewhere.else.altogether', hostname='g.h.i', user='******')
    ]
示例#5
0
  def __init__(self):
    """ Setup the GUI and the business logic """
    # Basic setup
    self.indicator = appindicator.Indicator.new(
      self.APPINDICATOR_ID,
      self.CLOSED_ICON,
      appindicator.IndicatorCategory.SYSTEM_SERVICES)
    self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)

    # Build menu
    self.menu = gtk.Menu()

    # State of the connections: either 1 or 0
    self.connections = 0

    # Populate menu with ssh hosts
    config = ssh.Config(path.expanduser('~/.ssh/config'))
    self.selectable = []
    self.hosts = config.chaussettes_hosts
    for h in self.hosts:
      item = gtk.CheckMenuItem(
        '{}\n\t{}'.format(h.host, h.hostname) if h.hostname else
        h.host)
      item.connect('toggled', self.select, h)
      self.menu.append(item)
      self.selectable.append(item)

    # Quit
    self.menu.append(gtk.SeparatorMenuItem())
    item_quit = gtk.MenuItem('Quit')
    item_quit.connect('activate', self.quit)
    self.menu.append(item_quit)

    # Finish menu setup
    self.menu.show_all()
    self.indicator.set_menu(self.menu)
示例#6
0
def test_default_value():
    config = ssh.Config(fileobj=StringIO("Host=somewhere"))
    assert len(config.hosts) == 1
    h = config.hosts[0]
    assert h.forwardx11 is None