MCPcopy
hub / github.com/apache/caldera / test_encrypt_upload

Method test_encrypt_upload

tests/services/test_file_svc.py:178–195  ·  view source on GitHub ↗
(self, event_loop, file_svc)

Source from the content-addressed store, hash-verified

176 os.rmdir(upload_dir)
177
178 def test_encrypt_upload(self, event_loop, file_svc):
179 upload_dir = event_loop.run_until_complete(file_svc.create_exfil_sub_directory('test-encrypted-upload'))
180 upload_filename = 'encryptedupload.txt'
181 upload_content = b'this is a test upload file'
182 event_loop.run_until_complete(file_svc.save_file(upload_filename, upload_content, upload_dir))
183 uploaded_file_path = os.path.join(upload_dir, upload_filename)
184 decrypted_file_path = upload_filename + '_decrypted'
185 config_to_use = 'conf/default.yml'
186 with open(config_to_use, encoding='utf-8') as conf:
187 config = list(yaml.load_all(conf, Loader=yaml.FullLoader))[0]
188 decrypt(uploaded_file_path, config, output_file=decrypted_file_path)
189 assert os.path.isfile(decrypted_file_path)
190 with open(decrypted_file_path, 'rb') as decrypted_file:
191 decrypted_data = decrypted_file.read()
192 assert decrypted_data == upload_content
193 os.remove(uploaded_file_path)
194 os.remove(decrypted_file_path)
195 os.rmdir(upload_dir)
196
197 def test_walk_file_path_exists_nonxor(self, event_loop, text_file, file_svc):
198 ret = event_loop.run_until_complete(file_svc.walk_file_path(text_file.dirname, text_file.basename))

Callers

nothing calls this directly

Calls 4

decryptFunction · 0.90
save_fileMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected