55import shutil
66import socket
77import stat
8+ import subprocess
89import time
910import unittest
1011
@@ -208,6 +209,7 @@ def test_create_erroneous_file(self):
208209 input = flist .encode (),
209210 exit_code = 0 ,
210211 )
212+ assert "retry: 3 of " in out
211213 assert "E input/file2" not in out # we managed to read it in the 3rd retry (after 3 failed reads)
212214 # repo looking good overall? checks for rc == 0.
213215 self .cmd (f"--repo={ self .repository_location } " , "check" , "--debug" )
@@ -217,6 +219,37 @@ def test_create_erroneous_file(self):
217219 assert "input/file2" in out
218220 assert "input/file3" in out
219221
222+ def test_create_no_permission_file (self ):
223+ file_path = os .path .join (self .input_path , "file" )
224+ self .create_regular_file (file_path + "1" , size = 1000 )
225+ self .create_regular_file (file_path + "2" , size = 1000 )
226+ self .create_regular_file (file_path + "3" , size = 1000 )
227+ # revoke read permissions on file2 for everybody, including us:
228+ if is_win32 :
229+ subprocess .run (["icacls.exe" , file_path + "2" , "/deny" , "everyone:(R)" ])
230+ else :
231+ os .chmod (file_path + "2" , 0o000 )
232+ self .cmd (f"--repo={ self .repository_location } " , "rcreate" , RK_ENCRYPTION )
233+ flist = "" .join (f"input/file{ n } \n " for n in range (1 , 4 ))
234+ out = self .cmd (
235+ f"--repo={ self .repository_location } " ,
236+ "create" ,
237+ "--paths-from-stdin" ,
238+ "--list" ,
239+ "test" ,
240+ input = flist .encode (),
241+ exit_code = 1 , # WARNING status: could not back up file2.
242+ )
243+ assert "retry: 1 of " not in out # retries were NOT attempted!
244+ assert "E input/file2" in out # no permissions!
245+ # repo looking good overall? checks for rc == 0.
246+ self .cmd (f"--repo={ self .repository_location } " , "check" , "--debug" )
247+ # check files in created archive
248+ out = self .cmd (f"--repo={ self .repository_location } " , "list" , "test" )
249+ assert "input/file1" in out
250+ assert "input/file2" not in out # it skipped file2
251+ assert "input/file3" in out
252+
220253 def test_create_content_from_command (self ):
221254 self .cmd (f"--repo={ self .repository_location } " , "rcreate" , RK_ENCRYPTION )
222255 input_data = "some test content"
0 commit comments