tests: Extend SMB test_save_load_text case to check overwrite
authorTim Beale <timbeale@catalyst.net.nz>
Tue, 4 Dec 2018 23:51:22 +0000 (12:51 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 12 Dec 2018 03:38:13 +0000 (04:38 +0100)
Extend the test case to check overwriting a file as well. Currently this
has the behaviour of appending to the existing file, rather than
overwriting the file with new contents.

It's not clear from the API that this is the intended behaviour in this
case, so I've marked it as a failure.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/knownfail.d/smb [new file with mode: 0644]

index 70d6cd8..e3af777 100644 (file)
@@ -134,6 +134,13 @@ class SMBTests(samba.tests.TestCase):
         self.assertEquals(contents.decode('utf8'), test_contents,
                           msg='contents of test file did not match what was written')
+        # check we can overwrite the file with new contents
+        new_contents = 'wxyz' * 128
+        self.conn.savefile(test_file, new_contents.encode('utf8'))
+        contents = self.conn.loadfile(test_file)
+        self.assertEquals(contents.decode('utf8'), new_contents,
+                          msg='contents of test file did not match what was written')
     # with python2 this will save/load str type (with embedded nulls)
     # with python3 this will save/load bytes type
     def test_save_load_string_bytes(self):
diff --git a/selftest/knownfail.d/smb b/selftest/knownfail.d/smb
new file mode 100644 (file)
index 0000000..32989a8
--- /dev/null
@@ -0,0 +1,3 @@
+# currently savefile appends rather than overwriting