summaryrefslogtreecommitdiff
path: root/tests-debian-base-install.py
blob: b2bcfcd2970195331c1148000ac238cafa819849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright 2011  Lars Wirzenius
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


'''Tests for a Debian base install, with openssh-server installed.'''


import systest


class DebianBasePlusOpenSshServerTests(systest.TestCase):

    def test_only_ssh_port(self):
        self.assertEqual(self.find_open_ports(), ['22/tcp'])

    def test_ssh_login(self):
        user = self.settings['user']
        out = self.targetcmd(['id'])
        self.assertMatches(r'^uid=\d+\(%s\)' % user, out)

    def test_simple_dns_lookup(self):
        out = self.targetcmd(['host', 'www.debian.org'])
        self.assert_('www.debian.org' in out)
        
    def test_ping_localhost(self):
        self.targetcmd(['ping', '-c1', 'localhost'])
        
    def test_ping6_localhost(self):
        self.targetcmd(['ping6', '-c1', 'ip6-localhost'])
        
    def test_cat(self):
        out = self.targetcmd(['cat'], stdin='foo')
        self.assertEqual(out, 'foo')

    def test_sudo(self):
        out = self.targetcmd(['sudo', '-S', 'id'], 
                             stdin='%s\n' % self.settings['user-password'])
        self.assertMatches(r'^uid=0\(root\)', out)