Exemplo n.º 1
0
	def test_long_header_line(self):
		"""Test message parsing with a very long header line"""
		msgType, firstLine, headers, body = parseSipMessage(
			"INVITE sip:foo SIP/2.0\n" + \
			"From: " + "x" * 1000)

		assert_equals(msgType, "INVITE")
		assert_equals(firstLine, "sip:foo SIP/2.0")
		assert_equals(headers["from"], "x" * 1000)
Exemplo n.º 2
0
    def test_long_header_line(self):
        """Test message parsing with a very long header line"""
        msgType, firstLine, headers, body = parseSipMessage(
         "INVITE sip:foo SIP/2.0\n" + \
         "From: " + "x" * 1000)

        assert_equals(msgType, "INVITE")
        assert_equals(firstLine, "sip:foo SIP/2.0")
        assert_equals(headers["from"], "x" * 1000)
Exemplo n.º 3
0
	def test_correct_parsing_empty_body(self):
		"""Test message parsing for correctness with an empty body"""
		msgType, firstLine, headers, body = parseSipMessage(
			"""INVITE sip:foo SIP/2.0
			f: test
			t: foo
			l: 0""")

		assert_equals(msgType, "INVITE")
		assert_equals(firstLine, "sip:foo SIP/2.0")
		assert_equals(headers["from"], "test")
		assert_equals(headers["to"], "foo")
		assert_equals(headers["content-length"], "0")
		assert_equals(body, "")
Exemplo n.º 4
0
	def test_correct_parsing_short_headers(self):
		"""Test message parsing for correctness with short headers"""
		msgType, firstLine, headers, body = parseSipMessage(
			"""INVITE sip:foo SIP/2.0
			f: test
			t: foo
			l: 4\n\n1234""")

		assert_equals(msgType, "INVITE")
		assert_equals(firstLine, "sip:foo SIP/2.0")
		assert_equals(headers["from"], "test")
		assert_equals(headers["to"], "foo")
		assert_equals(headers["content-length"], "4")
		assert_equals(body, "1234")
Exemplo n.º 5
0
	def test_correct_parsing(self):
		"""Test normal message parsing for correctness"""
		msgType, firstLine, headers, body = parseSipMessage(
			"""INVITE sip:foo SIP/2.0
			From: test
			To: foo
			Content-Length: 4\n\n1234""")

		assert_equals(msgType, "INVITE")
		assert_equals(firstLine, "sip:foo SIP/2.0")
		assert_equals(headers["from"], "test")
		assert_equals(headers["to"], "foo")
		assert_equals(headers["content-length"], "4")
		assert_equals(body, "1234")
Exemplo n.º 6
0
	def test_multiple_via_headers(self):
		"""Test SIP message parsing with multiple Via header lines"""
		headers = parseSipMessage("""OPTIONS sip:foo SIP/2.0
			f: test
			v: SIP/2.0/UDP proxyA.domain
			t: foo
			v: SIP/2.0/UDP proxyB.domain
			l:0""")[2]

		assert_equals(headers["from"], "test")
		assert_equals(headers["to"], "foo")
		assert_equals(headers["via"][0], "SIP/2.0/UDP proxyA.domain")
		assert_equals(headers["via"][1], "SIP/2.0/UDP proxyB.domain")
		assert_equals(headers["content-length"], "0")
Exemplo n.º 7
0
    def test_correct_parsing_empty_body(self):
        """Test message parsing for correctness with an empty body"""
        msgType, firstLine, headers, body = parseSipMessage(
            """INVITE sip:foo SIP/2.0
			f: test
			t: foo
			l: 0""")

        assert_equals(msgType, "INVITE")
        assert_equals(firstLine, "sip:foo SIP/2.0")
        assert_equals(headers["from"], "test")
        assert_equals(headers["to"], "foo")
        assert_equals(headers["content-length"], "0")
        assert_equals(body, "")
Exemplo n.º 8
0
    def test_correct_parsing_short_headers(self):
        """Test message parsing for correctness with short headers"""
        msgType, firstLine, headers, body = parseSipMessage(
            """INVITE sip:foo SIP/2.0
			f: test
			t: foo
			l: 4\n\n1234""")

        assert_equals(msgType, "INVITE")
        assert_equals(firstLine, "sip:foo SIP/2.0")
        assert_equals(headers["from"], "test")
        assert_equals(headers["to"], "foo")
        assert_equals(headers["content-length"], "4")
        assert_equals(body, "1234")
Exemplo n.º 9
0
    def test_correct_parsing(self):
        """Test normal message parsing for correctness"""
        msgType, firstLine, headers, body = parseSipMessage(
            """INVITE sip:foo SIP/2.0
			From: test
			To: foo
			Content-Length: 4\n\n1234""")

        assert_equals(msgType, "INVITE")
        assert_equals(firstLine, "sip:foo SIP/2.0")
        assert_equals(headers["from"], "test")
        assert_equals(headers["to"], "foo")
        assert_equals(headers["content-length"], "4")
        assert_equals(body, "1234")
Exemplo n.º 10
0
    def test_multiple_via_headers(self):
        """Test SIP message parsing with multiple Via header lines"""
        headers = parseSipMessage("""OPTIONS sip:foo SIP/2.0
			f: test
			v: SIP/2.0/UDP proxyA.domain
			t: foo
			v: SIP/2.0/UDP proxyB.domain
			l:0""")[2]

        assert_equals(headers["from"], "test")
        assert_equals(headers["to"], "foo")
        assert_equals(headers["via"][0], "SIP/2.0/UDP proxyA.domain")
        assert_equals(headers["via"][1], "SIP/2.0/UDP proxyB.domain")
        assert_equals(headers["content-length"], "0")
Exemplo n.º 11
0
    def test_mixed_short_and_long_headers(self):
        """Test message parsing for correctness with mixed short and long
		headers"""
        msgType, firstLine, headers, body = parseSipMessage(
            """INVITE sip:foo SIP/2.0
			From: test
			t: foo
			v: foobar
			content-length: 0""")

        assert_equals(msgType, "INVITE")
        assert_equals(firstLine, "sip:foo SIP/2.0")
        assert_equals(headers["from"], "test")
        assert_equals(headers["to"], "foo")
        assert_equals(headers["via"][0], "foobar")
        assert_equals(headers["content-length"], "0")
        assert_equals(body, "")
Exemplo n.º 12
0
	def test_mixed_short_and_long_headers(self):
		"""Test message parsing for correctness with mixed short and long
		headers"""
		msgType, firstLine, headers, body = parseSipMessage(
			"""INVITE sip:foo SIP/2.0
			From: test
			t: foo
			v: foobar
			content-length: 0""")

		assert_equals(msgType, "INVITE")
		assert_equals(firstLine, "sip:foo SIP/2.0")
		assert_equals(headers["from"], "test")
		assert_equals(headers["to"], "foo")
		assert_equals(headers["via"][0], "foobar")
		assert_equals(headers["content-length"], "0")
		assert_equals(body, "")
Exemplo n.º 13
0
	def test_exception_on_malformed_header_line(self):
		"""Test SIP message parsing with malformed header line"""
		parseSipMessage("INVITE foo SIP/2.0\nfrom=foo\nto=test\n\n")
Exemplo n.º 14
0
	def test_exception_on_malformed_request_line(self):
		"""Test SIP message parsing with malformed request line"""
		parseSipMessage("INVITE \n")
Exemplo n.º 15
0
 def test_exception_on_malformed_request_line(self):
     """Test SIP message parsing with malformed request line"""
     parseSipMessage("INVITE \n")
Exemplo n.º 16
0
 def test_exception_on_malformed_header_line(self):
     """Test SIP message parsing with malformed header line"""
     parseSipMessage("INVITE foo SIP/2.0\nfrom=foo\nto=test\n\n")
Exemplo n.º 17
0
	def test_all_request_types(self):
		"""Test correct message parsing of all request types"""
		for t in ["INVITE", "ACK", "OPTIONS", "BYE", "CANCEL", "REGISTER"]:
			msgType = parseSipMessage(t + " foo SIP/2.0\n")[0]
			assert_equals(msgType, t)
Exemplo n.º 18
0
 def test_all_request_types(self):
     """Test correct message parsing of all request types"""
     for t in ["INVITE", "ACK", "OPTIONS", "BYE", "CANCEL", "REGISTER"]:
         msgType = parseSipMessage(t + " foo SIP/2.0\n")[0]
         assert_equals(msgType, t)