Opened 6 years ago

Closed 4 years ago

#10240 closed defect (wontfix)

Additional unit tests for obfsproxy/test/test_socks.py

Reported by: dcf Owned by: asn
Priority: Low Milestone:
Component: Archived/Obfsproxy Version:
Severity: Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

obfsproxy uses the Python csv module to parse SOCKS parameters. That causes it to inherit some behavior involving quotes that's not in pt-spec.txt.

Here are some tests that fail.

        socks_args = socks.split_socks_args("key=value\na=b")
        self.assertListEqual(socks_args, ["key=value\na=b"])

        socks_args = socks.split_socks_args("key=\"value\";\"key\"=value;\"key=value\";key=\"\"value\"\"")
        self.assertListEqual(socks_args, ["key=\"value\"", "\"key\"=value", "\"key=value\"", "key=\"\"value\"\""])

        # ValueError? I dunno.
        self.assertRaises(ValueError, socks.split_socks_args, "key=endingescape\\")
        self.assertRaises(ValueError, socks.split_socks_args, "=value")

Child Tickets

Change History (2)

comment:1 Changed 6 years ago by dcf

Here's the output of running these tests.

[ERROR]
Traceback (most recent call last):
  File "/home/david/branches/obfsproxy/obfsproxy/test/test_socks.py", line 19, in test_socks_args_splitting
    socks_args = socks.split_socks_args("key=value\na=b")
  File "/home/david/branches/obfsproxy/obfsproxy/network/socks.py", line 18, in split_socks_args
    return csv.reader([args_str], delimiter=';', escapechar='\\').next()
_csv.Error: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
[FAIL]
Traceback (most recent call last):
  File "/home/david/branches/obfsproxy/obfsproxy/test/test_socks.py", line 20, in test_socks_args_splitting
    self.assertListEqual(socks_args, ["key=\"value\"", "\"key\"=value", "\"key=value\"", "key=\"\"value\"\""])
  File "/usr/lib/python2.7/unittest/case.py", line 744, in assertListEqual
    self.assertSequenceEqual(list1, list2, msg, seq_type=list)
  File "/usr/lib/python2.7/unittest/case.py", line 726, in assertSequenceEqual
    self.fail(msg)
twisted.trial.unittest.FailTest: Lists differ: ['key="value"', 'key=value', '... != ['key="value"', '"key"=value',...

First differing element 1:
key=value
"key"=value

- ['key="value"', 'key=value', 'key=value', 'key=""value""']
?                             -------------

+ ['key="value"', '"key"=value', '"key=value"', 'key=""value""']
?                  ++++++++++++++++         +
[FAIL]
Traceback (most recent call last):
  File "/home/david/branches/obfsproxy/obfsproxy/test/test_socks.py", line 20, in test_socks_args_splitting
    self.assertRaises(ValueError, socks.split_socks_args, "key=endingescape\\")
  File "/usr/lib/python2.7/dist-packages/twisted/trial/_synctest.py", line 338, in assertRaises
    % (exception.__name__, result))
twisted.trial.unittest.FailTest: ValueError not raised (['key=endingescape\n'] returned)
[FAIL]
Traceback (most recent call last):
  File "/home/david/branches/obfsproxy/obfsproxy/test/test_socks.py", line 20, in test_socks_args_splitting
    self.assertRaises(ValueError, socks.split_socks_args, "=value")
  File "/usr/lib/python2.7/dist-packages/twisted/trial/_synctest.py", line 338, in assertRaises
    % (exception.__name__, result))
twisted.trial.unittest.FailTest: ValueError not raised (['=value'] returned)

comment:2 Changed 4 years ago by dcf

Resolution: wontfix
Status: newclosed

obfs4proxy makes this obsolete.

Note: See TracTickets for help on using tickets.