torture/ntlm_auth: do not assume a line is less than 2047 bytes
authorBob Campbell <bobcampbell@catalyst.net.nz>
Wed, 18 Jan 2017 02:55:49 +0000 (15:55 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 11 Feb 2017 06:49:16 +0000 (07:49 +0100)
These tests would fail when ran in our cloud. This was due to lines that
were more than 2047 bytes in length, causing us to fail readLine with a
ReadChildError. This fix lets it read lines of any length, but in 2047
byte segments.

Signed-off-by: Bob Campbell <bobcampbell@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/torture/test_ntlm_auth.py

index fffeb2696b25d003ad8b4fbf2b9b78d5dd887104..076019c539b925645880abfef7d8e017fd1c24d7 100755 (executable)
@@ -37,10 +37,15 @@ def readLine(pipe):
     Read a line from the child's pipe, returns the string read.
     Throws ReadChildError if the read fails.
     """
-    buf = os.read(pipe, 2047)
-    newline = buf.find('\n')
-    if newline == -1:
-        raise ReadChildError()
+    newline = -1
+    buf = ""
+    while newline == -1:
+        more = os.read(pipe, 2047)
+        buf = buf + more
+        newline = buf.find('\n')
+        if more == "":
+            raise ReadChildError()
+
     return buf[:newline]
 
 def writeLine(pipe, buf):