2 # Martin Gracik <mgracik@redhat.com>
4 # Copyright 2009 Red Hat, Inc.
6 # This copyrighted material is made available to anyone wishing to use, modify,
7 # copy, or redistribute it subject to the terms and conditions of the GNU
8 # General Public License v.2. This program is distributed in the hope that it
9 # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10 # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # See the GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License along with
14 # this program; if not, write to the Free Software Foundation, Inc., 51
15 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16 # trademarks that are incorporated in the source code or documentation are not
17 # subject to the GNU General Public License and may only be used or replicated
18 # with the express permission of Red Hat, Inc.
22 from tests
.baseclass
import *
24 class FC3_TestCase(CommandTest
):
30 if "--service" in self
.optionList
:
31 self
.assert_parse("firewall --enabled --trust=eth0 --ssh --port=imap:tcp",
32 "firewall --enabled --port=imap:tcp --trust=eth0 --service=ssh\n")
33 self
.assert_parse("firewall --enabled --ssh --ftp", "firewall --enabled --service=ssh,ftp\n")
35 self
.assert_parse("firewall --enabled --trust=eth0 --ssh --port=imap:tcp",
36 "firewall --enabled --port=22:tcp,imap:tcp --trust=eth0\n")
37 self
.assert_parse("firewall --enable --port=1234:udp,4321:tcp", "firewall --enabled --port=1234:udp,4321:tcp\n")
39 if "--telnet" in self
.optionList
:
40 self
.assert_parse("firewall --enable --trust=eth0,eth1 --ssh --telnet --http --smtp --ftp --port=1234:udp"
41 "firewall --enabled --port=22:tcp,23:tcp,80:tcp,443:tcp,25:tcp,21:tcp,1234:udp --trust=eth0,eth1\n")
42 elif "--service" in self
.optionList
:
43 self
.assert_parse("firewall --enable --trust=eth0,eth1 --ssh --http --smtp --ftp --port=1234:udp"
44 "firewall --enabled --port=1234:udp --trust=eth0,eth1 --service=ssh,http,smtp,ftp\n")
47 if "--remove-service" in self
.optionList
:
48 self
.assert_parse("firewall --remove-service=mdns",
49 "firewall --remove-service=mdns\n") # remove only
50 # service & remove service at once
51 self
.assert_parse("firewall --service=ssh --remove-service=mdns",
52 "firewall --service=ssh --remove-service=mdns\n")
53 # with alternative service notation
54 self
.assert_parse("firewall --ssh --smtp --ftp --remove-service=mdns",
55 "firewall --ssh --smtp --ftp --remove-service=mdns\n")
56 # multiple remove & remove ssh
57 self
.assert_parse("firewall --service=mdns --remove-service=dhcpv6-client --remove-service=ssh",
58 "firewall --service=mdns --remove-service=dhcpv6-client --remove-service=ssh\n")
61 self
.assert_parse("firewall --disabled", "firewall --disabled\n")
62 self
.assert_parse("firewall --disable", "firewall --disabled\n")
65 self
.assert_parse("firewall --trust=eth0", "firewall --enabled --trust=eth0\n")
66 self
.assert_parse("firewall", "firewall --enabled\n")
69 if "--high" in self
.optionList
:
70 self
.assert_deprecated("firewall", "--high")
71 if "--medium" in self
.optionList
:
72 self
.assert_deprecated("firewall", "--medium")
76 self
.assert_parse_error("firewall --bad-flag", KickstartParseError
)
78 self
.assert_parse_error("firewall arg", KickstartValueError
)
80 class F9_TestCase(FC3_TestCase
):
83 FC3_TestCase
.runTest(self
)
86 self
.assert_removed("firewall", "--high")
87 self
.assert_removed("firewall", "--medium")
89 class F10_TestCase(F9_TestCase
):
91 F9_TestCase
.runTest(self
)
94 self
.assert_deprecated("firewall", "--telnet")
96 class F14_TestCase(F10_TestCase
):
98 F10_TestCase
.runTest(self
)
101 self
.assert_removed("firewall", "--telnet")
103 if __name__
== "__main__":