File: test_invalid_tcp.py

package info (click to toggle)
nufw 2.4.3-2.2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 5,728 kB
  • sloc: ansic: 32,174; sh: 10,146; python: 4,176; makefile: 965; perl: 630; lex: 176; php: 168; yacc: 117; xml: 34
file content (30 lines) | stat: -rwxr-xr-x 888 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/python
from unittest import TestCase, main
from common import startNufw, connectClient
from nuauth import Nuauth
from nuauth_conf import NuauthConf
from inl_tests.iptables import Iptables
from mysocket import connectTcp
from filter import testAllowPort, HOST, VALID_PORT, TIMEOUT

class TestSYNACKignore(TestCase):
    def setUp(self):
        self.iptables = Iptables()
        self.iptables.command('-A OUTPUT -p tcp --sport %u -d %s --tcp-flags SYN,ACK SYN,ACK -j NFQUEUE' % (VALID_PORT, HOST))
        config = NuauthConf()

        self.nuauth = Nuauth(config)
        self.nufw = startNufw()

    def tearDown(self):
        self.nuauth.stop()
        self.iptables.flush()

    def testsynack(self):
        # Create socket
        self.assertEqual(connectTcp(HOST, VALID_PORT, TIMEOUT), True)

if __name__ == "__main__":
    print "Test TCP SYN ACK packet"
    main()